Documentation/driver-api/gpio/drivers-on-gpio.rst
Source file repositories/reference/linux-study-clean/Documentation/driver-api/gpio/drivers-on-gpio.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/driver-api/gpio/drivers-on-gpio.rst- Extension
.rst- Size
- 6387 bytes
- Lines
- 120
- Domain
- Support Tooling And Documentation
- Bucket
- Documentation
- Inferred role
- Support Tooling And Documentation: documentation
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
============================
Subsystem drivers using GPIO
============================
Note that standard kernel drivers exist for common GPIO tasks and will provide
the right in-kernel and userspace APIs/ABIs for the job, and that these
drivers can quite easily interconnect with other kernel subsystems using
hardware descriptions such as device tree or ACPI:
- leds-gpio: drivers/leds/leds-gpio.c will handle LEDs connected to GPIO
lines, giving you the LED sysfs interface
- ledtrig-gpio: drivers/leds/trigger/ledtrig-gpio.c will provide a LED trigger,
i.e. a LED will turn on/off in response to a GPIO line going high or low
(and that LED may in turn use the leds-gpio as per above).
- gpio-keys: drivers/input/keyboard/gpio_keys.c is used when your GPIO line
can generate interrupts in response to a key press. Also supports debounce.
- gpio-keys-polled: drivers/input/keyboard/gpio_keys_polled.c is used when your
GPIO line cannot generate interrupts, so it needs to be periodically polled
by a timer.
- gpio_mouse: drivers/input/mouse/gpio_mouse.c is used to provide a mouse with
up to three buttons by simply using GPIOs and no mouse port. You can cut the
mouse cable and connect the wires to GPIO lines or solder a mouse connector
to the lines for a more permanent solution of this type.
- gpio-beeper: drivers/input/misc/gpio-beeper.c is used to provide a beep from
an external speaker connected to a GPIO line. (If the beep is controlled by
off/on, for an actual PWM waveform, see pwm-gpio below.)
- pwm-gpio: drivers/pwm/pwm-gpio.c is used to toggle a GPIO with a high
resolution timer producing a PWM waveform on the GPIO line, as well as
Linux high resolution timers can do.
- extcon-gpio: drivers/extcon/extcon-gpio.c is used when you need to read an
external connector status, such as a headset line for an audio driver or an
HDMI connector. It will provide a better userspace sysfs interface than GPIO.
- restart-gpio: drivers/power/reset/gpio-restart.c is used to restart/reboot
the system by pulling a GPIO line and will register a restart handler so
userspace can issue the right system call to restart the system.
- poweroff-gpio: drivers/power/reset/gpio-poweroff.c is used to power the
system down by pulling a GPIO line and will register a pm_power_off()
callback so that userspace can issue the right system call to power down the
system.
- gpio-gate-clock: drivers/clk/clk-gpio.c is used to control a gated clock
(off/on) that uses a GPIO, and integrated with the clock subsystem.
- i2c-gpio: drivers/i2c/busses/i2c-gpio.c is used to drive an I2C bus
(two wires, SDA and SCL lines) by hammering (bitbang) two GPIO lines. It will
appear as any other I2C bus to the system and makes it possible to connect
drivers for the I2C devices on the bus like any other I2C bus driver.
- spi_gpio: drivers/spi/spi-gpio.c is used to drive an SPI bus (variable number
of wires, at least SCK and optionally MISO, MOSI and chip select lines) using
GPIO hammering (bitbang). It will appear as any other SPI bus on the system
and makes it possible to connect drivers for SPI devices on the bus like
any other SPI bus driver. For example any MMC/SD card can then be connected
to this SPI by using the mmc_spi host from the MMC/SD card subsystem.
- w1-gpio: drivers/w1/masters/w1-gpio.c is used to drive a one-wire bus using
a GPIO line, integrating with the W1 subsystem and handling devices on
the bus like any other W1 device.
- gpio-fan: drivers/hwmon/gpio-fan.c is used to control a fan for cooling the
system, connected to a GPIO line (and optionally a GPIO alarm line),
Annotation
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.