1*4882a593Smuzhiyun============================ 2*4882a593SmuzhiyunSubsystem drivers using GPIO 3*4882a593Smuzhiyun============================ 4*4882a593Smuzhiyun 5*4882a593SmuzhiyunNote that standard kernel drivers exist for common GPIO tasks and will provide 6*4882a593Smuzhiyunthe right in-kernel and userspace APIs/ABIs for the job, and that these 7*4882a593Smuzhiyundrivers can quite easily interconnect with other kernel subsystems using 8*4882a593Smuzhiyunhardware descriptions such as device tree or ACPI: 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun- leds-gpio: drivers/leds/leds-gpio.c will handle LEDs connected to GPIO 11*4882a593Smuzhiyun lines, giving you the LED sysfs interface 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun- ledtrig-gpio: drivers/leds/trigger/ledtrig-gpio.c will provide a LED trigger, 14*4882a593Smuzhiyun i.e. a LED will turn on/off in response to a GPIO line going high or low 15*4882a593Smuzhiyun (and that LED may in turn use the leds-gpio as per above). 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun- gpio-keys: drivers/input/keyboard/gpio_keys.c is used when your GPIO line 18*4882a593Smuzhiyun can generate interrupts in response to a key press. Also supports debounce. 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun- gpio-keys-polled: drivers/input/keyboard/gpio_keys_polled.c is used when your 21*4882a593Smuzhiyun GPIO line cannot generate interrupts, so it needs to be periodically polled 22*4882a593Smuzhiyun by a timer. 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun- gpio_mouse: drivers/input/mouse/gpio_mouse.c is used to provide a mouse with 25*4882a593Smuzhiyun up to three buttons by simply using GPIOs and no mouse port. You can cut the 26*4882a593Smuzhiyun mouse cable and connect the wires to GPIO lines or solder a mouse connector 27*4882a593Smuzhiyun to the lines for a more permanent solution of this type. 28*4882a593Smuzhiyun 29*4882a593Smuzhiyun- gpio-beeper: drivers/input/misc/gpio-beeper.c is used to provide a beep from 30*4882a593Smuzhiyun an external speaker connected to a GPIO line. 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun- extcon-gpio: drivers/extcon/extcon-gpio.c is used when you need to read an 33*4882a593Smuzhiyun external connector status, such as a headset line for an audio driver or an 34*4882a593Smuzhiyun HDMI connector. It will provide a better userspace sysfs interface than GPIO. 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun- restart-gpio: drivers/power/reset/gpio-restart.c is used to restart/reboot 37*4882a593Smuzhiyun the system by pulling a GPIO line and will register a restart handler so 38*4882a593Smuzhiyun userspace can issue the right system call to restart the system. 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun- poweroff-gpio: drivers/power/reset/gpio-poweroff.c is used to power the 41*4882a593Smuzhiyun system down by pulling a GPIO line and will register a pm_power_off() 42*4882a593Smuzhiyun callback so that userspace can issue the right system call to power down the 43*4882a593Smuzhiyun system. 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun- gpio-gate-clock: drivers/clk/clk-gpio.c is used to control a gated clock 46*4882a593Smuzhiyun (off/on) that uses a GPIO, and integrated with the clock subsystem. 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun- i2c-gpio: drivers/i2c/busses/i2c-gpio.c is used to drive an I2C bus 49*4882a593Smuzhiyun (two wires, SDA and SCL lines) by hammering (bitbang) two GPIO lines. It will 50*4882a593Smuzhiyun appear as any other I2C bus to the system and makes it possible to connect 51*4882a593Smuzhiyun drivers for the I2C devices on the bus like any other I2C bus driver. 52*4882a593Smuzhiyun 53*4882a593Smuzhiyun- spi_gpio: drivers/spi/spi-gpio.c is used to drive an SPI bus (variable number 54*4882a593Smuzhiyun of wires, at least SCK and optionally MISO, MOSI and chip select lines) using 55*4882a593Smuzhiyun GPIO hammering (bitbang). It will appear as any other SPI bus on the system 56*4882a593Smuzhiyun and makes it possible to connect drivers for SPI devices on the bus like 57*4882a593Smuzhiyun any other SPI bus driver. For example any MMC/SD card can then be connected 58*4882a593Smuzhiyun to this SPI by using the mmc_spi host from the MMC/SD card subsystem. 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun- w1-gpio: drivers/w1/masters/w1-gpio.c is used to drive a one-wire bus using 61*4882a593Smuzhiyun a GPIO line, integrating with the W1 subsystem and handling devices on 62*4882a593Smuzhiyun the bus like any other W1 device. 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun- gpio-fan: drivers/hwmon/gpio-fan.c is used to control a fan for cooling the 65*4882a593Smuzhiyun system, connected to a GPIO line (and optionally a GPIO alarm line), 66*4882a593Smuzhiyun presenting all the right in-kernel and sysfs interfaces to make your system 67*4882a593Smuzhiyun not overheat. 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun- gpio-regulator: drivers/regulator/gpio-regulator.c is used to control a 70*4882a593Smuzhiyun regulator providing a certain voltage by pulling a GPIO line, integrating 71*4882a593Smuzhiyun with the regulator subsystem and giving you all the right interfaces. 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun- gpio-wdt: drivers/watchdog/gpio_wdt.c is used to provide a watchdog timer 74*4882a593Smuzhiyun that will periodically "ping" a hardware connected to a GPIO line by toggling 75*4882a593Smuzhiyun it from 1-to-0-to-1. If that hardware does not receive its "ping" 76*4882a593Smuzhiyun periodically, it will reset the system. 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun- gpio-nand: drivers/mtd/nand/raw/gpio.c is used to connect a NAND flash chip 79*4882a593Smuzhiyun to a set of simple GPIO lines: RDY, NCE, ALE, CLE, NWP. It interacts with the 80*4882a593Smuzhiyun NAND flash MTD subsystem and provides chip access and partition parsing like 81*4882a593Smuzhiyun any other NAND driving hardware. 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun- ps2-gpio: drivers/input/serio/ps2-gpio.c is used to drive a PS/2 (IBM) serio 84*4882a593Smuzhiyun bus, data and clock line, by bit banging two GPIO lines. It will appear as 85*4882a593Smuzhiyun any other serio bus to the system and makes it possible to connect drivers 86*4882a593Smuzhiyun for e.g. keyboards and other PS/2 protocol based devices. 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun- cec-gpio: drivers/media/platform/cec-gpio/ is used to interact with a CEC 89*4882a593Smuzhiyun Consumer Electronics Control bus using only GPIO. It is used to communicate 90*4882a593Smuzhiyun with devices on the HDMI bus. 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun- gpio-charger: drivers/power/supply/gpio-charger.c is used if you need to do 93*4882a593Smuzhiyun battery charging and all you have to go by to check the presence of the 94*4882a593Smuzhiyun AC charger or more complex tasks such as indicating charging status using 95*4882a593Smuzhiyun nothing but GPIO lines, this driver provides that and also a clearly defined 96*4882a593Smuzhiyun way to pass the charging parameters from hardware descriptions such as the 97*4882a593Smuzhiyun device tree. 98*4882a593Smuzhiyun 99*4882a593SmuzhiyunApart from this there are special GPIO drivers in subsystems like MMC/SD to 100*4882a593Smuzhiyunread card detect and write protect GPIO lines, and in the TTY serial subsystem 101*4882a593Smuzhiyunto emulate MCTRL (modem control) signals CTS/RTS by using two GPIO lines. The 102*4882a593SmuzhiyunMTD NOR flash has add-ons for extra GPIO lines too, though the address bus is 103*4882a593Smuzhiyunusually connected directly to the flash. 104*4882a593Smuzhiyun 105*4882a593SmuzhiyunUse those instead of talking directly to the GPIOs from userspace; they 106*4882a593Smuzhiyunintegrate with kernel frameworks better than your userspace code could. 107*4882a593SmuzhiyunNeedless to say, just using the appropriate kernel drivers will simplify and 108*4882a593Smuzhiyunspeed up your embedded hacking in particular by providing ready-made components. 109