Skip to content
Snippets Groups Projects
Verified Commit 10c361c8 authored by Marek Behun's avatar Marek Behun
Browse files

patches/openwrt/kernel-5.15: Move Turris Omnia LED patches to backport-5.15

Take the 8 backported Turris Omnia LED patches from
target/mvebu/patches-5.15 and move them to target/generic/backport-5.15
as they are in upstream OpenWRT.
parent 304a5cba
No related branches found
No related tags found
1 merge request!679Fix kernel 5.15 on Turris 1.x and use it
From 3b5a1a4124b025f242e269c1ac72d0f4e306d05d Mon Sep 17 00:00:00 2001
From e4bb65724234112cdeea590c97d64d7e7f523507 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <marek.behun@nic.cz>
Date: Mon, 16 Oct 2023 10:59:27 +0200
Subject: [PATCH 1/3] mvebu: patches-5.15: Backport Turris Omnia LED changes
---
...rris-omnia-convert-to-use-dev_groups.patch | 48 ++++
...ia-Use-sysfs_emit-instead-of-sprintf.patch | 35 +++
...omnia-Drop-unnecessary-mutex-locking.patch | 69 +++++
...-turris-omnia-Do-not-use-SMBUS-calls.patch | 150 +++++++++++
...a-Make-set_brightness-more-efficient.patch | 222 ++++++++++++++++
...a-Support-HW-controlled-mode-via-pri.patch | 209 +++++++++++++++
...a-Add-support-for-enabling-disabling.patch | 249 ++++++++++++++++++
...a-Fix-brightness-setting-and-trigger.patch | 172 ++++++++++++
8 files changed, 1154 insertions(+)
create mode 100644 target/linux/mvebu/patches-5.15/102-v6.0-leds-turris-omnia-convert-to-use-dev_groups.patch
create mode 100644 target/linux/mvebu/patches-5.15/102-v6.6-1-leds-turris-omnia-Use-sysfs_emit-instead-of-sprintf.patch
create mode 100644 target/linux/mvebu/patches-5.15/102-v6.6-2-leds-turris-omnia-Drop-unnecessary-mutex-locking.patch
create mode 100644 target/linux/mvebu/patches-5.15/102-v6.7-1-leds-turris-omnia-Do-not-use-SMBUS-calls.patch
create mode 100644 target/linux/mvebu/patches-5.15/102-v6.7-2-leds-turris-omnia-Make-set_brightness-more-efficient.patch
create mode 100644 target/linux/mvebu/patches-5.15/102-v6.7-3-leds-turris-omnia-Support-HW-controlled-mode-via-pri.patch
create mode 100644 target/linux/mvebu/patches-5.15/102-v6.7-4-leds-turris-omnia-Add-support-for-enabling-disabling.patch
create mode 100644 target/linux/mvebu/patches-5.15/102-v6.7-5-leds-turris-omnia-Fix-brightness-setting-and-trigger.patch
...rris-omnia-convert-to-use-dev_groups.patch | 45 ++++
...ia-Use-sysfs_emit-instead-of-sprintf.patch | 31 +++
...omnia-Drop-unnecessary-mutex-locking.patch | 66 +++++
...-turris-omnia-Do-not-use-SMBUS-calls.patch | 145 +++++++++++
...a-Make-set_brightness-more-efficient.patch | 207 +++++++++++++++
...a-Support-HW-controlled-mode-via-pri.patch | 201 +++++++++++++++
...a-Add-support-for-enabling-disabling.patch | 244 ++++++++++++++++++
...a-Fix-brightness-setting-and-trigger.patch | 167 ++++++++++++
8 files changed, 1106 insertions(+)
create mode 100644 target/linux/generic/backport-5.15/830-v6.0-leds-turris-omnia-convert-to-use-dev_groups.patch
create mode 100644 target/linux/generic/backport-5.15/830-v6.6-1-leds-turris-omnia-Use-sysfs_emit-instead-of-sprintf.patch
create mode 100644 target/linux/generic/backport-5.15/830-v6.6-2-leds-turris-omnia-Drop-unnecessary-mutex-locking.patch
create mode 100644 target/linux/generic/backport-5.15/830-v6.7-1-leds-turris-omnia-Do-not-use-SMBUS-calls.patch
create mode 100644 target/linux/generic/backport-5.15/830-v6.7-2-leds-turris-omnia-Make-set_brightness-more-efficient.patch
create mode 100644 target/linux/generic/backport-5.15/830-v6.7-3-leds-turris-omnia-Support-HW-controlled-mode-via-pri.patch
create mode 100644 target/linux/generic/backport-5.15/830-v6.7-4-leds-turris-omnia-Add-support-for-enabling-disabling.patch
create mode 100644 target/linux/generic/backport-5.15/830-v6.7-5-leds-turris-omnia-Fix-brightness-setting-and-trigger.patch
diff --git a/target/linux/mvebu/patches-5.15/102-v6.0-leds-turris-omnia-convert-to-use-dev_groups.patch b/target/linux/mvebu/patches-5.15/102-v6.0-leds-turris-omnia-convert-to-use-dev_groups.patch
diff --git a/target/linux/generic/backport-5.15/830-v6.0-leds-turris-omnia-convert-to-use-dev_groups.patch b/target/linux/generic/backport-5.15/830-v6.0-leds-turris-omnia-convert-to-use-dev_groups.patch
new file mode 100644
index 0000000000..6c7df7041e
index 0000000000..b9ba07b485
--- /dev/null
+++ b/target/linux/mvebu/patches-5.15/102-v6.0-leds-turris-omnia-convert-to-use-dev_groups.patch
@@ -0,0 +1,48 @@
+From 7ffac542e880e77305723c15558ee1c57652f1a5 Mon Sep 17 00:00:00 2001
+++ b/target/linux/generic/backport-5.15/830-v6.0-leds-turris-omnia-convert-to-use-dev_groups.patch
@@ -0,0 +1,45 @@
+From a01633cd867b8ddf2d8321fe575dc3c54e037b09 Mon Sep 17 00:00:00 2001
+From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Date: Fri, 29 Jul 2022 16:03:46 +0200
+Subject: [PATCH 01/17] leds: turris-omnia: convert to use dev_groups
+Subject: leds: turris-omnia: convert to use dev_groups
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
......@@ -51,11 +51,11 @@ index 0000000000..6c7df7041e
+ drivers/leds/leds-turris-omnia.c | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c
+index 1adfed1c0619..eac6f4a573b2 100644
+(limited to 'drivers/leds/leds-turris-omnia.c')
+
+--- a/drivers/leds/leds-turris-omnia.c
++++ b/drivers/leds/leds-turris-omnia.c
+@@ -239,9 +239,6 @@ static int omnia_leds_probe(struct i2c_client *client,
+@@ -239,9 +239,6 @@ static int omnia_leds_probe(struct i2c_c
+ led += ret;
+ }
+
......@@ -65,7 +65,7 @@ index 0000000000..6c7df7041e
+ return 0;
+ }
+
+@@ -283,6 +280,7 @@ static struct i2c_driver omnia_leds_driver = {
+@@ -283,6 +280,7 @@ static struct i2c_driver omnia_leds_driv
+ .driver = {
+ .name = "leds-turris-omnia",
+ .of_match_table = of_omnia_leds_match,
......@@ -73,20 +73,16 @@ index 0000000000..6c7df7041e
+ },
+ };
+
+--
+2.41.0
+
diff --git a/target/linux/mvebu/patches-5.15/102-v6.6-1-leds-turris-omnia-Use-sysfs_emit-instead-of-sprintf.patch b/target/linux/mvebu/patches-5.15/102-v6.6-1-leds-turris-omnia-Use-sysfs_emit-instead-of-sprintf.patch
diff --git a/target/linux/generic/backport-5.15/830-v6.6-1-leds-turris-omnia-Use-sysfs_emit-instead-of-sprintf.patch b/target/linux/generic/backport-5.15/830-v6.6-1-leds-turris-omnia-Use-sysfs_emit-instead-of-sprintf.patch
new file mode 100644
index 0000000000..de1e5808fb
index 0000000000..200d693b73
--- /dev/null
+++ b/target/linux/mvebu/patches-5.15/102-v6.6-1-leds-turris-omnia-Use-sysfs_emit-instead-of-sprintf.patch
@@ -0,0 +1,35 @@
+From 64a87f953bb96fb8a006e3e02530463b7e1a4e59 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <kabel@kernel.org>
+++ b/target/linux/generic/backport-5.15/830-v6.6-1-leds-turris-omnia-Use-sysfs_emit-instead-of-sprintf.patch
@@ -0,0 +1,31 @@
+From 72a29725b6f2577fa447ca9059cdcd17100043b4 Mon Sep 17 00:00:00 2001
+From: Marek Behún <kabel@kernel.org>
+Date: Wed, 2 Aug 2023 18:07:45 +0200
+Subject: [PATCH 02/17] leds: turris-omnia: Use sysfs_emit() instead of
+ sprintf()
+Subject: leds: turris-omnia: Use sysfs_emit() instead of sprintf()
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
......@@ -101,11 +97,11 @@ index 0000000000..de1e5808fb
+ drivers/leds/leds-turris-omnia.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c
+index eac6f4a573b2..7c016f3f0f84 100644
+(limited to 'drivers/leds/leds-turris-omnia.c')
+
+--- a/drivers/leds/leds-turris-omnia.c
++++ b/drivers/leds/leds-turris-omnia.c
+@@ -166,7 +166,7 @@ static ssize_t brightness_show(struct device *dev, struct device_attribute *a,
+@@ -166,7 +166,7 @@ static ssize_t brightness_show(struct de
+ if (ret < 0)
+ return ret;
+
......@@ -114,19 +110,16 @@ index 0000000000..de1e5808fb
+ }
+
+ static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
+--
+2.41.0
+
diff --git a/target/linux/mvebu/patches-5.15/102-v6.6-2-leds-turris-omnia-Drop-unnecessary-mutex-locking.patch b/target/linux/mvebu/patches-5.15/102-v6.6-2-leds-turris-omnia-Drop-unnecessary-mutex-locking.patch
diff --git a/target/linux/generic/backport-5.15/830-v6.6-2-leds-turris-omnia-Drop-unnecessary-mutex-locking.patch b/target/linux/generic/backport-5.15/830-v6.6-2-leds-turris-omnia-Drop-unnecessary-mutex-locking.patch
new file mode 100644
index 0000000000..168ec09b2b
index 0000000000..4178f150d9
--- /dev/null
+++ b/target/linux/mvebu/patches-5.15/102-v6.6-2-leds-turris-omnia-Drop-unnecessary-mutex-locking.patch
@@ -0,0 +1,69 @@
+From 4a29f3904b72a1384dac9055251080b60aa56be7 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <kabel@kernel.org>
+++ b/target/linux/generic/backport-5.15/830-v6.6-2-leds-turris-omnia-Drop-unnecessary-mutex-locking.patch
@@ -0,0 +1,66 @@
+From 760b6b7925bf09491aafa4727eef74fc6bf738b0 Mon Sep 17 00:00:00 2001
+From: Marek Behún <kabel@kernel.org>
+Date: Wed, 2 Aug 2023 18:07:43 +0200
+Subject: [PATCH 03/17] leds: turris-omnia: Drop unnecessary mutex locking
+Subject: leds: turris-omnia: Drop unnecessary mutex locking
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
......@@ -147,11 +140,11 @@ index 0000000000..168ec09b2b
+ drivers/leds/leds-turris-omnia.c | 11 +----------
+ 1 file changed, 1 insertion(+), 10 deletions(-)
+
+diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c
+index 7c016f3f0f84..78cea01883c3 100644
+(limited to 'drivers/leds/leds-turris-omnia.c')
+
+--- a/drivers/leds/leds-turris-omnia.c
++++ b/drivers/leds/leds-turris-omnia.c
+@@ -156,12 +156,9 @@ static ssize_t brightness_show(struct device *dev, struct device_attribute *a,
+@@ -156,12 +156,9 @@ static ssize_t brightness_show(struct de
+ char *buf)
+ {
+ struct i2c_client *client = to_i2c_client(dev);
......@@ -164,7 +157,7 @@ index 0000000000..168ec09b2b
+
+ if (ret < 0)
+ return ret;
+@@ -173,7 +170,6 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
+@@ -173,7 +170,6 @@ static ssize_t brightness_store(struct d
+ const char *buf, size_t count)
+ {
+ struct i2c_client *client = to_i2c_client(dev);
......@@ -172,7 +165,7 @@ index 0000000000..168ec09b2b
+ unsigned long brightness;
+ int ret;
+
+@@ -183,15 +179,10 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
+@@ -183,15 +179,10 @@ static ssize_t brightness_store(struct d
+ if (brightness > 100)
+ return -EINVAL;
+
......@@ -180,28 +173,25 @@ index 0000000000..168ec09b2b
+ ret = i2c_smbus_write_byte_data(client, CMD_LED_SET_BRIGHTNESS,
+ (u8)brightness);
+- mutex_unlock(&leds->lock);
+-
+
+- if (ret < 0)
+- return ret;
+
+-
+- return count;
++ return ret < 0 ? ret : count;
+ }
+ static DEVICE_ATTR_RW(brightness);
+
+--
+2.41.0
+
diff --git a/target/linux/mvebu/patches-5.15/102-v6.7-1-leds-turris-omnia-Do-not-use-SMBUS-calls.patch b/target/linux/mvebu/patches-5.15/102-v6.7-1-leds-turris-omnia-Do-not-use-SMBUS-calls.patch
diff --git a/target/linux/generic/backport-5.15/830-v6.7-1-leds-turris-omnia-Do-not-use-SMBUS-calls.patch b/target/linux/generic/backport-5.15/830-v6.7-1-leds-turris-omnia-Do-not-use-SMBUS-calls.patch
new file mode 100644
index 0000000000..ef78942b4f
index 0000000000..5460881cca
--- /dev/null
+++ b/target/linux/mvebu/patches-5.15/102-v6.7-1-leds-turris-omnia-Do-not-use-SMBUS-calls.patch
@@ -0,0 +1,150 @@
+From 9eab9de4aa833e4922017c606daa5b0da7d0a2a3 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <kabel@kernel.org>
+++ b/target/linux/generic/backport-5.15/830-v6.7-1-leds-turris-omnia-Do-not-use-SMBUS-calls.patch
@@ -0,0 +1,145 @@
+From 28350bc0ac77e17365ba87d3edb2db0a79c98fdd Mon Sep 17 00:00:00 2001
+From: Marek Behún <kabel@kernel.org>
+Date: Mon, 18 Sep 2023 18:11:01 +0200
+Subject: [PATCH 04/17] leds: turris-omnia: Do not use SMBUS calls
+Subject: leds: turris-omnia: Do not use SMBUS calls
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
......@@ -228,11 +218,9 @@ index 0000000000..ef78942b4f
+Link: https://lore.kernel.org/r/20230918161104.20860-2-kabel@kernel.org
+Signed-off-by: Lee Jones <lee@kernel.org>
+---
+ drivers/leds/leds-turris-omnia.c | 54 +++++++++++++++++++++++++-------
+ drivers/leds/leds-turris-omnia.c | 54 +++++++++++++++++++++++++++++++---------
+ 1 file changed, 42 insertions(+), 12 deletions(-)
+
+diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c
+index 78cea01883c3..a1e8553c3254 100644
+--- a/drivers/leds/leds-turris-omnia.c
++++ b/drivers/leds/leds-turris-omnia.c
+@@ -2,7 +2,7 @@
......@@ -282,7 +270,7 @@ index 0000000000..ef78942b4f
+ static int omnia_led_brightness_set_blocking(struct led_classdev *cdev,
+ enum led_brightness brightness)
+ {
+@@ -64,7 +95,7 @@ static int omnia_led_brightness_set_blocking(struct led_classdev *cdev,
+@@ -64,7 +95,7 @@ static int omnia_led_brightness_set_bloc
+ if (buf[2] || buf[3] || buf[4])
+ state |= CMD_LED_STATE_ON;
+
......@@ -291,7 +279,7 @@ index 0000000000..ef78942b4f
+ if (ret >= 0 && (state & CMD_LED_STATE_ON))
+ ret = i2c_master_send(leds->client, buf, 5);
+
+@@ -114,9 +145,9 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
+@@ -114,9 +145,9 @@ static int omnia_led_register(struct i2c
+ cdev->brightness_set_blocking = omnia_led_brightness_set_blocking;
+
+ /* put the LED into software mode */
......@@ -304,7 +292,7 @@ index 0000000000..ef78942b4f
+ if (ret < 0) {
+ dev_err(dev, "Cannot set LED %pOF to software mode: %i\n", np,
+ ret);
+@@ -124,8 +155,8 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
+@@ -124,8 +155,8 @@ static int omnia_led_register(struct i2c
+ }
+
+ /* disable the LED */
......@@ -315,7 +303,7 @@ index 0000000000..ef78942b4f
+ if (ret < 0) {
+ dev_err(dev, "Cannot set LED %pOF brightness: %i\n", np, ret);
+ return ret;
+@@ -158,7 +189,7 @@ static ssize_t brightness_show(struct device *dev, struct device_attribute *a,
+@@ -158,7 +189,7 @@ static ssize_t brightness_show(struct de
+ struct i2c_client *client = to_i2c_client(dev);
+ int ret;
+
......@@ -324,7 +312,7 @@ index 0000000000..ef78942b4f
+
+ if (ret < 0)
+ return ret;
+@@ -179,8 +210,7 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
+@@ -179,8 +210,7 @@ static ssize_t brightness_store(struct d
+ if (brightness > 100)
+ return -EINVAL;
+
......@@ -334,7 +322,7 @@ index 0000000000..ef78942b4f
+
+ return ret < 0 ? ret : count;
+ }
+@@ -238,8 +268,8 @@ static int omnia_leds_remove(struct i2c_client *client)
+@@ -238,8 +268,8 @@ static int omnia_leds_remove(struct i2c_
+ u8 buf[5];
+
+ /* put all LEDs into default (HW triggered) mode */
......@@ -345,20 +333,16 @@ index 0000000000..ef78942b4f
+
+ /* set all LEDs color to [255, 255, 255] */
+ buf[0] = CMD_LED_COLOR;
+--
+2.41.0
+
diff --git a/target/linux/mvebu/patches-5.15/102-v6.7-2-leds-turris-omnia-Make-set_brightness-more-efficient.patch b/target/linux/mvebu/patches-5.15/102-v6.7-2-leds-turris-omnia-Make-set_brightness-more-efficient.patch
diff --git a/target/linux/generic/backport-5.15/830-v6.7-2-leds-turris-omnia-Make-set_brightness-more-efficient.patch b/target/linux/generic/backport-5.15/830-v6.7-2-leds-turris-omnia-Make-set_brightness-more-efficient.patch
new file mode 100644
index 0000000000..0af72a91e6
index 0000000000..3f7dd64841
--- /dev/null
+++ b/target/linux/mvebu/patches-5.15/102-v6.7-2-leds-turris-omnia-Make-set_brightness-more-efficient.patch
@@ -0,0 +1,222 @@
+From edfbaa8ac2376f4f2bebc0e981833d83fb4ad7cb Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <kabel@kernel.org>
+++ b/target/linux/generic/backport-5.15/830-v6.7-2-leds-turris-omnia-Make-set_brightness-more-efficient.patch
@@ -0,0 +1,207 @@
+From 4d5ed2621c2437d40b8fe92bd0fd34b0b1870753 Mon Sep 17 00:00:00 2001
+From: Marek Behún <kabel@kernel.org>
+Date: Mon, 18 Sep 2023 18:11:02 +0200
+Subject: [PATCH 05/17] leds: turris-omnia: Make set_brightness() more
+ efficient
+Subject: leds: turris-omnia: Make set_brightness() more efficient
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
......@@ -414,11 +398,9 @@ index 0000000000..0af72a91e6
+Link: https://lore.kernel.org/r/20230918161104.20860-3-kabel@kernel.org
+Signed-off-by: Lee Jones <lee@kernel.org>
+---
+ drivers/leds/leds-turris-omnia.c | 100 +++++++++++++++++++++++++------
+ 1 file changed, 82 insertions(+), 18 deletions(-)
+ drivers/leds/leds-turris-omnia.c | 96 ++++++++++++++++++++++++++++++++--------
+ 1 file changed, 78 insertions(+), 18 deletions(-)
+
+diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c
+index a1e8553c3254..a44df9ab14c4 100644
+--- a/drivers/leds/leds-turris-omnia.c
++++ b/drivers/leds/leds-turris-omnia.c
+@@ -30,6 +30,8 @@
......@@ -430,7 +412,7 @@ index 0000000000..0af72a91e6
+ int reg;
+ };
+
+@@ -72,36 +74,85 @@ static int omnia_cmd_read_u8(const struct i2c_client *client, u8 cmd)
+@@ -72,36 +74,82 @@ static int omnia_cmd_read_u8(const struc
+ return -EIO;
+ }
+
......@@ -439,7 +421,6 @@ index 0000000000..0af72a91e6
++{
++ char cmd[5];
++ int ret;
++ int i;
++
++ cmd[0] = CMD_LED_COLOR;
++ cmd[1] = led->reg;
......@@ -453,7 +434,7 @@ index 0000000000..0af72a91e6
++ return ret;
++
++ /* Cache the RGB channel brightnesses */
++ for (i = 0; i < OMNIA_LED_NUM_CHANNELS; ++i)
++ for (int i = 0; i < OMNIA_LED_NUM_CHANNELS; ++i)
++ led->cached_channels[i] = led->subled_info[i].brightness;
++
++ return 0;
......@@ -462,9 +443,7 @@ index 0000000000..0af72a91e6
++/* Determine if the computed RGB channels are different from the cached ones */
++static bool omnia_led_channels_changed(struct omnia_led *led)
++{
++ int i;
++
++ for (i = 0; i < OMNIA_LED_NUM_CHANNELS; ++i)
++ for (int i = 0; i < OMNIA_LED_NUM_CHANNELS; ++i)
++ if (led->subled_info[i].brightness != led->cached_channels[i])
++ return true;
++
......@@ -506,19 +485,21 @@ index 0000000000..0af72a91e6
+- buf[2] = mc_cdev->subled_info[0].brightness;
+- buf[3] = mc_cdev->subled_info[1].brightness;
+- buf[4] = mc_cdev->subled_info[2].brightness;
++ /* Send on/off state change only if (bool)brightness changed */
++ if (!err && !brightness != !led->on) {
++ u8 state = CMD_LED_STATE_LED(led->reg);
+
+-
+- state = CMD_LED_STATE_LED(led->reg);
+- if (buf[2] || buf[3] || buf[4])
+- state |= CMD_LED_STATE_ON;
++ if (brightness)
++ state |= CMD_LED_STATE_ON;
+
+-
+- ret = omnia_cmd_write_u8(leds->client, CMD_LED_STATE, state);
+- if (ret >= 0 && (state & CMD_LED_STATE_ON))
+- ret = i2c_master_send(leds->client, buf, 5);
++ /* Send on/off state change only if (bool)brightness changed */
++ if (!err && !brightness != !led->on) {
++ u8 state = CMD_LED_STATE_LED(led->reg);
++
++ if (brightness)
++ state |= CMD_LED_STATE_ON;
++
++ err = omnia_cmd_write_u8(leds->client, CMD_LED_STATE, state);
++ if (!err)
++ led->on = !!brightness;
......@@ -531,15 +512,7 @@ index 0000000000..0af72a91e6
+ }
+
+ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
+@@ -111,6 +162,7 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
+ struct device *dev = &client->dev;
+ struct led_classdev *cdev;
+ int ret, color;
++ int i;
+
+ ret = of_property_read_u32(np, "reg", &led->reg);
+ if (ret || led->reg >= OMNIA_BOARD_LEDS) {
+@@ -129,11 +181,15 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
+@@ -129,11 +177,15 @@ static int omnia_led_register(struct i2c
+ }
+
+ led->subled_info[0].color_index = LED_COLOR_ID_RED;
......@@ -550,7 +523,7 @@ index 0000000000..0af72a91e6
+- led->subled_info[2].channel = 2;
++
++ /* Initial color is white */
++ for (i = 0; i < OMNIA_LED_NUM_CHANNELS; ++i) {
++ for (int i = 0; i < OMNIA_LED_NUM_CHANNELS; ++i) {
++ led->subled_info[i].intensity = 255;
++ led->subled_info[i].brightness = 255;
++ led->subled_info[i].channel = i;
......@@ -558,7 +531,7 @@ index 0000000000..0af72a91e6
+
+ led->mc_cdev.subled_info = led->subled_info;
+ led->mc_cdev.num_colors = OMNIA_LED_NUM_CHANNELS;
+@@ -162,6 +218,14 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
+@@ -162,6 +214,14 @@ static int omnia_led_register(struct i2c
+ return ret;
+ }
+
......@@ -573,20 +546,16 @@ index 0000000000..0af72a91e6
+ ret = devm_led_classdev_multicolor_register_ext(dev, &led->mc_cdev,
+ &init_data);
+ if (ret < 0) {
+--
+2.41.0
+
diff --git a/target/linux/mvebu/patches-5.15/102-v6.7-3-leds-turris-omnia-Support-HW-controlled-mode-via-pri.patch b/target/linux/mvebu/patches-5.15/102-v6.7-3-leds-turris-omnia-Support-HW-controlled-mode-via-pri.patch
diff --git a/target/linux/generic/backport-5.15/830-v6.7-3-leds-turris-omnia-Support-HW-controlled-mode-via-pri.patch b/target/linux/generic/backport-5.15/830-v6.7-3-leds-turris-omnia-Support-HW-controlled-mode-via-pri.patch
new file mode 100644
index 0000000000..c53b309bb4
index 0000000000..dd2b310d66
--- /dev/null
+++ b/target/linux/mvebu/patches-5.15/102-v6.7-3-leds-turris-omnia-Support-HW-controlled-mode-via-pri.patch
@@ -0,0 +1,209 @@
+From 885141a3382b5f82ea4b6e9fc11aea2c71e2a593 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <kabel@kernel.org>
+++ b/target/linux/generic/backport-5.15/830-v6.7-3-leds-turris-omnia-Support-HW-controlled-mode-via-pri.patch
@@ -0,0 +1,201 @@
+From aaf38273cf766d88296f4aa3f2e4e3c0d399a4a2 Mon Sep 17 00:00:00 2001
+From: Marek Behún <kabel@kernel.org>
+Date: Mon, 18 Sep 2023 18:11:03 +0200
+Subject: [PATCH 06/17] leds: turris-omnia: Support HW controlled mode via
+ private trigger
+Subject: leds: turris-omnia: Support HW controlled mode via private trigger
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
......@@ -628,11 +597,9 @@ index 0000000000..c53b309bb4
+Signed-off-by: Lee Jones <lee@kernel.org>
+---
+ drivers/leds/Kconfig | 1 +
+ drivers/leds/leds-turris-omnia.c | 98 +++++++++++++++++++++++++++++---
+ drivers/leds/leds-turris-omnia.c | 98 ++++++++++++++++++++++++++++++++++++----
+ 2 files changed, 91 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
+index 8bf545100fb0..0d5538402447 100644
+--- a/drivers/leds/Kconfig
++++ b/drivers/leds/Kconfig
+@@ -163,6 +163,7 @@ config LEDS_TURRIS_OMNIA
......@@ -643,8 +610,6 @@ index 0000000000..c53b309bb4
+ 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 a44df9ab14c4..9a01025ce793 100644
+--- a/drivers/leds/leds-turris-omnia.c
++++ b/drivers/leds/leds-turris-omnia.c
+@@ -31,7 +31,7 @@ struct omnia_led {
......@@ -656,7 +621,7 @@ index 0000000000..c53b309bb4
+ int reg;
+ };
+
+@@ -123,12 +123,14 @@ static int omnia_led_brightness_set_blocking(struct led_classdev *cdev,
+@@ -120,12 +120,14 @@ static int omnia_led_brightness_set_bloc
+
+ /*
+ * Only recalculate RGB brightnesses from intensities if brightness is
......@@ -676,7 +641,7 @@ index 0000000000..c53b309bb4
+
+ /*
+ * Send color command only if brightness is non-zero and the RGB
+@@ -138,8 +140,11 @@ static int omnia_led_brightness_set_blocking(struct led_classdev *cdev,
+@@ -135,8 +137,11 @@ static int omnia_led_brightness_set_bloc
+ err = omnia_led_send_color_cmd(leds->client, led);
+ }
+
......@@ -690,7 +655,7 @@ index 0000000000..c53b309bb4
+ u8 state = CMD_LED_STATE_LED(led->reg);
+
+ if (brightness)
+@@ -155,6 +160,71 @@ static int omnia_led_brightness_set_blocking(struct led_classdev *cdev,
+@@ -152,6 +157,71 @@ static int omnia_led_brightness_set_bloc
+ return err;
+ }
+
......@@ -762,7 +727,7 @@ index 0000000000..c53b309bb4
+ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
+ struct device_node *np)
+ {
+@@ -199,6 +269,12 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
+@@ -195,6 +265,12 @@ static int omnia_led_register(struct i2c
+ cdev = &led->mc_cdev.led_cdev;
+ cdev->max_brightness = 255;
+ cdev->brightness_set_blocking = omnia_led_brightness_set_blocking;
......@@ -775,7 +740,7 @@ index 0000000000..c53b309bb4
+
+ /* put the LED into software mode */
+ ret = omnia_cmd_write_u8(client, CMD_LED_MODE,
+@@ -313,6 +389,12 @@ static int omnia_leds_probe(struct i2c_client *client,
+@@ -309,6 +385,12 @@ static int omnia_leds_probe(struct i2c_c
+
+ mutex_init(&leds->lock);
+
......@@ -788,15 +753,12 @@ index 0000000000..c53b309bb4
+ led = &leds->leds[0];
+ for_each_available_child_of_node(np, child) {
+ ret = omnia_led_register(client, led, child);
+--
+2.41.0
+
diff --git a/target/linux/mvebu/patches-5.15/102-v6.7-4-leds-turris-omnia-Add-support-for-enabling-disabling.patch b/target/linux/mvebu/patches-5.15/102-v6.7-4-leds-turris-omnia-Add-support-for-enabling-disabling.patch
diff --git a/target/linux/generic/backport-5.15/830-v6.7-4-leds-turris-omnia-Add-support-for-enabling-disabling.patch b/target/linux/generic/backport-5.15/830-v6.7-4-leds-turris-omnia-Add-support-for-enabling-disabling.patch
new file mode 100644
index 0000000000..8450c27ce0
index 0000000000..3bda4a9cef
--- /dev/null
+++ b/target/linux/mvebu/patches-5.15/102-v6.7-4-leds-turris-omnia-Add-support-for-enabling-disabling.patch
@@ -0,0 +1,249 @@
+++ b/target/linux/generic/backport-5.15/830-v6.7-4-leds-turris-omnia-Add-support-for-enabling-disabling.patch
@@ -0,0 +1,244 @@
+From 00125699bb35ef58fffa8425e32a44a7af82cd28 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <kabel@kernel.org>
+Date: Mon, 18 Sep 2023 18:11:04 +0200
......@@ -821,11 +783,9 @@ index 0000000000..8450c27ce0
+ drivers/leds/leds-turris-omnia.c | 137 +++++++++++++++---
+ 2 files changed, 134 insertions(+), 17 deletions(-)
+
+diff --git a/Documentation/ABI/testing/sysfs-class-led-driver-turris-omnia b/Documentation/ABI/testing/sysfs-class-led-driver-turris-omnia
+index c4d46970c1cf..369b4ae8be5f 100644
+--- a/Documentation/ABI/testing/sysfs-class-led-driver-turris-omnia
++++ b/Documentation/ABI/testing/sysfs-class-led-driver-turris-omnia
+@@ -12,3 +12,17 @@ Description: (RW) On the front panel of the Turris Omnia router there is also
+@@ -12,3 +12,17 @@ Description: (RW) On the front panel of
+ able to change this setting from software.
+
+ Format: %i
......@@ -843,8 +803,6 @@ index 0000000000..8450c27ce0
++ in the EOPNOTSUPP error.
++
++ Format: %i
+diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c
+index 9a01025ce793..728efcaca162 100644
+--- a/drivers/leds/leds-turris-omnia.c
++++ b/drivers/leds/leds-turris-omnia.c
+@@ -15,17 +15,30 @@
......@@ -854,18 +812,20 @@ index 0000000000..8450c27ce0
+-#define CMD_LED_MODE 3
+-#define CMD_LED_MODE_LED(l) ((l) & 0x0f)
+-#define CMD_LED_MODE_USER 0x10
++/* MCU controller commands at I2C address 0x2a */
++#define OMNIA_MCU_I2C_ADDR 0x2a
+
+-
+-#define CMD_LED_STATE 4
+-#define CMD_LED_STATE_LED(l) ((l) & 0x0f)
+-#define CMD_LED_STATE_ON 0x10
++#define CMD_GET_STATUS_WORD 0x01
++#define STS_FEATURES_SUPPORTED BIT(2)
+
+-
+-#define CMD_LED_COLOR 5
+-#define CMD_LED_SET_BRIGHTNESS 7
+-#define CMD_LED_GET_BRIGHTNESS 8
++/* 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)
++
......@@ -895,7 +855,7 @@ index 0000000000..8450c27ce0
+ struct omnia_led leds[];
+ };
+
+@@ -50,30 +64,42 @@ static int omnia_cmd_write_u8(const struct i2c_client *client, u8 cmd, u8 val)
+@@ -50,30 +64,42 @@ static int omnia_cmd_write_u8(const stru
+ return i2c_master_send(client, buf, sizeof(buf));
+ }
+
......@@ -946,7 +906,7 @@ index 0000000000..8450c27ce0
+ static int omnia_led_send_color_cmd(const struct i2c_client *client,
+ struct omnia_led *led)
+ {
+@@ -356,12 +382,74 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
+@@ -352,12 +378,74 @@ static ssize_t brightness_store(struct d
+ }
+ static DEVICE_ATTR_RW(brightness);
+
......@@ -1021,7 +981,7 @@ index 0000000000..8450c27ce0
+ static int omnia_leds_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+ {
+@@ -387,6 +475,21 @@ static int omnia_leds_probe(struct i2c_client *client,
+@@ -383,6 +471,21 @@ static int omnia_leds_probe(struct i2c_c
+ leds->client = client;
+ i2c_set_clientdata(client, leds);
+
......@@ -1043,15 +1003,12 @@ index 0000000000..8450c27ce0
+ mutex_init(&leds->lock);
+
+ ret = devm_led_trigger_register(dev, &omnia_hw_trigger);
+--
+2.41.0
+
diff --git a/target/linux/mvebu/patches-5.15/102-v6.7-5-leds-turris-omnia-Fix-brightness-setting-and-trigger.patch b/target/linux/mvebu/patches-5.15/102-v6.7-5-leds-turris-omnia-Fix-brightness-setting-and-trigger.patch
diff --git a/target/linux/generic/backport-5.15/830-v6.7-5-leds-turris-omnia-Fix-brightness-setting-and-trigger.patch b/target/linux/generic/backport-5.15/830-v6.7-5-leds-turris-omnia-Fix-brightness-setting-and-trigger.patch
new file mode 100644
index 0000000000..0e9cdb6295
index 0000000000..ec6171ec67
--- /dev/null
+++ b/target/linux/mvebu/patches-5.15/102-v6.7-5-leds-turris-omnia-Fix-brightness-setting-and-trigger.patch
@@ -0,0 +1,172 @@
+++ b/target/linux/generic/backport-5.15/830-v6.7-5-leds-turris-omnia-Fix-brightness-setting-and-trigger.patch
@@ -0,0 +1,167 @@
+From 33f339b70f020273ea40fb3c5d7b65697446bd6c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Marek=20Beh=C3=BAn?= <kabel@kernel.org>
+Date: Mon, 16 Oct 2023 15:28:06 +0200
......@@ -1092,8 +1049,6 @@ index 0000000000..0e9cdb6295
+ drivers/leds/leds-turris-omnia.c | 37 +++++++++++++++++---------------
+ 1 file changed, 20 insertions(+), 17 deletions(-)
+
+diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c
+index 728efcaca162..9cd49833c6b2 100644
+--- a/drivers/leds/leds-turris-omnia.c
++++ b/drivers/leds/leds-turris-omnia.c
+@@ -60,8 +60,11 @@ struct omnia_leds {
......@@ -1109,7 +1064,7 @@ index 0000000000..0e9cdb6295
+ }
+
+ static int omnia_cmd_read_raw(struct i2c_adapter *adapter, u8 addr, u8 cmd,
+@@ -81,7 +84,7 @@ static int omnia_cmd_read_raw(struct i2c_adapter *adapter, u8 addr, u8 cmd,
+@@ -81,7 +84,7 @@ static int omnia_cmd_read_raw(struct i2c
+
+ ret = i2c_transfer(adapter, msgs, ARRAY_SIZE(msgs));
+ if (likely(ret == ARRAY_SIZE(msgs)))
......@@ -1118,7 +1073,7 @@ index 0000000000..0e9cdb6295
+ else if (ret < 0)
+ return ret;
+ else
+@@ -91,11 +94,11 @@ static int omnia_cmd_read_raw(struct i2c_adapter *adapter, u8 addr, u8 cmd,
+@@ -91,11 +94,11 @@ static int omnia_cmd_read_raw(struct i2c
+ static int omnia_cmd_read_u8(const struct i2c_client *client, u8 cmd)
+ {
+ u8 reply;
......@@ -1134,7 +1089,7 @@ index 0000000000..0e9cdb6295
+
+ return reply;
+ }
+@@ -239,7 +242,7 @@ static void omnia_hwtrig_deactivate(struct led_classdev *cdev)
+@@ -236,7 +239,7 @@ static void omnia_hwtrig_deactivate(stru
+
+ mutex_unlock(&leds->lock);
+
......@@ -1143,7 +1098,7 @@ index 0000000000..0e9cdb6295
+ dev_err(cdev->dev, "Cannot put LED to software mode: %i\n",
+ err);
+ }
+@@ -306,7 +309,7 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
+@@ -302,7 +305,7 @@ static int omnia_led_register(struct i2c
+ ret = omnia_cmd_write_u8(client, CMD_LED_MODE,
+ CMD_LED_MODE_LED(led->reg) |
+ CMD_LED_MODE_USER);
......@@ -1152,7 +1107,7 @@ index 0000000000..0e9cdb6295
+ dev_err(dev, "Cannot set LED %pOF to software mode: %i\n", np,
+ ret);
+ return ret;
+@@ -315,7 +318,7 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
+@@ -311,7 +314,7 @@ static int omnia_led_register(struct i2c
+ /* disable the LED */
+ ret = omnia_cmd_write_u8(client, CMD_LED_STATE,
+ CMD_LED_STATE_LED(led->reg));
......@@ -1161,7 +1116,7 @@ index 0000000000..0e9cdb6295
+ dev_err(dev, "Cannot set LED %pOF brightness: %i\n", np, ret);
+ return ret;
+ }
+@@ -368,7 +371,7 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
+@@ -364,7 +367,7 @@ static ssize_t brightness_store(struct d
+ {
+ struct i2c_client *client = to_i2c_client(dev);
+ unsigned long brightness;
......@@ -1170,7 +1125,7 @@ index 0000000000..0e9cdb6295
+
+ if (kstrtoul(buf, 10, &brightness))
+ return -EINVAL;
+@@ -376,9 +379,9 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *a,
+@@ -372,9 +375,9 @@ static ssize_t brightness_store(struct d
+ if (brightness > 100)
+ return -EINVAL;
+
......@@ -1182,7 +1137,7 @@ index 0000000000..0e9cdb6295
+ }
+ static DEVICE_ATTR_RW(brightness);
+
+@@ -407,7 +410,7 @@ static ssize_t gamma_correction_store(struct device *dev,
+@@ -403,7 +406,7 @@ static ssize_t gamma_correction_store(st
+ struct i2c_client *client = to_i2c_client(dev);
+ struct omnia_leds *leds = i2c_get_clientdata(client);
+ bool val;
......@@ -1191,7 +1146,7 @@ index 0000000000..0e9cdb6295
+
+ if (!leds->has_gamma_correction)
+ return -EOPNOTSUPP;
+@@ -415,9 +418,9 @@ static ssize_t gamma_correction_store(struct device *dev,
+@@ -411,9 +414,9 @@ static ssize_t gamma_correction_store(st
+ if (kstrtobool(buf, &val) < 0)
+ return -EINVAL;
+
......@@ -1203,7 +1158,7 @@ index 0000000000..0e9cdb6295
+ }
+ static DEVICE_ATTR_RW(gamma_correction);
+
+@@ -435,7 +438,7 @@ static int omnia_mcu_get_features(const struct i2c_client *client)
+@@ -431,7 +434,7 @@ static int omnia_mcu_get_features(const
+
+ err = omnia_cmd_read_raw(client->adapter, OMNIA_MCU_I2C_ADDR,
+ CMD_GET_STATUS_WORD, &reply, sizeof(reply));
......@@ -1212,7 +1167,7 @@ index 0000000000..0e9cdb6295
+ return err;
+
+ /* Check whether MCU firmware supports the CMD_GET_FEAUTRES command */
+@@ -444,7 +447,7 @@ static int omnia_mcu_get_features(const struct i2c_client *client)
+@@ -440,7 +443,7 @@ static int omnia_mcu_get_features(const
+
+ err = omnia_cmd_read_raw(client->adapter, OMNIA_MCU_I2C_ADDR,
+ CMD_GET_FEATURES, &reply, sizeof(reply));
......@@ -1221,9 +1176,6 @@ index 0000000000..0e9cdb6295
+ return err;
+
+ return le16_to_cpu(reply);
+--
+2.41.0
+
--
2.41.0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment