platform-driver-x86.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Define LEDs with mixed colors
@ 2021-09-01  8:39 hamza.farooq
  2021-09-01 11:09 ` Pavel Machek
  0 siblings, 1 reply; 4+ messages in thread
From: hamza.farooq @ 2021-09-01  8:39 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linux Kernel Mailing List, Linux LED Subsystem, Platform Driver,
	henning.schild, jan.kiszka, Haeussler, Gerd

Hello all,

I am toying with the idea of writing a multicolor LED GPIO driver. What would be the right way to define mixed color LEDs (for leds-gpio), in device tree or ACPI?
Consider the following:

leds {
	compatible = "gpio-leds";
	led0 {
		gpios = <&mcu_pio 0 GPIO_ACTIVE_LOW>;
		color = <LED_COLOR_ID_RED>;
	};

	led1 {
		gpios = <&mcu_pio 1 GPIO_ACTIVE_HIGH>;
		color = <LED_COLOR_ID_GREEN>;
	};
	led2 {
		gpios = <&mcu_pio 0 GPIO_ACTIVE_LOW
			&mcu_pio 1 GPIO_ACTIVE_LOW>;
		color = <LED_COLOR_ID_AMBER>;
	};
};

This probably won't work as "gpios" seem to be single object in gpio-leds driver code, but what can I do to achieve something similar?
It is important to define this LED in DT/ACPI in order for the user app to see it in the /sys/class/led folder, without having to write platform-specific driver.

Best,
Hamza

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Define LEDs with mixed colors
  2021-09-01  8:39 Define LEDs with mixed colors hamza.farooq
@ 2021-09-01 11:09 ` Pavel Machek
  2021-09-01 11:24   ` hamza.farooq
  0 siblings, 1 reply; 4+ messages in thread
From: Pavel Machek @ 2021-09-01 11:09 UTC (permalink / raw)
  To: hamza.farooq
  Cc: Andy Shevchenko, Linux Kernel Mailing List, Linux LED Subsystem,
	Platform Driver, henning.schild, jan.kiszka, Haeussler, Gerd

[-- Attachment #1: Type: text/plain, Size: 1115 bytes --]

Hi!

> I am toying with the idea of writing a multicolor LED GPIO driver. What would be the right way to define mixed color LEDs (for leds-gpio), in device tree or ACPI?
> Consider the following:
> 
> leds {
> 	compatible = "gpio-leds";
> 	led0 {
> 		gpios = <&mcu_pio 0 GPIO_ACTIVE_LOW>;
> 		color = <LED_COLOR_ID_RED>;
> 	};
> 
> 	led1 {
> 		gpios = <&mcu_pio 1 GPIO_ACTIVE_HIGH>;
> 		color = <LED_COLOR_ID_GREEN>;
> 	};
> 	led2 {
> 		gpios = <&mcu_pio 0 GPIO_ACTIVE_LOW
> 			&mcu_pio 1 GPIO_ACTIVE_LOW>;
> 		color = <LED_COLOR_ID_AMBER>;
> 	};
> };
> 
> This probably won't work as "gpios" seem to be single object in gpio-leds driver code, but what can I do to achieve something similar?
> It is important to define this LED in DT/ACPI in order for the user app to see it in the /sys/class/led folder, without having to write platform-specific driver.
> 

So you have one package with red and green LED, each connected to one
GPIO?

Can you take a look at Documentation/leds/leds-class-multicolor.rst?

Best regards,
								Pavel
-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Define LEDs with mixed colors
  2021-09-01 11:09 ` Pavel Machek
@ 2021-09-01 11:24   ` hamza.farooq
  2021-11-01 12:18     ` Pavel Machek
  0 siblings, 1 reply; 4+ messages in thread
From: hamza.farooq @ 2021-09-01 11:24 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Andy Shevchenko, Linux Kernel Mailing List, Linux LED Subsystem,
	Platform Driver, henning.schild, jan.kiszka, Haeussler, Gerd



