From patchwork Mon Nov 4 14:19:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13861475 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 449D77083E for ; Mon, 4 Nov 2024 14:19:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730729976; cv=none; b=d9aGEewiRMocizqkD1x1lBEwLU6Ve6dT3L/Jd6X6dAarygV3X8/OEYblNjxMwPYzO0HmpjyzAkQHuOdw/81aM0VoCXvFpfuiBOg/MzMlth75dNGb31/WC0E9gXCk3Q0H181pjqGkS+0HhoAh5cLi+C3Z3Dk+41UVV03fnTwd72o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730729976; c=relaxed/simple; bh=eeBYr2p6za6laSDrNMtl6LIf0+fxsP9YIvYI/u+rMD4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tOVCumSTGksKxftce+s0kxTTn2LF+zmnXojeGSdIjNl65Iug1gdklIRUGRfDytFOPGmu5b9k949anJkaeG7DuBwqSDQF98Ag9Zn8S5qtIThEeYE884erKhgK9i2TrrrB9ivgk42ojpJQ4g+IzUqZIQdTKi+hbKpPLJreKfD+74A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L3jl5Z+O; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L3jl5Z+O" Received: by smtp.kernel.org (Postfix) id 345F5C4CED5; Mon, 4 Nov 2024 14:19:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A4DAC4CED8; Mon, 4 Nov 2024 14:19:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730729976; bh=eeBYr2p6za6laSDrNMtl6LIf0+fxsP9YIvYI/u+rMD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L3jl5Z+OTAzG12km0UEdW4MYNIFz2V1Ie+p2wpz/a3axeK5qkxOxC1yXQVT4CwUTw KgGPYtgCZT8SQXVPMFwyspR89euxUy0A54DRc5Szd6pvSXw53NsDeqP2ZN77H7qDi+ flY0frW8nSfW4mSDcd8PJfgdm54nlqCaPHqNB3lKARUVY1jOlTQDmIFSNB78RPNTi8 8I8jRXajFR12I4i38dzeU/NAoMlEv0Fpb9iIXA717MCZnR+VmWVpEOf3QqG5PRXYCm CGRN27FARSvAVMTL1pASVMwjeDDLMY5Tj9oGybjA14KcVFLJDLc+8QwkwowH1oK7/M aZr4GTQ31cMmw== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lee Jones Cc: Pavel Machek , linux-leds@vger.kernel.org, Arnd Bergmann , soc@kernel.org, Gregory CLEMENT , arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andrew Lunn , Sebastian Hesselbarth , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, =?utf-8?q?M?= =?utf-8?q?arek_Beh=C3=BAn?= Subject: [PATCH leds v5 01/12] turris-omnia-mcu-interface.h: Move command execution function to global header Date: Mon, 4 Nov 2024 15:19:13 +0100 Message-ID: <20241104141924.18816-2-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241104141924.18816-1-kabel@kernel.org> References: <20241104141924.18816-1-kabel@kernel.org> Precedence: bulk X-Mailing-List: soc@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the command execution functions from the turris-omnia-mcu platform driver private header to the global turris-omnia-mcu-interface.h header, so that they can be used by the LED driver. Signed-off-by: Marek Behún --- .../platform/cznic/turris-omnia-mcu-base.c | 1 + drivers/platform/cznic/turris-omnia-mcu.h | 130 ----------------- include/linux/turris-omnia-mcu-interface.h | 136 +++++++++++++++++- 3 files changed, 136 insertions(+), 131 deletions(-) diff --git a/drivers/platform/cznic/turris-omnia-mcu-base.c b/drivers/platform/cznic/turris-omnia-mcu-base.c index 58f9afae2867..bb871226e357 100644 --- a/drivers/platform/cznic/turris-omnia-mcu-base.c +++ b/drivers/platform/cznic/turris-omnia-mcu-base.c @@ -52,6 +52,7 @@ int omnia_cmd_write_read(const struct i2c_client *client, return 0; } +EXPORT_SYMBOL_GPL(omnia_cmd_write_read); static int omnia_get_version_hash(struct omnia_mcu *mcu, bool bootloader, char version[static OMNIA_FW_VERSION_HEX_LEN]) diff --git a/drivers/platform/cznic/turris-omnia-mcu.h b/drivers/platform/cznic/turris-omnia-mcu.h index 57ef5d350043..b36f9626e660 100644 --- a/drivers/platform/cznic/turris-omnia-mcu.h +++ b/drivers/platform/cznic/turris-omnia-mcu.h @@ -8,7 +8,6 @@ #ifndef __TURRIS_OMNIA_MCU_H #define __TURRIS_OMNIA_MCU_H -#include #include #include #include @@ -17,8 +16,6 @@ #include #include #include -#include -#include struct i2c_client; struct rtc_device; @@ -63,133 +60,6 @@ struct omnia_mcu { #endif }; -int omnia_cmd_write_read(const struct i2c_client *client, - void *cmd, unsigned int cmd_len, - void *reply, unsigned int reply_len); - -static inline int omnia_cmd_write(const struct i2c_client *client, void *cmd, - unsigned int len) -{ - return omnia_cmd_write_read(client, cmd, len, NULL, 0); -} - -static inline int omnia_cmd_write_u8(const struct i2c_client *client, u8 cmd, - u8 val) -{ - u8 buf[2] = { cmd, val }; - - return omnia_cmd_write(client, buf, sizeof(buf)); -} - -static inline int omnia_cmd_write_u16(const struct i2c_client *client, u8 cmd, - u16 val) -{ - u8 buf[3]; - - buf[0] = cmd; - put_unaligned_le16(val, &buf[1]); - - return omnia_cmd_write(client, buf, sizeof(buf)); -} - -static inline int omnia_cmd_write_u32(const struct i2c_client *client, u8 cmd, - u32 val) -{ - u8 buf[5]; - - buf[0] = cmd; - put_unaligned_le32(val, &buf[1]); - - return omnia_cmd_write(client, buf, sizeof(buf)); -} - -static inline int omnia_cmd_read(const struct i2c_client *client, u8 cmd, - void *reply, unsigned int len) -{ - return omnia_cmd_write_read(client, &cmd, 1, reply, len); -} - -static inline unsigned int -omnia_compute_reply_length(unsigned long mask, bool interleaved, - unsigned int offset) -{ - if (!mask) - return 0; - - return ((__fls(mask) >> 3) << interleaved) + 1 + offset; -} - -/* Returns 0 on success */ -static inline int omnia_cmd_read_bits(const struct i2c_client *client, u8 cmd, - unsigned long bits, unsigned long *dst) -{ - __le32 reply; - int err; - - if (!bits) { - *dst = 0; - return 0; - } - - err = omnia_cmd_read(client, cmd, &reply, - omnia_compute_reply_length(bits, false, 0)); - if (err) - return err; - - *dst = le32_to_cpu(reply) & bits; - - return 0; -} - -static inline int omnia_cmd_read_bit(const struct i2c_client *client, u8 cmd, - unsigned long bit) -{ - unsigned long reply; - int err; - - err = omnia_cmd_read_bits(client, cmd, bit, &reply); - if (err) - return err; - - return !!reply; -} - -static inline int omnia_cmd_read_u32(const struct i2c_client *client, u8 cmd, - u32 *dst) -{ - __le32 reply; - int err; - - err = omnia_cmd_read(client, cmd, &reply, sizeof(reply)); - if (err) - return err; - - *dst = le32_to_cpu(reply); - - return 0; -} - -static inline int omnia_cmd_read_u16(const struct i2c_client *client, u8 cmd, - u16 *dst) -{ - __le16 reply; - int err; - - err = omnia_cmd_read(client, cmd, &reply, sizeof(reply)); - if (err) - return err; - - *dst = le16_to_cpu(reply); - - return 0; -} - -static inline int omnia_cmd_read_u8(const struct i2c_client *client, u8 cmd, - u8 *reply) -{ - return omnia_cmd_read(client, cmd, reply, sizeof(*reply)); -} - #ifdef CONFIG_TURRIS_OMNIA_MCU_GPIO extern const u8 omnia_int_to_gpio_idx[32]; extern const struct attribute_group omnia_mcu_gpio_group; diff --git a/include/linux/turris-omnia-mcu-interface.h b/include/linux/turris-omnia-mcu-interface.h index 2da8cbeb158a..7f24cc682780 100644 --- a/include/linux/turris-omnia-mcu-interface.h +++ b/include/linux/turris-omnia-mcu-interface.h @@ -9,7 +9,10 @@ #define __TURRIS_OMNIA_MCU_INTERFACE_H #include -#include +#include +#include +#include +#include enum omnia_commands_e { OMNIA_CMD_GET_STATUS_WORD = 0x01, /* slave sends status word back */ @@ -246,4 +249,135 @@ enum omnia_cmd_usb_ovc_prot_e { OMNIA_CMD_xET_USB_OVC_PROT_ENABLE = BIT(4), }; +/* Command execution functions */ + +struct i2c_client; + +int omnia_cmd_write_read(const struct i2c_client *client, + void *cmd, unsigned int cmd_len, + void *reply, unsigned int reply_len); + +static inline int omnia_cmd_write(const struct i2c_client *client, void *cmd, + unsigned int len) +{ + return omnia_cmd_write_read(client, cmd, len, NULL, 0); +} + +static inline int omnia_cmd_write_u8(const struct i2c_client *client, u8 cmd, + u8 val) +{ + u8 buf[2] = { cmd, val }; + + return omnia_cmd_write(client, buf, sizeof(buf)); +} + +static inline int omnia_cmd_write_u16(const struct i2c_client *client, u8 cmd, + u16 val) +{ + u8 buf[3]; + + buf[0] = cmd; + put_unaligned_le16(val, &buf[1]); + + return omnia_cmd_write(client, buf, sizeof(buf)); +} + +static inline int omnia_cmd_write_u32(const struct i2c_client *client, u8 cmd, + u32 val) +{ + u8 buf[5]; + + buf[0] = cmd; + put_unaligned_le32(val, &buf[1]); + + return omnia_cmd_write(client, buf, sizeof(buf)); +} + +static inline int omnia_cmd_read(const struct i2c_client *client, u8 cmd, + void *reply, unsigned int len) +{ + return omnia_cmd_write_read(client, &cmd, 1, reply, len); +} + +static inline unsigned int +omnia_compute_reply_length(unsigned long mask, bool interleaved, + unsigned int offset) +{ + if (!mask) + return 0; + + return ((__fls(mask) >> 3) << interleaved) + 1 + offset; +} + +/* Returns 0 on success */ +static inline int omnia_cmd_read_bits(const struct i2c_client *client, u8 cmd, + unsigned long bits, unsigned long *dst) +{ + __le32 reply; + int err; + + if (!bits) { + *dst = 0; + return 0; + } + + err = omnia_cmd_read(client, cmd, &reply, + omnia_compute_reply_length(bits, false, 0)); + if (err) + return err; + + *dst = le32_to_cpu(reply) & bits; + + return 0; +} + +static inline int omnia_cmd_read_bit(const struct i2c_client *client, u8 cmd, + unsigned long bit) +{ + unsigned long reply; + int err; + + err = omnia_cmd_read_bits(client, cmd, bit, &reply); + if (err) + return err; + + return !!reply; +} + +static inline int omnia_cmd_read_u32(const struct i2c_client *client, u8 cmd, + u32 *dst) +{ + __le32 reply; + int err; + + err = omnia_cmd_read(client, cmd, &reply, sizeof(reply)); + if (err) + return err; + + *dst = le32_to_cpu(reply); + + return 0; +} + +static inline int omnia_cmd_read_u16(const struct i2c_client *client, u8 cmd, + u16 *dst) +{ + __le16 reply; + int err; + + err = omnia_cmd_read(client, cmd, &reply, sizeof(reply)); + if (err) + return err; + + *dst = le16_to_cpu(reply); + + return 0; +} + +static inline int omnia_cmd_read_u8(const struct i2c_client *client, u8 cmd, + u8 *reply) +{ + return omnia_cmd_read(client, cmd, reply, sizeof(*reply)); +} + #endif /* __TURRIS_OMNIA_MCU_INTERFACE_H */ From patchwork Mon Nov 4 14:19:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13861476 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B405BAD24 for ; Mon, 4 Nov 2024 14:19:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730729981; cv=none; b=OCwr0EM6Q8wv9aPxwIud7TLvecYbVqwriEOwukAf7xP+YC/GIcNtF+TSJz4vJVHEnMhvPxtknQGayqwoV2Ou+RL/bGkWl2TafQFlxi40/l6lFtGHYpQUqrIeooYF3CrhnvpwGZpvpVksdb7Ow3gXQnfgSapy7VOAcn0juPjsuS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730729981; c=relaxed/simple; bh=D6A9yZwod9RyaYcsbShQlW2Y89y5mowC4F2k/d7+MZc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BocggrmiZ8vR5asxmwMD14V0BI6KfLGiumAOBshTsMJ/sICSp8O1gWZrv34Yu5r7tqislZkjfhkxG0xah0XPehqD0DP7uXXOgqzi3S/Kx5D8yKJV+W9+NpOWHC7R/iwVk+RqL5/Zp3ccLRr8ZfChvewHjWDbIb5TEXiEgNGlxHM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iZJ/wJ+0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iZJ/wJ+0" Received: by smtp.kernel.org (Postfix) id 4A57CC4CED0; Mon, 4 Nov 2024 14:19:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E8ACC4CED1; Mon, 4 Nov 2024 14:19:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730729980; bh=D6A9yZwod9RyaYcsbShQlW2Y89y5mowC4F2k/d7+MZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iZJ/wJ+0UCPg8h5PeVXtJ8g26Sv3qLdEdzgx7phcS5eULaSl3/6l1E2oDLUr1Gs8Y 5BZYfE2bDRh0KHix9odp423IdUSFJie3BPbLShAylkwXjzCeSq9Vqgwx+Ytp+XE+Vj 3/TOQrf99aST4bHALG7lxPXwuuw2KndQgpeziid/ke/qJqLEwh/zXa5avRfciOArcQ OtjJq6+6RcKkUeEe9j+HgUE+GbKoQUG2lRT+MfzN9B1VGxW/AQT4ClBG13N40Waa4s kKoKtLXZPVYSPH+Nrm5EMKd2Ah/T5QpQDoDDg4IBDdgaw5lk8Nc+xk3W4F3kHgqowu ZijTajLSFAZbA== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lee Jones Cc: Pavel Machek , linux-leds@vger.kernel.org, Arnd Bergmann , soc@kernel.org, Gregory CLEMENT , arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andrew Lunn , Sebastian Hesselbarth , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, =?utf-8?q?M?= =?utf-8?q?arek_Beh=C3=BAn?= Subject: [PATCH leds v5 02/12] leds: turris-omnia: Use command execution functions from the MCU driver Date: Mon, 4 Nov 2024 15:19:14 +0100 Message-ID: <20241104141924.18816-3-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241104141924.18816-1-kabel@kernel.org> References: <20241104141924.18816-1-kabel@kernel.org> Precedence: bulk X-Mailing-List: soc@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use the MCU command execution functions from the MCU driver instead of the ad-hoc implementation in the LED driver. This allows as to drop the LED driver implementation, which is a duplicate. Signed-off-by: Marek Behún --- drivers/leds/Kconfig | 1 + drivers/leds/leds-turris-omnia.c | 137 ++++++++++++------------------- 2 files changed, 55 insertions(+), 83 deletions(-) diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index b784bb74a837..fcbe93b61e49 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -217,6 +217,7 @@ config LEDS_TURRIS_OMNIA depends on I2C depends on MACH_ARMADA_38X || COMPILE_TEST depends on OF + depends on TURRIS_OMNIA_MCU select LEDS_TRIGGERS help This option enables basic support for the LEDs found on the front diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index 4cff8c4b020c..00cd3bb86703 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -2,7 +2,7 @@ /* * CZ.NIC's Turris Omnia LEDs driver * - * 2020, 2023 by Marek Behún + * 2020, 2023, 2024 by Marek Behún */ #include @@ -10,6 +10,7 @@ #include #include #include +#include #include "leds.h" #define OMNIA_BOARD_LEDS 12 @@ -57,66 +58,21 @@ struct omnia_leds { struct omnia_led leds[]; }; -static int omnia_cmd_write_u8(const struct i2c_client *client, u8 cmd, u8 val) +static int omnia_cmd_set_color(const struct i2c_client *client, u8 led, u8 r, u8 g, u8 b) { - u8 buf[2] = { cmd, val }; - int ret; - - ret = i2c_master_send(client, buf, sizeof(buf)); + u8 buf[5] = { CMD_LED_COLOR, led, r, g, b }; - return ret < 0 ? ret : 0; -} - -static int omnia_cmd_read_raw(struct i2c_adapter *adapter, u8 addr, u8 cmd, - void *reply, size_t len) -{ - struct i2c_msg msgs[2]; - int ret; - - msgs[0].addr = addr; - msgs[0].flags = 0; - msgs[0].len = 1; - msgs[0].buf = &cmd; - msgs[1].addr = addr; - msgs[1].flags = I2C_M_RD; - msgs[1].len = len; - msgs[1].buf = reply; - - ret = i2c_transfer(adapter, msgs, ARRAY_SIZE(msgs)); - if (likely(ret == ARRAY_SIZE(msgs))) - return 0; - else if (ret < 0) - return ret; - else - return -EIO; -} - -static int omnia_cmd_read_u8(const struct i2c_client *client, u8 cmd) -{ - u8 reply; - int err; - - err = omnia_cmd_read_raw(client->adapter, client->addr, cmd, &reply, 1); - if (err) - return err; - - return reply; + return omnia_cmd_write(client, buf, sizeof(buf)); } static int omnia_led_send_color_cmd(const struct i2c_client *client, struct omnia_led *led) { - char cmd[5]; int ret; - cmd[0] = CMD_LED_COLOR; - cmd[1] = led->reg; - cmd[2] = led->subled_info[0].brightness; - cmd[3] = led->subled_info[1].brightness; - cmd[4] = led->subled_info[2].brightness; - /* Send the color change command */ - ret = i2c_master_send(client, cmd, 5); + ret = omnia_cmd_set_color(client, led->reg, led->subled_info[0].brightness, + led->subled_info[1].brightness, led->subled_info[2].brightness); if (ret < 0) return ret; @@ -352,14 +308,14 @@ static ssize_t brightness_show(struct device *dev, struct device_attribute *a, char *buf) { struct i2c_client *client = to_i2c_client(dev); - int ret; - - ret = omnia_cmd_read_u8(client, CMD_LED_GET_BRIGHTNESS); + u8 reply; + int err; - if (ret < 0) - return ret; + err = omnia_cmd_read_u8(client, CMD_LED_GET_BRIGHTNESS, &reply); + if (err < 0) + return err; - return sysfs_emit(buf, "%d\n", ret); + return sysfs_emit(buf, "%d\n", reply); } static ssize_t brightness_store(struct device *dev, struct device_attribute *a, @@ -386,17 +342,16 @@ static ssize_t gamma_correction_show(struct device *dev, { struct i2c_client *client = to_i2c_client(dev); struct omnia_leds *leds = i2c_get_clientdata(client); - int ret; + u8 reply = 0; + int err; if (leds->has_gamma_correction) { - ret = omnia_cmd_read_u8(client, CMD_GET_GAMMA_CORRECTION); - if (ret < 0) - return ret; - } else { - ret = 0; + err = omnia_cmd_read_u8(client, CMD_GET_GAMMA_CORRECTION, &reply); + if (err < 0) + return err; } - return sysfs_emit(buf, "%d\n", !!ret); + return sysfs_emit(buf, "%d\n", !!reply); } static ssize_t gamma_correction_store(struct device *dev, @@ -427,26 +382,51 @@ static struct attribute *omnia_led_controller_attrs[] = { }; ATTRIBUTE_GROUPS(omnia_led_controller); -static int omnia_mcu_get_features(const struct i2c_client *client) +static int omnia_mcu_get_features(const struct i2c_client *mcu_client) { u16 reply; int err; - err = omnia_cmd_read_raw(client->adapter, OMNIA_MCU_I2C_ADDR, - CMD_GET_STATUS_WORD, &reply, sizeof(reply)); + err = omnia_cmd_read_u16(mcu_client, CMD_GET_STATUS_WORD, &reply); if (err) return err; /* Check whether MCU firmware supports the CMD_GET_FEAUTRES command */ - if (!(le16_to_cpu(reply) & STS_FEATURES_SUPPORTED)) + if (!(reply & STS_FEATURES_SUPPORTED)) return 0; - err = omnia_cmd_read_raw(client->adapter, OMNIA_MCU_I2C_ADDR, - CMD_GET_FEATURES, &reply, sizeof(reply)); + err = omnia_cmd_read_u16(mcu_client, CMD_GET_FEATURES, &reply); if (err) return err; - return le16_to_cpu(reply); + return reply; +} + +static int omnia_match_mcu_client(struct device *dev, void *data) +{ + struct i2c_client *client; + + client = i2c_verify_client(dev); + if (!client) + return 0; + + return client->addr == OMNIA_MCU_I2C_ADDR; +} + +static int omnia_find_mcu_and_get_features(struct device *dev) +{ + struct device *mcu_dev; + int ret; + + mcu_dev = device_find_child(dev->parent, NULL, omnia_match_mcu_client); + if (!mcu_dev) + return -ENODEV; + + ret = omnia_mcu_get_features(i2c_verify_client(mcu_dev)); + + put_device(mcu_dev); + + return ret; } static int omnia_leds_probe(struct i2c_client *client) @@ -473,7 +453,7 @@ static int omnia_leds_probe(struct i2c_client *client) leds->client = client; i2c_set_clientdata(client, leds); - ret = omnia_mcu_get_features(client); + ret = omnia_find_mcu_and_get_features(dev); if (ret < 0) { dev_err(dev, "Cannot determine MCU supported features: %d\n", ret); @@ -510,20 +490,11 @@ static int omnia_leds_probe(struct i2c_client *client) static void omnia_leds_remove(struct i2c_client *client) { - u8 buf[5]; - /* put all LEDs into default (HW triggered) mode */ - omnia_cmd_write_u8(client, CMD_LED_MODE, - CMD_LED_MODE_LED(OMNIA_BOARD_LEDS)); + omnia_cmd_write_u8(client, CMD_LED_MODE, CMD_LED_MODE_LED(OMNIA_BOARD_LEDS)); /* set all LEDs color to [255, 255, 255] */ - buf[0] = CMD_LED_COLOR; - buf[1] = OMNIA_BOARD_LEDS; - buf[2] = 255; - buf[3] = 255; - buf[4] = 255; - - i2c_master_send(client, buf, 5); + omnia_cmd_set_color(client, OMNIA_BOARD_LEDS, 255, 255, 255); } static const struct of_device_id of_omnia_leds_match[] = { From patchwork Mon Nov 4 14:19:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13861477 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91CB47346F for ; Mon, 4 Nov 2024 14:19:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730729984; cv=none; b=e81AkXJ5NykhO0U+DVBgk89/LklkaJmEIskfCbG2rTIfjGhDIQs/wiXvbsDhjsQU9G0aozD915ndf8DY8/U3+net8rKu6GQQ0y5cX3qBqyxey1cDCZjNQW2iTKTXHm/8zGevqyUvtHhbCAWHEfffjCfOf9lr0BFxgI5Gn5oTDCI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730729984; c=relaxed/simple; bh=k2ET+mNmV11DXD5Dqt3IxyuEPJFzW2WgZvGZBxEVi74=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=msui70aVywFGD3Ib9P7DQl4Kc6rFgQBxtvODe4n3HMH+jGS7rp6F1eL4fjLed+I/21SCRh+IL1BJnIOGioLIxnlH7o3osNXBNIisLZvcuZLpuAxkomRBNQTbzj+Xe+77yDAZJ0dBTmHobwfe1WyQ7wVgfCsdliiRoPBJaYJjOVw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nX2TFR5Q; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nX2TFR5Q" Received: by smtp.kernel.org (Postfix) id 6028EC4CED5; Mon, 4 Nov 2024 14:19:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4E56C4CED7; Mon, 4 Nov 2024 14:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730729984; bh=k2ET+mNmV11DXD5Dqt3IxyuEPJFzW2WgZvGZBxEVi74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nX2TFR5Qd8+QiLcV7pj55KT2EowrrXFQor5r0toYxbx0EjjswlN5lDe9TQ+Z6RZ+K a/ON0jQkcerdAlqGSLuq5bashkB+nLZL2qBPoPAfSl3MJA8pjjRr1kdA/kaftl/5tG lgOUc9S4zrQihKaOoC5stIbLIDxyLm9OQKI752E7R67vS63kN5W78vgljEpVJJc6Zw /WWgbkYqk8TKSUHPfzpWoD70eJ3eE9T5LUrD0f4yt39nMiWHboaqwDFaGnvw8MGd9i Kbk9HtM77ww68oPZ7MnmG4VBr9/qhXqWIXg5cs0HZxAriijmiQcub2/Wd8EMEKlLRx +HQD+J20q7Mhw== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lee Jones Cc: Pavel Machek , linux-leds@vger.kernel.org, Arnd Bergmann , soc@kernel.org, Gregory CLEMENT , arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andrew Lunn , Sebastian Hesselbarth , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, =?utf-8?q?M?= =?utf-8?q?arek_Beh=C3=BAn?= Subject: [PATCH leds v5 03/12] turris-omnia-mcu-interface.h: Add LED commands related definitions to global header Date: Mon, 4 Nov 2024 15:19:15 +0100 Message-ID: <20241104141924.18816-4-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241104141924.18816-1-kabel@kernel.org> References: <20241104141924.18816-1-kabel@kernel.org> Precedence: bulk X-Mailing-List: soc@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add definitions for contents of the OMNIA_CMD_LED_MODE and OMNIA_CMD_LED_STATE commands to the global turris-omnia-mcu-interface.h header. Signed-off-by: Marek Behún --- include/linux/turris-omnia-mcu-interface.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/turris-omnia-mcu-interface.h b/include/linux/turris-omnia-mcu-interface.h index 7f24cc682780..06c94e032c6f 100644 --- a/include/linux/turris-omnia-mcu-interface.h +++ b/include/linux/turris-omnia-mcu-interface.h @@ -239,6 +239,18 @@ enum omnia_int_e { OMNIA_INT_LAN5_LED1 = BIT(31), }; +enum omnia_cmd_led_mode_e { + OMNIA_CMD_LED_MODE_LED_MASK = GENMASK(3, 0), +#define OMNIA_CMD_LED_MODE_LED(_l) FIELD_PREP(OMNIA_CMD_LED_MODE_LED_MASK, _l) + OMNIA_CMD_LED_MODE_USER = BIT(4), +}; + +enum omnia_cmd_led_state_e { + OMNIA_CMD_LED_STATE_LED_MASK = GENMASK(3, 0), +#define OMNIA_CMD_LED_STATE_LED(_l) FIELD_PREP(OMNIA_CMD_LED_STATE_LED_MASK, _l) + OMNIA_CMD_LED_STATE_ON = BIT(4), +}; + enum omnia_cmd_poweroff_e { OMNIA_CMD_POWER_OFF_POWERON_BUTTON = BIT(0), OMNIA_CMD_POWER_OFF_MAGIC = 0xdead, From patchwork Mon Nov 4 14:19:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13861478 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C65A47083E for ; Mon, 4 Nov 2024 14:19:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730729988; cv=none; b=Xo/e/O+UL2dhIdCxP62Kl1avCH8d041u4H3qY+nrUNjOVzHZZokVzSXgqIJ4rvA2VqFAzTvHF5QCUxtneQtt4ZIslMDx+GRvCPIyCuziDDXf7Meg0wlpBDUZl5LxAmOAlQlJwUeGcaM8hQIrXD4HbXM8J3EB5SA44jb6JKk2qhs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730729988; c=relaxed/simple; bh=+BaD6yzWcHU4DwqJoicMokFjifwQXkQ4xTT2A5vPyxs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tb3pqvhCbUp06t0pcI+/9vyRVvGeOqPjBKTYO6XYg8kH8fONZHL6PI0fjLiER0dDSloDcV2RZscmGTwosC4uGWe4S0BGQsZ16VjZEBNfEHv7nRmS9FgRwIIe81jS0ZHlGHHbhRVh+IAnpJTmS+7od/JSC6AqwGIGD3tVlpR4LLo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KlhuWoBI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KlhuWoBI" Received: by smtp.kernel.org (Postfix) id 722F2C4AF0D; Mon, 4 Nov 2024 14:19:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB406C4CED5; Mon, 4 Nov 2024 14:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730729988; bh=+BaD6yzWcHU4DwqJoicMokFjifwQXkQ4xTT2A5vPyxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KlhuWoBIcstqD2G2+Cy0UI28XncXmzJsfsaOyHj7MlmcraEKnb9SUfzjXZaE6mj3L ZKqDuQvsWnGompbboQnARWe6RFu7Nq+B7VCPpWNWAocsmEUyjdhHSYkcRzcZ1519ke XmB34oVvH6HKBp0hMvMCLEv1ziPFLkdGI//F1Lam+4x15fDlNnEQ39WRGKbFZ4G0p5 F/HbD75OQ80+Kz2nm6AGiYl45qU8O5fz5HcgPeQjnTWUw05FcWhb6h8bac09FrzL1t O2BZqnkZRRzR8M/z1dRx3yP3Ix0zafk7BIYJro9wvcPbfxmMrjswajJ9HLqAx/aUv5 ZoTaw2boq2Hlg== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lee Jones Cc: Pavel Machek , linux-leds@vger.kernel.org, Arnd Bergmann , soc@kernel.org, Gregory CLEMENT , arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andrew Lunn , Sebastian Hesselbarth , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, =?utf-8?q?M?= =?utf-8?q?arek_Beh=C3=BAn?= Subject: [PATCH leds v5 04/12] leds: turris-omnia: Use global header for MCU command definitions Date: Mon, 4 Nov 2024 15:19:16 +0100 Message-ID: <20241104141924.18816-5-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241104141924.18816-1-kabel@kernel.org> References: <20241104141924.18816-1-kabel@kernel.org> Precedence: bulk X-Mailing-List: soc@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The global turris-omnia-mcu-interface.h header file contains the definitions for MCU commands. Drop the driver-internal definitions and use the global ones. Signed-off-by: Marek Behún --- drivers/leds/leds-turris-omnia.c | 71 +++++++++++--------------------- 1 file changed, 23 insertions(+), 48 deletions(-) diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index 00cd3bb86703..50fef4389c93 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -16,30 +16,8 @@ #define OMNIA_BOARD_LEDS 12 #define OMNIA_LED_NUM_CHANNELS 3 -/* MCU controller commands at I2C address 0x2a */ -#define OMNIA_MCU_I2C_ADDR 0x2a - -#define CMD_GET_STATUS_WORD 0x01 -#define STS_FEATURES_SUPPORTED BIT(2) - -#define CMD_GET_FEATURES 0x10 -#define FEAT_LED_GAMMA_CORRECTION BIT(5) - -/* LED controller commands at I2C address 0x2b */ -#define CMD_LED_MODE 0x03 -#define CMD_LED_MODE_LED(l) ((l) & 0x0f) -#define CMD_LED_MODE_USER 0x10 - -#define CMD_LED_STATE 0x04 -#define CMD_LED_STATE_LED(l) ((l) & 0x0f) -#define CMD_LED_STATE_ON 0x10 - -#define CMD_LED_COLOR 0x05 -#define CMD_LED_SET_BRIGHTNESS 0x07 -#define CMD_LED_GET_BRIGHTNESS 0x08 - -#define CMD_SET_GAMMA_CORRECTION 0x30 -#define CMD_GET_GAMMA_CORRECTION 0x31 +/* MCU controller I2C address 0x2a, needed for detecting MCU features */ +#define OMNIA_MCU_I2C_ADDR 0x2a struct omnia_led { struct led_classdev_mc mc_cdev; @@ -60,7 +38,7 @@ struct omnia_leds { static int omnia_cmd_set_color(const struct i2c_client *client, u8 led, u8 r, u8 g, u8 b) { - u8 buf[5] = { CMD_LED_COLOR, led, r, g, b }; + u8 buf[5] = { OMNIA_CMD_LED_COLOR, led, r, g, b }; return omnia_cmd_write(client, buf, sizeof(buf)); } @@ -127,12 +105,12 @@ static int omnia_led_brightness_set_blocking(struct led_classdev *cdev, * is not being blinked by HW. */ if (!err && !led->hwtrig && !brightness != !led->on) { - u8 state = CMD_LED_STATE_LED(led->reg); + u8 state = OMNIA_CMD_LED_STATE_LED(led->reg); if (brightness) - state |= CMD_LED_STATE_ON; + state |= OMNIA_CMD_LED_STATE_ON; - err = omnia_cmd_write_u8(leds->client, CMD_LED_STATE, state); + err = omnia_cmd_write_u8(leds->client, OMNIA_CMD_LED_STATE, state); if (!err) led->on = !!brightness; } @@ -167,8 +145,8 @@ static int omnia_hwtrig_activate(struct led_classdev *cdev) if (!err) { /* Put the LED into MCU controlled mode */ - err = omnia_cmd_write_u8(leds->client, CMD_LED_MODE, - CMD_LED_MODE_LED(led->reg)); + err = omnia_cmd_write_u8(leds->client, OMNIA_CMD_LED_MODE, + OMNIA_CMD_LED_MODE_LED(led->reg)); if (!err) led->hwtrig = true; } @@ -189,9 +167,8 @@ static void omnia_hwtrig_deactivate(struct led_classdev *cdev) led->hwtrig = false; /* Put the LED into software mode */ - err = omnia_cmd_write_u8(leds->client, CMD_LED_MODE, - CMD_LED_MODE_LED(led->reg) | - CMD_LED_MODE_USER); + err = omnia_cmd_write_u8(leds->client, OMNIA_CMD_LED_MODE, + OMNIA_CMD_LED_MODE_LED(led->reg) | OMNIA_CMD_LED_MODE_USER); mutex_unlock(&leds->lock); @@ -258,9 +235,8 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led, cdev->default_trigger = omnia_hw_trigger.name; /* put the LED into software mode */ - ret = omnia_cmd_write_u8(client, CMD_LED_MODE, - CMD_LED_MODE_LED(led->reg) | - CMD_LED_MODE_USER); + ret = omnia_cmd_write_u8(client, OMNIA_CMD_LED_MODE, OMNIA_CMD_LED_MODE_LED(led->reg) | + OMNIA_CMD_LED_MODE_USER); if (ret) { dev_err(dev, "Cannot set LED %pOF to software mode: %i\n", np, ret); @@ -268,8 +244,7 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led, } /* disable the LED */ - ret = omnia_cmd_write_u8(client, CMD_LED_STATE, - CMD_LED_STATE_LED(led->reg)); + ret = omnia_cmd_write_u8(client, OMNIA_CMD_LED_STATE, OMNIA_CMD_LED_STATE_LED(led->reg)); if (ret) { dev_err(dev, "Cannot set LED %pOF brightness: %i\n", np, ret); return ret; @@ -311,7 +286,7 @@ static ssize_t brightness_show(struct device *dev, struct device_attribute *a, u8 reply; int err; - err = omnia_cmd_read_u8(client, CMD_LED_GET_BRIGHTNESS, &reply); + err = omnia_cmd_read_u8(client, OMNIA_CMD_GET_BRIGHTNESS, &reply); if (err < 0) return err; @@ -331,7 +306,7 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *a, if (brightness > 100) return -EINVAL; - err = omnia_cmd_write_u8(client, CMD_LED_SET_BRIGHTNESS, brightness); + err = omnia_cmd_write_u8(client, OMNIA_CMD_SET_BRIGHTNESS, brightness); return err ?: count; } @@ -346,7 +321,7 @@ static ssize_t gamma_correction_show(struct device *dev, int err; if (leds->has_gamma_correction) { - err = omnia_cmd_read_u8(client, CMD_GET_GAMMA_CORRECTION, &reply); + err = omnia_cmd_read_u8(client, OMNIA_CMD_GET_GAMMA_CORRECTION, &reply); if (err < 0) return err; } @@ -369,7 +344,7 @@ static ssize_t gamma_correction_store(struct device *dev, if (kstrtobool(buf, &val) < 0) return -EINVAL; - err = omnia_cmd_write_u8(client, CMD_SET_GAMMA_CORRECTION, val); + err = omnia_cmd_write_u8(client, OMNIA_CMD_SET_GAMMA_CORRECTION, val); return err ?: count; } @@ -387,15 +362,15 @@ static int omnia_mcu_get_features(const struct i2c_client *mcu_client) u16 reply; int err; - err = omnia_cmd_read_u16(mcu_client, CMD_GET_STATUS_WORD, &reply); + err = omnia_cmd_read_u16(mcu_client, OMNIA_CMD_GET_STATUS_WORD, &reply); if (err) return err; - /* Check whether MCU firmware supports the CMD_GET_FEAUTRES command */ - if (!(reply & STS_FEATURES_SUPPORTED)) + /* Check whether MCU firmware supports the OMNIA_CMD_GET_FEAUTRES command */ + if (!(reply & OMNIA_STS_FEATURES_SUPPORTED)) return 0; - err = omnia_cmd_read_u16(mcu_client, CMD_GET_FEATURES, &reply); + err = omnia_cmd_read_u16(mcu_client, OMNIA_CMD_GET_FEATURES, &reply); if (err) return err; @@ -460,7 +435,7 @@ static int omnia_leds_probe(struct i2c_client *client) return ret; } - leds->has_gamma_correction = ret & FEAT_LED_GAMMA_CORRECTION; + leds->has_gamma_correction = ret & OMNIA_FEAT_LED_GAMMA_CORRECTION; if (!leds->has_gamma_correction) { dev_info(dev, "Your board's MCU firmware does not support the LED gamma correction feature.\n"); @@ -491,7 +466,7 @@ static int omnia_leds_probe(struct i2c_client *client) static void omnia_leds_remove(struct i2c_client *client) { /* put all LEDs into default (HW triggered) mode */ - omnia_cmd_write_u8(client, CMD_LED_MODE, CMD_LED_MODE_LED(OMNIA_BOARD_LEDS)); + omnia_cmd_write_u8(client, OMNIA_CMD_LED_MODE, OMNIA_CMD_LED_MODE_LED(OMNIA_BOARD_LEDS)); /* set all LEDs color to [255, 255, 255] */ omnia_cmd_set_color(client, OMNIA_BOARD_LEDS, 255, 255, 255); From patchwork Mon Nov 4 14:19:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13861479 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE5C0AD24 for ; Mon, 4 Nov 2024 14:19:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730729992; cv=none; b=SE4JhU+vweOa7lwTmzkz4QZwYlUK0B2h7KDSEAU2f1kN841ekP/JVGEX1jb5+zsO9cpszpalBMHsI6yaidOwTrCNF6p0VHXv9zu/IIZCNucVZITSuav9RgjNVwMXa4RhVWfe001CDuan7VvXcs3Ktrsb3kBt3AlQLZeOikjcF1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730729992; c=relaxed/simple; bh=IL6ApZj/AEN4ogtSsw2hRDlMG6U3NVDiHfarNqZTetA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Su0j3/GoYsuSy1q2Yq/l9iZrtIZlSXU4ITBMPREOhHgIAjRqCDeR3WKZMROV/c60BoVJdAxPkd1qKk/NpVLFEjDyd5pm11WQ4LChWFRYstavDbxsD35badrMkxPC7Jqb7ltLiJUqCRy1odbekfaU5YmZreKZOtm6pFjvnz9zOi8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I3IYBSb7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I3IYBSb7" Received: by smtp.kernel.org (Postfix) id B4EE2C4AF0C; Mon, 4 Nov 2024 14:19:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE647C4CED2; Mon, 4 Nov 2024 14:19:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730729992; bh=IL6ApZj/AEN4ogtSsw2hRDlMG6U3NVDiHfarNqZTetA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I3IYBSb7xqbhf/xrxG9aeUpCxW5cDBX8vb4IgsqY4dWay8VPnglmCXpA8J+7eQtvN WbKW+IDLv9D9sD6EPSgP3zhPitQmrzThubRwPz6PLbnlbQujWHGDBzlNchq3QyPGsM PCpe16y8X8FlSbFUppTsjSuKOc5lO62vHyzVKcwrE7uWCry3brGx5GOX6eXXa00ZtU xM2TabW4nDXffivE99LGchAf1TOSmZu+MpQNhdjiuTASiBRfwj4MsEwqt26hrxgVjU s4dGLrcP9NZuC121jUto6vthrwQaIlcW+c0H453fo/UhUdPrT4iAKdD/2iCxdukdQc alOI5kkjB0JzQ== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lee Jones Cc: Pavel Machek , linux-leds@vger.kernel.org, Arnd Bergmann , soc@kernel.org, Gregory CLEMENT , arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andrew Lunn , Sebastian Hesselbarth , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, =?utf-8?q?M?= =?utf-8?q?arek_Beh=C3=BAn?= , Krzysztof Kozlowski Subject: [PATCH leds v5 05/12] dt-bindings: leds: cznic,turris-omnia-leds: Allow interrupts property Date: Mon, 4 Nov 2024 15:19:17 +0100 Message-ID: <20241104141924.18816-6-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241104141924.18816-1-kabel@kernel.org> References: <20241104141924.18816-1-kabel@kernel.org> Precedence: bulk X-Mailing-List: soc@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Extend the cznic,turris-omnia-leds binding with interrupts property, specifying the global LED brightness changed by button press interrupt. Signed-off-by: Marek Behún Acked-by: Krzysztof Kozlowski --- .../devicetree/bindings/leds/cznic,turris-omnia-leds.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/cznic,turris-omnia-leds.yaml b/Documentation/devicetree/bindings/leds/cznic,turris-omnia-leds.yaml index 34ef5215c150..f52f6304c79e 100644 --- a/Documentation/devicetree/bindings/leds/cznic,turris-omnia-leds.yaml +++ b/Documentation/devicetree/bindings/leds/cznic,turris-omnia-leds.yaml @@ -23,6 +23,12 @@ properties: description: I2C slave address of the microcontroller. maxItems: 1 + interrupts: + description: + Specifier for the global LED brightness changed by front button press + interrupt. + maxItems: 1 + "#address-cells": const: 1 @@ -56,6 +62,7 @@ additionalProperties: false examples: - | + #include #include i2c { @@ -65,6 +72,7 @@ examples: led-controller@2b { compatible = "cznic,turris-omnia-leds"; reg = <0x2b>; + interrupts-extended = <&mcu 11 IRQ_TYPE_NONE>; #address-cells = <1>; #size-cells = <0>; From patchwork Mon Nov 4 14:19:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13861480 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0CED3398B for ; Mon, 4 Nov 2024 14:19:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730729996; cv=none; b=uICGa0jXLlGkk/GSCS45uWFDK2zgzOTrxA+h1G3tx1d0b1lW57N3gUB0kIi4ISYagtWlZ5d7A6dyXst3b0Z32/rOJ4UadNsqy6GWp6mMVjc1ZsH4+NcAXzG7NXD+fTMbhaONsLigkiJExvtdL9/vS+h8GdRz6g3aagu9R1d7CiQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730729996; c=relaxed/simple; bh=rTAIY6aQ5hb64k5weAhBRvT5KfxwL7qw3p8nyT7tcWs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ByNtMW/QUdG9jDmsYfKyD9CbDjcLvMy4oyd8vabnMxsVYM94syHRBXoa1VsUESv8Sy6RJwBfC+UxewQt0Q1ijEHznPDV3dlK9gE9NblCbjyggYCkmCeUrOUSwCLhCmLRiMLRrT1m07bIWygqvtrAuINxoJC2wAPgrl0WebyoFvQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TriR2BpN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TriR2BpN" Received: by smtp.kernel.org (Postfix) id C82D0C4CED0; Mon, 4 Nov 2024 14:19:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D39CC4CED5; Mon, 4 Nov 2024 14:19:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730729996; bh=rTAIY6aQ5hb64k5weAhBRvT5KfxwL7qw3p8nyT7tcWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TriR2BpNeEIc6o1Ght8c2kGxwvaLn/is7DQ/L3QYweYlrqVilNA//Zmg2d4Ev0ru/ /yTafdUmKjt3kC6j1jc8PphJd3R++zesLmMvz/6RLQJMiPJYxFpDVJ9r7Vz8QYqtci gHqeuqipjttdKUZteUVMQ169c46n/je14GZLhcYgPwWTJVGm+ExW0aU460Y1iMtr6A xnyXmGVqTDmy2kDNItDSG1OmoxZelogk0lSvLEPxbYN/kI4s8F58wNtuVyUWIinUTq MQF0p6KiXbs2WUnL2+vRu4oTvrEkRgLgfdISeAaz/dYls2HeaKBwqxuTzPu+ZOlfmj CUjD3oGUYKF0w== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lee Jones Cc: Pavel Machek , linux-leds@vger.kernel.org, Arnd Bergmann , soc@kernel.org, Gregory CLEMENT , arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andrew Lunn , Sebastian Hesselbarth , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, =?utf-8?q?M?= =?utf-8?q?arek_Beh=C3=BAn?= Subject: [PATCH leds v5 06/12] leds: turris-omnia: Document driver private structures Date: Mon, 4 Nov 2024 15:19:18 +0100 Message-ID: <20241104141924.18816-7-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241104141924.18816-1-kabel@kernel.org> References: <20241104141924.18816-1-kabel@kernel.org> Precedence: bulk X-Mailing-List: soc@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add documentation for driver private structures, `struct omnia_leds` and `struct omnia_led`. Signed-off-by: Marek Behún --- drivers/leds/leds-turris-omnia.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index 50fef4389c93..7d2ed0c6500a 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -19,6 +19,15 @@ /* MCU controller I2C address 0x2a, needed for detecting MCU features */ #define OMNIA_MCU_I2C_ADDR 0x2a +/** + * struct omnia_led - per-LED part of driver private data structure + * @mc_cdev: multi-color LED class device + * @subled_info: per-channel information + * @cached_channels: cached values of per-channel brightness that was sent to the MCU + * @on: whether the LED was set on + * @hwtrig: whether the LED blinking was offloaded to the MCU + * @reg: LED identifier to the MCU + */ struct omnia_led { struct led_classdev_mc mc_cdev; struct mc_subled subled_info[OMNIA_LED_NUM_CHANNELS]; @@ -29,6 +38,13 @@ struct omnia_led { #define to_omnia_led(l) container_of(l, struct omnia_led, mc_cdev) +/** + * struct omnia_leds - driver private data structure + * @client: I2C client device + * @lock: mutex to protect + * @has_gamma_correction: whether the MCU firmware supports gamma correction + * @leds: flexible array of per-LED data + */ struct omnia_leds { struct i2c_client *client; struct mutex lock; From patchwork Mon Nov 4 14:19:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13861481 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7F7C4502B for ; Mon, 4 Nov 2024 14:20:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730730001; cv=none; b=jrarhIaQ32HfihM812Z5U2fOszQGsK9zJHpHQu3NZEb10rm7LBKsJ3o37jyZ6reEL0DIO05eGgGT/lLJBCtIHeBnWrRgEIj+Y0ZbsP12BjXsMAkKbfOY/3q1wVR1UmwLA91vuJww2ODg9cxNvjpDSIAWrSZbHFeBrI1NVPFvgg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730730001; c=relaxed/simple; bh=SlODgSG/IsQ68Nggxqk0gTPcTViSrI9YmTzyE7UmCnY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nHNf7ujptzoUhpgz0ILfwxfvAuPHxHhlIRWDuUfUHKQeizzlkSxnHjtvjc501OJtfIOSEuuO1CyqYvqR3jPrnUkNor2RBRp6my7XattPC7kWiA8JvjVZEllsBQrtM306BcI4FtImNXjq/Bpl91ycSjxusjcrnU1IvFqOZ5ZG9Fk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Fw/ZaRQp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Fw/ZaRQp" Received: by smtp.kernel.org (Postfix) id DC049C4AF0C; Mon, 4 Nov 2024 14:20:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 314B6C4CED2; Mon, 4 Nov 2024 14:19:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730730000; bh=SlODgSG/IsQ68Nggxqk0gTPcTViSrI9YmTzyE7UmCnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fw/ZaRQp9UW+1qqpdjedwC/MfQuzwUkHLjnMAqPa/GAU7yKAtwB/QjZ902/DT+l5t gYA3duve2L6zILYMA/IkTWOrs/VNklAsUIOkU2DaJn1AfDzh4QsaOA5jTzJbmjeZyL z2p5/hP8WWJ6/qHBJKV5FTe+IpqK1PeGOWn4RKDwiNLdFPI2olnSXShd9LwKvkUBEU iUXy8WU0zkHYBoXh1zjw43qo/P+dCv1qUBUTlf9guKVvQd4LxBTY9nSqEIABEK2Iea Nlsq11EIPh47wgvZBThS7C1z66S8lRvqtIbl/uKzr4VG6o2ByF6OcUBLCxGQ9eke4E DqoayPUMKQO1A== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lee Jones Cc: Pavel Machek , linux-leds@vger.kernel.org, Arnd Bergmann , soc@kernel.org, Gregory CLEMENT , arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andrew Lunn , Sebastian Hesselbarth , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, =?utf-8?q?M?= =?utf-8?q?arek_Beh=C3=BAn?= Subject: [PATCH leds v5 07/12] leds: turris-omnia: Notify sysfs on MCU global LEDs brightness change Date: Mon, 4 Nov 2024 15:19:19 +0100 Message-ID: <20241104141924.18816-8-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241104141924.18816-1-kabel@kernel.org> References: <20241104141924.18816-1-kabel@kernel.org> Precedence: bulk X-Mailing-List: soc@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Recall that on Turris Omnia, the LED controller has a global brightness property, which allows the user to make the front LED panel dimmer. There is also a button on the front panel, which by default is configured so that pressing it changes the global brightness to a lower value (unless it is at 0%, in which case pressing the button changes the global brightness to 100%). Newer versions of the MCU firmware support informing the SOC that the brightness was changed by button press event via an interrupt. Now that we have the turris-omnia-mcu driver, which adds support for MCU interrupts, add the ability to inform the userspace (via a sysfs notification) that the global brightness was changed. Signed-off-by: Marek Behún --- drivers/leds/Kconfig | 2 +- drivers/leds/leds-turris-omnia.c | 48 ++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index fcbe93b61e49..148384aacdcc 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -217,7 +217,7 @@ config LEDS_TURRIS_OMNIA depends on I2C depends on MACH_ARMADA_38X || COMPILE_TEST depends on OF - depends on TURRIS_OMNIA_MCU + depends on TURRIS_OMNIA_MCU_GPIO select LEDS_TRIGGERS help This option enables basic support for the LEDs found on the front diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index 7d2ed0c6500a..168ce362fd14 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -43,12 +43,15 @@ struct omnia_led { * @client: I2C client device * @lock: mutex to protect * @has_gamma_correction: whether the MCU firmware supports gamma correction + * @brightness_knode: kernel node of the "brightness" device sysfs attribute (this is the + * driver specific global brightness, not the LED classdev brightness) * @leds: flexible array of per-LED data */ struct omnia_leds { struct i2c_client *client; struct mutex lock; bool has_gamma_correction; + struct kernfs_node *brightness_knode; struct omnia_led leds[]; }; @@ -373,6 +376,30 @@ static struct attribute *omnia_led_controller_attrs[] = { }; ATTRIBUTE_GROUPS(omnia_led_controller); +static irqreturn_t omnia_brightness_changed_threaded_fn(int irq, void *data) +{ + struct omnia_leds *leds = data; + + if (unlikely(!leds->brightness_knode)) { + /* + * It would be nicer to get this dirent in the driver probe method, before the IRQ + * is requested. But the really_probe() function in drivers/base/dd.c registers + * driver's .dev_groups only after probe is finished, so during driver probe the + * "brightness" sysfs node is not yet present. + * + * Note that sysfs_get_dirent() may sleep. This is okay, because we are in threaded + * context. + */ + leds->brightness_knode = sysfs_get_dirent(leds->client->dev.kobj.sd, "brightness"); + if (!leds->brightness_knode) + return IRQ_NONE; + } + + sysfs_notify_dirent(leds->brightness_knode); + + return IRQ_HANDLED; +} + static int omnia_mcu_get_features(const struct i2c_client *mcu_client) { u16 reply; @@ -459,6 +486,14 @@ static int omnia_leds_probe(struct i2c_client *client) "Consider upgrading MCU firmware with the omnia-mcutool utility.\n"); } + if (client->irq && (ret & OMNIA_FEAT_BRIGHTNESS_INT)) { + ret = devm_request_threaded_irq(dev, client->irq, NULL, + omnia_brightness_changed_threaded_fn, IRQF_ONESHOT, + "leds-turris-omnia", leds); + if (ret < 0) + return dev_err_probe(dev, ret, "Cannot request brightness IRQ\n"); + } + mutex_init(&leds->lock); ret = devm_led_trigger_register(dev, &omnia_hw_trigger); @@ -481,6 +516,19 @@ static int omnia_leds_probe(struct i2c_client *client) static void omnia_leds_remove(struct i2c_client *client) { + struct omnia_leds *leds = i2c_get_clientdata(client); + + /* + * We need to free the brightness IRQ here, before putting away the brightness sysfs node. + * Otherwise devres would free the interrupt only after the sysfs node is removed, and if + * an interrupt occurred between those two events, it would use a removed sysfs node. + */ + devm_free_irq(&client->dev, client->irq, leds); + + /* Now put away the sysfs node we got the first time the interrupt handler was called */ + if (leds->brightness_knode) + sysfs_put(leds->brightness_knode); + /* put all LEDs into default (HW triggered) mode */ omnia_cmd_write_u8(client, OMNIA_CMD_LED_MODE, OMNIA_CMD_LED_MODE_LED(OMNIA_BOARD_LEDS)); From patchwork Mon Nov 4 14:19:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13861482 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 080224502B for ; Mon, 4 Nov 2024 14:20:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730730005; cv=none; b=GY8Y33KJOPs5rtuMWtp6o979oGta1wbrHo4vvwnv1rRpjmYVHCbiBCMS94EtubJzpg7NL665nK9HEN7EcC9Z4kPuMTWaGz1XYFpwbca4Pu71D2eukR/staqVrgOBObSHXDqLnW8kLv2snx/47Ltc3e+AiSDxklj3Sj8wUzLK4KE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730730005; c=relaxed/simple; bh=8xxaLaeqEAFIPs2iLJxr0JwGVdVOwPrRyzlBgb3dEzU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bwleba7VRIfbO5IYxB9BQsr4s0Sc/JePI4C3ySX5cghxYdzqucwlIqUeil492GvI74YR5NTCNZCJ/90rtV+tkScQt9fUDiyCBU2yhVsPoEngJn8RzClqfB8/RB1kMxGuqL0qh4uLYIPkoUizqVNiBIW44WKgyz6hdKpJD1x62jQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WInPpBmD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WInPpBmD" Received: by smtp.kernel.org (Postfix) id F2EB4C4AF0B; Mon, 4 Nov 2024 14:20:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4502FC4CEDD; Mon, 4 Nov 2024 14:20:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730730004; bh=8xxaLaeqEAFIPs2iLJxr0JwGVdVOwPrRyzlBgb3dEzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WInPpBmD6JDX1KIblM+gi9jXX6DShPYToEZYpuJRQOFLNXlVlbwZMOb8izWA2pbYt 0OEfZet6Wr9pZ2XSE9tesJzDX6qjE/ApM1h7F/N7mlLEPXDfFQso0/qmHj6B0KuvWt LlneDCgdzrJNRiQaHw+BTYVsW5O3zYP+CJKNWSPLcbU6JULSZArzgJQ2i2SnxPbTCt zflnHbgbSPNOFn6a4k60eMKHSsRVOd1QD1sXwnlMzZHVkuEHPcpBWXt9yv9byDtcXp F4gb3hgvsuklweXEqWPmRe25l47DAxQ8nmuFuEXtmBtI6CyYeEHkF/n+VSx4Oanf5S S+8zqhg8EagNA== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lee Jones Cc: Pavel Machek , linux-leds@vger.kernel.org, Arnd Bergmann , soc@kernel.org, Gregory CLEMENT , arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andrew Lunn , Sebastian Hesselbarth , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, =?utf-8?q?M?= =?utf-8?q?arek_Beh=C3=BAn?= Subject: [PATCH leds v5 08/12] platform: cznic: turris-omnia-mcu: Inform about missing LED panel brightness change interrupt feature Date: Mon, 4 Nov 2024 15:19:20 +0100 Message-ID: <20241104141924.18816-9-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241104141924.18816-1-kabel@kernel.org> References: <20241104141924.18816-1-kabel@kernel.org> Precedence: bulk X-Mailing-List: soc@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When reading MCU firmware features, check also for the LED panel brightness change interrupt feature, and suggest upgrading the firmware if it is missing. Signed-off-by: Marek Behún --- drivers/platform/cznic/turris-omnia-mcu-base.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/platform/cznic/turris-omnia-mcu-base.c b/drivers/platform/cznic/turris-omnia-mcu-base.c index bb871226e357..3bb4a3cfdb29 100644 --- a/drivers/platform/cznic/turris-omnia-mcu-base.c +++ b/drivers/platform/cznic/turris-omnia-mcu-base.c @@ -258,6 +258,7 @@ static int omnia_mcu_read_features(struct omnia_mcu *mcu) _DEF_FEAT(NEW_INT_API, "new interrupt API"), _DEF_FEAT(POWEROFF_WAKEUP, "poweroff and wakeup"), _DEF_FEAT(TRNG, "true random number generator"), + _DEF_FEAT(BRIGHTNESS_INT, "LED panel brightness change interrupt"), #undef _DEF_FEAT }; struct i2c_client *client = mcu->client; From patchwork Mon Nov 4 14:19:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13861483 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D6FB2AD0C for ; Mon, 4 Nov 2024 14:20:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730730009; cv=none; b=gGBupVVhss9eb3owL7iR2e3LB68KMSFbzXtKrkVD4Ct7DbTHbOYt2Qj9W3vkvaSmjQ7hl0RzqQsyVKcK2PIeDXRA9rd2nG0+qFMIOn2dRUJZWU5qKqZC3rEBUPf71Ah2dUqyb8Hzz4RL6BtMO9PCQPrl4/izjeavyQS58h2npuw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730730009; c=relaxed/simple; bh=v+4wpYKP4Bkc9/Tq8/Zeq+f2mOiKlspjFg9hSrNjaqU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RQPSB0XMrA5HAlCeUlT6Dy7/vpOwMfkPMzxkUGXMp/O3eZmh8bEHzUhFcAgSAngNlecfCxGVtB7qRfUDPz8NQgXm5SGIND3I3lwXss0MxqnbxK56LToxhf1+7cyPtwtGD82L9xV97/Ryx5HVKfeMFWFk9TxH4ULMwBmoP80/WeE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZofDMtKp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZofDMtKp" Received: by smtp.kernel.org (Postfix) id 12C75C4AF0D; Mon, 4 Nov 2024 14:20:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B405C4CED1; Mon, 4 Nov 2024 14:20:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730730009; bh=v+4wpYKP4Bkc9/Tq8/Zeq+f2mOiKlspjFg9hSrNjaqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZofDMtKphrH6ovc2vdFOjYuB0xC6o/btw0y7qB98/aC0Ks+62pS5yNRQST24035U9 Kh6lxcfFtachiLrxv6NzMj9yInyHZ1J5nAj1y+pgQDlGfaG22S0XsTSjjsbIa+UdbU RZ59BhPVesnClB4LrNh8bdppdB2tUtAELqglh5lmsveB/100yWi5rvEdnqncYRFeXs UIRKy16WobohMsBCelGxMa4F3/wURDLTH0DL8J8vXJiZi4kxic+tgg23J9yQDLv21w dw+B8jiA98ttYi0fbrYR1olwYDa0OR8rtu45TOQ/Z7FI957A6BpqCP7FRKemA7XptO sSa4plbI1cHLA== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lee Jones Cc: Pavel Machek , linux-leds@vger.kernel.org, Arnd Bergmann , soc@kernel.org, Gregory CLEMENT , arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andrew Lunn , Sebastian Hesselbarth , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, =?utf-8?q?M?= =?utf-8?q?arek_Beh=C3=BAn?= Subject: [PATCH leds v5 09/12] leds: turris-omnia: Inform about missing LED gamma correction feature in the MCU driver Date: Mon, 4 Nov 2024 15:19:21 +0100 Message-ID: <20241104141924.18816-10-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241104141924.18816-1-kabel@kernel.org> References: <20241104141924.18816-1-kabel@kernel.org> Precedence: bulk X-Mailing-List: soc@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If the LED gamma correction feature is missing in the MCU firmware, inform about this in the MCU firmware probe function instead of LED driver probe function, so that all the feature checks are in one place. Signed-off-by: Marek Behún --- drivers/leds/leds-turris-omnia.c | 6 ------ drivers/platform/cznic/turris-omnia-mcu-base.c | 1 + 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index 168ce362fd14..d26200d34237 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -479,12 +479,6 @@ static int omnia_leds_probe(struct i2c_client *client) } leds->has_gamma_correction = ret & OMNIA_FEAT_LED_GAMMA_CORRECTION; - if (!leds->has_gamma_correction) { - dev_info(dev, - "Your board's MCU firmware does not support the LED gamma correction feature.\n"); - dev_info(dev, - "Consider upgrading MCU firmware with the omnia-mcutool utility.\n"); - } if (client->irq && (ret & OMNIA_FEAT_BRIGHTNESS_INT)) { ret = devm_request_threaded_irq(dev, client->irq, NULL, diff --git a/drivers/platform/cznic/turris-omnia-mcu-base.c b/drivers/platform/cznic/turris-omnia-mcu-base.c index 3bb4a3cfdb29..770e680b96f9 100644 --- a/drivers/platform/cznic/turris-omnia-mcu-base.c +++ b/drivers/platform/cznic/turris-omnia-mcu-base.c @@ -259,6 +259,7 @@ static int omnia_mcu_read_features(struct omnia_mcu *mcu) _DEF_FEAT(POWEROFF_WAKEUP, "poweroff and wakeup"), _DEF_FEAT(TRNG, "true random number generator"), _DEF_FEAT(BRIGHTNESS_INT, "LED panel brightness change interrupt"), + _DEF_FEAT(LED_GAMMA_CORRECTION, "LED gamma correction"), #undef _DEF_FEAT }; struct i2c_client *client = mcu->client; From patchwork Mon Nov 4 14:19:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13861484 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 684FE13CA81 for ; Mon, 4 Nov 2024 14:20:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730730013; cv=none; b=JYzjiy0HFqRNxPLAIqTlJxxBMykiGc2AvvPK98YfmFQN5GCabJfRwxD/wc20+dg2SZ/q55TLyVXtxR5AYryFDXEAIZ+s9I8ljyOfc25HOs1EPFWtxUaZL4Pf3trSoUgiCDwCqwzWlaY3UzDY/V5koqz9BSFBHnvAZ60lqunF6gk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730730013; c=relaxed/simple; bh=1fdnVe+JrWceCYOK/R8vtGz9yb1mrHPfcJe2zoo5qAg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TLlcSuje1n1Xa/+1RW/8si+GbHJ0JpT1LPfUxawVd5n3+K+joyazxjMmM10RxTMXzYrBVIAuiJLlVl9PLpv37Y+aUwAs38iBnOzbGIGdxgDqPgdBodgAIHnukMpqK3QSyL9q+xifvujRVX4fX1+rV5ENfONv6G3yK/gmcfI5aIQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BMSDzCR1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BMSDzCR1" Received: by smtp.kernel.org (Postfix) id 28A64C4AF0D; Mon, 4 Nov 2024 14:20:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F611C4CED0; Mon, 4 Nov 2024 14:20:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730730013; bh=1fdnVe+JrWceCYOK/R8vtGz9yb1mrHPfcJe2zoo5qAg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BMSDzCR16Cga8z2tZ4qTX2e3TjOz/JFdFRPJTBbQ/C4LU2slNxifXd751zJ7BmIf9 19CGcTcS5pStzujP1dOLIzf8ncOCXhmR7735AO8n3cEQDCi0XYMtsEUse6aAcC+n2U uKSuG0qG6C7hbcFd6wPHehuNCHxt0tV3yufAKffUwLzn/9x1/Ww6s/nTg/2sroCL/M x7aNPxn8rjPLjaP7G812/S3PndApU5QeVEaxmSD8U4vHoTpl5VUZ18QRkoBgWolVPb ZylDgBKw+zLJ2JSZ3R+f3jqqT2+Yz4BVHXZUhwmohXjpnfykXczw7RdWioTs/uNDUn P4q67cQWIQBTA== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lee Jones Cc: Pavel Machek , linux-leds@vger.kernel.org, Arnd Bergmann , soc@kernel.org, Gregory CLEMENT , arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andrew Lunn , Sebastian Hesselbarth , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, =?utf-8?q?M?= =?utf-8?q?arek_Beh=C3=BAn?= Subject: [PATCH leds v5 10/12] leds: turris-omnia: Use dev_err_probe() where appropriate Date: Mon, 4 Nov 2024 15:19:22 +0100 Message-ID: <20241104141924.18816-11-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241104141924.18816-1-kabel@kernel.org> References: <20241104141924.18816-1-kabel@kernel.org> Precedence: bulk X-Mailing-List: soc@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use dev_err_probe() instead of dev_err() + separate return where appropriate. Signed-off-by: Marek Behún --- drivers/leds/leds-turris-omnia.c | 50 ++++++++++---------------------- 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index d26200d34237..51f68252fa2c 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -256,33 +256,23 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led, /* put the LED into software mode */ ret = omnia_cmd_write_u8(client, OMNIA_CMD_LED_MODE, OMNIA_CMD_LED_MODE_LED(led->reg) | OMNIA_CMD_LED_MODE_USER); - if (ret) { - dev_err(dev, "Cannot set LED %pOF to software mode: %i\n", np, - ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "Cannot set LED %pOF to software mode\n", np); /* disable the LED */ ret = omnia_cmd_write_u8(client, OMNIA_CMD_LED_STATE, OMNIA_CMD_LED_STATE_LED(led->reg)); - if (ret) { - dev_err(dev, "Cannot set LED %pOF brightness: %i\n", np, ret); - return ret; - } + if (ret) + return dev_err_probe(dev, ret, "Cannot set LED %pOF brightness\n", np); /* Set initial color and cache it */ ret = omnia_led_send_color_cmd(client, led); - if (ret < 0) { - dev_err(dev, "Cannot set LED %pOF initial color: %i\n", np, - ret); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, "Cannot set LED %pOF initial color\n", np); ret = devm_led_classdev_multicolor_register_ext(dev, &led->mc_cdev, &init_data); - if (ret < 0) { - dev_err(dev, "Cannot register LED %pOF: %i\n", np, ret); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, "Cannot register LED %pOF\n", np); return 1; } @@ -456,13 +446,10 @@ static int omnia_leds_probe(struct i2c_client *client) int ret, count; count = of_get_available_child_count(np); - if (!count) { - dev_err(dev, "LEDs are not defined in device tree!\n"); - return -ENODEV; - } else if (count > OMNIA_BOARD_LEDS) { - dev_err(dev, "Too many LEDs defined in device tree!\n"); - return -EINVAL; - } + if (count == 0) + return dev_err_probe(dev, -ENODEV, "LEDs are not defined in device tree!\n"); + if (count > OMNIA_BOARD_LEDS) + return dev_err_probe(dev, -EINVAL, "Too many LEDs defined in device tree!\n"); leds = devm_kzalloc(dev, struct_size(leds, leds, count), GFP_KERNEL); if (!leds) @@ -472,11 +459,8 @@ static int omnia_leds_probe(struct i2c_client *client) i2c_set_clientdata(client, leds); ret = omnia_find_mcu_and_get_features(dev); - if (ret < 0) { - dev_err(dev, "Cannot determine MCU supported features: %d\n", - ret); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, "Cannot determine MCU supported features\n"); leds->has_gamma_correction = ret & OMNIA_FEAT_LED_GAMMA_CORRECTION; @@ -491,10 +475,8 @@ static int omnia_leds_probe(struct i2c_client *client) mutex_init(&leds->lock); ret = devm_led_trigger_register(dev, &omnia_hw_trigger); - if (ret < 0) { - dev_err(dev, "Cannot register private LED trigger: %d\n", ret); - return ret; - } + if (ret < 0) + return dev_err_probe(dev, ret, "Cannot register private LED trigger\n"); led = &leds->leds[0]; for_each_available_child_of_node_scoped(np, child) { From patchwork Mon Nov 4 14:19:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13861485 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A26D13A257 for ; Mon, 4 Nov 2024 14:20:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730730017; cv=none; b=WPZFAR7NItsQ48e+JboFMuOTP0+vP5QfF0Z7uCW6lnPhvcy4m2r3GF8uGLYGyjttv5+yydZ5qReN0pjDSyQ2piyupLlKH3uWGVq9tmCY6Jq39a776v2bB6+uDc+BYyTz4kudzMV676ztY0KwVs3daBci/6HXdxRWZdc4A52mYjs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730730017; c=relaxed/simple; bh=SceZzYvRl3MzrSiPy/Plowa5y9Lt9xq2+UK4lTG9wEU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Fw+fp4pSKTBRbsqRCSgAlN3cHJm+m5IAYVK+7ZqKa42tuEpwG07+kn//PQtKEkUk92JtCg2UsrWBXlhRXPF32JH4dCMbBeaxr+TGrEXc5ldFpmx29BmwlE+/KtnO7yNPtM4yYP7a82DSyvKafBeqwknzOF+buw7SOp6khX0ctCM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DY7Z+Brx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DY7Z+Brx" Received: by smtp.kernel.org (Postfix) id 3DA67C4CED1; Mon, 4 Nov 2024 14:20:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85B3EC4CED0; Mon, 4 Nov 2024 14:20:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730730017; bh=SceZzYvRl3MzrSiPy/Plowa5y9Lt9xq2+UK4lTG9wEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DY7Z+BrxVohJXPN+lOdq3mHH4rmmsJBpa7ai80p/84EZceB83ep6jYI0YXy0vvVj+ ogz374yc4xJfN3/u4VcRrQiqHqZHwVu7IuNiordXX0MKCXlFC8s5GNR9DoT7pN0/xN KT6YkADitoXTOtLDWEjlvQ7JlY2n+3vxlpPCoRljtjjqPPeB/dijpLCvP+vBjg2kMl PNM51OM9WGeW5NgzIgkUXoZ9JPJDfTLsZSNXRCGSox4HiWEfGMzyBcs/YIG9oAcgxl tzpUKDEgsXU9PAhYrBUiKvRHrVLx1NbYuRfuo2axfGUVT0Ku/A+ONYR15kdsubzMiy CPvKJmjh046pw== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lee Jones Cc: Pavel Machek , linux-leds@vger.kernel.org, Arnd Bergmann , soc@kernel.org, Gregory CLEMENT , arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andrew Lunn , Sebastian Hesselbarth , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, =?utf-8?q?M?= =?utf-8?q?arek_Beh=C3=BAn?= Subject: [PATCH leds v5 11/12] leds: turris-omnia: Use uppercase first letter in all comments Date: Mon, 4 Nov 2024 15:19:23 +0100 Message-ID: <20241104141924.18816-12-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241104141924.18816-1-kabel@kernel.org> References: <20241104141924.18816-1-kabel@kernel.org> Precedence: bulk X-Mailing-List: soc@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Change first letter of 4 more comments to uppercase to make the driver comments uniform. Signed-off-by: Marek Behún --- drivers/leds/leds-turris-omnia.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index 51f68252fa2c..e255b911cca7 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -253,13 +253,13 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led, */ cdev->default_trigger = omnia_hw_trigger.name; - /* put the LED into software mode */ + /* Put the LED into software mode */ ret = omnia_cmd_write_u8(client, OMNIA_CMD_LED_MODE, OMNIA_CMD_LED_MODE_LED(led->reg) | OMNIA_CMD_LED_MODE_USER); if (ret) return dev_err_probe(dev, ret, "Cannot set LED %pOF to software mode\n", np); - /* disable the LED */ + /* Disable the LED */ ret = omnia_cmd_write_u8(client, OMNIA_CMD_LED_STATE, OMNIA_CMD_LED_STATE_LED(led->reg)); if (ret) return dev_err_probe(dev, ret, "Cannot set LED %pOF brightness\n", np); @@ -505,10 +505,10 @@ static void omnia_leds_remove(struct i2c_client *client) if (leds->brightness_knode) sysfs_put(leds->brightness_knode); - /* put all LEDs into default (HW triggered) mode */ + /* Put all LEDs into default (HW triggered) mode */ omnia_cmd_write_u8(client, OMNIA_CMD_LED_MODE, OMNIA_CMD_LED_MODE_LED(OMNIA_BOARD_LEDS)); - /* set all LEDs color to [255, 255, 255] */ + /* Set all LEDs color to [255, 255, 255] */ omnia_cmd_set_color(client, OMNIA_BOARD_LEDS, 255, 255, 255); } From patchwork Mon Nov 4 14:19:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13861486 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B9462AD0C for ; Mon, 4 Nov 2024 14:20:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730730021; cv=none; b=syok2oxzrTLvwbmF+tn9FmwTci4oTq2yTrFxj5/TvGl/YOhu4EpoZIucRBj/UCaAGgWh9oa/UjkztfH9LY/Mh9bMtJozfkGztpN9HYGr/psjdR9WturGcV6PraGHDRve0vVxZAnLWGha7lhKf2UmA3MpUo9OorbnRSU58K/TbP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730730021; c=relaxed/simple; bh=02cumqv7Pptd8Tkhcc6pofXSXkHGb+wYsFd9giydYr4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YENNs6c+NcAJumb2bythQj4D1WXdj75Vdy9qcCKHmGU3Cjdbm9Ahm6V/sWUKf0J6TVsAwlvFPoROM/AX/H03OnLAG8vBkorto8wvWmSYszKvb4KAkToodtKEAnrPrC5dQrT5uwfGDKqT6isEFsyETUV/WH3EvlDRA3wP6JLA2fs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mJRmrsJO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mJRmrsJO" Received: by smtp.kernel.org (Postfix) id 53D05C4CED0; Mon, 4 Nov 2024 14:20:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C424C4CEDB; Mon, 4 Nov 2024 14:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730730021; bh=02cumqv7Pptd8Tkhcc6pofXSXkHGb+wYsFd9giydYr4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mJRmrsJOR9MTLMeiDc3UdRBlUA6b8l9lBH5W129vD3MOgCD+YrhKDsJbP69La44ki GTJrs2jdcMVPryBJOZxP8fUcCndSyjO3hhp6UAbhJ0mbP1o6f5ReM9k+II1udOf4TA Maanwxq/pGBPWz2mDBIPt6l76rhrDLwVCYe0iftXy6C0k7CMpDcPG7MAN9SyI1Fp8A 5l4VQujSQ2bC0gLJp9kFzpBD8v4YegsYSjjuN4zYRs9NhwXgv6AG9+QrLrTB1G1ZA1 SKaJCzqzlVgkvW1Pv9deMWBsXSAfWTe3Up91paYIHzAwsnmq9sj4zHg8JDTIaDJNDD 7OrPhW0FBMm6g== From: =?utf-8?q?Marek_Beh=C3=BAn?= To: Lee Jones Cc: Pavel Machek , linux-leds@vger.kernel.org, Arnd Bergmann , soc@kernel.org, Gregory CLEMENT , arm@kernel.org, Andy Shevchenko , Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andrew Lunn , Sebastian Hesselbarth , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, =?utf-8?q?M?= =?utf-8?q?arek_Beh=C3=BAn?= Subject: [PATCH leds v5 12/12] ARM: dts: turris-omnia: Add global LED brightness change interrupt Date: Mon, 4 Nov 2024 15:19:24 +0100 Message-ID: <20241104141924.18816-13-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241104141924.18816-1-kabel@kernel.org> References: <20241104141924.18816-1-kabel@kernel.org> Precedence: bulk X-Mailing-List: soc@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When global LED brightness is changed by pressing the front button on Turris Omnia, the MCU can produce an interrupt to the CPU. Add the description of this interrupt to the LED controller node. Signed-off-by: Marek Behún --- arch/arm/boot/dts/marvell/armada-385-turris-omnia.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/boot/dts/marvell/armada-385-turris-omnia.dts b/arch/arm/boot/dts/marvell/armada-385-turris-omnia.dts index 43202890c959..83fe00abd652 100644 --- a/arch/arm/boot/dts/marvell/armada-385-turris-omnia.dts +++ b/arch/arm/boot/dts/marvell/armada-385-turris-omnia.dts @@ -251,6 +251,7 @@ mcu: system-controller@2a { led-controller@2b { compatible = "cznic,turris-omnia-leds"; reg = <0x2b>; + interrupts-extended = <&mcu 11 IRQ_TYPE_NONE>; #address-cells = <1>; #size-cells = <0>; status = "okay";