I'm using openwrt on an Olimex board with RT5350.
The gpio0, though not in the gpio-export of the .dts file, is by default exported and there's a folder gpio0 in /sys/class/gpio after bootup.
The direction can not be changed, it is always an input.
Does anybody know which kernel mode driver does this export?
How could I use gpio0 as an output ?
If it’s even possible to do, pretty sure you would have to compile your own image with the changes in the dts to specify it as an output.
thank you for your reply, but this can't work. The .dts exports to user space. The kernel-mode-driver that exports the gpio wins.
thanks mate, I wasn’t aware of the precedence there regarding user and kernel space. TIL.
I just stumbled across this page - you’ve probably already seen it , but just in case the example 1 under multiplexing shows how existing gpios can be repurposed on the fly, and further down the same page shows the direction can also be controlled in similar way. Most of the material there is over my head right now, but if you get it working, I’d be interested to know how it turns out for you.
the gpios can be exported and then used from userspace via /sys/class/gpio/export, even if they are already in use (exported), you can change the value and the direction and irq event handling. But if the direction has been blocked before during the export by a kernelmode driver with gpiod_export(gpio_desc,false) , you don't have access to the direction.
The gpio0 seems to be exported that way, so the direction can not be changed, is always input.
So far my search in the src files of openwrt has not been succesful. Maybe because is not in the sources but in a precompiled kernel library. Also this is probably not an openwrt specific issue, but a general linux problem. I guess every version of linux uses the gpio0 as a reset-switch.