> -----Original Message-----
> From: Pavel Machek <pavel@ucw.cz>
> Sent: Wednesday, September 1, 2021 1:09 PM
> To: Farooq, Muhammad Hamza (DI FA CTR IPC PRC2)
> <hamza.farooq@siemens.com>
> Cc: Andy Shevchenko <andy.shevchenko@gmail.com>; Linux Kernel Mailing
> List <linux-kernel@vger.kernel.org>; Linux LED Subsystem <linux-
> leds@vger.kernel.org>; Platform Driver <platform-driver-
> x86@vger.kernel.org>; Schild, Henning (T RDA IOT SES-DE)
> <henning.schild@siemens.com>; Kiszka, Jan (T RDA IOT)
> <jan.kiszka@siemens.com>; Haeussler, Gerd (ext) (DI FA CTR IPC PRC2)
> <gerd.haeussler.ext@siemens.com>
> Subject: Re: Define LEDs with mixed colors
> 
> Hi!
> 
> > I am toying with the idea of writing a multicolor LED GPIO driver. What
> would be the right way to define mixed color LEDs (for leds-gpio), in device
> tree or ACPI?
> > Consider the following:
> >
> > leds {
> > 	compatible = "gpio-leds";
> > 	led0 {
> > 		gpios = <&mcu_pio 0 GPIO_ACTIVE_LOW>;
> > 		color = <LED_COLOR_ID_RED>;
> > 	};
> >
> > 	led1 {
> > 		gpios = <&mcu_pio 1 GPIO_ACTIVE_HIGH>;
> > 		color = <LED_COLOR_ID_GREEN>;
> > 	};
> > 	led2 {
> > 		gpios = <&mcu_pio 0 GPIO_ACTIVE_LOW
> > 			&mcu_pio 1 GPIO_ACTIVE_LOW>;
> > 		color = <LED_COLOR_ID_AMBER>;
> > 	};
> > };
> >
> > This probably won't work as "gpios" seem to be single object in gpio-leds
> driver code, but what can I do to achieve something similar?
> > It is important to define this LED in DT/ACPI in order for the user app to see
> it in the /sys/class/led folder, without having to write platform-specific
> driver.
> >
> 
> So you have one package with red and green LED, each connected to one
> GPIO?
Right. It is possible to create orange color, and I want to use DT/ACPI to present this info to the userland.

> 
> Can you take a look at Documentation/leds/leds-class-multicolor.rst?
Couldn't find a hint there therefore this email thread. I might eventually write a multicolor led-gpio driver so want to know how to handle mixed LED.

> 
> Best regards,
> 								Pavel
> --
> http://www.livejournal.com/~pavelmachek

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Define LEDs with mixed colors
  2021-09-01 11:24   ` hamza.farooq
@ 2021-11-01 12:18     ` Pavel Machek
  0 siblings, 0 replies; 4+ messages in thread
From: Pavel Machek @ 2021-11-01 12:18 UTC (permalink / raw)
  To: hamza.farooq
  Cc: Andy Shevchenko, Linux Kernel Mailing List, Linux LED Subsystem,
	Platform Driver, henning.schild, jan.kiszka, Haeussler, Gerd

[-- Attachment #1: Type: text/plain, Size: 1635 bytes --]

Hi!

> > > I am toying with the idea of writing a multicolor LED GPIO driver. What
> > would be the right way to define mixed color LEDs (for leds-gpio), in device
> > tree or ACPI?
> > > Consider the following:
> > >
> > > leds {
> > > 	compatible = "gpio-leds";
> > > 	led0 {
> > > 		gpios = <&mcu_pio 0 GPIO_ACTIVE_LOW>;
> > > 		color = <LED_COLOR_ID_RED>;
> > > 	};
> > >
> > > 	led1 {
> > > 		gpios = <&mcu_pio 1 GPIO_ACTIVE_HIGH>;
> > > 		color = <LED_COLOR_ID_GREEN>;
> > > 	};
> > > 	led2 {
> > > 		gpios = <&mcu_pio 0 GPIO_ACTIVE_LOW
> > > 			&mcu_pio 1 GPIO_ACTIVE_LOW>;
> > > 		color = <LED_COLOR_ID_AMBER>;
> > > 	};
> > > };
> > >
> > > This probably won't work as "gpios" seem to be single object in gpio-leds
> > driver code, but what can I do to achieve something similar?
> > > It is important to define this LED in DT/ACPI in order for the user app to see
> > it in the /sys/class/led folder, without having to write platform-specific
> > driver.
> > >
> > 
> > So you have one package with red and green LED, each connected to one
> > GPIO?
> Right. It is possible to create orange color, and I want to use DT/ACPI to present this info to the userland.
> 
> > 
> > Can you take a look at Documentation/leds/leds-class-multicolor.rst?
> Couldn't find a hint there therefore this email thread. I might eventually write a multicolor led-gpio driver so want to know how to handle mixed LED.
>

There's no similar driver in the tree, and we don't have estabilished
API. You are mostly on your own.

Best regards,
								Pavel

-- 
http://www.livejournal.com/~pavelmachek

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-01 12:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-01  8:39 Define LEDs with mixed colors hamza.farooq
2021-09-01 11:09 ` Pavel Machek
2021-09-01 11:24   ` hamza.farooq
2021-11-01 12:18     ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).