Lines Matching refs:GPIO
2 Legacy GPIO Interfaces
5 This provides an overview of GPIO access conventions on Linux.
11 What is a GPIO?
13 A "General Purpose Input/Output" (GPIO) is a flexible software-controlled
15 to Linux developers working with embedded and custom hardware. Each GPIO
22 non-dedicated pin can be configured as a GPIO; and most chips have at least
26 also "GPIO Expander" chips that connect using the I2C or SPI serial busses.
27 Most PC southbridges have a few dozen GPIO-capable pins (with only the BIOS
39 cases (to support bidirectional signaling). GPIO controllers may have
46 - Usually a GPIO will be configurable as either input or output, as needed
52 On a given board each GPIO is used for one specific purpose like monitoring
58 GPIO conventions
71 used for several very different kinds of GPIO controller. (There is some
73 in this document, but drivers acting as clients to the GPIO interface must
77 use it when possible. Platforms must select GPIOLIB if GPIO functionality
79 standard GPIO calls should have Kconfig entries which depend on GPIOLIB. The
80 GPIO calls are available, either as "real code" or as optimized-away stubs,
100 for the GPIO lines so that board-specific setup code directly corresponds
101 to the relevant schematics. In contrast, drivers should only use GPIO
107 uses numbers 0..63 with one set of GPIO controllers, 64-79 with another
108 type of GPIO controller, and on one particular board 80-95 with an FPGA.
110 use numbers 2000-2063 to identify GPIOs in a bank of I2C GPIO expanders.
112 If you want to initialize a structure with an invalid GPIO number, use
114 test if such number from such a structure could reference a GPIO, you
123 Whether a platform supports multiple GPIO controllers is a platform-specific
125 of GPIO numbers, and whether new controllers can be added at runtime. Such issues
126 can affect things including whether adjacent GPIO numbers are both valid.
130 The first thing a system should do with a GPIO is allocate it, using
133 One of the next things to do with a GPIO, often in board setup code when
134 setting up a platform_device using the GPIO, is mark its direction::
150 of a GPIO implicitly requests that GPIO (see below) if it has not been
154 Setting the direction can fail if the GPIO number is invalid, or when
155 that particular GPIO can't be used in that mode. It's generally a bad
158 that board setup code probably needs to multiplex that pin as a GPIO,
162 Spinlock-Safe GPIO access
164 Most GPIO controllers can be accessed with memory read/write instructions.
171 /* GPIO INPUT: return zero or nonzero */
174 /* GPIO OUTPUT */
182 The get/set calls have no error returns because "invalid GPIO" should have
189 calls to access the GPIO value in cases where the GPIO number (and for
197 GPIO access that may sleep
199 Some GPIO controllers must be accessed using message based busses like I2C
200 or SPI. Commands to read or write those GPIO values require waiting to
204 Platforms that support this type of GPIO distinguish them from other GPIOs
205 by returning nonzero from this call (which requires a valid GPIO number,
212 /* GPIO INPUT: return zero or nonzero, might sleep */
215 /* GPIO OUTPUT, might sleep */
228 from contexts which may sleep, since they may need to access the GPIO
249 /* request GPIO, returning 0 or negative errno.
254 /* release previously-claimed GPIO */
257 Passing invalid GPIO numbers to gpio_request() will fail, as will requesting
270 GPIO can serve as a kind of lock.
284 GPIO signal to the appropriate pin should occur within a GPIO driver's
286 setup of an output GPIO's value. This allows a glitch-free migration from a
287 pin's special function to GPIO. This is sometimes required when using a GPIO
288 to implement a workaround on signals typically driven by a non-GPIO HW block.
290 Some platforms allow some or all GPIO signals to be routed to different pins.
291 Similarly, other aspects of the GPIO or pin may need to be configured, such as
294 the pinctrl subsystem's mapping table, so that GPIO users need not be aware
297 Also note that it's your responsibility to have stopped using a GPIO
303 /* request a single GPIO, with initial configuration specified by
383 GPIO numbers are unsigned integers; so are IRQ numbers. These make up
384 two logically distinct namespaces (GPIO 0 need not use IRQ 0). You can
387 /* map GPIO numbers to IRQ numbers */
392 some GPIOs can't be used as IRQs.) It is an unchecked error to use a GPIO
417 Some GPIO controllers directly support open drain outputs; many don't. When
419 there's a common idiom you can use to emulate it with any GPIO pin that can
436 GPIO controllers and the pinctrl subsystem
439 A GPIO controller on a SOC might be tightly coupled with the pinctrl
442 case where e.g. a GPIO controller need to reserve a pin or set the
450 But how does the pin control subsystem cross-correlate the GPIO
484 to route a given GPIO to any one of several pins. (Yes, those examples all
506 a side effect of configuring an add-on board with some GPIO expanders.
509 GPIO implementor's framework (OPTIONAL)
512 easier for platforms to support different kinds of GPIO controller using
522 In this framework each GPIO controller is packaged as a "struct gpio_chip"
525 - methods to establish GPIO direction
526 - methods used to access GPIO values
532 the number of its first GPIO, and how many GPIOs it exposes.
536 gpio_chip and issue gpiochip_add(). Removing a GPIO controller should be
540 not exposed by the GPIO interfaces, such as addressing, power management,
541 and more. Chips such as codecs will have complex non-GPIO state.
545 either NULL or the label associated with that GPIO when it was requested.
551 else it is up to the user to configure support for GPIO.
554 GPIOs through GPIO-lib and the code cannot be enabled by the user.
565 referenced GPIO is the constant "12", getting or setting its value could
581 For external GPIO controllers -- such as I2C or SPI expanders, ASICs, multi
583 registering controller devices and ensures that their drivers know what GPIO
588 of GPIOs that chip will expose, and passes them to each GPIO expander chip
593 an I2C-based GPIO, its probe() routine should only be called after that GPIO
595 calls for that GPIO can work. One way to address such dependencies is for
599 the GPIO controller device becomes unavailable.
606 debugfs interface, since it provides control over GPIO direction and
611 know for example that GPIO #23 controls the write protect line used to
613 may need to temporarily remove that protection, first importing a GPIO,
615 the write protection. In normal use, GPIO #23 would never be touched,
619 userspace GPIO can be used to determine system configuration data that
621 GPIO drivers could be all that the system really needs.
624 GPIO tasks: "leds-gpio" and "gpio_keys", respectively. Use those
637 - GPIO controllers ("gpio_chip" instances).
646 a GPIO to userspace by writing its number to this file.
649 for GPIO #19, if that's not requested by kernel code.
656 GPIO signals have paths like /sys/class/gpio/gpio42/ (for GPIO #42)
665 configure the GPIO as an output with that initial value.
668 doesn't support changing the direction of a GPIO, or
670 allow userspace to reconfigure this GPIO's direction.
672 "value" ... reads as either 0 (low) or 1 (high). If the GPIO
699 GPIO controllers have paths like /sys/class/gpio/gpiochip42/ (for the
705 "base" ... same as N, the first GPIO managed by this chip
716 the correct GPIO number to use for a given signal.
724 /* export the GPIO to userspace */
730 After a kernel driver requests a GPIO, it may only be made available in
743 The functions listed in this section are deprecated. The GPIO descriptor based