Skip to contentSkip to conversation

leds: initial support for Turris Omnia LEDs

RFC PATCH In review Marek Behún 4 participants 29 messages Mar 19, 2020 – Apr 6, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 leds: initial support for Turris Omnia LEDs

This adds basic support for LEDs on the front side of CZ.NIC's Turris Omnia router.

There are 12 RGB LEDs. The controller supports HW triggering mode for the LEDs, but this driver does not support it yet, and sets all the LEDs into SW mode upon probe.

The user can either group all three channels of one RGB LED into one LED classdev, or expose each channel as an individual LED classdev. This is done by utilizing the 'led-sources' and 'color' DT properties.

In the following example the first RGB LED is exposed as one LED classdev with color WHITE, and the second RGB LED is exposed as three classdevs, one per each channel:

	led@0 {
		reg = <0>;
		led-sources = <0 1 2>;
		color = <LED_COLOR_ID_WHITE>;
	};

	led@1,0 {
		reg = <1>;
		led-sources = <3>;
		color = <LED_COLOR_ID_RED>;
	};

	led@1,1 {
		reg = <1>;
		led-sources = <4>;
		color = <LED_COLOR_ID_GREEN>;
	};

	led@1,2 {
		reg = <1>;
		led-sources = <5>;
		color = <LED_COLOR_ID_BLUE>;
	};

I am not comfortable with the 'reg' property being same for multiple nodes. Perhaps the 'reg' property shouldn't be used, since the information needed by the driver can be deduced from the 'led-sources'.

---
 drivers/leds/Kconfig             |  14 ++
 drivers/leds/Makefile            |   1 +
 drivers/leds/leds-turris-omnia.c | 295 +++++++++++++++++++++++++++++++
 3 files changed, 310 insertions(+)
 create mode 100644 drivers/leds/leds-turris-omnia.c
drivers/leds/Kconfig +14 -0
index d82f1dea3711..c33159370bcb 100644
@@ -145,6 +145,20 @@ config LEDS_EL15203000
 	  To compile this driver as a module, choose M here: the module
 	  will be called leds-el15203000.
 
+config LEDS_TURRIS_OMNIA
+	tristate "LED support for CZ.NIC's Turris Omnia"
+	depends on LEDS_CLASS
+	depends on I2C
+	depends on MACH_ARMADA_38X || COMPILE_TEST
+	depends on OF
+	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
+	  front panel.
+	  This driver does not currently support setting LED colors, only
+	  brightness. Also HW triggering is disabled when the controller is
+	  probed by this driver.
+
 config LEDS_LM3530
 	tristate "LCD Backlight driver for LM3530"
 	depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
index d7e1107753fb..95feaf4bea81 100644
@@ -86,6 +86,7 @@ obj-$(CONFIG_LEDS_TI_LMU_COMMON)	+= leds-ti-lmu-common.o
 obj-$(CONFIG_LEDS_LM3697)		+= leds-lm3697.o
 obj-$(CONFIG_LEDS_LM36274)		+= leds-lm36274.o
 obj-$(CONFIG_LEDS_TPS6105X)		+= leds-tps6105x.o
+obj-$(CONFIG_LEDS_TURRIS_OMNIA)		+= leds-turris-omnia.o
 
 # LED SPI Drivers
 obj-$(CONFIG_LEDS_CR0014114)		+= leds-cr0014114.o
drivers/leds/leds-turris-omnia.c new file +295 -0

295 lines not on this page · raw message

Signature · 1 line
2.24.1
#1 lore raw

Hi!

Quoted 2 lines

This adds basic support for LEDs on the front side of CZ.NIC's Turris Omnia router.

Looks good, I had to apply it by hand, by I took it. I realize that dts interface may not be final, but I do not want to solve Makefile rejects in future.

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#2 lore raw

Hi Pavel.

Quoted 8 lines · Pavel Machek

Hi!

Quoted 2 lines

This adds basic support for LEDs on the front side of CZ.NIC's Turris Omnia router.

Looks good, I had to apply it by hand, by I took it. I realize that dts interface may not be final, but I do not want to solve Makefile rejects in future.

I don't think it is a good idea to merge it without bindings, and with DT parser that will certainly undergo essential changes.

Besides, you appear as the commit author in your tree and moreover the patch has a broken title. Also the commit message contains DT bindings that will have different shape eventually.

