From patchwork Mon Nov 11 10:03: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: 13870482 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 2F09E15C15A for ; Mon, 11 Nov 2024 10:04:06 +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=1731319446; cv=none; b=b8VrJye+dHSJ7ww444BnQoP2sXTEx5L2a6GlY4iNgJcMT2aPypgBcY6g8JhUpQpZfuCSE+q1TULgSAipRMKQFOKrddn4EOpKLhMTeTiWRtL8XE7OzimVMtj0Jh+0F9CeORSUERCTFIxevYxNvujpBmhVnTbTjN7A0Wcl5PO/+vI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731319446; 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=G0+3J3LtDb+FHknQkLrbZoBMhxcXYGHNxcZhZYord6bC2ilrCN/GcP5IggzIJfZicdHbdD2bGv6JOsB4qMqHFEIogxxBrR/VgRESNt25I1eiFkvNITof1F0P7s9snCm5hhk5F7RYomcpqlzULSVvKZOXWcVFDnEMAUxUJGy4Wf0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=n12ynlQO; 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="n12ynlQO" Received: by smtp.kernel.org (Postfix) id 0257FC4CED8; Mon, 11 Nov 2024 10:04:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88574C4CED7; Mon, 11 Nov 2024 10:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731319445; bh=eeBYr2p6za6laSDrNMtl6LIf0+fxsP9YIvYI/u+rMD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n12ynlQOx994n2yaPf6PGBHpx8vWKzDO5EyN8MLszGGGQ+Yd8JaN+LcRae/880Qx2 UL+m2bPv7D3LBdMg/+9ilLcV/EGwuWwN0pHn6EN9TOyv1brxgS+DsDyBprAcIUj+Vt zV2jypppS4A5ojQXiTqwZi5buUCsMBfRjXcsICMJAQbgonw3xQU3bar/wbEuyhuotU FlTcsxEG4Idw0c2n3kaPtQd6cgSJY/s6IypX946m9bjpgeNejL/7GOnWGyM8GYUPXk F2PR9rHjIk7pHUzkgTgvRneLeptDep399ItTNRLIbz3aZf324BUuTqUOOyuvT6rLaJ b8UaOwlWRc25w== 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 v7 01/11] turris-omnia-mcu-interface.h: Move command execution function to global header Date: Mon, 11 Nov 2024 11:03:45 +0100 Message-ID: <20241111100355.6978-2-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241111100355.6978-1-kabel@kernel.org> References: <20241111100355.6978-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 11 10:03:46 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: 13870483 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 EEB9215C15A for ; Mon, 11 Nov 2024 10:04: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=1731319450; cv=none; b=EfhR57NhBQfPWcZWhjhDgXYC167i7INwB489QDhgRNp20dgSqgTB64NLpl0iHcZcFHrjwdANoXA/sZXSyT7jJvzR6QmO8wOv1W83/D5HzMlCGg3/693/XWFh7Y5S4HSU8sukD12+QCx0x/QZ8eoNyD80LR5mcpz+y37xR5FGrjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731319450; c=relaxed/simple; bh=D6A9yZwod9RyaYcsbShQlW2Y89y5mowC4F2k/d7+MZc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hX/BrpgJZtkq+GL8f+LYJsD5AHtmQ3pyIdGzKGnVKN6jn34Q10Roz6XasQxfuiMEOlOIAKQ9qZfms0AqicSfe3fBNB+Vi968nTbyucoJLSXUqkxJxr3N8DQU5jL2v2QQRS2SePczhtVUtnpk2gkAd8e9djHRMEVTKeoYHfOFBfM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BT3iuHOc; 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="BT3iuHOc" Received: by smtp.kernel.org (Postfix) id C1E6CC4CED6; Mon, 11 Nov 2024 10:04:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57A22C4CED0; Mon, 11 Nov 2024 10:04:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731319449; bh=D6A9yZwod9RyaYcsbShQlW2Y89y5mowC4F2k/d7+MZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BT3iuHOcGdPJk2+dyIezWz/J8YOaMU7eRAcP5QfLZjbxcR68uKCMfohIg69k0+6Hc NXzTpGGEbR2MVUjL8b2J8Ddd1qJN0xCmG1S2EMdemjByZQe9Ll1/jz73a4J21ftjpL ilUmudt6WOHoGiKW9yy0+zzxOGtKsJ4jfijblEOgAnmSRWRfxqc0pd6mJZsoL9nEr0 A+WiyzJz3IqaDAfu+h8Z7HZ2PBBgNY5dkU9bVxzEN9gO+9TWRsWEvZQ8WdSOkU7+xg UQOEW9a6pJRC6K6MJs15KuXtC6soNfPyl/DwQq5FA8D1UeVkyGPJuJFbqz2nDbetuL JicYRBYwnou4w== 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 v7 02/11] leds: turris-omnia: Use command execution functions from the MCU driver Date: Mon, 11 Nov 2024 11:03:46 +0100 Message-ID: <20241111100355.6978-3-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241111100355.6978-1-kabel@kernel.org> References: <20241111100355.6978-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 11 10:03:47 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: 13870484 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 C0AE516CD1D for ; Mon, 11 Nov 2024 10:04: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=1731319453; cv=none; b=ioEOb9KwyUa1SlllYUaB0vOnpcPESNx3qkUgLuqgVehvzeGSPaeQRtuuHXpvTqlM43B4l8vEDF/xO2Ikf01v1SRdxU03lRCG3Bub/ixRFZz42AgUyj98yGs+ZOWqbFxAjviWiPb8yUpqGX4jkTsaYC0rWibCDIEQcHtV7xUtLtw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731319453; c=relaxed/simple; bh=k2ET+mNmV11DXD5Dqt3IxyuEPJFzW2WgZvGZBxEVi74=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=RlC2dhvKrlrpIICKLsdIr/cDy99WBDkNXEWw7AcIdIsksw0m09G7QxXw8rQs9zyqJSj/zyWYR9PqDDOjGKAmF4B8z20K3Jor7bd9CNGOiEBJuSFWWmqgYahQBptWsxTWw3aU3rjMCDa0US0QQ3vhlnxbt3O4n96Vu/RF8cn3JIs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UO5iHny7; 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="UO5iHny7" Received: by smtp.kernel.org (Postfix) id 90B85C4AF0B; Mon, 11 Nov 2024 10:04:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 254FBC4CED7; Mon, 11 Nov 2024 10:04:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731319453; bh=k2ET+mNmV11DXD5Dqt3IxyuEPJFzW2WgZvGZBxEVi74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UO5iHny7IQ0nWMZId7CvsxJuBBi7mSpZLlkD4JJMh3zFw3CMmvZEbFUIJYJX5LUVR 0I5Uec3TQAWM4tK7PMKZryA1KCGeg1WPOd+86gU/4ATf8h4JAniHMTP8hVWI2uOfxa DtsOp3e6MI4fvMfDACo+Kmp/90+6ysvM2Rl3kbncP9SJ8TlzhpILFBR7m3SwowrBpu elT7A22adas95dGf2DvdOzA4dXUuNFyIIVIH6QUHYH8bvvfRArX/jFXsImp6M/aste rXy/UztdqlSDxlqZD0H0Lvxvo6k4LUPV7bCPfqHqSqj5sP6+d9/uzK76nIU8R9FsQb EX65tCimGd1oQ== 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 v7 03/11] turris-omnia-mcu-interface.h: Add LED commands related definitions to global header Date: Mon, 11 Nov 2024 11:03:47 +0100 Message-ID: <20241111100355.6978-4-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241111100355.6978-1-kabel@kernel.org> References: <20241111100355.6978-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 11 10:03:48 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: 13870485 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 B7A661714B2 for ; Mon, 11 Nov 2024 10:04: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=1731319457; cv=none; b=C8snQg0Aczmi9b0+2QiHlP7NoKdFHpWQyYbvOLZ874FhljVWnomNT1676YRrn4SAuAf7nV72Zuft4Oqzo94zctItsaen/CyXwlQLKSBzBOHY42vGjzItXmV/tTJZJ0k4rACFJ9ERd/orxV5zE7DvkmwzSzV3o9x9dQWWe9JfY6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731319457; c=relaxed/simple; bh=+BaD6yzWcHU4DwqJoicMokFjifwQXkQ4xTT2A5vPyxs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AQF5gUNp0sRvK1amHejuSHLT3zQ3s3o7NXxXQSFnVWFpzQvodYKkApDqsRiMsz/UqVbscIvgMdI+Obb7ZyvaTSWE1x6pWB2EjOG/PJdH9gHYXXRYKlhIk7zIs6BVnAbai81cyCDVuUotQP6IkKShj1p3BkyaAMojoIPlfovi7S0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ajb3KZA5; 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="Ajb3KZA5" Received: by smtp.kernel.org (Postfix) id 5E82AC4AF0B; Mon, 11 Nov 2024 10:04:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7E55C4CED0; Mon, 11 Nov 2024 10:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731319457; bh=+BaD6yzWcHU4DwqJoicMokFjifwQXkQ4xTT2A5vPyxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ajb3KZA5R7Q5qdZhcItvxFApMWQWwx2xF3PGtAev+l1KEiWUb1cyRp/SygIHTFQ9S LRhhpS9sBH5NTgv9/ZGnUYdgc5KpjGh/ILuHrc4uvLeHR7yOAHudqbFV5jmyhC466U T25RaqrdQ5s7iddVHfiEQCpOa3MwEeRAgvhbG4aapvaJOjztLlSmu2k20sXn1uOb9q 42AdcjYe7CQqNHzWAMsyn3Bu63K/T39wUn54wlSOhybKxPfex/kvZGiJq2mPjTnSR7 2Wz/sJJAPBaSlkPTKZxkrhYXzpcJoKA0BDFO7DRJ6ReIL1ZLoPjV5uf22aPkwvw8lK iE3tt3bX3CMjg== 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 v7 04/11] leds: turris-omnia: Use global header for MCU command definitions Date: Mon, 11 Nov 2024 11:03:48 +0100 Message-ID: <20241111100355.6978-5-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241111100355.6978-1-kabel@kernel.org> References: <20241111100355.6978-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 11 10:03:49 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: 13870486 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 AE0C81714C4 for ; Mon, 11 Nov 2024 10:04: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=1731319461; cv=none; b=oiU8b2HyN9vOJXgOVF3MHJMwJ+WNe9GzFrAtTuwRNTedl3oGQUHk5b7XGp2PzM5fPFVPNTQ+oWWUMY5WWErEH/3hpAA/236Ne3fPUVePTkVj0wgfbvGFZMnK876mkwVJXrB33i5HOahnEDlOFzI2GHLy04OfM6QtIqKHPbgpM1c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731319461; c=relaxed/simple; bh=IL6ApZj/AEN4ogtSsw2hRDlMG6U3NVDiHfarNqZTetA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Mpjm1awtvklGApa2gWBv/mML+2quaSWJGRkXW95pt1742N0oukvkVGdIALhC0K5+UA/ES6axScZEaHUe1oXdC/mzcBGCxJEXcdTo1kAeY5SHuUltQ4OsdEq79+u+vsS1DKwS5puNolDSWtKD/f6ta+3FbtzwvxD6nzChzQwSZLA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=agOFtOGl; 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="agOFtOGl" Received: by smtp.kernel.org (Postfix) id 59765C4AF0D; Mon, 11 Nov 2024 10:04:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B692FC4AF09; Mon, 11 Nov 2024 10:04:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731319461; bh=IL6ApZj/AEN4ogtSsw2hRDlMG6U3NVDiHfarNqZTetA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=agOFtOGlyrFlKEtDWQtdOHNBJOrG1vf4ZSdmYsLx0uTRY6WrjeK3hGPbl2HD+uGDS dVQa7DFwq+geYIdn8qexRJ2kbQVqhWZxRKJXNzLcHZ+U90DJrWGJUbib7Pk+9q6Hy8 VtYdnSqkPc9Sq4w7WWFhZtAHKC7Rw0bDXubIZdB1dN+BcI1JenmM13A+nUw0NSgpeX jwt2zI+/oTe4CiMADHbmEkS4WrWrQ1B2Jr6PPZG5a1a+5pzbG85BtFQ4U0tkcaz8hP boDYLRRoRMls5+hKvHWHfqtbkpxNSWX0K7TTBZPvNoL+rRSKvPVlH30BCOgXLE8pb9 W0H6jlpDYDNsw== 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 v7 05/11] dt-bindings: leds: cznic,turris-omnia-leds: Allow interrupts property Date: Mon, 11 Nov 2024 11:03:49 +0100 Message-ID: <20241111100355.6978-6-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241111100355.6978-1-kabel@kernel.org> References: <20241111100355.6978-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 11 10:03:50 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: 13870487 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 3A165166F3A for ; Mon, 11 Nov 2024 10:04:25 +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=1731319465; cv=none; b=FiG3kokmGdybg53Eqy7Zg6rO+N2N5IRXG/pIJ1tvEerHbemDjpFDV7LZA5t0y3GgQX0hbs/FqzMRA8ZGBrO7+dsO4bVdr6vK2nqHB60wQqreUiecoYOBujLHiYQ55iMTnE8cKYhXxK8VRy8vlFCIbgbx3id9/M8tZvFGYe2uHz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731319465; c=relaxed/simple; bh=v7WL23ms+ZXopV86QQbTvWoLrATGoi65c3m/UcEpUlc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eCnk23thwaYURZrtXA1mz3wCM7rATUGAD23Fo3fgsD7Qe6ONuakQ45zWdz5wVmKSExNxwKGPXjvTmfTr1GKniAhKO3WPtyde5TqZmU4GykE0B5i8F+8kuZVMUuwes/rYUMef9ZgMx+Dtu2rjXhtzWvOmUr46+SVbxfkDF7uzHxI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iogNKRKX; 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="iogNKRKX" Received: by smtp.kernel.org (Postfix) id 28D40C4AF0B; Mon, 11 Nov 2024 10:04:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1A57C4CED8; Mon, 11 Nov 2024 10:04:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731319465; bh=v7WL23ms+ZXopV86QQbTvWoLrATGoi65c3m/UcEpUlc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iogNKRKXYNCLxVUg9+CTQpiWoSwg1smhkoUnxxKMuEtCyDj2QC2Fg5znpEVJjRCwO /un0S0ZXcGYl53AdAwgvZOFxmMWr00FV1g8lwOFRu1KgMBBGZv4z6W7QYKrG6auz6K ODLGlOOg24G0OGvLXFhV6OJDKyG3tWgHY1tofGSUtC6SX+YcDuCpl7zHLsoYhiFPPA csWmxO4iIl5byENLONrsj12Q0ivi8GGk2EkH8gSBxyX1upKeZNM0IMbZa2zwAma8cp SwyaQzB1B+xZLuPMbm+lAhzGcNbWbzaFIOLW94El2dEG64Rgxn33/9rKExTCnVwL4M JQJxAz21dhNSQ== 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 v7 06/11] leds: turris-omnia: Document driver private structures Date: Mon, 11 Nov 2024 11:03:50 +0100 Message-ID: <20241111100355.6978-7-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241111100355.6978-1-kabel@kernel.org> References: <20241111100355.6978-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..b60c34f57d0e 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 cached state + * @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 11 10:03:51 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: 13870488 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 33A6E149C4D for ; Mon, 11 Nov 2024 10:04:29 +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=1731319469; cv=none; b=T42T9MR+a4PGZS5cKCD/W60mOyNorFzFDLGFhyyG7i0MSIDHijhsllLGrpnTDkcj+yjjn1QQt6dQFr6ETv+67y4GUnAFxqMg+g+BMmG2sb1zjHrDLszxHt7jMhaFM7F90s99RLl2exWLwkwlCWTel09pJ7A8ClAiDNEE/a7kpUU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731319469; c=relaxed/simple; bh=L03X2l5xIJgoGgO3xAuN5DbnHI/1H9gFJ2yZ8353ycg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=e0nj9O08UU2bW/CVIuT9FCQoFSfbcRBVv9un5OfitbUyIHuYCmqLQSid7xCdfZIfwSRhjS6h3WUtw5bf4+YMVmUR/2MgJ6x+v3FfbpP2xsHxzfEtVHZ4++8lhNMQcu6qwluDg2Q7I4S4uGKPN9/CQvKP+9HFjy/SGyxROfdUyuI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kRNmAlfI; 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="kRNmAlfI" Received: by smtp.kernel.org (Postfix) id EF409C4AF0C; Mon, 11 Nov 2024 10:04:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 838CEC4CEDE; Mon, 11 Nov 2024 10:04:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731319468; bh=L03X2l5xIJgoGgO3xAuN5DbnHI/1H9gFJ2yZ8353ycg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kRNmAlfIi4mDWJGszqBvExNYFY4LxJmT+ZXOFiX93X5OcP0/qVv8LdL69MuE+mui7 HJG+kSLyqI21wxEdJCYQohOOxRPakECP0Y9kLYAxkfYNealrV5t5ArcL6/ILZ3+t5c pJ6rDVFGW//mGflJ2ms+RcJVZe6DbMe2ypaAtlA0o6lZ7ZMV3W5kgIOpewKzvUkTY6 R1zRbEy++Y4W7uRDfYmJyCc0Vf8gFZG383GxRWDmCGEFT1AkpoMk8hsL1HKQpP5as7 QjKdmfba2nAvHxhDd93TJdifUYHbrvR39eOS3JnRJdxm+vg4BZM/HSJmRpzE2t5Pxt jcdz98RVOyS1g== 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 v7 07/11] leds: turris-omnia: Notify sysfs on MCU global LEDs brightness change Date: Mon, 11 Nov 2024 11:03:51 +0100 Message-ID: <20241111100355.6978-8-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241111100355.6978-1-kabel@kernel.org> References: <20241111100355.6978-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 b60c34f57d0e..61186c3a6c2f 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 cached state * @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 Mon Nov 11 10:03:52 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: 13870489 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 C87FD15C15A for ; Mon, 11 Nov 2024 10:04:32 +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=1731319472; cv=none; b=JicQQwDWa5ZzNBle4PoWGzpD6s17IvSpGfHXt0z9fKxB6BJsbdSNwI+aWaax2z6h2dZe7uAd8dcwzetpH3vTZBXXymfkR7F8KPjX6u0C+vVknZJFczLq+ytJhmToah9ChJy7RjBeoCbdY4pfYvAV4AZPi4YZpTqYlVLN7AlSe4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731319472; c=relaxed/simple; bh=8xxaLaeqEAFIPs2iLJxr0JwGVdVOwPrRyzlBgb3dEzU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=S88J/aDIjYzFJAaK/wTWUwx1f8uzkRVFfSe29oY3GLRY/duGCLsk+Q9S+QBWEDB7PPtUA0zxJJ5X72JF6SbtwN0Pa8ZymOQujZlHpsgL+wyhIXPZ9Vudw9G+vveeGRIJeyGAi7hq1jmpmoblmY/8p27V+dqYWEALNSDfoZSHJIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F2r6wF/R; 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="F2r6wF/R" Received: by smtp.kernel.org (Postfix) id C03FBC4AF0E; Mon, 11 Nov 2024 10:04:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5292EC4CED6; Mon, 11 Nov 2024 10:04:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731319472; bh=8xxaLaeqEAFIPs2iLJxr0JwGVdVOwPrRyzlBgb3dEzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F2r6wF/RhlAH7GT2Q1vAfKTeze/jZmbUAbMN+mNSJyZ2LN6lnZo80JCnmhywsE8mr zfFdfpTGyaH0DdvHQcUbpP2bMfr5cCvhOqOWIvZerFXgxn+G1tXAIeXQmaOX83gjkC a7Q7+EEQQCLVoyDyXH77qsVREisU7ZieRZKtOTGDAE00Qkglaibt4ehojIaAN6kM7S p2ttNUTPYSJnowZaqALBkKeP5x1/82XUNJ0idKCGbExQ1RP9OeM8Pv0Z8pddYKMj8B eP3TvKUwcLMjBEtM9qVpELJiM2xHAZ3I9XAZ6wvghdNd3e2Mreo7CdMMr9oKz6TPXz twPMYg571iAvw== 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 v7 08/11] platform: cznic: turris-omnia-mcu: Inform about missing LED panel brightness change interrupt feature Date: Mon, 11 Nov 2024 11:03:52 +0100 Message-ID: <20241111100355.6978-9-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241111100355.6978-1-kabel@kernel.org> References: <20241111100355.6978-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 11 10:03:53 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: 13870490 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 9541215C15A for ; Mon, 11 Nov 2024 10:04: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=1731319476; cv=none; b=CLjeWADcqm8D+XgGAGWXDMr28m39OZuRKGF0BRHfKHpdPGod3gsumrJLj3J7nPw3Ktir3OvkqM+XDshR2QwrMKWa2HyNJSJM3eu0cWirEGhWu7wrCMdvQ13gmzi5WI3AFhY7OfxTA7PrgDAliOnRBXPeK5mlWo/uoZa1liUVTUI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731319476; c=relaxed/simple; bh=D9VtqYE/cACS2Sn5whXPGMF4jXGgBU1iSggl7IiHGqA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Tb1L+YjUpHtH7zFpcxjzICRuVadeLnE7dRdhptf0o5oanIyPu/mjmMvjEsrAzOPuqU5leSH6Kmq/nbpmTVAM8OzqRvYiMzm9dVBAddqzvIi99Qy7DSv8dHjvZRSWBl1MVwYomce7e6xBXLAyXuaPxBzAoTU5uPpiXb/dnIe9igM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cv4AfH4Q; 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="cv4AfH4Q" Received: by smtp.kernel.org (Postfix) id 8D03DC4CED0; Mon, 11 Nov 2024 10:04:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 213EBC4CEDA; Mon, 11 Nov 2024 10:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731319476; bh=D9VtqYE/cACS2Sn5whXPGMF4jXGgBU1iSggl7IiHGqA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cv4AfH4QQGLcttY5znG1LRJEELZ74PkQIIwx8LqLzN/8gHPdJ6xCZrrSVlPNX6EFw P+9XpZYgUU8XXfGFWDXQTA8DVevFOYWJudbUybBzObSBqB+XPjIWRSTXhF5hfPaufo gBv0ZQ7Jo5zPCP3rstAISS1PdZAJEwA4EM/9bvKfVLzQJjycpuowGBtTC4aqxnJNrm EBrHtY6+W0XL8I5SqDGXA3dtqe7VL1AFj2HwY/cZfBUHjxUpCSq9uipxaP1h5eBp6p KblPwKpOmiPE0YzFSYtPX3NHlH7ft6xcgXZHLP1RH3aqMVpPJQdGNuqoCiDdrPraqE u58DViem7eOfw== 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 v7 09/11] leds: turris-omnia: Inform about missing LED gamma correction feature in the MCU driver Date: Mon, 11 Nov 2024 11:03:53 +0100 Message-ID: <20241111100355.6978-10-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241111100355.6978-1-kabel@kernel.org> References: <20241111100355.6978-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 61186c3a6c2f..dc6e076addf0 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 Mon Nov 11 10:03:54 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: 13870491 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 6436E15C15A for ; Mon, 11 Nov 2024 10:04: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=1731319480; cv=none; b=UUYxNsjLcGnXTW63YUZkmnQKIbNWEu3jDNix8XQWnw1qIjDdBnE/ETtWK5qZ7vVPuK8hD6QmXU7vVR4FDUUwvZ/cYTS8cnBs69FF7U9eP5DZahBowj3CLfEZ8FucB5PH0dq7JvxwWcowgtLSF1RMy08sTITHlNZpN/6ehYPd1wc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731319480; c=relaxed/simple; bh=qADAyP5xVW6uxjf/xVlBmr4NOphL+2Q0YgrDCPMRgZ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QDxYoHdAEQlduT3ds6E/kgsEX0VA+Xs/85VMIZ6AgIU+jH1u8HXZyEZTMJo+FlKCcbN+RGbJToVnl41s3pAPAKW9tkki8giWURbHXMVIi+Pi2SElqA/wrmPTUS25aGWICzjrrRZIqgGrLzWlKj9c7G2lnEUpPO8kYY4O+Wu+iCM= 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+ynI+W8; 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+ynI+W8" Received: by smtp.kernel.org (Postfix) id 5B77BC4AF0B; Mon, 11 Nov 2024 10:04:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5585C4CEDB; Mon, 11 Nov 2024 10:04:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731319480; bh=qADAyP5xVW6uxjf/xVlBmr4NOphL+2Q0YgrDCPMRgZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q+ynI+W8YlUto9A40Z40kDpY+Cd3NT4T1M+tnGS5VZE0BxdY6XBaGipKSZTgN6quY S2PztzsemzkOzlBl0BhVTrufAFM3D+WYPPa631znhU7P5M+N8vjpZZhM+X0BQmZG22 PDi1aFWMEPyVvnoZDhbP40ryrzh/O/6vjlBbgl5NGQWQAxxD69GyQk/8X4RFR8+00o yf3qjYqWEQPD0MGz0gCW7Ew6BY0es8yGFcf6+UP1/2RZB0g9wScfC90Uczfe2NP2x3 JJZlb45cHISH6mUgHZaSpQss0aaA5Xu4c3ZqCYuOjZtbNXKOL8CGM6fVV/YC9PWvJK 2bU02AkVrrWOw== 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 v7 10/11] leds: turris-omnia: Use dev_err_probe() where appropriate Date: Mon, 11 Nov 2024 11:03:54 +0100 Message-ID: <20241111100355.6978-11-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241111100355.6978-1-kabel@kernel.org> References: <20241111100355.6978-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 dc6e076addf0..4fdd5d9b55fe 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 Mon Nov 11 10:03:55 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: 13870492 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 36D3515C15A for ; Mon, 11 Nov 2024 10:04: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=1731319484; cv=none; b=mvflhRv4THFqBDPidwHGAmEHYhDPA+/t5SBG6KWlXUGOuNY88Z/IHSGF48eVur+O7p7NVsd0pYfF0MIL6EP+0F196bN2Ss5LOrtElpNH9/qFuoVVDh0vfy3wFaw2CQa0sK1Zd3ODUY7KIqi7gOfq1wn0ZI83rO4nCIdeDvQzBvg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731319484; c=relaxed/simple; bh=kXWKak3NFWbVEuxA3fSpdYQ6LarXKFsQoaxaZk/VptM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=s17HJ9TyJRjrrpjOuYIc6f9rR0JAKoO5MKEiG8X2vUT1exd3PHeQVj77ZbWJfV4wUhokprvvddZFy1EERVasWleSY8HVXPxzwSO4prjRug3BwG+E/mpjWVESBeh22rPtLIaY5K6dESpcMupsZoHTZwbx7qUvfjYKih0ogTz0yk8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JeB31ULG; 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="JeB31ULG" Received: by smtp.kernel.org (Postfix) id 2B1FFC4AF0F; Mon, 11 Nov 2024 10:04:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2E74C4CEDA; Mon, 11 Nov 2024 10:04:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731319484; bh=kXWKak3NFWbVEuxA3fSpdYQ6LarXKFsQoaxaZk/VptM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JeB31ULG6XltmK6J9IIVybD65d8x+SgB7XQD9JeYXa3nUOVgc8wujZvLzLUx9oLke hMkTK2bkMv29QBFF+wXsd92b7UcpHwl14kJaUlv3Hh8x7fOViaUTfZKlje8tHT26vS CEoD348Uu6riXv3+J3VJapXRKiV6l2Dr3kN7JqtcHX7t+cRBdFcr49tU5PcbbOhVwO DgqrNn5GYlmirl4Z6qZnms0Bp/5Vl3r6k/uIIBCjB82dOgHJyIx5jv5g+Lc1o8N351 SmTgiMYdGKfjmhdk7hFq67B1PLww3ayUSykegHEdtXo8n2fCzZRdspR2IDRc/EICj5 Wtj2MFsCc1yRQ== 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 v7 11/11] leds: turris-omnia: Use uppercase first letter in all comments Date: Mon, 11 Nov 2024 11:03:55 +0100 Message-ID: <20241111100355.6978-12-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241111100355.6978-1-kabel@kernel.org> References: <20241111100355.6978-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 4fdd5d9b55fe..b3dd6af769c6 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); }