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.


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


User Layer

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.

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


  • Access GPIO from user space as input or output
  • Leverage GPIO from another “consumer” driver