GPIO Usage Overview¶
In Critical Link kernels we enable GPIO support by default and almost every design will make use of a GPIO for some function (Ethernet reset, status LED, etc.). Please note that the TI Linux GPIO Wiki concerning the GPIO driver is a great resource to reference.
GPIO Pin Muxing¶
As for all OMAP-L138 pins the pin-mux must be configured in the kernel for every processor pin as each can support different pin-mux modes.
Below are the default GPIO Pin-mux settings for our development board from the arch/arm/mach-davinci/baseboard-industrialio.c file:
/* * GPIO pins, this is an exhaustive list which may be overridden by * other devices */ static short baseboard_gpio_pins[] __initdata = { DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_3, DA850_GPIO0_4, DA850_GPIO0_5, DA850_GPIO0_6, DA850_GPIO0_7, DA850_GPIO0_8, DA850_GPIO0_9, DA850_GPIO0_10, DA850_GPIO0_11, DA850_GPIO0_12, DA850_GPIO0_13, DA850_GPIO0_14, DA850_GPIO0_15, DA850_GPIO2_12, DA850_GPIO2_15, -1, };
GPIO Mapping¶
The OMAP-L138 processor features up to 144 pins that can be configured as GPIO. They are divided into 9 banks of GPIO's with 16 GPIO's in each.
For example module pin 22 when pin-muxed as a GPIO is GPIO0[6]
. That means that to access that GPIO at the Userspace level it is referenced as GPIO# 6. This is based on the 0[6]
portion of the GPIO mode name.
0 (GPIO Bank #) * 16 (# of GPIO's per bank) = 0
0 (Base number for bank 0) + 6 (index of this specific GPIO in the bank) = 6.
Example Userspace Usage (for development kit and development kit Kernel)¶
J701 (50-pin header bottom side) - Pin 19 (Module pin 22 - GPIO0[6]
)
- Login to Linux through the console serial port using the user name of "root" with no password
- This will export the GPIO and allow you to use it
echo "6" > /sys/class/gpio/export
- Set the direction as an output
echo "out" > /sys/class/gpio/gpio6/direction
- Set the GPIO - 3.3V driven on this bus
echo "1" > /sys/class/gpio/gpio6/value
- Clear the GPIO - 0V
echo "0" > /sys/class/gpio/gpio6/value
Go to top