gpiolib request/free hooks
Subsystems (3)
PATCH 1/5 gpiolib request/free hooks
From: David Brownell <[email protected]>
Add a new internal mechanism to gpiolib to support low power operations by letting gpio_chip instances see when their GPIOs are in use. When no GPIOs are active, chips may be able to enter lower powered runtime states by disabling clocks and/or power domains.
Signed-off-by David Brownell <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
--- Documentation/gpio.txt | 4 + drivers/gpio/gpiolib.c | 91 ++++++++++++++++++++++++++++++++++++------- include/asm-generic/gpio.h | 9 ++++ 3 files changed, 91 insertions(+), 13 deletions(-)
Documentation/gpio.txt +4 -0
@@ -240,6 +240,10 @@ signal, or (b) something wrongly believe needed to manage a signal that's in active use. That is, requesting a GPIO can serve as a kind of lock. +Some platforms may also use knowledge about what GPIOs are active for +power management, such as by powering down unused chip sectors and, more +easily, gating off unused clocks. + These two calls are optional because not not all current Linux platforms offer such functionality in their GPIO support; a valid implementation could return success for all gpio_request() calls. Unlike the other calls,
drivers/gpio/gpiolib.c +78 -13
169 lines not on this page · raw message
include/asm-generic/gpio.h +9 -0
@@ -35,6 +35,10 @@ struct module;* @label: for diagnostics * @dev: optional device providing the GPIOs * @owner: helps prevent removal of modules exporting active GPIOs +* @request: optional hook for chip-specific activation, such as +* enabling module power and clock; may sleep +* @free: optional hook for chip-specific deactivation, such as +* disabling module power and clock; may sleep * @direction_input: configures signal "offset" as input, or returns error * @get: returns value for signal "offset"; for output signals this * returns either the value actually sensed, or zero
@@ -67,6 +71,11 @@ struct gpio_chip {struct device *dev;struct module *owner; +int (*request)(struct gpio_chip *chip, +unsigned offset); +void (*free)(struct gpio_chip *chip, +unsigned offset); +int (*direction_input)(struct gpio_chip *chip,unsigned offset); int (*get)(struct gpio_chip *chip,