GPIO Driver Overview
The GPIO Driver enables the GPIO controllers available on the device. The driver configures the GPIO hardware and interfaces and makes them available to the sysfs interface for user space interaction or other device drivers that need to access pins. For example, a MMC/SD driver may need to read a GPIO as in input to determine if a card is present. The H/W GPIO controllers available will vary by SoC and system configuration.
J721E SoCs host DAVINCI GPIO IP.
Current software supports banked GPIO interrupt only. 16 GPIOs form a bank. Each bank can produce an interrupt; this is done to save the number of interrupt lines reaching the CPU. CONFIG_GPIO_DAVINCI=y should be part of the defconfig. Driver source code: drivers/gpio/gpio-davinci.c
The GPIO controllers allow interaction with GPIO pins for input/output and interrupt generation.
The GPIO driver can be used via the sysfs interface in user space or by other drivers that may need to access pins as either input/outputs or interrupts. More information about this driver and GPIO usage in Linux can be found in the kernel documentation:
- GPIO Interface: Under Kernel directory Documentation/gpio/gpio.txt
- GPIO Driver: Under Kernel directory Documentation/gpio/driver.txt
The sysfs interface is for GPIO is located in the kernel at /sys/class/gpio. More information about this interface can also be found in the kernel sources:
- GPIO sysfs: Under Kernel directory Documentation/gpio/sysfs.txt
For controlling LEDs and Buttons, the kernel has standard drivers, “leds-gpio” and “gpio_keys”, respectively, that should be used instead of GPIO directly.
The GPIO Driver can also be easily leveraged by other drivers to “consume” a GPIO.
- GPIO Consumer: Under Kernel directory Documentation/gpio/consumer.txt
For an example of a driver using a GPIO pin, examine this entry in a dts file for how the MMC/SD interface could use a GPIO as a card detect pin Under Kernel directory arch/arm/boot/dts/am335x-bone-common.dtsi line 401
- Access GPIO from user space as input or output
- Leverage GPIO from another “consumer” driver