drivers-on-gpio.txt 5.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. Subsystem drivers using GPIO
  2. ============================
  3. Note that standard kernel drivers exist for common GPIO tasks and will provide
  4. the right in-kernel and userspace APIs/ABIs for the job, and that these
  5. drivers can quite easily interconnect with other kernel subsystems using
  6. hardware descriptions such as device tree or ACPI:
  7. - leds-gpio: drivers/leds/leds-gpio.c will handle LEDs connected to GPIO
  8. lines, giving you the LED sysfs interface
  9. - ledtrig-gpio: drivers/leds/trigger/ledtrig-gpio.c will provide a LED trigger,
  10. i.e. a LED will turn on/off in response to a GPIO line going high or low
  11. (and that LED may in turn use the leds-gpio as per above).
  12. - gpio-keys: drivers/input/keyboard/gpio_keys.c is used when your GPIO line
  13. can generate interrupts in response to a key press. Also supports debounce.
  14. - gpio-keys-polled: drivers/input/keyboard/gpio_keys_polled.c is used when your
  15. GPIO line cannot generate interrupts, so it needs to be periodically polled
  16. by a timer.
  17. - gpio_mouse: drivers/input/mouse/gpio_mouse.c is used to provide a mouse with
  18. up to three buttons by simply using GPIOs and no mouse port. You can cut the
  19. mouse cable and connect the wires to GPIO lines or solder a mouse connector
  20. to the lines for a more permanent solution of this type.
  21. - gpio-beeper: drivers/input/misc/gpio-beeper.c is used to provide a beep from
  22. an external speaker connected to a GPIO line.
  23. - gpio-tilt-polled: drivers/input/misc/gpio_tilt_polled.c provides tilt
  24. detection switches using GPIO, which is useful for your homebrewn pinball
  25. machine if for nothing else. It can detect different tilt angles of the
  26. monitored object.
  27. - extcon-gpio: drivers/extcon/extcon-gpio.c is used when you need to read an
  28. external connector status, such as a headset line for an audio driver or an
  29. HDMI connector. It will provide a better userspace sysfs interface than GPIO.
  30. - restart-gpio: drivers/power/gpio-restart.c is used to restart/reboot the
  31. system by pulling a GPIO line and will register a restart handler so
  32. userspace can issue the right system call to restart the system.
  33. - poweroff-gpio: drivers/power/gpio-poweroff.c is used to power the system down
  34. by pulling a GPIO line and will register a pm_power_off() callback so that
  35. userspace can issue the right system call to power down the system.
  36. - gpio-gate-clock: drivers/clk/clk-gpio-gate.c is used to control a gated clock
  37. (off/on) that uses a GPIO, and integrated with the clock subsystem.
  38. - i2c-gpio: drivers/i2c/busses/i2c-gpio.c is used to drive an I2C bus
  39. (two wires, SDA and SCL lines) by hammering (bitbang) two GPIO lines. It will
  40. appear as any other I2C bus to the system and makes it possible to connect
  41. drivers for the I2C devices on the bus like any other I2C bus driver.
  42. - spi_gpio: drivers/spi/spi-gpio.c is used to drive an SPI bus (variable number
  43. of wires, atleast SCK and optionally MISO, MOSI and chip select lines) using
  44. GPIO hammering (bitbang). It will appear as any other SPI bus on the system
  45. and makes it possible to connect drivers for SPI devices on the bus like
  46. any other SPI bus driver. For example any MMC/SD card can then be connected
  47. to this SPI by using the mmc_spi host from the MMC/SD card subsystem.
  48. - w1-gpio: drivers/w1/masters/w1-gpio.c is used to drive a one-wire bus using
  49. a GPIO line, integrating with the W1 subsystem and handling devices on
  50. the bus like any other W1 device.
  51. - gpio-fan: drivers/hwmon/gpio-fan.c is used to control a fan for cooling the
  52. system, connected to a GPIO line (and optionally a GPIO alarm line),
  53. presenting all the right in-kernel and sysfs interfaces to make your system
  54. not overheat.
  55. - gpio-regulator: drivers/regulator/gpio-regulator.c is used to control a
  56. regulator providing a certain voltage by pulling a GPIO line, integrating
  57. with the regulator subsystem and giving you all the right interfaces.
  58. - gpio-wdt: drivers/watchdog/gpio_wdt.c is used to provide a watchdog timer
  59. that will periodically "ping" a hardware connected to a GPIO line by toggling
  60. it from 1-to-0-to-1. If that hardware does not recieve its "ping"
  61. periodically, it will reset the system.
  62. - gpio-nand: drivers/mtd/nand/gpio.c is used to connect a NAND flash chip to
  63. a set of simple GPIO lines: RDY, NCE, ALE, CLE, NWP. It interacts with the
  64. NAND flash MTD subsystem and provides chip access and partition parsing like
  65. any other NAND driving hardware.
  66. Apart from this there are special GPIO drivers in subsystems like MMC/SD to
  67. read card detect and write protect GPIO lines, and in the TTY serial subsystem
  68. to emulate MCTRL (modem control) signals CTS/RTS by using two GPIO lines. The
  69. MTD NOR flash has add-ons for extra GPIO lines too, though the address bus is
  70. usually connected directly to the flash.
  71. Use those instead of talking directly to the GPIOs using sysfs; they integrate
  72. with kernel frameworks better than your userspace code could. Needless to say,
  73. just using the apropriate kernel drivers will simplify and speed up your
  74. embedded hacking in particular by providing ready-made components.