eclipse / mraa

Linux Library for low speed IO Communication in C with bindings for C++, Python, Node.js & Java. Supports generic io platforms, as well as Intel Edison, Intel Joule, Raspberry Pi and many more.
http://mraa.io
MIT License
1.36k stars 613 forks source link

rockpi4.c: Add chardev GPIO support #1083

Closed cubanismo closed 2 years ago

cubanismo commented 2 years ago

The recommended config for upstream kernels (arm64 defconfig) on the Radxa "mainline" kernel Wiki does not include GPIO sysfs support, so libmraa applications and utilies don't work out of the box. This change marks the board as supporting the GPIO character device interface and fixes the group and line number assignments such that it actually works. Performance is also noticeably better with the chardev path.

I tested this by using mraa-gpio to toggle various pins on the 40-pin header with a multimeter attached, and with a program I have that that toggles 8 GPIO pins at the same time to upload data to another system using a parallel protocol. On upstream/mainline kernels, chardev support is now used. On the older 4.4 kernels from Radxa, chardev support is not available and libmraa gracefully falls back to sysfs.

Note another significant difference compared to the Radxa kernels in upstream kernels is the default devicetree must be tweaked to disable the 'i2s1' device in order to use GPIO pins 12, 35, 36, 38, and 40 via libmraa. For example, I appended the following section:

&i2s1 { status = "disabled"; };

to arch/arm64/boot/dts/rockchip/rk3399-rock-pi-4b.dts to accomplish this.

Signed-off-by: James Jones linux@theinnocuous.com

cubanismo commented 2 years ago

Just reviewing my old pull requests: Is something further required on my side to get this merged?

tingleby commented 2 years ago

Nope, Sorry. Merged