3.2.2.5. GPIO

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 user space as character device 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.

Overview

The GPIO controllers allow interaction with GPIO pins for input/output and interrupt generation.

../../../../_images/GPIO_driver_diagram.png

User Layer

The GPIO driver can be used via 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

Note

Since linux 4.8 the GPIO sysfs interface is deprecated. User space should use the character device instead.

Consuming Drivers

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


Features

  • Access GPIO from user space as input or output

  • Leverage GPIO from another “consumer” driver