diff mbox series

[v2,07/11] ARM: dts: mstar: unitv2: Wire up LEDs

Message ID 20210923065500.2284347-8-daniel@0x0f.com (mailing list archive)
State New, archived
Headers show
Series gpio: msc313: Add gpio support for ssd20xd | expand

Commit Message

Daniel Palmer Sept. 23, 2021, 6:54 a.m. UTC
Add the red and white leds present on the unitv2.

Signed-off-by: Daniel Palmer <daniel@0x0f.com>
---
 .../boot/dts/mstar-infinity2m-ssd202d-unitv2.dts   | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Pavel Machek Nov. 30, 2021, 6:55 p.m. UTC | #1
Hi!

> Add the red and white leds present on the unitv2.

Thanks for cc-ing me.

> @@ -18,6 +20,18 @@ aliases {
>  	chosen {
>  		stdout-path = "serial0:115200n8";
>  	};
> +
> +	leds {
> +		compatible = "gpio-leds";
> +		led-white {
> +			gpios = <&gpio SSD20XD_GPIO_GPIO0 GPIO_ACTIVE_LOW>;
> +			linux,default-trigger = "activity";
> +		};
> +		led-red {
> +			gpios = <&gpio SSD20XD_GPIO_GPIO1 GPIO_ACTIVE_LOW>;
> +			linux,default-trigger = "heartbeat";
> +		};
> +	};

How do these look in userspace (ls /sys/class/leds)? See
Documentation/devicetree/bindings/leds/common.yaml . Should the first
one be disk-activity?

Best regards,
								Pavel
Daniel Palmer Dec. 2, 2021, 9:44 a.m. UTC | #2
Hi Pavel,

On Wed, 1 Dec 2021 at 03:56, Pavel Machek <pavel@ucw.cz> wrote:
>
> Hi!
>
> > Add the red and white leds present on the unitv2.
>
> Thanks for cc-ing me.
>
> > @@ -18,6 +20,18 @@ aliases {
> >       chosen {
> >               stdout-path = "serial0:115200n8";
> >       };
> > +
> > +     leds {
> > +             compatible = "gpio-leds";
> > +             led-white {
> > +                     gpios = <&gpio SSD20XD_GPIO_GPIO0 GPIO_ACTIVE_LOW>;
> > +                     linux,default-trigger = "activity";
> > +             };
> > +             led-red {
> > +                     gpios = <&gpio SSD20XD_GPIO_GPIO1 GPIO_ACTIVE_LOW>;
> > +                     linux,default-trigger = "heartbeat";
> > +             };
> > +     };
>
> How do these look in userspace (ls /sys/class/leds)?

From what I remember the above results in /sys/class/leds/red and
/sys/class/leds/white.
I'll check though. Is there something wrong with that? :)

>Should the first one be disk-activity?

Good question. My personal preference was for some sort of load
indicator as it helped me when debugging. That's why I have heartbeat
and activity. An "I'm alive signal" and some indication of how much is
going on.
I'm not sure if disk-activity is too useful with these devices as they
usually have everything in a very small rootfs and don't do lots of
disk io because they have pretty small SPI NAND flash for local
storage. Also there isn't anything in mainline that'll trigger the
disk-activity trigger at the moment.
As "activity" isn't documented in the bindings and I don't think I got
an answer from Rob about it, maybe I'll just drop the trigger for now.

Cheers,

Daniel
Pavel Machek Oct. 2, 2022, 10:26 a.m. UTC | #3
Hi!

> > > Add the red and white leds present on the unitv2.
> >
> > Thanks for cc-ing me.
> >
> > > @@ -18,6 +20,18 @@ aliases {
> > >       chosen {
> > >               stdout-path = "serial0:115200n8";
> > >       };
> > > +
> > > +     leds {
> > > +             compatible = "gpio-leds";
> > > +             led-white {
> > > +                     gpios = <&gpio SSD20XD_GPIO_GPIO0 GPIO_ACTIVE_LOW>;
> > > +                     linux,default-trigger = "activity";
> > > +             };
> > > +             led-red {
> > > +                     gpios = <&gpio SSD20XD_GPIO_GPIO1 GPIO_ACTIVE_LOW>;
> > > +                     linux,default-trigger = "heartbeat";
> > > +             };
> > > +     };
> >
> > How do these look in userspace (ls /sys/class/leds)?
> 
> >From what I remember the above results in /sys/class/leds/red and
> /sys/class/leds/white.
> I'll check though. Is there something wrong with that? :)

Yes.

LEDs are supposed to be named device:color:function. Did manufacturer
somehow label them? See also Documentation/leds/well-known-leds.txt .

> >Should the first one be disk-activity?
> 
> Good question. My personal preference was for some sort of load
> indicator as it helped me when debugging. That's why I have heartbeat
> and activity. An "I'm alive signal" and some indication of how much is
> going on.
> I'm not sure if disk-activity is too useful with these devices as they
> usually have everything in a very small rootfs and don't do lots of
> disk io because they have pretty small SPI NAND flash for local
> storage. Also there isn't anything in mainline that'll trigger the
> disk-activity trigger at the moment.
> As "activity" isn't documented in the bindings and I don't think I got
> an answer from Rob about it, maybe I'll just drop the trigger for now.

CPU activity is fine, too, but we want that option documented as you
did later in the series.

Best regards,
								Pavel
diff mbox series

Patch

diff --git a/arch/arm/boot/dts/mstar-infinity2m-ssd202d-unitv2.dts b/arch/arm/boot/dts/mstar-infinity2m-ssd202d-unitv2.dts
index a81684002e45..a51490defabc 100644
--- a/arch/arm/boot/dts/mstar-infinity2m-ssd202d-unitv2.dts
+++ b/arch/arm/boot/dts/mstar-infinity2m-ssd202d-unitv2.dts
@@ -7,6 +7,8 @@ 
 /dts-v1/;
 #include "mstar-infinity2m-ssd202d.dtsi"
 
+#include <dt-bindings/gpio/gpio.h>
+
 / {
 	model = "UnitV2";
 	compatible = "m5stack,unitv2", "mstar,infinity2m";
@@ -18,6 +20,18 @@  aliases {
 	chosen {
 		stdout-path = "serial0:115200n8";
 	};
+
+	leds {
+		compatible = "gpio-leds";
+		led-white {
+			gpios = <&gpio SSD20XD_GPIO_GPIO0 GPIO_ACTIVE_LOW>;
+			linux,default-trigger = "activity";
+		};
+		led-red {
+			gpios = <&gpio SSD20XD_GPIO_GPIO1 GPIO_ACTIVE_LOW>;
+			linux,default-trigger = "heartbeat";
+		};
+	};
 };
 
 &pm_uart {