From patchwork Tue Oct 29 13:56:10 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: 13854945 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 0A9B020695D for ; Tue, 29 Oct 2024 13:56: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=1730210198; cv=none; b=X0nqyUs8orngvuoIZfMqDsySObcs1fjISPDWGDAY8V+i04zEcEol7+FOgD2Hofy/Hbd3CXWNknKbQyDEptvdZvgNghCt7osuC9CMhxBYWZ9uurqJgIrSrQv0lbmCvHF+D61vqGivM/vAjBHqHVEkYXqgS8eJpRd+xcClyowinoc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730210198; 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=aHSSjTKM8V1WAPHgmS7y6LtXJN35qQe1Lh3aSiZ2nWFHdF3AQU7NEQmS+GZXZrADgXxdvKVAYcXFso7DsqEvfgAyAOxc1uA9MMJOZ1wvUZjC3bivvqEfbH8mJ2VSLuFNh4rFa+QZ97FriTdxFlbmZfssZhgjEJYGvD3Ohb/mXFI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V2dPrr6B; 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="V2dPrr6B" Received: by smtp.kernel.org (Postfix) id 8AAD1C4CEEA; Tue, 29 Oct 2024 13:56:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10A1DC4CEE3; Tue, 29 Oct 2024 13:56:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730210197; bh=eeBYr2p6za6laSDrNMtl6LIf0+fxsP9YIvYI/u+rMD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V2dPrr6Bd7IRwtx7KbkorcqeoUjbVYrce9hzZ1n6HB0zI4YsqU4itZeItfWRyErts F1TFEJpOIUalukZwD+mODV0yGLeHNofxra60I0oWA6fTSrcbo/Yb3jc0iCWcffuKJ5 iU0dt8I2AsOP+vFBc4X/fsnV5TC8p4cczlRBVX/2svJRPILyo19HrijtQRfs72t8ki 84bfWqIhS9hwWKl2qYNTQQFFQrmuiwRe/SQQqZZdLWZFq9EnNX0RXm86TajzF26KTB 3pmUyyzN3KCP6vrPPbC4ZsZPn2DXWpkGbiE4O/gc2wjy0W4a/JrPZyJNKI5Xugyppc bD4NDrALSQpSA== 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 v4 01/12] turris-omnia-mcu-interface.h: Move command execution function to global header Date: Tue, 29 Oct 2024 14:56:10 +0100 Message-ID: <20241029135621.12546-2-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241029135621.12546-1-kabel@kernel.org> References: <20241029135621.12546-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 Tue Oct 29 13:56:11 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: 13854946 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 BCCAD20696B for ; Tue, 29 Oct 2024 13:56: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=1730210201; cv=none; b=H67GHS+oCm5dD5qsQEFlrv+fKBC5gx/bMvh6UC/E061BZvEdTaBJTJoUzPXxD6dCK1K3VWcXnEBs1gC6PIOyyUQdkTWnpxhT8i12SS8JeU61LwZbk7lxsOLqPLtVOBfFLFJ8LUwWrFjkqoKeznB23MCV/gvKZCz7ZPCj0LMPTqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730210201; c=relaxed/simple; bh=Lzp4c2xwPI9Bv29V8ootRPCIxvn2SWSPnFiRixJ18kk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qjNs6m9tv/zPiwjThHmO/GcpLsh6JLAlxeW4/YM1loEsIYxNc6HHBGFfak9G4IqOKDVd973Nig8DXlvfl8n4DVXV/lUf8G1oRW+SeG8knRMI4lG1BNaEj6ihq8XMkPEDTZwda7bu97vcJWTDCVuox6ivyZvtAp4Ha/6QdH9ORYo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LYQ90ZC1; 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="LYQ90ZC1" Received: by smtp.kernel.org (Postfix) id 65239C4CEE5; Tue, 29 Oct 2024 13:56:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC622C4CEE3; Tue, 29 Oct 2024 13:56:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730210201; bh=Lzp4c2xwPI9Bv29V8ootRPCIxvn2SWSPnFiRixJ18kk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LYQ90ZC1yDSdxLhhTrhV2HdyGMVXpIeOzfcmr1jLWQnp/w04XKsOEeiHuvtifl/A5 oaFk6PpLuz36uwl7dpSgg48JK4g58/niEQ6oSX+WXU8z6+zma/y47zws5uOpHoGXac qAXPFPMguavUbgk8xOUaDl+aKWgzHvy4nrOSMLTIdFvQjP+I8eScx/MTfUn1iQSs9C OjJZQCVHtW7OaPp4HVzHHIQIgc+IMtbKZRi4r7jlJRU8WuifZ7ZNIdhg5RfhSQoyUy xi42z8IuuNvg3NrP2mse39s2Ecs4goke+V6MBa/s5nvUTGdWeluQ7kmYuv+O6xaV4f tKPenKL1T4TiQ== 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 v4 02/12] leds: turris-omnia: Use command execution functions from the MCU driver Date: Tue, 29 Oct 2024 14:56:11 +0100 Message-ID: <20241029135621.12546-3-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241029135621.12546-1-kabel@kernel.org> References: <20241029135621.12546-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 | 110 ++++++++----------------------- 2 files changed, 30 insertions(+), 81 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..0b71848930dd 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, @@ -429,24 +384,26 @@ ATTRIBUTE_GROUPS(omnia_led_controller); static int omnia_mcu_get_features(const struct i2c_client *client) { + struct i2c_client mcu_client = *client; u16 reply; int err; - err = omnia_cmd_read_raw(client->adapter, OMNIA_MCU_I2C_ADDR, - CMD_GET_STATUS_WORD, &reply, sizeof(reply)); + /* We have to read features from different I2C address */ + mcu_client.addr = OMNIA_MCU_I2C_ADDR; + + 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_leds_probe(struct i2c_client *client) @@ -510,20 +467,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 Tue Oct 29 13:56:12 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: 13854947 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 955AF20696B for ; Tue, 29 Oct 2024 13:56:45 +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=1730210205; cv=none; b=dD0A1cfIs9nmnl+jjY1fjBlSl6YnbI0IL1nipHh58Z5T3ORtxKNNLP0sEXOdKwaW+NQqTDVXtTsL4v7qsA5bPHTml22vKOM4+VJEm7QlgtZWcFpPdOROqrBUsSdJLnRmuxVwv52vLKB3nMKEa0AsNqjMr3K4Y2dVBvhZWqC9MmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730210205; c=relaxed/simple; bh=k2ET+mNmV11DXD5Dqt3IxyuEPJFzW2WgZvGZBxEVi74=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FDChkStWyuaXyKp7tvpqfZevRy/jVKsP1wmpM6XdBoo7QUcvZW5yayrKkfMkSUZ/c1FzBwPvtJmiFvkWVcH1euB6dOnXMLdS2z+dKHlREmWa5nbtLh/GcfcNOBidYu/638Kyl35U+9fNvy8E4UCsxJvTkUkcYLjCP9Bzvw1pxyg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AEEVbvud; 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="AEEVbvud" Received: by smtp.kernel.org (Postfix) id 3A68FC4CEE8; Tue, 29 Oct 2024 13:56:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4AF8C4CEE3; Tue, 29 Oct 2024 13:56:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730210205; bh=k2ET+mNmV11DXD5Dqt3IxyuEPJFzW2WgZvGZBxEVi74=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AEEVbvuddxQFsXMPV+nUNCsZmMpd2IYw0V6Uzvga6fENNIzCOIQOvoYZ7r9IkzZuE w4gNjsoZPwB+pALR2SMndqERsloOOE/LXavsjCcagmA7uIFvDOt7OoeRUFznSI5hmC NWarF13fs9ISoGVIUPmkWqKIPFU/7ZHxHB9ZnK1p83ws6UGWPYJMLe4hYa3ePRXLRn 2f0k2rNrt9xGKp5nBW8RR+uLP6vjBuIUgVsLDhekAqwQwNWgiP2vEWrg9SkN327LHq Cvgv+D0eZ0WOupUrEx+hGueP+MNQDonsCZ3fk8KxmpxXlyEcg7RmiQYdkH1xuGEiRB +Vbz2f0R2So1Q== 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 v4 03/12] turris-omnia-mcu-interface.h: Add LED commands related definitions to global header Date: Tue, 29 Oct 2024 14:56:12 +0100 Message-ID: <20241029135621.12546-4-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241029135621.12546-1-kabel@kernel.org> References: <20241029135621.12546-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 Tue Oct 29 13:56:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13854948 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 1AF8F206971 for ; Tue, 29 Oct 2024 13:56:49 +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=1730210209; cv=none; b=UWwDjKl9UHu2Lki++FhXWVGlkYUOtw5HZqqEJz9SRECJI3hFcP9ZFvfOLm1U6r1wt2NR5pgLtzudldSQg22+xuY37eLNPRAfLQSejMbSzGih+UgxEko02XEs1owvHeTOgCTOnZFAXH5sxS6iTfK2LZ/l1qoc6/Ql7KNJkrfxOzg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730210209; c=relaxed/simple; bh=D7toZgZkypjWzfI/Fg+Y0UJKTep6HUwLDQE5Dybc+Xs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=G2JVMA/O0MAePglB0NJVdflmItjKa+0WkEbJHpHIfG3HXBdEotGCKtsS1NgUG3z8T+wh7gKNdCgsAZXuLHTWS7plOhWrnNZdp1+Z24YNBA9vNJSC6K5WfQhYqgU1gkOHfDsAXPh0seOEty0U0sC7/dXcX5/EeCTl90wLEp44aqY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MPPLz00W; 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="MPPLz00W" Received: by smtp.kernel.org (Postfix) id 13594C4CEE5; Tue, 29 Oct 2024 13:56:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E8FBC4CEE9; Tue, 29 Oct 2024 13:56:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730210209; bh=D7toZgZkypjWzfI/Fg+Y0UJKTep6HUwLDQE5Dybc+Xs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MPPLz00WpTaaO/LwoCx407z7nKjUYbZml52kEX8LmhhXUZtLgwuNH0Lp6df2hvGXf 6934fAue5WfOQZmZpkjizFPbCFxJv+sisR/aRvwulhsFDok6IQQRZ7XHhMCBiDDEaW cxObOnu671SPMiKPPEElId9fSbgLDW2guIUrnTQeVZkBWYAAGRi6JjI/KLayYPAap3 pJhXpcPfXAzyWJHDaEyEeoEz1n/xfKYSl7tt0hHUBoIYNxrlaMTtp41czDlYCqbXw0 UOnIYlXDPBacYHSaasClQNtjMl7RTBnE5bVz4LkJrF7x43mnA2IguaB0RWRKBSJ2HA +4xdBrIPaX1tQ== 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 v4 04/12] leds: turris-omnia: Use global header for MCU command definitions Date: Tue, 29 Oct 2024 14:56:13 +0100 Message-ID: <20241029135621.12546-5-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241029135621.12546-1-kabel@kernel.org> References: <20241029135621.12546-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 0b71848930dd..82cf58fbe946 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; } @@ -391,15 +366,15 @@ static int omnia_mcu_get_features(const struct i2c_client *client) /* We have to read features from different I2C address */ mcu_client.addr = OMNIA_MCU_I2C_ADDR; - 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; @@ -437,7 +412,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"); @@ -468,7 +443,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 Tue Oct 29 13:56:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13854949 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 1E16B206971 for ; Tue, 29 Oct 2024 13:56:53 +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=1730210213; cv=none; b=EWCSHnxiN9jHcjZfnkcNZOEPOzEOVIqQSmXh38z2x9rgyns5GwRKGUa8tQfY3Kw7YWLAGMOnFFcV5I05gOY658ogWMZSLM4Fa2CJBzQUmwLNLdG+u58QaTp8NelbLn61bZhDB3cQeqUQpb36nrwfN2Qv6aFTZSwqoiRn6FTiDD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730210213; c=relaxed/simple; bh=IL6ApZj/AEN4ogtSsw2hRDlMG6U3NVDiHfarNqZTetA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DycsjnTzyXLcuUZzbEpyKH7Ds25HaShkFBvKGlavPWCum7JVdnTdbl4i3uwScumoPYj1F5a/VX5Fk8h7rzi3qJNvEfZ4nm/mLako6dPlIS8HIr1Bo0jtCul5BiibPHJOAK1n1wfxmhbLxuqt8fTDLR7P0nvGORNYtQ3pfzvlJno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dzoJrKMM; 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="dzoJrKMM" Received: by smtp.kernel.org (Postfix) id 15E3BC4AF0F; Tue, 29 Oct 2024 13:56:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65F99C4CEEF; Tue, 29 Oct 2024 13:56:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730210213; bh=IL6ApZj/AEN4ogtSsw2hRDlMG6U3NVDiHfarNqZTetA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dzoJrKMMUZmNxW6oCOv8DyCPLOolrL4FWgTZXgFuhv2qyHLrNUSzGMe56qawboHBy Hv30HYsGtzrogM+C7y9PGyNbEnf0Sk6SMHQeUvetOXN7c8fMAFbKC6ggTpZKRs0NfB RT/jQ76paPOHZWicGPMzJxvTiHAfuH10RF2RmbGXv3POyEIci9A/Y4yJN15DjHhDCW tty05gd+e1R/bM9S0C/AFBl6+WgDqrQPPeIUeuEy3FKyuMrhL+VnRstvUcoOomer50 4+nh8V1XQEH6BHbv6Sl4s+NV538HS7BMLMHHmxpgtPj1NvA/JOqteI+dC3Yzbe3Jv2 F61POGOhdBefw== 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 v4 05/12] dt-bindings: leds: cznic,turris-omnia-leds: Allow interrupts property Date: Tue, 29 Oct 2024 14:56:14 +0100 Message-ID: <20241029135621.12546-6-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241029135621.12546-1-kabel@kernel.org> References: <20241029135621.12546-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 Tue Oct 29 13:56:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13854950 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 25A1C206E70 for ; Tue, 29 Oct 2024 13:56:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730210217; cv=none; b=MqDGXXaxBmjbbQTadnDNVpQALGv/tG+VtwpDxnEMbNMKOJa03cOc4I/+303UxtRwKiDUgAX52bt9A1nfLLNelXvOiigqZb1CTNg0v10yMo8+DMRFC50E6es446SCSdySIx3DR+FH0jvyLq1toVyqPaOjMWDMeAWI8fHr/06DNfM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730210217; c=relaxed/simple; bh=wCvR1DsmVcTKlbR4ZRdGJLWwzhcOYcxjtGptt9x3GTc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Kgi5EKroxcxsy2oiEyxdfuoe6eBb5O09KZVatKRl91A1hWqgBlesYRH5GVjqmYfukev9lYE+acQvGRhFAJ9/Dino8IEGMIe7nVx2ID+zclwWg04ofeWFyuERFwu1/W/xUGvRjoW8BjuJrSeJrEX4Ho0vs+cq1keK0yiJ8Lfe5DA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TBzZTaMX; 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="TBzZTaMX" Received: by smtp.kernel.org (Postfix) id DCDDCC4AF0B; Tue, 29 Oct 2024 13:56:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6933EC4CEE6; Tue, 29 Oct 2024 13:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730210216; bh=wCvR1DsmVcTKlbR4ZRdGJLWwzhcOYcxjtGptt9x3GTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TBzZTaMXn3Dd+Q6HH/kgaa3P/8/1ndZw02zIFqeRsqr2J+2H6/F5FQ0ijhAwzQbql bohvr7w9pnvp8EkDzRujWOD4E9qTnknn3kjhkuYxaICi7gDJNzkhk5Vwb2mFePSx6V tqIvXbzxGgT93T4FH30Nepkt6D3g6Qu1mObuGmHhKUeJ21TIXBIRzL4Jh0mmWEtsf3 B7bjFo65YyEzFOI6hy9SMwdH8v33Ims0YHuN5OxKK1oFuSVN7FugRxt1b1WYGnKBSu 0atl4+5/csRx9jzmUaA75nEpRRK5JWtrRDxp+MOiYNNRcnWCk8f6/l9iSpM03o1uPq TEjlOFfQTPvjA== 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 v4 06/12] leds: turris-omnia: Document driver private structures Date: Tue, 29 Oct 2024 14:56:15 +0100 Message-ID: <20241029135621.12546-7-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241029135621.12546-1-kabel@kernel.org> References: <20241029135621.12546-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 82cf58fbe946..b13b3b269ae9 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 Tue Oct 29 13:56:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13854951 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 C1133206E6D for ; Tue, 29 Oct 2024 13:57:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730210220; cv=none; b=PqR72K16Gk+lVC3UkXUrEqw3nyYzszmAvEJT8uCGfKuVm68FXJ2KZlOgyKTRwhanrzbfxNnQyiSfrTPZcf7LdbQIldNk97bkzd/oz44ATH2RsN7rTQ2M5ntyJS+ZG9R/5rrir219tyupYCIT4TcE+6EJ9Eds0UzeBAvHZPGHRsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730210220; c=relaxed/simple; bh=MSD9y2n/tjvuERbL3dPKRUkIWXA6bylEOX2usY03xaM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Vd/QusRW23EXLTKhqwbUgoJxrfJ89RCENAuLJ87c17j6giyzkwVsuMEFkOr1VTzgPfobyDQElKTPGv3p9Bu181JjW2RlvkJSXSKPkS1OjqBOeHnT6eVvRnToarEXS8jiLiMmMxur+pVlVCBkfMbjTUYYtk4jdmn78YeWxQlrTdU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gDBkUyDl; 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="gDBkUyDl" Received: by smtp.kernel.org (Postfix) id B71BBC4AF09; Tue, 29 Oct 2024 13:57:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41382C4CEE3; Tue, 29 Oct 2024 13:56:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730210220; bh=MSD9y2n/tjvuERbL3dPKRUkIWXA6bylEOX2usY03xaM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gDBkUyDlycXFxow+CiF4Wjz3K07iHLBooLXkde89U8WYzNegzwdd5jRdh+guKBTOU xiMy38OJgwUo3PX49mDP6txPLC2amXfBXocEKG858+anUZiEcQY2UqFk7JIopqe6bm erpXsYSg1vpvYo0/NEevMcEkZJTe0nbC8bqi9dZKtBOA32/oBAfq8hXY0sR7LiUhEZ JBa7pFTmyC2CiGKwZcZiXQM2XaD0mdcSW1FLPphYMPhJlcERGE3sDYzUwWAPR5CFid eUB1k+S988bLbClf41CI/MFvd0O4QWrWtARQhN6s3YCQsBoTs/2QWj/zuIOOTcS2w7 7wFYF4iAIJQKA== 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 v4 07/12] leds: turris-omnia: Notify sysfs on MCU global LEDs brightness change Date: Tue, 29 Oct 2024 14:56:16 +0100 Message-ID: <20241029135621.12546-8-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241029135621.12546-1-kabel@kernel.org> References: <20241029135621.12546-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 | 48 ++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index fcbe93b61e49..443aaf948bb8 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -219,6 +219,7 @@ config LEDS_TURRIS_OMNIA depends on OF depends on TURRIS_OMNIA_MCU select LEDS_TRIGGERS + select TURRIS_OMNIA_MCU_GPIO help This option enables basic support for the LEDs found on the front side of CZ.NIC's Turris Omnia router. There are 12 RGB LEDs on the diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index b13b3b269ae9..ac7938f57bfe 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -43,12 +43,15 @@ struct omnia_led { * @client: I2C client device * @lock: mutex to protect * @has_gamma_correction: whether the MCU firmware supports gamma correction + * @brightness_knode: kernel node of the "brightness" device sysfs attribute (this is the + * driver specific global brightness, not the LED classdev brightness) * @leds: flexible array of per-LED data */ struct omnia_leds { struct i2c_client *client; struct mutex lock; bool has_gamma_correction; + struct kernfs_node *brightness_knode; struct omnia_led leds[]; }; @@ -373,6 +376,30 @@ static struct attribute *omnia_led_controller_attrs[] = { }; ATTRIBUTE_GROUPS(omnia_led_controller); +static irqreturn_t omnia_brightness_changed_threaded_fn(int irq, void *data) +{ + struct omnia_leds *leds = data; + + if (unlikely(!leds->brightness_knode)) { + /* + * It would be nicer to get this dirent in the driver probe method, before the IRQ + * is requested. But the really_probe() function in drivers/base/dd.c registers + * driver's .dev_groups only after probe is finished, so during driver probe the + * "brightness" sysfs node is not yet present. + * + * Note that sysfs_get_dirent() may sleep. This is okay, because we are in threaded + * context. + */ + leds->brightness_knode = sysfs_get_dirent(leds->client->dev.kobj.sd, "brightness"); + if (!leds->brightness_knode) + return IRQ_NONE; + } + + sysfs_notify_dirent(leds->brightness_knode); + + return IRQ_HANDLED; +} + static int omnia_mcu_get_features(const struct i2c_client *client) { struct i2c_client mcu_client = *client; @@ -436,6 +463,14 @@ 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 = devm_request_threaded_irq(dev, client->irq, NULL, + omnia_brightness_changed_threaded_fn, IRQF_ONESHOT, + "leds-turris-omnia", leds); + if (ret <= 0) + return dev_err_probe(dev, ret ?: -ENXIO, "Cannot request brightness IRQ\n"); + } + mutex_init(&leds->lock); ret = devm_led_trigger_register(dev, &omnia_hw_trigger); @@ -458,6 +493,19 @@ static int omnia_leds_probe(struct i2c_client *client) static void omnia_leds_remove(struct i2c_client *client) { + struct omnia_leds *leds = i2c_get_clientdata(client); + + /* + * We need to free the brightness IRQ here, before putting away the brightness sysfs node. + * Otherwise devres would free the interrupt only after the sysfs node is removed, and if + * an interrupt occurred between those two events, it would use a removed sysfs node. + */ + devm_free_irq(&client->dev, client->irq, leds); + + /* Now put away the sysfs node we got the first time the interrupt handler was called */ + if (leds->brightness_knode) + sysfs_put(leds->brightness_knode); + /* put all LEDs into default (HW triggered) mode */ omnia_cmd_write_u8(client, OMNIA_CMD_LED_MODE, OMNIA_CMD_LED_MODE_LED(OMNIA_BOARD_LEDS)); From patchwork Tue Oct 29 13:56:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13854952 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 9DAA020695A for ; Tue, 29 Oct 2024 13:57:04 +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=1730210224; cv=none; b=MnGZyWptfwZaI6uXFqm0+f3Is2nET1vmxEeQC25svYi94kgo2AIrhafDHNFYDYG66E2RSNbiq4ZW8TUPdd/FgI9RurYhOgs2YixGf2sGO6TejMITjWT7ZaSdp7X14o5vAeank2/oKdfT9LYmyniThC5XkDfP0eqRDfsia0Ju+TE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730210224; c=relaxed/simple; bh=8xxaLaeqEAFIPs2iLJxr0JwGVdVOwPrRyzlBgb3dEzU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PVLmmpMZAxw/hS2F3qFBHmTYqG1i78hMUWdVDC9jZozt6LkrW2PLI5ZnzWqw+b/pBop3Gjc4aDXyPICs0RVdjNVmgPrkDjptnfLB/VQ9VPP76ewrbBoSThor2iiU2mjctJuH6PhMcdsfjTGybpTocquApgetbf/I6Ej+S0XmW2Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=txd4ZATU; 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="txd4ZATU" Received: by smtp.kernel.org (Postfix) id 90432C4AF0D; Tue, 29 Oct 2024 13:57:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AA6DC4CEF1; Tue, 29 Oct 2024 13:57:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730210224; bh=8xxaLaeqEAFIPs2iLJxr0JwGVdVOwPrRyzlBgb3dEzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=txd4ZATUmkVgcfssV3MltLERVxSDgAMZ2Y+lxSzZa3S2hV5JheIzHsfoon8HN0jF5 COA3Wx2HidN/cyWiHPue6v8RPgFiPfZ1SNi9BEPon4LvWl8nLT3wc2eP/AydaikD5l PymDmNFjKegAMACjHVv9n3NSjOTsB65bsYnshIFnLJpLQCeuvQy8jZmiU8bwTvb+i/ xmSkTHvmG4UYhj4WSf+a8NYu4wlJa3OFlGJf/3gC0DevdN/vIiXJusFPqeGIwNJO6p VBzW0bvbIAk9jXbIRtJ7OTVp6Gkc5mWlypWmWOfhRBJ3kfQLFzh1zNIddo9tRZd+vD QG0IKbN05MGvw== 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 v4 08/12] platform: cznic: turris-omnia-mcu: Inform about missing LED panel brightness change interrupt feature Date: Tue, 29 Oct 2024 14:56:17 +0100 Message-ID: <20241029135621.12546-9-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241029135621.12546-1-kabel@kernel.org> References: <20241029135621.12546-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 Tue Oct 29 13:56:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13854953 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 D7B4920697B for ; Tue, 29 Oct 2024 13:57:08 +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=1730210228; cv=none; b=baoJJypNcnpFIyVR9Fo8oati+MbKF1UYvsMt+y5tnLg+ZAN2VOnknlgllKkNc6WlcJwGcYZwio4RmA0TtAYYwrJib+jseKaM5jEZt9YJcw+QQwvv2v6HdxmGJSJ6utBfhHTtLymwVJtSIDvJkgpIxFGqP7IAQoBYFdKZuRC+yfw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730210228; c=relaxed/simple; bh=CCLzLrkY1aUdwA4JUmu0VIFCmTUXNRsm5pghqLPBTbQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VJv2a67mCcdYNvBOmrwizEua2fbpzudeNkazPwXOlsD7pL90eY6LCOIepEXe8V54MUvoMJ2LY5NwdwgoXMvT5EJlHhQKp21CmV6GrYYiH19FJImk8dX9/EKqWIESM83h/k3VlMKKzOQkaxhvgQhzMcj2ukFfeAsosOkrvXT2wnc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HPDqrvHz; 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="HPDqrvHz" Received: by smtp.kernel.org (Postfix) id 6C80FC4AF0F; Tue, 29 Oct 2024 13:57:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7229C4CEEA; Tue, 29 Oct 2024 13:57:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730210228; bh=CCLzLrkY1aUdwA4JUmu0VIFCmTUXNRsm5pghqLPBTbQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HPDqrvHzA5uFPY5XHbdOY6BmwmPDyllAmOtgQuD1DjfPKQYqR3JupXtNRmHWhp7xm kCrtgvqtVcalhmx5HePCy/rM410y5quStkMkojOXVbKBELZv3zggofkhfTcnjwLuje ubPIqmr5/v+dau4OuWAF8RXqXmV8A7Yp/SVbdAPI7obmcVNgz8p8ygRmvth0CsanQ7 ov7oUJzKUI7Hg4I9J55uz+jMvMdKXXt4d7y0vJDDS9VTAiJfpbdq0xDubw144lBHzi mzNXoXVDlAWf+rQoNvnafJ4hX+kDZH5IYmOAaf71GJxDHcK6LNzXmcNUixFAPHmIpc PGZuqAgw2uFzg== 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 v4 09/12] leds: turris-omnia: Inform about missing LED gamma correction feature in the MCU driver Date: Tue, 29 Oct 2024 14:56:18 +0100 Message-ID: <20241029135621.12546-10-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241029135621.12546-1-kabel@kernel.org> References: <20241029135621.12546-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 ac7938f57bfe..0b0cf592557a 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -456,12 +456,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 = devm_request_threaded_irq(dev, client->irq, NULL, diff --git a/drivers/platform/cznic/turris-omnia-mcu-base.c b/drivers/platform/cznic/turris-omnia-mcu-base.c index 3bb4a3cfdb29..770e680b96f9 100644 --- a/drivers/platform/cznic/turris-omnia-mcu-base.c +++ b/drivers/platform/cznic/turris-omnia-mcu-base.c @@ -259,6 +259,7 @@ static int omnia_mcu_read_features(struct omnia_mcu *mcu) _DEF_FEAT(POWEROFF_WAKEUP, "poweroff and wakeup"), _DEF_FEAT(TRNG, "true random number generator"), _DEF_FEAT(BRIGHTNESS_INT, "LED panel brightness change interrupt"), + _DEF_FEAT(LED_GAMMA_CORRECTION, "LED gamma correction"), #undef _DEF_FEAT }; struct i2c_client *client = mcu->client; From patchwork Tue Oct 29 13:56:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13854954 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 4E443206514 for ; Tue, 29 Oct 2024 13:57:12 +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=1730210232; cv=none; b=U/xL5iNmllz8fJiA2VUqBYhx4ppXamW0Eug1dXCV+2bXR+brIms6j/rdd3K7I1/syd+/jNu8so87QM1iR/imv88F7lFnRhXjHkI6gRpO2PUAl2tR66xl7/FZDq3LRwYCz0I3gGybj913I7ULlfr2zSuT1PgNp61wA+v1GoRzbiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730210232; c=relaxed/simple; bh=UD+3tqchUpRa+12ezJSKWb7rFIQVb01f08TAR0S0Iuo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OobOHA1fuRSLkmb5++Ae8npoM8uPhiVdjrdXfVQV2J6C2raSeWJZK/LQ+TcsRTFoAnzlcT3xiTZI6v6p90td8wRz1Qpi+g9i70OppjK+GuIaRpIDOpmu+oEo6Bv3+zslRxxxPrhntdE9GttX9YbFBcAx4e7KE+wttI0PLsU7uHc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iBAiXv4A; 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="iBAiXv4A" Received: by smtp.kernel.org (Postfix) id 43383C4AF0D; Tue, 29 Oct 2024 13:57:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C20DDC4CEEB; Tue, 29 Oct 2024 13:57:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730210232; bh=UD+3tqchUpRa+12ezJSKWb7rFIQVb01f08TAR0S0Iuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iBAiXv4AUn25Q16gO/UFkiITJTKHYrDUe9YFXCvN2q1Nn8MIwb6BPUjvmpCUQSUTW SUVmFMh2q3dgrVMqPo4MiFY8/BnYGtpdtcyqPsRIxcioYuBU6ZQqvoT+GPOaEx/oi3 LaM1UM94SzYPkHFFo9NsRr/wCMbeyNsaIW9U+1AWIfiL5qfzdLPI8ukVQ02b+y+Bdz UPwTVXtuoHO8I+07EcCNAkmNlwfh8adb6OaWogHAtdQqCT2gSk+qeAbzRwZZZM8rDp fnohabhJFoESZKwg7kDblI/ZwF55KhKD5W0/MzHLBfzDNjpUpU1HRpCIXqwoxmQ3lr 82HbUy5KDVi5Q== 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 v4 10/12] leds: turris-omnia: Use dev_err_probe() where appropriate Date: Tue, 29 Oct 2024 14:56:19 +0100 Message-ID: <20241029135621.12546-11-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241029135621.12546-1-kabel@kernel.org> References: <20241029135621.12546-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 0b0cf592557a..515ba2991cf5 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; } @@ -433,13 +423,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) @@ -449,11 +436,8 @@ static int omnia_leds_probe(struct i2c_client *client) i2c_set_clientdata(client, leds); ret = omnia_mcu_get_features(client); - 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; @@ -468,10 +452,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 Tue Oct 29 13:56:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13854955 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 4732520696C for ; Tue, 29 Oct 2024 13:57:16 +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=1730210236; cv=none; b=THwz73urJgpvK6V+xMZ1mPI3fYE4mZERKR+XRQ5etOieMaZaQccAwL6Yn8srYx9ostmilhpa0awqiPWlN4qGGfqXIOUP2hnZBRWA/eASJbT6GKCR7vogPO7jiBkxdV5+ciztN2Znd7RWvJ38cnjRHlCcyzdJM7wgYBsvl7FqsKA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730210236; c=relaxed/simple; bh=mLMKwJMTWg5EKRK5X4wSqHZxkmJnB9Dd4yvJMwI+P7o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TPvIJXMLJO5yTkSDPYZB6BGFqgzzrI0gJT6I2tuEkIrg6YiNgyq3kjNA5JydHCah/OkcLykq4tbD7ZFxclb3sta6f2E657+pFbnz3586R4Ui/jQPvvDqGw7EdPC4LCISyILBMjn2Urq8u5Ku5kKqFIrffl7IYTk0ZpA1uDOu6P4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sVr8asgt; 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="sVr8asgt" Received: by smtp.kernel.org (Postfix) id 1BF15C4AF0D; Tue, 29 Oct 2024 13:57:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99F49C4CECD; Tue, 29 Oct 2024 13:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730210236; bh=mLMKwJMTWg5EKRK5X4wSqHZxkmJnB9Dd4yvJMwI+P7o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sVr8asgtIznNiUcCktBMjFbkM+g3TBwhFtDvDx20JTLD3Eh4Q74qrupS4JbMD0tvi LWMXHqranuxO2oFTHjlIjNpaNbJJg4qZ+iq1/pIXwrzLMmHwHtHFZj1Ao8UpVW3YGt njzSOHZevICC7wk6xSKGY7XjyPk2/Y5l8XgFlXYgGVnrKFu/0kgtyX8xt3r9KrtSXC u/YXbr087xI5DJguMue+xMBUhTL+Cb/eXMPklg9hud6728zbHeDprtFCGoDPJwWU78 9cHyS1+Sm63kOgTLCy3fMiScGObEFU+GyF5OyEiSyRhGZPS5c8B8BXrFnTh9SGqcTR NQR2GruGEEHbw== 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 v4 11/12] leds: turris-omnia: Use uppercase first letter in all comments Date: Tue, 29 Oct 2024 14:56:20 +0100 Message-ID: <20241029135621.12546-12-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241029135621.12546-1-kabel@kernel.org> References: <20241029135621.12546-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 515ba2991cf5..326958e099c9 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); @@ -482,10 +482,10 @@ static void omnia_leds_remove(struct i2c_client *client) if (leds->brightness_knode) sysfs_put(leds->brightness_knode); - /* put all LEDs into default (HW triggered) mode */ + /* Put all LEDs into default (HW triggered) mode */ omnia_cmd_write_u8(client, OMNIA_CMD_LED_MODE, OMNIA_CMD_LED_MODE_LED(OMNIA_BOARD_LEDS)); - /* set all LEDs color to [255, 255, 255] */ + /* Set all LEDs color to [255, 255, 255] */ omnia_cmd_set_color(client, OMNIA_BOARD_LEDS, 255, 255, 255); } From patchwork Tue Oct 29 13:56:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 13854956 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 F0741205132 for ; Tue, 29 Oct 2024 13:57:19 +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=1730210240; cv=none; b=Qw0LD5d+30P/4EwfkOvGXTJ7T027cussGneVku1pASDtjCET3USR7oXXmbWMxJCF2eHO+MOmw8X7n1OPpDTP+34GXUnKafeHYJfPDXsz0Oc/yZQrTtV1ivrhF9nCuY7PHxFJxtZ+PwkI+FgaRXo6SrwQStmahMgIrLsYvBqenZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730210240; c=relaxed/simple; bh=02cumqv7Pptd8Tkhcc6pofXSXkHGb+wYsFd9giydYr4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iJ0QEkP7Q1SMDR674F09wgBwjEOn6/viGmn4otZkBgqJUuRiddTqWy2Gw4RV+ZSWQH/sYw3oPvu0f+3wEhixH0anu1oYx2+/Jv8OMKAoWPkA5hXJMuP+6hE4YZEJcR1ql28D8Lwnw2zk4yDkjCOWY3YTd5khzZhqJFLE/fTIqIc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jipdGpCV; 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="jipdGpCV" Received: by smtp.kernel.org (Postfix) id E751CC4AF09; Tue, 29 Oct 2024 13:57:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72B24C4CEE6; Tue, 29 Oct 2024 13:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730210239; bh=02cumqv7Pptd8Tkhcc6pofXSXkHGb+wYsFd9giydYr4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jipdGpCV0QP8ceDBVUoVQzTgnZTZm720UFG4wqfXHR2qoB9vMgq/0GW1ovrO5gPG+ 0Z+fiTDqXFbl4SYbeoFoj5IZ+1IhZbHw5D9hXcB6emzLafCapBDThWVoWvuMqiE2xS XIKBVnOjUecFMtoqjsYdkMOPtGq5lG8YYN37tueUaPLyiiLxbxxi4sS2XVp2VO8Ug3 p/yZUmvfS7cONnO596N2L7Xjfs+yd8jJ+IlB5+wrvgFGuyn/g0NaUU7jFGJg/seFaR 6VkkNFFqFMsTOA1jY+qjqzR+0WVsRW/b8nKG/4PSDENRHkwF9OrJ09Uo/jbzrj2uEi WP9Hh2AGh5AjA== 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 v4 12/12] ARM: dts: turris-omnia: Add global LED brightness change interrupt Date: Tue, 29 Oct 2024 14:56:21 +0100 Message-ID: <20241029135621.12546-13-kabel@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241029135621.12546-1-kabel@kernel.org> References: <20241029135621.12546-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";