General Purpose Input Output
General Purpose Input Output
GPIO, Kernel Driver Tests
Let's find if GPIOs are found under Sysfs
user@Minnowboard:~$ ls /sys/kernel/gpio
ls: cannot access /sys/kernel/gpio: No such file or directory
GPIO, Kernel Drivers Enablement
One way to enable GPIOs is to follow ELinux MinnowMax Linux Kernel
Compile your kernel, once compiled we enable all needed drivers via menuconfig:
user@Minnowboard:~$ cd linux
user@Minnowboard:~$ make menuconfig
Processor type and features --->
[*] Intel Low Power Subsystem Support
Symbol: X86_INTEL_LPSS [=y]
Prompt: Intel Low Power Subsystem Support
Device Drivers --->
Pin controllers --->
[*] Intel Baytrail GPIO pin control
Symbol: PINCTRL_BAYTRAIL [=y]
Prompt: Intel Baytrail GPIO pin control
Device Drivers --->
-*- GPIO Support --->
Symbol: GPIOLIB [=y]
Prompt: GPIO Support
[*] Debug GPIO calls
Symbol: DEBUG_GPIO [=y]
Prompt: Debug GPIO calls
[*] /sys/class/gpio/... (sysfs interface)
Symbol: GPIO_SYSFS [=y]
Prompt: /sys/class/gpio/... (sysfs interface)
Once configured, we save the changes, compile and reboot
GPIO, Kernel Modules Tests
Ready! We test that our GPIOs are enabled in dmesg, sysfs y debugfs
user@Minnowboard:~$ dmesg | grep gpio
[ 0.222366] gpiochip_find_base: found new base at 410
[ 0.222466] gpiochip_add: registered GPIOs 410 to 511 on device: INT33FC:00
[ 0.223202] gpiochip_find_base: found new base at 382
[ 0.223285] gpiochip_add: registered GPIOs 382 to 409 on device: INT33FC:01
[ 0.223683] gpiochip_find_base: found new base at 338
[ 0.223777] gpiochip_add: registered GPIOs 338 to 381 on device: INT33FC:02
[ 7.823125] acpi 80860F16:00: GPIO: looking up 80860F16:00 cd-gpios
[ 7.823138] acpi 80860F16:00: GPIO: looking up 80860F16:00 cd-gpio
[ 7.823415] sdhci-acpi 80860F16:00: failed to setup card detect gpio
user@Minnowboard:~$ ls /sys/class/gpio
export gpiochip338 gpiochip382 gpiochip410 unexport
root@Minnowboard:~# mount -t debugfs none /sys/kernel/debug
root@Minnowboard:~# cat gpio
GPIOs 338-381, platform/INT33FC:02, INT33FC:02:
gpio-0 (Unrequested ) in hi pad-29 offset:0x1d0 mux:0 up 20k
...
gpio-43 (Unrequested ) in out lo pad-40 offset:0x280 mux:0
...
GPIOs 382-409, platform/INT33FC:01, INT33FC:01:
gpio-0 (Unrequested ) in lo pad-19 offset:0x130 mux:2
...
gpio-27 (Unrequested ) lo pad-7 offset:0x070 mux:0 down 20k
GPIOs 410-511, platform/INT33FC:00, INT33FC:00:
gpio-0 (Unrequested ) in lo pad-85 offset:0x550 mux:1
...
gpio-101 (Unrequested ) in out lo pad-100 offset:0x640 mux:0
To know the GPIO values let's look at the Minnowboard Elinux Wikipage
or we use the following script
user@Minnowboard:~$ wget https://raw.githubusercontent.com/MinnowBoard/minnow-max-extras/master/lse/what_gpio_num.sh
user@Minnowboard:~$ chmod +x what_gpio_num.sh
root@Minnowboard:~# ./what_gpio_num.sh
GPIO, Userspace Tests
A very simple test is to enable a GPIO as output and use a multimeter to check the voltage, Minnowboard MAX Pin 1 (Ground | Gnd) and Pin 21 (GPIO / Wakeup | GPIO_S5_0) are connected to the negative y positive terminales of our multimeter.
The next commands will give us the configuration and output of 0 and 3.3 Volts respectively:
root@Minnowboard:~# echo 338 > /sys/class/gpio/export
root@Minnowboard:~# echo out > /sys/class/gpio/gpio338/direction
root@Minnowboard:~# echo 0 > /sys/class/gpio/gpio338/value
root@Minnowboard:~# echo 1 > /sys/class/gpio/gpio338/value
root@Minnowboard:~# echo 0 > /sys/class/gpio/gpio338/value
root@Minnowboard:~# echo 1 > /sys/class/gpio/gpio338/value
GPIO, Online Resources
End of File
Last updated