Welcome! Log In Create A New Profile

Advanced

new ledtrig-gpio driver allowing trigger source

Posted by CyberPK 
new ledtrig-gpio driver allowing trigger source
February 26, 2024 03:35AM
I've just noticed a rewrite of ledtrig-gpio driver: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/drivers/leds/trigger/ledtrig-gpio.c?id=4a11dbf04f31c71eb458c062129e95b7aa308464
If I'm not wrong, this patch should enable the trigger source, eliminating the need to set the leds in rc.local
Re: new ledtrig-gpio driver allowing trigger source
February 26, 2024 02:05PM
> I've just noticed a rewrite of ledtrig-gpio
> driver:
> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/drivers/leds/trigger/ledtrig-gpio.c?id=4a11dbf04f31c71eb458c062129e95b7aa308464
> If I'm not wrong, this patch should enable the
> trigger source, eliminating the need to set the
> leds in rc.local

Not sure I get the idea of this patch yet.

Actually there is no need to set the trigger GPIOs in /etc/rc.local. Specifying the default trigger in the DTS is enough for LEDs. For example,

green-sata2 {
                        label = "nsa325:green:sata2";
                        gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
                        linux,default-trigger = "ide-disk2";

                green-usb {
                        label = "nsa325:green:usb";
                        gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
                        linux,default-trigger = "usb-host";
                };

                green-sys {
                        label = "nsa325:green:sys";
                        gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>;
                        linux,default-trigger = "default-on";

I purposely put the echo statements in /etc/rc.local as an example to users for how we can control the LEDs in userspace.

Note that the ide-disk2 trigger is my patch to the kernel to have individual trigger for each disk. This was done a long time ago when this was the only way to do this.

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)



Edited 1 time(s). Last edit at 02/26/2024 04:14PM by bodhi.
Re: new ledtrig-gpio driver allowing trigger source
February 27, 2024 01:29PM
Hi bodhi,

for WD MyCloud Mirror Gen2 the gpio 16 and 26 (mpp48 and mpp58) sense the disk presence. So it is useful on this machines to mimic the default behavior:
blue led, solid on = disk presence, solid off = disk absence, blink disk activity.

I'm struggling to make this behavior work, but I probably need to edit your patch because I'm still not able to connect both the behaviour (disk presence + disk activity) to the same led. The ide-disk1/2 trigger seems to override the gpio input. Until now, I've used blue light to signal disk presence and red light to signal disk activity, but I would like to limit the red light to an error state.
Any idea?

Regards.
Re: new ledtrig-gpio driver allowing trigger source
February 27, 2024 02:13PM
CyberPK,

> blue led, solid on = disk presence, solid off =
> disk absence, blink disk activity.
>
> I'm struggling to make this behavior work, but I
> probably need to edit your patch because I'm still
> not able to connect both the behaviour (disk
> presence + disk activity) to the same led. The
> ide-disk1/2 trigger seems to override the gpio
> input.

Right. The current behavior (with my patch) is: HDD LED is OFF. When there is disk activity, the corresponding LED will blink. And then go back to OFF.

> Until now, I've used blue light to signal
> disk presence and red light to signal disk
> activity, but I would like to limit the red light
> to an error state.
> Any idea?

It is possible to inverse the default state (i.e to turn on LED when there is no disk activity). In fact I thougt about this a bit. But I decided that it is too much trouble to do. The reason was the current blinking code (at that time) must be changed or rewritten to achieve this effect (or create a new function). This might have an unknown affect to other parts of the system.

Also another reason I did not want to implement the inverse behavior was because most of the time people don't want to see any LED turned on except for the System/Power LED.

However, this would be better because then you will not need to worry about disk present signal after the system is running. The default state of disk LED is already ON.

=====

Possibly you could change my current patch to force the LED to be ON after the blinking (so that the blinking behavior remains unchanged system wide).

-bodhi
===========================
Forum Wiki
bodhi's corner (buy bodhi a beer)
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: