Linux GPIO Controller Architecture¶
Linux GPIO support is built on top of GPIO controller drivers that expose hardware GPIO lines through a common abstraction layer.
Understanding the GPIO subsystem requires separating three different concepts:
GPIO Controller¶
A GPIO controller is a hardware peripheral responsible for controlling a group of GPIO lines.
From a hardware perspective, a GPIO controller is usually implemented as a MMIO register block.
Typical registers include:
Example:
Linux represents a GPIO controller through:
GPIO Line¶
A GPIO line represents a single GPIO signal managed by a GPIO controller.
Conceptually:
Example:
represent:
A GPIO controller typically manages multiple GPIO lines.
Example:
GPIO Consumer¶
A GPIO consumer is a device driver that owns and uses a GPIO line.
Examples:
Debug information can be observed through:
Example:
Where:
Linux GPIO Architecture¶
The GPIO subsystem is layered as follows:
Hardware-specific register operations remain inside the controller driver.
Generic GPIO APIs are provided by gpiolib.
GPIO Controller and gpio_chip¶
Linux uses:
to represent a GPIO controller.
A simplified model looks like:
struct gpio_chip {
int (*direction_input)(...);
int (*direction_output)(...);
int (*get)(...);
int (*set)(...);
};
The callbacks provide hardware-specific implementations.
Example:
GPIO Numbering¶
Historically Linux exposed global GPIO numbers.
Example:
Global GPIO number:
Modern GPIO drivers should avoid relying on global GPIO numbers.
Preferred models are:
Raspberry Pi 5 Example¶
Observed GPIO hierarchy:
Example controllers:
Example GPIO chip:
Relationship to MMIO¶
GPIO controllers are implemented on top of MMIO register blocks.
Typical operation flow:
This abstraction allows Linux GPIO APIs to remain independent of hardware-specific register layouts.
Related Topics¶
- MMIO Register Access
- Platform Driver
- Linux Driver Model
- gpiolib
- GPIO Descriptor
- Device Tree GPIO Binding