Skip to contentSkip to conversation

leds: turris-omnia: updates

PATCH In review Marek Behún 3 participants 6 messages Jul 4, 2022 – Mar 4, 2023

Subsystems (2)
lore
Share & tools
lore

Marek Behún

author maintainer
#0 lore raw

cover leds: turris-omnia: updates

Hello Pavel,

the upstream leds-turris-omnia driver is disabled in upstream Omnia device-tree and isn't used by TurrisOS because it does not support enabling HW control. This is because I wanted to implement it via netdev trigger transparent offloading, but I still wasn't able to implement this satisfactorily (and truthfully haven't had much time to look into this for almost half a year now).

Let's implement this in the meantime via the private trigger mechanism that we added two years ago.

In the future if netdev offloading gets implemented, we can still keep this implementation if backwards compatibility is desired, or we can just drop it.

Marek

Marek Behún (3):
leds: turris-omnia: support HW controlled mode via private trigger
leds: turris-omnia: initialize multi-intensity to full
leds: turris-omnia: change max brightness from 255 to 1

 drivers/leds/Kconfig             |  1 +
 drivers/leds/leds-turris-omnia.c | 46 +++++++++++++++++++++++++++++++-
 2 files changed, 46 insertions(+), 1 deletion(-)
Signature · 1 line
2.35.1
author maintainer
#1 lore raw

PATCH 1/3 leds: turris-omnia: support HW controlled mode via private trigger

Add support for enabling MCU controlled mode of the Turris Omnia LEDs via a LED private trigger called "omnia-mcu".

When in MCU controlled mode, the user can still set LED color, but the blinking is done by MCU, which does different things for various LEDs:
- WAN LED is blinked according to the LED[0] pin of the WAN PHY
- LAN LEDs are blinked according to the LED[0] output of corresponding port of the LAN switch
- PCIe LEDs are blinked according to the logical OR of the MiniPCIe port LED pins

For a long time I wanted to actually do this differently: I wanted to make the netdev trigger to transparently offload the blinking to the HW if user set compatible settings for the netdev trigger. There was some work on this, and hopefully we will be able to complete it sometime, but since there are various complications, it will probably not be soon.

In the meantime let's support HW controlled mode via this private LED trigger. If, in the future, we manage to complete the netdev trigger offloading, we can still keep this private trigger for backwards compatiblity, if needed.

We also set "omnia-mcu" to cdev->default_trigger, so that the MCU keeps control until the user first wants to take over it. If a different default trigger is specified in device-tree via the linux,default-trigger property, LED class will overwrite cdev->default_trigger, and so the DT property will be respected.

---
 drivers/leds/Kconfig             |  1 +
 drivers/leds/leds-turris-omnia.c | 41 ++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)
drivers/leds/Kconfig +1 -0
index a49979f41eee..bc148320416d 100644
@@ -163,6 +163,7 @@ config LEDS_TURRIS_OMNIA
 	depends on I2C
 	depends on MACH_ARMADA_38X || COMPILE_TEST
 	depends on OF
+	select LEDS_TRIGGERS
 	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
drivers/leds/leds-turris-omnia.c +41 -0

59 lines not on this page · raw message

Signature · 1 line
2.35.1
author maintainer
#2 lore raw

PATCH 2/3 leds: turris-omnia: initialize multi-intensity to full

In reply to Marek Behún

The default color of each LED before driver probe (255, 255, 255). Initialize multi_intensity to this value, so that it corresponds to the reality.

---
 drivers/leds/leds-turris-omnia.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/leds/leds-turris-omnia.c +3 -0
index c2dfb22d3065..fae155bd119c 100644
@@ -131,10 +131,13 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
 	}
 
 	led->subled_info[0].color_index = LED_COLOR_ID_RED;
+	led->subled_info[0].intensity = 255;
 	led->subled_info[0].channel = 0;
 	led->subled_info[1].color_index = LED_COLOR_ID_GREEN;
