Using GPIO from sysfs
Where to find GPIO's in sysfs
GPIO's are listed under /sys/class/gpio
Calculate Linux GPIO Number Freescale i.MX Processor Family
Linux GPIO Number = <GPIO_bank – 1> × 32 + <GPIO Port number>
Calculate Linux GPIO Number Texas Instruments Sitara Family
Linux GPIO Number = <GPIO_bank x 32> + <GPIO Port number>
Set GPIO as output
root@MBaXXX:~ echo <gpionr> >/sys/class/gpio/export // export GPIO pin root@MBaXXX:~ echo out > /sys/class/gpio/gpio<gpionr>/direction // set GPIO direction root@MBaXXX:~ echo 1 > /sys/class/gpio/gpio<gpionr>/value // toggle GPIO to high root@MBaXXX:~ echo 0 > /sys/class/gpio/gpio<gpionr>/value // toggle GPIO to low
Set GPIO as Input
root@MBaXXX:~ echo „<gpionr>" >/sys/class/gpio/export // export GPIO pin root@MBaXXX:~ echo in > /sys/class/gpio/gpio<gpionr>/direction // set GPIO direction root@MBaXXX:~ cat /sys/class/gpio/gpio<gpionr>/value // read GPIO value
Using GPIO in U-Boot
Tested with TQMa28
It is possible to toggle the GPIO's in U-Boot with the gpio command. To use gpio command the desired gpio pin number has to be given as parameter to the command. The following bitmask applies to GPIO pin number in U-Boot:
[PPPP P_BBB] P = pin, B = bank
For example we toggle GPIO0_24 on MBa28
GPIO0_24 = GPIO Bank 0, Pin 24, GPIO0_24 = 11000
Disclaimer
TQ-Systems GmbH provides the Board Support Packages (BSP) free of charge. The software included in the shipment has been configured individually for the starter kits. The software is only intended to evaluate the module. The use of the Board Support Packages (BSP) is only allowed within the scope of functionality described by TQ-Systems GmbH. TQ-Systems GmbH does not accept any liability for all further changes of the Board Support Package and for any damage resulting from its use.
TQ-Systems GmbH provides the Board Support Packages (BSP) free of charge. The software included in the shipment has been configured individually for the starter kits. The software is only intended to evaluate the module. The use of the Board Support Packages (BSP) is only allowed within the scope of functionality described by TQ-Systems GmbH. TQ-Systems GmbH does not accept any liability for all further changes of the Board Support Package and for any damage resulting from its use.