NACK for merging this patch in this shape.

Signature · 2 lines
Best regards,
Jacek Anaszewski
#3 lore raw
Quoted 12 lines · On Sat, 28 Mar 2020 13:08:02 +0100 Jacek Anaszewski…

Hi Pavel.

Quoted 8 lines · Pavel Machek

Hi!

Quoted 2 lines

This adds basic support for LEDs on the front side of CZ.NIC's Turris Omnia router.

Looks good, I had to apply it by hand, by I took it. I realize that dts interface may not be final, but I do not want to solve Makefile rejects in future.

Quoted 9 lines

I don't think it is a good idea to merge it without bindings, and with DT parser that will certainly undergo essential changes.

Besides, you appear as the commit author in your tree and moreover the patch has a broken title. Also the commit message contains DT bindings that will have different shape eventually.

NACK for merging this patch in this shape.

This was only RFC, please do not merge.

#4 lore raw
Quoted 1 line

This was only RFC, please do not merge.

Jacek, Pavel,

I decided to abandon the microcontroller driver path. But nonetheless there is still one thing I would like to solve.

The front button on Omnia is used to control the global brightness of the RGB LEDs, so that user can change it if the LEDs glow too much. The microcontroller does this as such: there is another PWM on top of all the LED PWMs, and this value can be manipulated via the same i2c interface as the LEDs, but via another command.

The thing is that I would like to somehow export this global brightness setting to userspace, because otherwise it gets reset after reboot, and I want the user to be able to set this global brightness by software, so that they won't have to change it after every reboot manually by pressing the front button.

