GPIOLED(4)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

πŸ’… GPIOLED(4) β€” bestie edition πŸ’…

okay so this is the Kernel Interfaces Manual page for gpioled, and i'm literally about to make your whole kernel-dev career slay ✨ grab a boba and let's go πŸ§‹πŸ’–


✨ NAME ✨

gpioled β€” the GPIO LED generic device driver πŸŽ€ (yes it's giving "i make lights blink on pins" and it does it flawlessly, no cap)

🌸 SYNOPSIS 🌸

so to compile this icon into the kernel, you literally just drop these lines into your kernel configuration file, periodt:

device gpio
device gpioled

that's it. that's the whole vibe check. you got this bestie 🫢

πŸ’… DESCRIPTION πŸ’…

bestie listen β€” gpioled is the glue that attaches a led(4)-compatible device to a GPIO pin πŸ”₯ it's the matchmaker, the middleman, the main character of the wiring world ngl.

every LED in the system has a name, and that name is what's used to export a device as /dev/led/<name> πŸ¦‹ then you can control that GPIO pin by writing to this device, exactly the way led(4) describes. iykyk πŸ’œ

now, on a device.hints(5) based system β€” think MIPS vibes β€” these values are configurable for gpioled:

  • hint.gpioled.%d.at β€” the gpiobus you're attaching to πŸ™ˆ normally it's assigned to gpiobus0.
  • hint.gpioled.%d.name β€” the arbitrary name of the device in /dev/led/ to create for led(4). you name it, you own it πŸ’…
  • hint.gpioled.%d.pins β€” which pin on the GPIO interface gets mapped to this instance ✨ but bestie, please note: this mask should only ever have one bit set β€” any other bits (i.e., pins) will be flat-out ignored πŸ™ˆ okurrr.
  • hint.gpioled.%d.invert β€” if you set this to 1, the pin gets set to 0 to light the LED, and 1 to clear it πŸ”„ (yes, the logic flips, it's that girl 🀸)
  • hint.gpioled.%d.state β€” the initial state of the LED when the driver takes control over it πŸ‘‘ if it's 1 or 0, the LED is on or off correspondingly. if it's -1, the LED stays in its original state, no touching, no drama πŸ’€

πŸŽ€ FDT(4) vibes (ARM girls, this one's for you) πŸŽ€

on a FDT(4) based system, like ARM, the DTS part for a gpioled device usually looks like this, and yes it's giving art 🌈:

gpio: gpio {

        gpio-controller;
        ...

        led0 {
                compatible = "gpioled";
                gpios = <&gpio 16 2 0>;         /* GPIO pin 16. */
                name = "ok";
        };

        led1 {
                compatible = "gpioled";
                gpios = <&gpio 17 2 0>;         /* GPIO pin 17. */
                name = "user-led1";
        };
};

optionally β€” and this is lowkey the aesthetic upgrade β€” you can choose to combine all the LEDs under a single "gpio-leds" compatible node πŸŽ€ like so:

simplebus0 {

        ...

        leds {
                compatible = "gpio-leds";

                led0 {
                        gpios = <&gpio 16 2 0>;
                        name = "ok"
                };

                led1 {
                        gpios = <&gpio 17 2 0>;
                        name = "user-led1"
                };
        };
};

both methods are equally supported πŸ’– and it's totally possible to have LEDs defined with any sort of mix between the two methods. mix and match, it's your world 🌍✨

the only restriction (and this is the important part, bestie, don't skip it πŸ™): a GPIO pin cannot be mapped by two different (gpio)leds. no double-booking, no sharing, we don't do that here πŸ’€ periodt.

for more details about the gpios property, please consult /usr/src/sys/dts/bindings-gpio.txt πŸ“– (yes, go read it, it's giving homework but make it cute).

the property name is the arbitrary name of the device in /dev/led/ to create for led(4) 🧚 that's how you name your little light babies.

πŸ”₯ SEE ALSO πŸ”₯

go read them, they're all iconic in their own way πŸ‘‘

⭐ HISTORY ⭐

the gpioled manual page first appeared in FreeBSD 10.1 πŸŽ‰ a legend was born.

🌸 AUTHORS 🌸

this manual page was written by Luiz Otavio O Souza β€” thank you for your service king 🫢✨


and that's the whole page bestie πŸ’– written with love, Debian, May 23, 2019, for GPIOLED(4) β€” you're gonna do amazing things with those LEDs, i can feel it πŸŒŸπŸ’…πŸŽ€

πŸ“¦ where this page comes from