GPIOLED(4)

✨ GPIOLED(4) ✨

Kernel Interfaces Manual πŸŽ€ β€” like, the manual page for the gpioled driver, bestie πŸ’–


πŸ’… NAME

gpioled β€” the GPIO LED generic device driver πŸ‘‘


🌸 SYNOPSIS

okay so to get this driver baked into your kernel, you gotta drop these lines into your kernel config file:

device gpio
device gpioled

no cap, that's it. two lines. slay ✨


πŸ¦‹ DESCRIPTION

The gpioled driver is basically the glue 🫢 that attaches a led(4)-compatible device to a GPIO pin. Every LED in the system gets a name, and that name is what exports the device as /dev/led/<name>. Then you control the GPIO pin by writing to that device β€” exactly the way led(4) describes it. it's giving "tiny file, big power" πŸ’€

πŸ“ On a device.hints(5) based system (like MIPS!)

these values are configurable for gpioled:

  • hint.gpioled.%d.at β€” the gpiobus you're attaching to. normally it's assigned to gpiobus0. like, that's its home 🏠
  • hint.gpioled.%d.name β€” the arbitrary name of the device in /dev/led/ to create for led(4). pick something cute, iykyk πŸ’œ
  • hint.gpioled.%d.pins β€” which pin on the GPIO interface gets mapped to this instance. ⚠️ please note that this mask should only ever have one bit set β€” any other bits (i.e., pins) will just be ignored. one pin, one vibe. periodt.
  • 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. upside-down logic, main character energy πŸ™ˆ
  • hint.gpioled.%d.state β€” the initial state of the LED when the driver takes control over it. set it to 1 or 0 and the LED will be on or off correspondingly. set it to -1 and the LED gets kept in its original state. no notes, we love a neutral option πŸ’–

🌈 On a FDT(4) based system (like ARM!)

the DTS part for a gpioled device usually looks like this:

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 πŸ‘€ you can choose to combine all the LEDs under a single β€œgpio-leds” compatible node:

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 you can totally have the LEDs defined with any sort of mix between the two methods. the only restriction? a GPIO pin cannot be mapped by two different (gpio)leds. sharing is not caring here, bestie β€” pick a lane 🚫

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

the name property is the arbitrary name of the device in /dev/led/ to create for led(4). ✨


πŸ‘‘ SEE ALSO

fdt(4), gpio(4), gpioiic(4), led(4)


🌟 HISTORY

The gpioled manual page first appeared in FreeBSD 10.1. a legend was born, fr fr πŸŽ€


πŸ’– AUTHORS

This manual page was written by Luiz Otavio O Souza. thank you king 🫢


Debian Β· May 23, 2019 Β· GPIOLED(4) β€” okay bye bestie, go blink some LEDs for me πŸ’…βœ¨πŸŒˆ

πŸ“¦ where this page comes from