Questions
- What is the purpose and use-case of the
gpio-hog
declaration? - Can a 'hogged' gpio pin be interfaced with from Userspace?
- If a 'hogged' gpio pin cannot be interfaced with from Userspace, then is there any mechanism to configure GPIO pins in the dts file for Userspace interaction?
Background
I am trying to configure many (10+) GPIOs to speak with a low level chip from Userspace. I have spoken to the chip easily using sysfs
exports, but both the documentation in the kernel and programming forums have me concerned about using this mechanisms in our production system.
Reading more kernel documentation I read about gpio-hog
declarations and it seemed like the ideal mechanism to at least initially configure the GPIOs. From the documentation:
GPIO hogging is a mechanism providing automatic GPIO request and configuration as part of the gpio-controller's driver probe function.
As well as setting the correct low level, vendor settings, I enabled hogging on the desired gpio pins and they came up reporting the correct settings. The problem is that the gpio's are seemingly owned by the kernel and cannot be interfaced with by any Userspace tools such as sysfs
or libgpiod
. This makes hogging essentially useless to me and also makes me wonder what it's real purpose is. I am exploring libgpiod
as a last resort, but the documentation makes it seem that hogging
should be the mechanism I use.
gpio-keys
andgpio-leds
are intended for using with, well, real keys and real LEDs. Using them for plain logic IO is far from elegant. For example, manipulating a GPIO value via a parameter calledbrightness
doesn't make sense.DO NOT ABUSE SYSFS TO CONTROL HARDWARE THAT HAS PROPER KERNEL DRIVERS. PLEASE READ THE DOCUMENT NAMED "drivers-on-gpio.txt" IN THIS DOCUMENTATION DIRECTORY TO AVOID REINVENTING KERNEL WHEELS IN USERSPACE. I MEAN IT. REALLY.
I was hoping for a basicgpio-out
andgpio-in
driver that could be extend to havekey
andled
behavior, but I'll take what i can get for the time being.