From patchwork Fri Nov 8 13:28:34 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: 13868191 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 9F7A31E2857 for ; Fri, 8 Nov 2024 13:28:59 +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=1731072539; cv=none; b=j6BtzFoobqlcNZ3qoFtAnRXYInLI4E0Ljjj2h8odJsfQGgeywYEyqxK4QP39LaktAGkt/DapF3uM7ydOmyT1VwFmYBn//T6c0sRh6+2AoYwCxbfeGw5QvqwwZZWksK0V/8TLmmgiS52ZhBOOMgVNvwlaT9N5X/HotVF5Oad9F7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731072539; 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=j6ey99CeeCSemxdS4t5EoX9kRJ2il1gUrYGwoh9M9PMOcgyRHQtQPNoM5Daay/hBL//rfdf+4JvS3rv351PfR1/kl7Ka1t43rCTXEYTGsKCgoOq0gGzSRrCWjLBLe+4dl6EVG9zSRE4ImAUpmoBm7Pm7Md9IfBNoi53Ma8dSXqI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O7O7p0LL; 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="O7O7p0LL" Received: by smtp.kernel.org (Postfix) id 6EE68C4CED0; Fri, 8 Nov 2024 13:28:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECE4FC4CED3; Fri, 8 Nov 2024 13:28:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731072539; bh=eeBYr2p6za6laSDrNMtl6LIf0+fxsP9YIvYI/u+rMD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O7O7p0LL3to9gBufohwEKaeiIYp+7/Nets7sbjf2WCjpY6odZ70lViRkHqgr0yK+C 8wFPvSYESOVsW7uUYkIvxIn4eN0cIhSOBeXRztPQSszohqkAlTXG2cgkiFr1emW9Jf hobcMGzeLFEs84ksiEgIsdqBnQOk1oBKKp8e+i4PU2g44J3RBn8JvoTYXmcRVx4QtC v+nQ/isRKvIQLoKk4kN9CgLHs8cJHNib91K1BnPi6gCjwXz9A9r0LuFi5lYgNicJz+ oUYpSrougQxnYWDxFSc3z1e2qQYst8lSiqJhhU0hv+SbOliUWkRRP0WHB0kSgBbPwU Za3f+DhTmPLoQ== 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 v6 01/12] turris-omnia-mcu-interface.h: Move command execution function to global header Date: Fri, 8 Nov 2024 14:28:34 +0100 Message-ID: <20241108132845.31005-2-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108132845.31005-1-kabel@kernel.org> References: <20241108132845.31005-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 Fri Nov 8 13:28:35 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: 13868192 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 76F081EABDA for ; Fri, 8 Nov 2024 13:29:03 +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=1731072543; cv=none; b=oxqj2dJ9yS5AdFbsg2P8VJPN3dUSQ/bEVUPSDjn0PevRvMsNvi878qyu0yMEJMb6SSmDJOlhbzRRCaAmf8WrkKpu3+iD/kozsg4GrFdd85LUhGnkk8LrjOcKZYaUt3WV/bcHoFo/jgZgBWYU+j8zRHwXd46RUCl9GAP3p+sNJNA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731072543; c=relaxed/simple; bh=D6A9yZwod9RyaYcsbShQlW2Y89y5mowC4F2k/d7+MZc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fh6sCt1i2cxuxp2W/l32oMgw8jGh+8PoXT8sASUHqUaETRPTcjNUEK12kqpU5VINPz6iXx/cmbpBXEZaI7Xrz2P9z1N2dgePTPcoFpdE1bgVy8xxfoL5/Zl5hpl3sISU2cYf5bx7tm6AgyrZUT8tc5rXeZIRXilq7iwn5dLx2zc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q2ViHql3; 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="Q2ViHql3" Received: by smtp.kernel.org (Postfix) id 486DEC4CED5; Fri, 8 Nov 2024 13:29:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCB2BC4CED7; Fri, 8 Nov 2024 13:28:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731072543; bh=D6A9yZwod9RyaYcsbShQlW2Y89y5mowC4F2k/d7+MZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q2ViHql3+YxAKVLevKjBq+c+Xqts5g3FEkS15uDNTiCjep3BCOTbtHFTU4XJRfiTu 5B8PMXrNEGytw6kpOTBFXzDHA14bDcgMWJTZp965k7EHauA8xCJS+pQFbsxTPHkvvu m64k0iU9hHM5jGP76u4jjgyEJe0d0ljdPsuxgpqT3UsmN2U2fcPmSvsdaT+d1A2NCV UVocbvQk2TcCz7L7dKtC2b34Fe8AJBrAsEIWu7hJ+sf6vMyXoXI5u+VJPem/TgdKe4 dz8zvQIUYkOguKZ43Y1velRSt0awMyhxE32aJMkGHfAahWPflzwiNwKgAFvjLOU644 DG8bRMS75cEkg== 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 v6 02/12] leds: turris-omnia: Use command execution functions from the MCU driver Date: Fri, 8 Nov 2024 14:28:35 +0100 Message-ID: <20241108132845.31005-3-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108132845.31005-1-kabel@kernel.org> References: <20241108132845.31005-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 Fri Nov 8 13:28:36 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: 13868193 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 374531EB9F2 for ; Fri, 8 Nov 2024 13:29:07 +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=1731072547; cv=none; b=Pody6DLvxgRDDkr8G1VsnN2dpqUc+hS6YfmilfIu8iNSPzeNdGCLMozbhDBw/BFTMcB8gGjnIWCaOmNKB0ugM4f5c6GjUE+Nv34uwQXwFm6haDKDYYIw2x0bCXx/tiqMi3yyzupQ3WvFHjUjNdq4IPiPbaJI4sZRVk8AZ/yauMA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731072547; c=relaxed/simple; bh=k2ET+mNmV11DXD5Dqt3IxyuEPJFzW2WgZvGZBxEVi74=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kXz9KYPZw11QnQ+TYBDtST5AJ8RNproEXpsKKOcKvsPXmmOPjsJUKgbt2Ci0ioY4nJPDQcXTvZ1aE6j0DIT/p2TLsgONvy3njD17VKfwPOKmu3kDRPQSu7cLVVpsnWWVanJIhAdMUlvfayvuzK1ZYNsrRdRdcxzjR9k1aB+AVqg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=i4qvg5Hz; 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="i4qvg5Hz" Received: by smtp.kernel.org (Postfix) id 0AFA6C4CED4; Fri, 8 Nov 2024 13:29:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D894C4CED8; Fri, 8 Nov 2024 13:29:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731072546; bh=k2ET+mNmV11DXD5Dqt3IxyuEPJFzW2WgZvGZBxEVi74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i4qvg5Hz4Yh7Verd//i5NTdG0H8JmO93oHZgkxx3WxkWR+PgP8p2KVzHwrwdS5/Ry o0qfgeUDdbn1n/82VEH5C9/PghI72Cjoog2bpXuzPpbiAcTXDLr0lwu36llDyYr2Lu 0BbQAqut165hREGFVcIon08EiCsStwtu6oyCgSN3bTbTdxd7Y/mWkouOmpeJREdBFm rBBQMH8aORzHQtvIi3sGh1uXJbMwqra3oqcK/QoKRcaEgZYp0x6eWEkQMpJyJQN5eR Ikxx99Ab8I7WXp+22RBZ+iSTiznDueSKOHJBRNMmMh+GHRhQGVXnacYZpJPrtMMJYJ dcEII8FP/HWkw== 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 v6 03/12] turris-omnia-mcu-interface.h: Add LED commands related definitions to global header Date: Fri, 8 Nov 2024 14:28:36 +0100 Message-ID: <20241108132845.31005-4-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108132845.31005-1-kabel@kernel.org> References: <20241108132845.31005-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 Fri Nov 8 13:28:37 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: 13868194 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 330501EB9F6 for ; Fri, 8 Nov 2024 13:29:10 +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=1731072551; cv=none; b=uaLeF00+jYYJ0DDxDK7OkSpAJGLq92SjedeoGw7wi+Uz3acUDpIZebUR6y7X3pYoOipjuZNyn4VCUu8MHDNodk2RC6QbBvs+qOV2qK4tvO/523iiGOLdlZAY4kvwLQozeRM6VxGFvLKdiWXX+K/GVpjxAoQ6QfK2zM+nv6sTa3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731072551; c=relaxed/simple; bh=+BaD6yzWcHU4DwqJoicMokFjifwQXkQ4xTT2A5vPyxs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HAGEk7wpKCsu3P3/AKds1FSFikeB8TNn6+fkxFGUVoNDySq55+AvwTMMst/H66TzW6aw8ZEYI1AG8RiwQSqYFQuw8EMM5MifDt+VnpNbFU6Pq/J/fxJkS5BXnUMOmgD6INXPdtJncEtxoUlNwMqTAKiyI9qbaheVzo0WDbfhRQU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Xbbs7wAW; 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="Xbbs7wAW" Received: by smtp.kernel.org (Postfix) id CA5B8C4CED4; Fri, 8 Nov 2024 13:29:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C69CC4CED0; Fri, 8 Nov 2024 13:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731072550; bh=+BaD6yzWcHU4DwqJoicMokFjifwQXkQ4xTT2A5vPyxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xbbs7wAWkIsdmBwyq1LHcjok/FM6a6l0mQ+iKuut4CoIo3yrKjQXPFE6k03RzxtIk tEc3PuW0KQAskopLdhJAQg3+oDkxTdH2LvCn1NDY18xRkjny7l7ILkl1TqtBgfqjgB yaznyolleAV3ihS5YXpw/0Vgdbo3OI6d2ApdPodBP3otF9BqpCYL52WyCanh8FkHsl UgcYzGhazP5pvEvyT4MCq6OEWe3y//QNQGcGnOOajSdn0w6i/2gdXSXxbaRTC3rDwy yNS0MkJYuTSGOvWEzt12Dbo7ErVGObIPIBduzCmr9QnDCytiKedqqbjuSD2BqB004a aYPkg+4iTDLrw== 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 v6 04/12] leds: turris-omnia: Use global header for MCU command definitions Date: Fri, 8 Nov 2024 14:28:37 +0100 Message-ID: <20241108132845.31005-5-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108132845.31005-1-kabel@kernel.org> References: <20241108132845.31005-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 Fri Nov 8 13:28:38 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: 13868195 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 02AD41EABD3 for ; Fri, 8 Nov 2024 13:29:14 +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=1731072555; cv=none; b=XwnW1EnuBVc4m2zfX/UMz5+PcsAXUU7Y/28bU5VzCLiROCv/KiW6vcqAbZwlwCSyWv4HO4swU4Rf6Ghc/1LiO0IL8aGy7eRxmF5Eh13sXaia4gYxGwvWv/2pIK1btv7iMiwNyPqaI1CO5STCaklObVoKP710gKdnSOsv3mSEK2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731072555; c=relaxed/simple; bh=IL6ApZj/AEN4ogtSsw2hRDlMG6U3NVDiHfarNqZTetA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kiGgn6jhrDIDmt/YrT64vR6fscYaH3vGwOXufsXi4aeaXG9A5knXQbQIQLAGz5BpPw4o7gO67a0C93xOkAwJGxMnelIg5PpwR1dD8QE4nDd3N6XKmLtvXSima2oqlr6P8FsKYtdgfrJpTrsnO0jpqiepOG3LXmV2VAkU+ZzFkxk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RxcTkPzE; 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="RxcTkPzE" Received: by smtp.kernel.org (Postfix) id C55B8C4CED0; Fri, 8 Nov 2024 13:29:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A362C4CED9; Fri, 8 Nov 2024 13:29:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731072554; bh=IL6ApZj/AEN4ogtSsw2hRDlMG6U3NVDiHfarNqZTetA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RxcTkPzE8feuIqcjhDjR3p5UhmA5LgLvPrfxbiVeSw7P+d1FmBXmdpya+pNL/LFtp gsJ5bi8vrmNSXCtiPAKOVtdELj00PDPTlFxxlUmL6Mo5a1qmFy53tn3h6Ywio7UWWv VMKDZIs7EKyRcj0xb2HjH1XrI4f37Ee/eZ0qiym4xUG6+Wppej+HbmI48dlVF7W3fM P8hod2IPWOtr7ORb6bEym0oP6Od2kc8qrfhjmfPTBytoLOe4MLvcuuDE240Oc8ptix RadCtVaFFFnmxCZ9VwDCXUrwGRhetu8BUX5NgTG2dQwhrEFMifBTu/BciY0hb6EPS9 zR99xxNLPrazA== 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 v6 05/12] dt-bindings: leds: cznic,turris-omnia-leds: Allow interrupts property Date: Fri, 8 Nov 2024 14:28:38 +0100 Message-ID: <20241108132845.31005-6-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108132845.31005-1-kabel@kernel.org> References: <20241108132845.31005-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 Fri Nov 8 13:28:39 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: 13868196 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 99A8B1EE022 for ; Fri, 8 Nov 2024 13:29:18 +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=1731072558; cv=none; b=tjUIXwyY26n0f1z/GjbFy2LOcqipzEyhIiQCn2ZHfrrMC5i0HVAxhskVuYUmtLa5hsts4S0DsQUKv4e3+DVnpJwwRixKBnKFNllEfIvnBfvixXPiPafKOx16pfdT/5c81+vBnI5etS2SCa5Y3SWa2hzDsWalVphFqulxHkuNaao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731072558; c=relaxed/simple; bh=rTAIY6aQ5hb64k5weAhBRvT5KfxwL7qw3p8nyT7tcWs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=l/bA963s+cHpj07Qjs+gmmLGIIvYLjhSwTpVc+eLahkRLJyIOP9HCSjxG85suTsINyoQDi8NvI14uM+rxDZEBtC+OnO9Adl2PTb5+Bc+7JGKdLqu9K8BNuumj1G5argFCxf0ti02BqE4WFWUzHhy1L6szr42pWmaYunt9say26o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dlP1P3Yv; 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="dlP1P3Yv" Received: by smtp.kernel.org (Postfix) id 90AD0C4AF0C; Fri, 8 Nov 2024 13:29:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24448C4CED0; Fri, 8 Nov 2024 13:29:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731072558; bh=rTAIY6aQ5hb64k5weAhBRvT5KfxwL7qw3p8nyT7tcWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dlP1P3YvnkhI234tQ9DFN2eUOFfcjue+LHI6ChNlTDP7UBl+YM89jhwE99Bx5m3ET acbyOWzsTFqas6Y0mqZadcdqeR/AJo/MZVs1WN2ceeqhYhquv5LwHCDpZycmmAT//Q i7XA/0V3lbYUKLbjG+IY2RptwtmCu8yUCjfc3SWQCSMGhd4I6KM71YokJ7JM4i3Gau hVShnpU3icH8tw6HMz/rMTaeUh22j41GMPjgyYdYzYPNd65ZFBNFd4QbB775xo3BhX nIlV18wpFNT0PTj2kJSA3gRwr2M/F3ZdYhY6AVVyKRXFcSOMlwp82OtKzDcxmakqTi k4MWep/veY1nQ== 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 v6 06/12] leds: turris-omnia: Document driver private structures Date: Fri, 8 Nov 2024 14:28:39 +0100 Message-ID: <20241108132845.31005-7-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108132845.31005-1-kabel@kernel.org> References: <20241108132845.31005-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 Fri Nov 8 13:28:40 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: 13868197 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 69D4B1EC016 for ; Fri, 8 Nov 2024 13:29:22 +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=1731072562; cv=none; b=LCJEvyB+ozleGcCBJnxLblacLuLg3jPk7GX7wvfnCLYsrjT4TCpI+L1Wkm1hEuX6q4etBZ5s4D0g8BmViYBFJ1Tyu+oIfwd8G9nWteCbbQTbJ2qHz5dgS0Vb3kfxz4syMN+EBLXRzalWy2NSOfN4MajJuHpPqMMH0b4VK5LltAI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731072562; c=relaxed/simple; bh=2mCfw6DyCE9G4G1QDXR052pAiuSPWSjGKmy4YcCQVhM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sKAvm52QLCxFoNc1ai0e0WOtHdntfY9+FD2fcqz/C10pZWRo03TvWjeBZi47Q6XjHLPA91GEWRr1WLw+TvIHiu4HaF7/Q1tBzGqO388/k8c88d6SDIL/xvrGJX7YjwjleQLOx9zv7WBXTkq9XkNVijuypuWlhY9nqbJoVUkmn68= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=s2LaFnsY; 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="s2LaFnsY" Received: by smtp.kernel.org (Postfix) id 5F556C4AF0C; Fri, 8 Nov 2024 13:29:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6FD7C4CED3; Fri, 8 Nov 2024 13:29:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731072562; bh=2mCfw6DyCE9G4G1QDXR052pAiuSPWSjGKmy4YcCQVhM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s2LaFnsYVTJcX+S0mu6xfmiscCGEX6OR7am7zbqPt64CjvYDZH009GZQarH+8DnWw dNI6ZD+DLt82MmSRCmoTe4gURXPPt3B6WJkT/CAek9GxYhW3IZN53sMAcyZIp/9J6c Sz69PXOld3wCF2V8SFYkdtZgWqbMVQ+dKuzc9i5/hqi2MDrC51urN/R6VsoZ/J3YHr 0IHe8XFCo+ezsk9pH6tClC7s39GlV8zeGJebdR5XHOCkHEn5+xed+wGNNmlYFF2G0u jSPD/IT2tVxqmqCYveLBc2/sv+Ts4O0tFjtnEp6EJndO/SyMJuWm3Gc+G93DX6FSQ8 ws1rZNveD3StA== 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 v6 07/12] leds: turris-omnia: Notify sysfs on MCU global LEDs brightness change Date: Fri, 8 Nov 2024 14:28:40 +0100 Message-ID: <20241108132845.31005-8-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108132845.31005-1-kabel@kernel.org> References: <20241108132845.31005-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 | 1 + drivers/leds/leds-turris-omnia.c | 62 ++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index fcbe93b61e49..9ab6b56898c6 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -218,6 +218,7 @@ config LEDS_TURRIS_OMNIA 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..b2c37dd2e1cc 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,59 @@ 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)) { + /* + * 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 void omnia_brightness_knode_put(void *data) +{ + struct omnia_leds *leds = data; + + if (leds->brightness_knode) + sysfs_put(leds->brightness_knode); +} + +static int omnia_request_brightness_irq(struct omnia_leds *leds) +{ + struct device *dev = &leds->client->dev; + int ret; + + if (!leds->client->irq) { + dev_info(dev, + "Brightness change interrupt supported by MCU firmware but not described in device-tree\n"); + + return 0; + } + + /* + * Registering the brightness_knode destructor before requesting the IRQ ensures that on + * removal the brightness_knode sysfs node is put only after the IRQ is freed. + * This is needed because the interrupt handler uses the knode. + */ + ret = devm_add_action(dev, omnia_brightness_knode_put, leds); + if (ret < 0) + return ret; + + return devm_request_threaded_irq(dev, leds->client->irq, NULL, + omnia_brightness_changed_threaded_fn, IRQF_ONESHOT, + "leds-turris-omnia", leds); +} + static int omnia_mcu_get_features(const struct i2c_client *mcu_client) { u16 reply; @@ -459,6 +515,12 @@ static int omnia_leds_probe(struct i2c_client *client) "Consider upgrading MCU firmware with the omnia-mcutool utility.\n"); } + if (ret & OMNIA_FEAT_BRIGHTNESS_INT) { + ret = omnia_request_brightness_irq(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); From patchwork Fri Nov 8 13:28:41 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: 13868198 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 7A20C1EF92B for ; Fri, 8 Nov 2024 13:29:26 +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=1731072566; cv=none; b=PMvzKmhTNcAjBBR51XNBhCB24YzGwPFXRwaPI2dUtdHxFK3emI6hGMx5XEMUbaUDiYrKUnyMmMqs/4fcjGR1Mj9F9G9fdKmtQNeuf+csM9XFkNc/4jAWFGHcnXSu9Ms85IyLEREIhnfSYNZX9Xf0QQq8tW7y8n+tGvOBRyjCQZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731072566; c=relaxed/simple; bh=8xxaLaeqEAFIPs2iLJxr0JwGVdVOwPrRyzlBgb3dEzU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FuAoo9hBHcKF1GA2Zl/M5SFRL9JWYEs7p0rC4bu3AzbaDb1/zlgwW3RAtGbcl/2RSci6DaJQDmZLPZN4AtpIuAOwKYyKzq2xqpxw2E8Ch1wcFhiojnufLpnuCNDKz7PhyIGnwKIEXSdC0Dv+eldzT5I7yWkf50IhERFB/ServFg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Wc24V5K6; 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="Wc24V5K6" Received: by smtp.kernel.org (Postfix) id 2FE3CC4AF0C; Fri, 8 Nov 2024 13:29:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B68B9C4CED5; Fri, 8 Nov 2024 13:29:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731072566; bh=8xxaLaeqEAFIPs2iLJxr0JwGVdVOwPrRyzlBgb3dEzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wc24V5K6NOmGgBHHVV6UvSugHFUqXmenpiTWH6orzO5BlrtW+PUwiPDQD+HJ44EoE 7FMhMpj8GlWHVN7zMwdqKj6K9c3QgHC7WxRC4FO0kNgJ2d1gnqCVtyHKJl6KfZr5ya 7E6ZtfsPifyMDyrxehh+OK5jnKVOk60pIZzT3lpns+geuj6HvoqlH5UR0Fkszx3NC1 tckRNO5AlzMweNptHTsAGWGNRoSpQ3zXXaX8kpPDG6qJT4iWd22+WnDxYOpbL5Zdk0 cIFcYKD+DjAAQVPuUC6uMd7duXhCOJu6DcYPSOR9kd7I3fx+YkOzewnC5kYJSNalv/ V6MvpTSX8VHWQ== 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 v6 08/12] platform: cznic: turris-omnia-mcu: Inform about missing LED panel brightness change interrupt feature Date: Fri, 8 Nov 2024 14:28:41 +0100 Message-ID: <20241108132845.31005-9-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108132845.31005-1-kabel@kernel.org> References: <20241108132845.31005-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 Fri Nov 8 13:28:42 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: 13868199 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 078431EB9F0 for ; Fri, 8 Nov 2024 13:29:30 +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=1731072570; cv=none; b=luc/SSFuzfOxGE6nWPiuqEpCtIqd93y1qcF5anZi6xojKB8NyGgDWNwUSMI1jO1rqPsQrIUhKVyRPov10TWtW0G2RcC2+hhi1vISeijVq6PX1moafl43NPN9FGMVHNTcT4m1I9bDuCKhkh8KKlVXTr0E3wjrEioS7btYxKgXuys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731072570; c=relaxed/simple; bh=XMihtXGh+r/Y6SPiDk/zLGKcvwWE2VoZ+TFI2wM1zmI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YhFVzU6KAQzs56STXNd0j9eRSZmqaq9VMRhiRxxnkB4PUKSkM/+9L6AU/C+vlI7YhG/g0Q2uDPuDT1uKJbIMdRVvEvp+lEktDlgAOn8ipajn83z2hyfTOYkceZt1VHFCWjNONBv8APsestSdcFiQvGz7gtwQ5Yb0FL3Q3hnfGyc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CXUieb0P; 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="CXUieb0P" Received: by smtp.kernel.org (Postfix) id F1B78C4AF0B; Fri, 8 Nov 2024 13:29:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86776C4CED8; Fri, 8 Nov 2024 13:29:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731072569; bh=XMihtXGh+r/Y6SPiDk/zLGKcvwWE2VoZ+TFI2wM1zmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CXUieb0P8ovRukBpbXanwz4yPHz0zGaPaEnksPKeqPsIjvWOUNBuKlYtbj3HhltHR sP2Mx+w+go9G18FC8GGXSOizsYbnAFPnSdkzxCqF1nL5ADc0692triNGEwcQLef9tV uOde30+t/IsIcqHMmMMf0jJ9sAXcDAtS3LY+Snj+AYmIKU4/K4mUvTJ/09w9HQvOph olPlpMAuVmTXFxp1Q5N7DrjNZFQpaAtCqW7mwRMRkZzsDRZ1QihIezI4DS76ugNDwS 0bXlca8Y8t/g5lfGg8vNknh4USg5pA/2kcpeLtTnvB7uYeDavMBAxC0dz9VJwSL9mC MqIk7VhVV/wNg== 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 v6 09/12] leds: turris-omnia: Inform about missing LED gamma correction feature in the MCU driver Date: Fri, 8 Nov 2024 14:28:42 +0100 Message-ID: <20241108132845.31005-10-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108132845.31005-1-kabel@kernel.org> References: <20241108132845.31005-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 b2c37dd2e1cc..503e6e476c45 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -508,12 +508,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 (ret & OMNIA_FEAT_BRIGHTNESS_INT) { ret = omnia_request_brightness_irq(leds); 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 Fri Nov 8 13:28:43 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: 13868200 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 D09091EF95A for ; Fri, 8 Nov 2024 13:29:33 +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=1731072573; cv=none; b=mhkJcxnzjB0dGFSEjwM6a3X39oARXK3h3dp3uguC0SGB0m4B5R9fePdEzXxHLaaLV45E8NaHp+45u7UwAftWFZV3IvSgMOJ/AzvNH58SG4RND/LtRoQOVcGU7Zfwvn5y3LE9ICplpIlYjodDbnzwKnsikLvco19YFyBHu8DJr8w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731072573; c=relaxed/simple; bh=eSch87CyY3MehjJktN1nlntcOVi3d1d1k+yee2U49tQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=av93P+EHsPjm++30gpbELgHQzr7/Q2q4yJBuxE+wIlVOWIEcMmxDu+KtiYqowAfXQVr7BF5OD3Q42Z+7v2FHofFVmOvS/su+XvOA9CiBlWxCI0V7Tluut/DHhr5X6KgAomytfZQdNKJnWux9+28VqtdZRmKjUCCIpizRT3gt9Ms= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q+U+hsBH; 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="Q+U+hsBH" Received: by smtp.kernel.org (Postfix) id C0B19C4AF0B; Fri, 8 Nov 2024 13:29:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53CE8C4CEDB; Fri, 8 Nov 2024 13:29:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731072573; bh=eSch87CyY3MehjJktN1nlntcOVi3d1d1k+yee2U49tQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q+U+hsBHObh5um1syeXDkq6AukWQD8lEgf2wpmHFXqjqJTCE9i2OFIdJeDyu4yFcC eJO22tf0npCtJoSQvg5nqy7RsddgiiZA3r7im/HDjNvZeKQhN/wNYQfvcq83+ooh5I 9YDpy9IFCcm2V0LnNOYYob7Ech34N9z7U9ED7O35YTPYE/3HkNBsPt0btj3RGNBlLe HnXlBJgcslnkmNraGdnZZei/UgHMpOBVyORJ+zw+NnSc6UPJ8hCrqNm9mY4RNL14wv 0NN8mgWJ22ROV2KAtQYdyUdlTJnp45UAJ9ClFMZmjBNBmsGooDoMTsBXqh6zYZhJ3c qzDSaF5d6/wqw== 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 v6 10/12] leds: turris-omnia: Use dev_err_probe() where appropriate Date: Fri, 8 Nov 2024 14:28:43 +0100 Message-ID: <20241108132845.31005-11-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108132845.31005-1-kabel@kernel.org> References: <20241108132845.31005-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 503e6e476c45..cee53ef94bc9 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; } @@ -485,13 +475,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) @@ -501,11 +488,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; @@ -518,10 +502,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 Fri Nov 8 13:28:44 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: 13868201 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 CBA131F1305 for ; Fri, 8 Nov 2024 13:29:37 +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=1731072577; cv=none; b=eyjfwo17AvFQ1l3Whk6mM97mz2hmgYO49ATEiD3NbGEOJJIoofosrAOrMSKt03NT1g0v4GM8PMY//kEDBdPl2mMB6khc43lKwbZlffHS/sSvwmgHhPItmELklgPrQIGIcxvwAiSEem238MOFFqm4lec7JP0hET+Ef8SMMe9WuAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731072577; c=relaxed/simple; bh=6EykYPmcXwiVe7i1+kENv5nJzw4jRlQsfQ69afgTPII=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eisk6bJGJEwG9NG5JUDojChNbFnv2aUFPHpg7SjtOvB0cHJlfQIzCf7jh7I0F8jjTpzCeIx4U578l6h+g62iybAfWqLLFpI0OO4ky6SpUmvdCNwXKWRm4ILuPf1VZuq04rgEaU34uJ6hDpu+y4S/ZnwytHuWXF0ctSjHbGmKGOk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WgPamxqN; 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="WgPamxqN" Received: by smtp.kernel.org (Postfix) id 9378BC4CED5; Fri, 8 Nov 2024 13:29:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22CF1C4CED3; Fri, 8 Nov 2024 13:29:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731072577; bh=6EykYPmcXwiVe7i1+kENv5nJzw4jRlQsfQ69afgTPII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WgPamxqN4fLrujkmSCHphVohMOImVg4/mJODasdyithqRKHLfrU8gThm8A5MVy5ZJ AypURaDHPksq4mD52VBFXX0/V3vx/fvvFySBWJA6LS1tMiJ0bx6IJuL2LG2y7LSq/s /Pa3ujfoYicU3LmSxxLt1IFS2IpeBi6Q/Khfj7Gls7phn1DVrlpuvRwPx38qWv9v2o Rz+deSEMy6JMBxP29tqC+riYALOvQhAMmFf7eAlcmoOmse2AmPM+Wmb8MoifEWQIIz iOeMUgEJvr+Wc7XaN/0mtwO7PXD2qgifpOuByYgbKXNvbrNiFsKIxjiuNQ4d7GbgB3 RY8qSDkli4HfA== 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 v6 11/12] leds: turris-omnia: Use uppercase first letter in all comments Date: Fri, 8 Nov 2024 14:28:44 +0100 Message-ID: <20241108132845.31005-12-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108132845.31005-1-kabel@kernel.org> References: <20241108132845.31005-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 cee53ef94bc9..2c116abe4de2 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); @@ -519,10 +519,10 @@ 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 */ + /* 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 Fri Nov 8 13:28:45 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: 13868202 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 90C2B1EBA18 for ; Fri, 8 Nov 2024 13:29:41 +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=1731072581; cv=none; b=avnm+yEq/uIGUnbOM5Fe44LAAuccyssrNpJmyq55yQzJbw5EwPxUhzAevKrNxqKZdfqPCWFjto+FN0Ki2XzSeBsONEPIuKfU0XTlgoV4XfegPJrEjeqElfYrMcOd6zNX/W8XwfcOdXNpur8gWdEJtB6CO4W9FW85QGylFvyQb5o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731072581; c=relaxed/simple; bh=02cumqv7Pptd8Tkhcc6pofXSXkHGb+wYsFd9giydYr4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ifbepzR7CfaVeUWv5CYqgOVOvIS5USHrv49Qlt1HK18GmpUxVJl5JkmxRa39cv/Aw7x5Codef8TjOec8dvGwaupH2fUqBq13Y4j4KnYosZnnTeUDzB4GZfC4KHy1nZ7aQPGthmzDLwpDxqUdmdyEzJtQdTSZgn6Z08YMp7i+BpU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sWjwjNMf; 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="sWjwjNMf" Received: by smtp.kernel.org (Postfix) id 5EEE0C4CECE; Fri, 8 Nov 2024 13:29:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E70F7C4CED6; Fri, 8 Nov 2024 13:29:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731072581; bh=02cumqv7Pptd8Tkhcc6pofXSXkHGb+wYsFd9giydYr4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sWjwjNMfM53MoeZUD0FiH+R/36amSOCKTUXOFuBZ+72Ycl8Cbfn61KEiKAujBXgoW E1VwEZnhqMzPRiIUsCKy8hZu4TCIqjKR03PQDB/lc9ozqgf+IDgkkRBgbRJG3Pm7La JiBPgUA3Q6MjJ2oVOaSJhL2BIfybZmCkUu2ziaaZGhLhzvc5Mt4eDGdpLIk5fiCaCp uUC8sNrpzs2ed5jJ36bQkPvtPJeZ72XpLuhBqQ66k4uQlEVyzKzAJdsA0aaEPqaAaP pPhgEYf0iXu7U/5cMZBYlsCzkQdd8ttcNViH2Ks8PwCCE8WdaSdXvi+E79lEQ1Y/SB +eDELQqLaLrzQ== 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 v6 12/12] ARM: dts: turris-omnia: Add global LED brightness change interrupt Date: Fri, 8 Nov 2024 14:28:45 +0100 Message-ID: <20241108132845.31005-13-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241108132845.31005-1-kabel@kernel.org> References: <20241108132845.31005-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";