aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2017-01-31 09:43:05 -0500
committerLinus Walleij <linus.walleij@linaro.org>2017-01-31 09:43:05 -0500
commit7354740666cd07b089af81eb91f0d4a8f1253eb9 (patch)
treea236c5e0b1eb8920e8ec7406945f7cc0915751bd
parent3d84fdb3f0b5367248b403b6d4da11e124eb71fa (diff)
gpio: random documentation update
Updated and proofread the documentation for GPIO drivers a bit when looking over the changes for generic configuration. Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r--Documentation/gpio/driver.txt55
1 files changed, 46 insertions, 9 deletions
diff --git a/Documentation/gpio/driver.txt b/Documentation/gpio/driver.txt
index ad8f0c0cd13f..fc1d2f83564d 100644
--- a/Documentation/gpio/driver.txt
+++ b/Documentation/gpio/driver.txt
@@ -41,34 +41,71 @@ In the gpiolib framework each GPIO controller is packaged as a "struct
41gpio_chip" (see linux/gpio/driver.h for its complete definition) with members 41gpio_chip" (see linux/gpio/driver.h for its complete definition) with members
42common to each controller of that type: 42common to each controller of that type:
43 43
44 - methods to establish GPIO direction 44 - methods to establish GPIO line direction
45 - methods used to access GPIO values 45 - methods used to access GPIO line values
46 - method to return the IRQ number associated to a given GPIO 46 - method to set electrical configuration to a a given GPIO line
47 - method to return the IRQ number associated to a given GPIO line
47 - flag saying whether calls to its methods may sleep 48 - flag saying whether calls to its methods may sleep
49 - optional line names array to identify lines
48 - optional debugfs dump method (showing extra state like pullup config) 50 - optional debugfs dump method (showing extra state like pullup config)
49 - optional base number (will be automatically assigned if omitted) 51 - optional base number (will be automatically assigned if omitted)
50 - label for diagnostics and GPIOs mapping using platform data 52 - optional label for diagnostics and GPIO chip mapping using platform data
51 53
52The code implementing a gpio_chip should support multiple instances of the 54The code implementing a gpio_chip should support multiple instances of the
53controller, possibly using the driver model. That code will configure each 55controller, possibly using the driver model. That code will configure each
54gpio_chip and issue gpiochip_add(). Removing a GPIO controller should be rare; 56gpio_chip and issue gpiochip_add[_data]() or devm_gpiochip_add_data().
55use gpiochip_remove() when it is unavoidable. 57Removing a GPIO controller should be rare; use [devm_]gpiochip_remove() when
58it is unavoidable.
56 59
57Most often a gpio_chip is part of an instance-specific structure with state not 60Often a gpio_chip is part of an instance-specific structure with states not
58exposed by the GPIO interfaces, such as addressing, power management, and more. 61exposed by the GPIO interfaces, such as addressing, power management, and more.
59Chips such as codecs will have complex non-GPIO state. 62Chips such as audio codecs will have complex non-GPIO states.
60 63
61Any debugfs dump method should normally ignore signals which haven't been 64Any debugfs dump method should normally ignore signals which haven't been
62requested as GPIOs. They can use gpiochip_is_requested(), which returns either 65requested as GPIOs. They can use gpiochip_is_requested(), which returns either
63NULL or the label associated with that GPIO when it was requested. 66NULL or the label associated with that GPIO when it was requested.
64 67
65RT_FULL: GPIO driver should not use spinlock_t or any sleepable APIs 68RT_FULL: the GPIO driver should not use spinlock_t or any sleepable APIs
66(like PM runtime) in its gpio_chip implementation (.get/.set and direction 69(like PM runtime) in its gpio_chip implementation (.get/.set and direction
67control callbacks) if it is expected to call GPIO APIs from atomic context 70control callbacks) if it is expected to call GPIO APIs from atomic context
68on -RT (inside hard IRQ handlers and similar contexts). Normally this should 71on -RT (inside hard IRQ handlers and similar contexts). Normally this should
69not be required. 72not be required.
70 73
71 74
75GPIO electrical configuration
76-----------------------------
77
78GPIOs can be configured for several electrical modes of operation by using the
79.set_config() callback. Currently this API supports setting debouncing and
80single-ended modes (open drain/open source). These settings are described
81below.
82
83The .set_config() callback uses the same enumerators and configuration
84semantics as the generic pin control drivers. This is not a coincidence: it is
85possible to assign the .set_config() to the function gpiochip_generic_config()
86which will result in pinctrl_gpio_set_config() being called and eventually
87ending up in the pin control back-end "behind" the GPIO controller, usually
88closer to the actual pins. This way the pin controller can manage the below
89listed GPIO configurations.
90
91
92GPIOs with debounce support
93---------------------------
94
95Debouncing is a configuration set to a pin indicating that it is connected to
96a mechanical switch or button, or similar that may bounce. Bouncing means the
97line is pulled high/low quickly at very short intervals for mechanical
98reasons. This can result in the value being unstable or irqs fireing repeatedly
99unless the line is debounced.
100
101Debouncing in practice involves setting up a timer when something happens on
102the line, wait a little while and then sample the line again, so see if it
103still has the same value (low or high). This could also be repeated by a clever
104state machine, waiting for a line to become stable. In either case, it sets
105a certain number of milliseconds for debouncing, or just "on/off" if that time
106is not configurable.
107
108
72GPIOs with open drain/source support 109GPIOs with open drain/source support
73------------------------------------ 110------------------------------------
74 111