I am wondering how to do this. Last year I proposed this by adding a sysfs attribute file to the device which is parent to the LEDs, but you did not agree :(

Marek

#5 lore raw

Hi Marek,

Quoted 19 lines · Marek Behun
Quoted 1 line

This was only RFC, please do not merge.

Jacek, Pavel,

I decided to abandon the microcontroller driver path. But nonetheless there is still one thing I would like to solve.

The front button on Omnia is used to control the global brightness of the RGB LEDs, so that user can change it if the LEDs glow too much. The microcontroller does this as such: there is another PWM on top of all the LED PWMs, and this value can be manipulated via the same i2c interface as the LEDs, but via another command.

The thing is that I would like to somehow export this global brightness setting to userspace, because otherwise it gets reset after reboot, and I want the user to be able to set this global brightness by software, so that they won't have to change it after every reboot manually by pressing the front button.

Quoted 3 lines

I am wondering how to do this. Last year I proposed this by adding a sysfs attribute file to the device which is parent to the LEDs, but you did not agree :(

I already proposed adding a "luma" LED class device for similar case [0], but didn't here any feedback from Pavel so far.

[0]
https://lore.kernel.org/linux-leds/[email protected]/T/#mf52c8d4f68260a445223c26957c61e6267e0932d

Signature · 2 lines
Best regards,
Jacek Anaszewski
#6 lore raw
Quoted 6 lines · On Sat, 28 Mar 2020 14:01:47 +0100 Jacek Anaszewski…

I already proposed adding a "luma" LED class device for similar case [0], but didn't here any feedback from Pavel so far.

[0]
https://lore.kernel.org/linux-leds/[email protected]/T/#mf52c8d4f68260a445223c26957c61e6267e0932d

Hi Jacek,

in the case you mentioned there is a one "global" brightness setting per each RGB LED. On Omnia, all 12 RGB LEDs have just one "global" brightness property. Ie. I press the button, and all 12 LEDs glow get dimmer. So there could be a 13th LED device with color LUMA, but what function should it be given in DTS?

Marek

#7 lore raw

Hi Marek,

Quoted 10 lines · Marek Behun
Quoted 6 lines · On Sat, 28 Mar 2020 14:01:47 +0100 Jacek Anaszewski…

I already proposed adding a "luma" LED class device for similar case [0], but didn't here any feedback from Pavel so far.

[0]
https://lore.kernel.org/linux-leds/[email protected]/T/#mf52c8d4f68260a445223c26957c61e6267e0932d

Quoted 7 lines

Hi Jacek,

in the case you mentioned there is a one "global" brightness setting per each RGB LED. On Omnia, all 12 RGB LEDs have just one "global" brightness property. Ie. I press the button, and all 12 LEDs glow get dimmer. So there could be a 13th LED device with color LUMA, but what function should it be given in DTS?

Then, in this particular case, adding devicename prefix for the whole family of LEDs would be justified. The question is whether it should be hardware related name or rather something different.

Signature · 2 lines
Best regards,
Jacek Anaszewski
#8 lore raw
Quoted 9 lines · On Sun, 29 Mar 2020 14:53:57 +0200 Jacek Anaszewski…
Quoted 5 lines

in the case you mentioned there is a one "global" brightness setting per each RGB LED. On Omnia, all 12 RGB LEDs have just one "global" brightness property. Ie. I press the button, and all 12 LEDs glow get dimmer. So there could be a 13th LED device with color LUMA, but what function should it be given in DTS?

Then, in this particular case, adding devicename prefix for the whole family of LEDs would be justified. The question is whether it should be hardware related name or rather something different.

Hi Jacek,

so now we have
device:color:function
what if we made it so that there was a 4th part of LED name, ie
group:device:color:function
?

Would this be a problem?

Marek

#9 lore raw
Quoted 15 lines · Marek Behun
Quoted 9 lines · On Sun, 29 Mar 2020 14:53:57 +0200 Jacek Anaszewski…
Quoted 5 lines

in the case you mentioned there is a one "global" brightness setting per each RGB LED. On Omnia, all 12 RGB LEDs have just one "global" brightness property. Ie. I press the button, and all 12 LEDs glow get dimmer. So there could be a 13th LED device with color LUMA, but what function should it be given in DTS?

Then, in this particular case, adding devicename prefix for the whole family of LEDs would be justified. The question is whether it should be hardware related name or rather something different.

Hi Jacek,

Quoted 7 lines

so now we have
device:color:function
what if we made it so that there was a 4th part of LED name, ie
group:device:color:function
?

Would this be a problem?

Indeed, the device alone would not be a sufficient differentiator since it is possible to have more than one LED controller of the same type on the board.

Nonetheless, I'd rather avoid the addition of a new generic section. Probably we would have to make it specific to this device.

Signature · 2 lines
Best regards,
Jacek Anaszewski
#10 lore raw
Quoted 22 lines · On Thu, 2 Apr 2020 22:19:50 +0200 Jacek Anaszewski…
Quoted 21 lines · Marek Behun
Quoted 9 lines · On Sun, 29 Mar 2020 14:53:57 +0200 Jacek Anaszewski…
Quoted 5 lines

in the case you mentioned there is a one "global" brightness setting per each RGB LED. On Omnia, all 12 RGB LEDs have just one "global" brightness property. Ie. I press the button, and all 12 LEDs glow get dimmer. So there could be a 13th LED device with color LUMA, but what function should it be given in DTS?

Then, in this particular case, adding devicename prefix for the whole family of LEDs would be justified. The question is whether it should be hardware related name or rather something different.

Hi Jacek,

so now we have
device:color:function
what if we made it so that there was a 4th part of LED name, ie
group:device:color:function
?

Quoted 9 lines
Quoted 1 line

Would this be a problem?

Indeed, the device alone would not be a sufficient differentiator since it is possible to have more than one LED controller of the same type on the board.

Nonetheless, I'd rather avoid the addition of a new generic section. Probably we would have to make it specific to this device.

Ok, in that case I will do it so that devicename is "omnia". devicename_mandatory should be set to true, yes? Marek

#11 lore raw
Quoted 31 lines · Marek Behun
Quoted 28 lines · On Thu, 2 Apr 2020 22:19:50 +0200 Jacek Anaszewski…
Quoted 15 lines · Marek Behun
Quoted 9 lines · On Sun, 29 Mar 2020 14:53:57 +0200 Jacek Anaszewski…
Quoted 5 lines

in the case you mentioned there is a one "global" brightness setting per each RGB LED. On Omnia, all 12 RGB LEDs have just one "global" brightness property. Ie. I press the button, and all 12 LEDs glow get dimmer. So there could be a 13th LED device with color LUMA, but what function should it be given in DTS?

Then, in this particular case, adding devicename prefix for the whole family of LEDs would be justified. The question is whether it should be hardware related name or rather something different.

Hi Jacek,

Quoted 7 lines

so now we have
device:color:function
what if we made it so that there was a 4th part of LED name, ie
group:device:color:function
?

Would this be a problem?

Indeed, the device alone would not be a sufficient differentiator since it is possible to have more than one LED controller of the same type on the board.

Quoted 6 lines
Quoted 3 lines

Nonetheless, I'd rather avoid the addition of a new generic section. Probably we would have to make it specific to this device.

Ok, in that case I will do it so that devicename is "omnia". devicename_mandatory should be set to true, yes?

If you want to have four sections then you must compose LED name yourself and not use new *ext() API. But please hold on, since I suppose Pavel will have something to add to that.

Signature · 2 lines
Best regards,
Jacek Anaszewski
#12 lore raw

Hi!

Quoted 16 lines
Quoted 16 lines
Quoted 15 lines
Quoted 7 lines

so now we have
device:color:function
what if we made it so that there was a 4th part of LED name, ie
group:device:color:function
?

Would this be a problem?

Indeed, the device alone would not be a sufficient differentiator since it is possible to have more than one LED controller of the same type on the board.

Nonetheless, I'd rather avoid the addition of a new generic section. Probably we would have to make it specific to this device.

Quoted 6 lines
Quoted 2 lines

Ok, in that case I will do it so that devicename is "omnia". devicename_mandatory should be set to true, yes?

If you want to have four sections then you must compose LED name yourself and not use new *ext() API. But please hold on, since I suppose Pavel will have something to add to that.

Lets just handle global brightness outside LED subsystem.

And drop the omnia: .. it is useless. For some of your leds it should be "ethX:...:activity".

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#13 lore raw
In reply to Jacek Anaszewski

Hi!

Quoted 15 lines
Quoted 15 lines

I decided to abandon the microcontroller driver path. But nonetheless there is still one thing I would like to solve.

The front button on Omnia is used to control the global brightness of the RGB LEDs, so that user can change it if the LEDs glow too much. The microcontroller does this as such: there is another PWM on top of all the LED PWMs, and this value can be manipulated via the same i2c interface as the LEDs, but via another command.

The thing is that I would like to somehow export this global brightness setting to userspace, because otherwise it gets reset after reboot, and I want the user to be able to set this global brightness by software, so that they won't have to change it after every reboot manually by pressing the front button.

Quoted 3 lines
Quoted 3 lines

I am wondering how to do this. Last year I proposed this by adding a sysfs attribute file to the device which is parent to the LEDs, but you did not agree :(

This is really special feature, with button interaction. I don't expect to see it elsewhere. Can you put it into /sys somewhere close to the other controls for your platform? I have /proc/acpi/ibm on this machine. It should not be /proc in new code, but you get the idea...

Quoted 2 lines

I already proposed adding a "luma" LED class device for similar case [0], but didn't here any feedback from Pavel so far.

I dislike that. Luma is not really a color. Plus, this is different case AFAICT, as global brightness affects all the LEDs at the same time.

Quoted 2 lines

[0]
https://lore.kernel.org/linux-leds/[email protected]/T/#mf52c8d4f68260a445223c26957c61e6267e0932d

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#14 lore raw
In reply to Marek Behun

Hi!

Quoted 3 lines
Quoted 1 line

NACK for merging this patch in this shape.

This was only RFC, please do not merge.

Ok, dropped. But it would be good to merge some basic version, soon, before we get even more requirements :-).

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#15 lore raw
In reply to Marek Behún

Hi!

drivers/leds/leds-turris-omnia.c line 177

Quoted 9 lines
drivers/leds/leds-turris-omnia.c new file +9 -0
+	if (led->color != color) {
+		dev_warn(dev, "Node %pfw: 'color' should be %s!\n", node,
+			 led_colors[color]);
+		return 0;
+	}
+
+	init_data.devicename = "omnia";
+	init_data.fwnode = node;
+	init_data.devname_mandatory = true;

How will this look in the /sys/class/leds?

We don't want to see omnia:xxx:xx there. For the ethernet activity leds, it would be nice to get something like eth0:red:activity...?

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#16 lore raw
Quoted 14 lines · Pavel Machek

Hi!

drivers/leds/leds-turris-omnia.c line 177

Quoted 9 lines
drivers/leds/leds-turris-omnia.c new file +9 -0
+	if (led->color != color) {
+		dev_warn(dev, "Node %pfw: 'color' should be %s!\n", node,
+			 led_colors[color]);
+		return 0;
+	}
+
+	init_data.devicename = "omnia";
+	init_data.fwnode = node;
+	init_data.devname_mandatory = true;

How will this look in the /sys/class/leds?

Quoted 2 lines

We don't want to see omnia:xxx:xx there. For the ethernet activity leds, it would be nice to get something like eth0:red:activity...?

devicename and devicename_mandatory should be removed.

Signature · 2 lines
Best regards,
Jacek Anaszewski
#17 lore raw
Quoted 7 lines · On Sat, 21 Mar 2020 19:01:15 +0100 Jacek Anaszewski…
Quoted 4 lines

How will this look in the /sys/class/leds?

We don't want to see omnia:xxx:xx there. For the ethernet activity leds, it would be nice to get something like eth0:red:activity...?

devicename and devicename_mandatory should be removed.

Without this I have:

omnialeds /sys/class/leds # ls

blue:power   red:power    white:lan-2  white:pci-1  white:user-1
green:power  white:lan-0  white:lan-3  white:pci-2  white:user-2
mmc0::       white:lan-1  white:lan-4  white:pci-3  white:wan

(the mmc0:: is not created by this driver).

Is this okay?

#18 lore raw

Marek,

Quoted 11 lines · Marek Behun
Quoted 7 lines · On Sat, 21 Mar 2020 19:01:15 +0100 Jacek Anaszewski…
Quoted 4 lines

How will this look in the /sys/class/leds?

We don't want to see omnia:xxx:xx there. For the ethernet activity leds, it would be nice to get something like eth0:red:activity...?

devicename and devicename_mandatory should be removed.

Quoted 6 lines

Without this I have:

omnialeds /sys/class/leds # ls

blue:power   red:power    white:lan-2  white:pci-1  white:user-1
green:power  white:lan-0  white:lan-3  white:pci-2  white:user-2
mmc0::       white:lan-1  white:lan-4  white:pci-3  white:wan

You might want to associate the LED with actual eth interface, as Pavel mentioned, but that would require some more work.

Anyway, "omnia" alone doesn't allow to tell the location of the LED either.

Signature · 2 lines
Best regards,
Jacek Anaszewski
#19 lore raw
Quoted 16 lines · Jacek Anaszewski

Marek,

Quoted 13 lines · Marek Behun
Quoted 7 lines · On Sat, 21 Mar 2020 19:01:15 +0100 Jacek Anaszewski…
Quoted 4 lines

How will this look in the /sys/class/leds?

We don't want to see omnia:xxx:xx there. For the ethernet activity leds, it would be nice to get something like eth0:red:activity...?

devicename and devicename_mandatory should be removed.

Without this I have:

Quoted 7 lines
Quoted 4 lines

omnialeds /sys/class/leds # ls

blue:power   red:power    white:lan-2  white:pci-1  white:user-1
green:power  white:lan-0  white:lan-3  white:pci-2  white:user-2
mmc0::       white:lan-1  white:lan-4  white:pci-3  white:wan

You might want to associate the LED with actual eth interface, as Pavel mentioned, but that would require some more work.

Yes please.

Quoted 2 lines

Anyway, "omnia" alone doesn't allow to tell the location of the LED either.

ACK.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#20 lore raw
Quoted 6 lines · On Mon, 6 Apr 2020 10:34:23 +0200 Pavel Machek <[email protected]> wrote:

Yes please.

Quoted 2 lines

Anyway, "omnia" alone doesn't allow to tell the location of the LED either.

ACK.

Pavel, what about the other thread (starting with message ID <[email protected]>, sent at 04/02/2020 16:29) ?

Marek

#21 lore raw
In reply to Marek Behún

Hi Marek,

Thank you for the patch.

Quoted 38 lines · Marek Behún

This adds basic support for LEDs on the front side of CZ.NIC's Turris Omnia router.

There are 12 RGB LEDs. The controller supports HW triggering mode for the LEDs, but this driver does not support it yet, and sets all the LEDs into SW mode upon probe.

The user can either group all three channels of one RGB LED into one LED classdev, or expose each channel as an individual LED classdev. This is done by utilizing the 'led-sources' and 'color' DT properties.

In the following example the first RGB LED is exposed as one LED classdev with color WHITE, and the second RGB LED is exposed as three classdevs, one per each channel:

	led@0 {
		reg = <0>;
		led-sources = <0 1 2>;
		color = <LED_COLOR_ID_WHITE>;
	};

	led@1,0 {
		reg = <1>;
		led-sources = <3>;
		color = <LED_COLOR_ID_RED>;
	};

	led@1,1 {
		reg = <1>;
		led-sources = <4>;
		color = <LED_COLOR_ID_GREEN>;
	};

	led@1,2 {
		reg = <1>;
		led-sources = <5>;
		color = <LED_COLOR_ID_BLUE>;
	};
Quoted 3 lines

I am not comfortable with the 'reg' property being same for multiple nodes. Perhaps the 'reg' property shouldn't be used, since the information needed by the driver can be deduced from the 'led-sources'.

I agree. You can name the sub-nodes like led0,led1,led2 etc. reg is convenient if each sub-node refers to single iout, but in this case it is unnecessary complication. You can infer the reg in dt parser basing on led-sources.

And we need these bindings in a separate patch adding a new file in Documentation/devicetree/bindings/leds.

You should also mention what are the allowed led-sources configurations, i.e. I presume that only groups of (0,1,2), (2,3,4) etc. are allowed, or a single iout per child node.

[...]

Quoted 40 lines
drivers/leds/leds-turris-omnia.c new file +40 -0
+static int omnia_leds_probe(struct i2c_client *client,
+			    const struct i2c_device_id *id)
+{
+	struct device *dev = &client->dev;
+	struct device_node *np = dev->of_node, *child;
+	struct omnia_leds *leds;
+	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 > 3 * OMNIA_BOARD_LEDS) {
+		dev_err(dev, "Too many LEDs defined in device tree!\n");
+		return -EINVAL;
+	}
+
+	leds = devm_kzalloc(dev, sizeof(*leds) + count * sizeof(leds->leds[0]),
+			    GFP_KERNEL);
+	if (!leds)
+		return -ENOMEM;
+
+	leds->client = client;
+	i2c_set_clientdata(client, leds);
+
+	mutex_init(&leds->lock);
+
+	for_each_available_child_of_node(np, child) {
+		ret = omnia_led_register(leds, &child->fwnode);
+		if (ret < 0)
+			return ret;
+	}
+
+	return 0;
+}
+
+static int omnia_leds_remove(struct i2c_client *client)
+{
+	u8 buf[OMNIA_CMD_LED_COLOR_LEN];
+

drivers/leds/leds-turris-omnia.c line 264

Quoted 10 lines
drivers/leds/leds-turris-omnia.c new file +10 -0
+	/* put all LEDs into default (HW triggered) mode */
+	i2c_smbus_write_byte_data(client, CMD_LED_MODE,
+				  CMD_LED_MODE_LED(OMNIA_BOARD_LEDS));
+
+	/* set all LEDs color to [255, 255, 255] */
+	buf[OMNIA_CMD] = CMD_LED_COLOR;
+	buf[OMNIA_CMD_LED_COLOR_LED] = OMNIA_BOARD_LEDS;
+	buf[OMNIA_CMD_LED_COLOR_R] = 255;
+	buf[OMNIA_CMD_LED_COLOR_G] = 255;
+	buf[OMNIA_CMD_LED_COLOR_B] = 255;

What is the rationale behind setting all LEDs to max_brighntess on driver removal?

Signature · 2 lines
Best regards,
Jacek Anaszewski
#22 lore raw
Quoted 3 lines · On Sat, 21 Mar 2020 19:55:15 +0100 Jacek Anaszewski…

What is the rationale behind setting all LEDs to max_brighntess on driver removal?

For each RGB LED the microcontroller has ON/OFF setting, and color setting. When in HW triggering mode, the HW triggering manipulates the ON/OFF setting and the LED blinks with the color set by the color setting.

If I did not set color to white before driver removal, then the HW triggering would blink the LEDs with the color they had set by the user. That could be [0,0,0], so the LEDs wouldn't blink at all.

So on driver removal the LEDs are set into state in which they are after reset.

#23 lore raw

Hi Marek,

Quoted 12 lines · Marek Behun
Quoted 3 lines · On Sat, 21 Mar 2020 19:55:15 +0100 Jacek Anaszewski…

What is the rationale behind setting all LEDs to max_brighntess on driver removal?

For each RGB LED the microcontroller has ON/OFF setting, and color setting. When in HW triggering mode, the HW triggering manipulates the ON/OFF setting and the LED blinks with the color set by the color setting.

Quoted 6 lines

If I did not set color to white before driver removal, then the HW triggering would blink the LEDs with the color they had set by the user. That could be [0,0,0], so the LEDs wouldn't blink at all.

So on driver removal the LEDs are set into state in which they are after reset.

Sounds reasonable, ack.

Signature · 2 lines
Best regards,
Jacek Anaszewski
#24 lore raw
In reply to Marek Behún

Hmm.

The microcontroller on Turris Omnia supports more settings than just LEDs (usb3 port power and input button for example).

I am wondering if this approach (registering LED driver to communicate with the microcontroller) is correct, since the microcontroller can do other things.

For Turris Mox firmware I created a driver in
drivers/firmware/turris-mox-rwtm.c.

Maybe I should create I driver in drivers/firmware/ for the Omnia microcontroller, and then the LED driver could use functions exported by the microcontroller driver to manipulate LEDs.

What do you think?

Marek

#25 lore raw

Hi!

Quoted 9 lines

The microcontroller on Turris Omnia supports more settings than just LEDs (usb3 port power and input button for example).

I am wondering if this approach (registering LED driver to communicate with the microcontroller) is correct, since the microcontroller can do other things.

For Turris Mox firmware I created a driver in
drivers/firmware/turris-mox-rwtm.c.

this should be drivers/platform/turris/, I believe. It is not _firmware_, is it?

Quoted 5 lines

Maybe I should create I driver in drivers/firmware/ for the Omnia microcontroller, and then the LED driver could use functions exported by the microcontroller driver to manipulate LEDs.

What do you think?

So... you can do that, but you'll have multiple maintainers coordinating updates at that point. Feel free to split LED support into two files so that it can be moved to different directory later...

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#26 lore raw
Quoted 9 lines · On Sat, 21 Mar 2020 23:16:53 +0100 Pavel Machek <[email protected]> wrote:

Hi!

Quoted 7 lines

The microcontroller on Turris Omnia supports more settings than just LEDs (usb3 port power and input button for example).

I am wondering if this approach (registering LED driver to communicate with the microcontroller) is correct, since the microcontroller can do other things.

Quoted 6 lines
Quoted 2 lines

For Turris Mox firmware I created a driver in
drivers/firmware/turris-mox-rwtm.c.

this should be drivers/platform/turris/, I believe. It is not _firmware_, is it?

It is code that interacts with the firmware. It already is merged in drivers/firmware/. The raspberrypi firmware interacting drivers is also there...

#27 lore raw

Marek

Quoted 12 lines · Marek Behun
Quoted 9 lines · On Sat, 21 Mar 2020 23:16:53 +0100 Pavel Machek <[email protected]> wrote:

Hi!

Quoted 7 lines

The microcontroller on Turris Omnia supports more settings than just LEDs (usb3 port power and input button for example).

I am wondering if this approach (registering LED driver to communicate with the microcontroller) is correct, since the microcontroller can do other things.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

For Turris Mox firmware I created a driver in
drivers/firmware/turris-mox-rwtm.c.

this should be drivers/platform/turris/, I believe. It is not _firmware_, is it?

It is code that interacts with the firmware. It already is merged in drivers/firmware/. The raspberrypi firmware interacting drivers is also there...

Would a MFD driver be better here?

Dan

#28 lore raw
In reply to Marek Behun
Quoted 15 lines · Marek Behun
Quoted 12 lines · On Sat, 21 Mar 2020 23:16:53 +0100 Pavel Machek <[email protected]> wrote:

Hi!

Quoted 9 lines

The microcontroller on Turris Omnia supports more settings than just LEDs (usb3 port power and input button for example).

I am wondering if this approach (registering LED driver to communicate with the microcontroller) is correct, since the microcontroller can do other things.

For Turris Mox firmware I created a driver in
drivers/firmware/turris-mox-rwtm.c.

Quoted 6 lines
Quoted 2 lines

this should be drivers/platform/turris/, I believe. It is not _firmware_, is it?

It is code that interacts with the firmware. It already is merged in drivers/firmware/. The raspberrypi firmware interacting drivers is also

Everything has firmware these days, so everything is interacting with firmware. We have drivers/platform, not drivers/firmware/sata.

drivers/firmware is for firmware that runs on _main_ CPU.

drivers/platform is for talking with embedded controllers (that may have their own firmware).

But I suggest you put it all into drivers/leds for now, and then maybe move it, because otherwise it will be nightmare for maintainers.

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html