leds-gpio and/or gpio_keys on Jetson TK1?

I’ve been using the sysfs GPIO interface (i.e., writing/reading to files under /sys/class/gpio directory), but the documentation below says I should probably just be using the leds-gpio and gpio_keys kernel drivers for LEDs and buttons.


There’s a linux/leds.h and linux/gpio_keys.h in the kernel source code, but are these useable in normal user code? If so, how? (They aren’t copied to any of the standard include directories). Or are they just meant for use in making drivers. Can I make a driver and add it to the kernel without having to reflash my board? In case it’s not obvious, I have no experience messing with kernels.

I think the point of gpio_keys and related are for people writing code within the kernel. This coordinates with the sysfs gpio functions like export. User space code I’ve seen simply does file I/O on sysfs files. If you write a driver within the kernel, and use this interface, your driver might be a bit more efficient than with user space sysfs access.

If your Jetson uses u-boot (default in R21.x), you can simply copy the kernel into /boot with an alternate name and add a boot entry to the extlinux.conf file there to select that kernel via serial console (once you flash to R21.x no more flash is required for kernel updates). Or code as a module and insmod.

This URL may be of interest: