Back to home page

OSCL-LXR

 
 

    


0001 ============================
0002 Subsystem drivers using GPIO
0003 ============================
0004 
0005 Note that standard kernel drivers exist for common GPIO tasks and will provide
0006 the right in-kernel and userspace APIs/ABIs for the job, and that these
0007 drivers can quite easily interconnect with other kernel subsystems using
0008 hardware descriptions such as device tree or ACPI:
0009 
0010 - leds-gpio: drivers/leds/leds-gpio.c will handle LEDs connected to  GPIO
0011   lines, giving you the LED sysfs interface
0012 
0013 - ledtrig-gpio: drivers/leds/trigger/ledtrig-gpio.c will provide a LED trigger,
0014   i.e. a LED will turn on/off in response to a GPIO line going high or low
0015   (and that LED may in turn use the leds-gpio as per above).
0016 
0017 - gpio-keys: drivers/input/keyboard/gpio_keys.c is used when your GPIO line
0018   can generate interrupts in response to a key press. Also supports debounce.
0019 
0020 - gpio-keys-polled: drivers/input/keyboard/gpio_keys_polled.c is used when your
0021   GPIO line cannot generate interrupts, so it needs to be periodically polled
0022   by a timer.
0023 
0024 - gpio_mouse: drivers/input/mouse/gpio_mouse.c is used to provide a mouse with
0025   up to three buttons by simply using GPIOs and no mouse port. You can cut the
0026   mouse cable and connect the wires to GPIO lines or solder a mouse connector
0027   to the lines for a more permanent solution of this type.
0028 
0029 - gpio-beeper: drivers/input/misc/gpio-beeper.c is used to provide a beep from
0030   an external speaker connected to a GPIO line.
0031 
0032 - extcon-gpio: drivers/extcon/extcon-gpio.c is used when you need to read an
0033   external connector status, such as a headset line for an audio driver or an
0034   HDMI connector. It will provide a better userspace sysfs interface than GPIO.
0035 
0036 - restart-gpio: drivers/power/reset/gpio-restart.c is used to restart/reboot
0037   the system by pulling a GPIO line and will register a restart handler so
0038   userspace can issue the right system call to restart the system.
0039 
0040 - poweroff-gpio: drivers/power/reset/gpio-poweroff.c is used to power the
0041   system down by pulling a GPIO line and will register a pm_power_off()
0042   callback so that userspace can issue the right system call to power down the
0043   system.
0044 
0045 - gpio-gate-clock: drivers/clk/clk-gpio.c is used to control a gated clock
0046   (off/on) that uses a GPIO, and integrated with the clock subsystem.
0047 
0048 - i2c-gpio: drivers/i2c/busses/i2c-gpio.c is used to drive an I2C bus
0049   (two wires, SDA and SCL lines) by hammering (bitbang) two GPIO lines. It will
0050   appear as any other I2C bus to the system and makes it possible to connect
0051   drivers for the I2C devices on the bus like any other I2C bus driver.
0052 
0053 - spi_gpio: drivers/spi/spi-gpio.c is used to drive an SPI bus (variable number
0054   of wires, at least SCK and optionally MISO, MOSI and chip select lines) using
0055   GPIO hammering (bitbang). It will appear as any other SPI bus on the system
0056   and makes it possible to connect drivers for SPI devices on the bus like
0057   any other SPI bus driver. For example any MMC/SD card can then be connected
0058   to this SPI by using the mmc_spi host from the MMC/SD card subsystem.
0059 
0060 - w1-gpio: drivers/w1/masters/w1-gpio.c is used to drive a one-wire bus using
0061   a GPIO line, integrating with the W1 subsystem and handling devices on
0062   the bus like any other W1 device.
0063 
0064 - gpio-fan: drivers/hwmon/gpio-fan.c is used to control a fan for cooling the
0065   system, connected to a GPIO line (and optionally a GPIO alarm line),
0066   presenting all the right in-kernel and sysfs interfaces to make your system
0067   not overheat.
0068 
0069 - gpio-regulator: drivers/regulator/gpio-regulator.c is used to control a
0070   regulator providing a certain voltage by pulling a GPIO line, integrating
0071   with the regulator subsystem and giving you all the right interfaces.
0072 
0073 - gpio-wdt: drivers/watchdog/gpio_wdt.c is used to provide a watchdog timer
0074   that will periodically "ping" a hardware connected to a GPIO line by toggling
0075   it from 1-to-0-to-1. If that hardware does not receive its "ping"
0076   periodically, it will reset the system.
0077 
0078 - gpio-nand: drivers/mtd/nand/raw/gpio.c is used to connect a NAND flash chip
0079   to a set of simple GPIO lines: RDY, NCE, ALE, CLE, NWP. It interacts with the
0080   NAND flash MTD subsystem and provides chip access and partition parsing like
0081   any other NAND driving hardware.
0082 
0083 - ps2-gpio: drivers/input/serio/ps2-gpio.c is used to drive a PS/2 (IBM) serio
0084   bus, data and clock line, by bit banging two GPIO lines. It will appear as
0085   any other serio bus to the system and makes it possible to connect drivers
0086   for e.g. keyboards and other PS/2 protocol based devices.
0087 
0088 - cec-gpio: drivers/media/platform/cec-gpio/ is used to interact with a CEC
0089   Consumer Electronics Control bus using only GPIO. It is used to communicate
0090   with devices on the HDMI bus.
0091 
0092 - gpio-charger: drivers/power/supply/gpio-charger.c is used if you need to do
0093   battery charging and all you have to go by to check the presence of the
0094   AC charger or more complex tasks such as indicating charging status using
0095   nothing but GPIO lines, this driver provides that and also a clearly defined
0096   way to pass the charging parameters from hardware descriptions such as the
0097   device tree.
0098 
0099 - gpio-mux: drivers/mux/gpio.c is used for controlling a multiplexer using
0100   n GPIO lines such that you can mux in 2^n different devices by activating
0101   different GPIO lines. Often the GPIOs are on a SoC and the devices are
0102   some SoC-external entities, such as different components on a PCB that
0103   can be selectively enabled.
0104 
0105 Apart from this there are special GPIO drivers in subsystems like MMC/SD to
0106 read card detect and write protect GPIO lines, and in the TTY serial subsystem
0107 to emulate MCTRL (modem control) signals CTS/RTS by using two GPIO lines. The
0108 MTD NOR flash has add-ons for extra GPIO lines too, though the address bus is
0109 usually connected directly to the flash.
0110 
0111 Use those instead of talking directly to the GPIOs from userspace; they
0112 integrate with kernel frameworks better than your userspace code could.
0113 Needless to say, just using the appropriate kernel drivers will simplify and
0114 speed up your embedded hacking in particular by providing ready-made components.