+	led->subled_info[1].intensity = 255;
 	led->subled_info[1].channel = 1;
 	led->subled_info[2].color_index = LED_COLOR_ID_BLUE;
+	led->subled_info[2].intensity = 255;
 	led->subled_info[2].channel = 2;
 
 	led->mc_cdev.subled_info = led->subled_info;
Signature · 1 line
2.35.1
author maintainer
#3 lore raw

PATCH 3/3 leds: turris-omnia: change max brightness from 255 to 1

In reply to Marek Behún

Using binary brightness makes more sense for this controller, because internally in the MCU it works that way: the LED has a color, and a state whether it is ON or OFF.

The resulting brightness computation with led_mc_calc_color_components() will now always result in either (0, 0, 0) or the multi_intensity value.

---
 drivers/leds/leds-turris-omnia.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/leds-turris-omnia.c +1 -1
index fae155bd119c..f53bdc3f4cea 100644
@@ -146,7 +146,7 @@ static int omnia_led_register(struct i2c_client *client, struct omnia_led *led,
 	init_data.fwnode = &np->fwnode;
 
 	cdev = &led->mc_cdev.led_cdev;
-	cdev->max_brightness = 255;
+	cdev->max_brightness = 1;
 	cdev->brightness_set_blocking = omnia_led_brightness_set_blocking;
 	cdev->trigger_type = &omnia_hw_trigger_type;
 	cdev->default_trigger = omnia_hw_trigger.name;
Signature · 1 line
2.35.1
#4 lore raw
In reply to Marek Behún

Ping? Gentle reminder.

Quoted 30 lines · On Monday 04 July 2022 12:59:52 Marek Behún wrote:

Hello Pavel,

the upstream leds-turris-omnia driver is disabled in upstream Omnia device-tree and isn't used by TurrisOS because it does not support enabling HW control. This is because I wanted to implement it via netdev trigger transparent offloading, but I still wasn't able to implement this satisfactorily (and truthfully haven't had much time to look into this for almost half a year now).

Let's implement this in the meantime via the private trigger mechanism that we added two years ago.

In the future if netdev offloading gets implemented, we can still keep this implementation if backwards compatibility is desired, or we can just drop it.

Marek

Marek Behún (3):
leds: turris-omnia: support HW controlled mode via private trigger
leds: turris-omnia: initialize multi-intensity to full
leds: turris-omnia: change max brightness from 255 to 1

 drivers/leds/Kconfig             |  1 +
 drivers/leds/leds-turris-omnia.c | 46 +++++++++++++++++++++++++++++++-
 2 files changed, 46 insertions(+), 1 deletion(-)
Signature · 1 line
2.35.1
#5 lore raw

A kind reminder here.

Quoted 33 lines · Pali Rohár

Ping? Gentle reminder.

Quoted 30 lines · On Monday 04 July 2022 12:59:52 Marek Behún wrote:

Hello Pavel,

the upstream leds-turris-omnia driver is disabled in upstream Omnia device-tree and isn't used by TurrisOS because it does not support enabling HW control. This is because I wanted to implement it via netdev trigger transparent offloading, but I still wasn't able to implement this satisfactorily (and truthfully haven't had much time to look into this for almost half a year now).

Let's implement this in the meantime via the private trigger mechanism that we added two years ago.

In the future if netdev offloading gets implemented, we can still keep this implementation if backwards compatibility is desired, or we can just drop it.

Marek

Marek Behún (3):
leds: turris-omnia: support HW controlled mode via private trigger
leds: turris-omnia: initialize multi-intensity to full
leds: turris-omnia: change max brightness from 255 to 1

  drivers/leds/Kconfig             |  1 +
  drivers/leds/leds-turris-omnia.c | 46 +++++++++++++++++++++++++++++++-
  2 files changed, 46 insertions(+), 1 deletion(-)
Signature · 1 line
2.35.1