diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2017-01-31 09:43:05 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2017-01-31 09:43:05 -0500 |
commit | 7354740666cd07b089af81eb91f0d4a8f1253eb9 (patch) | |
tree | a236c5e0b1eb8920e8ec7406945f7cc0915751bd | |
parent | 3d84fdb3f0b5367248b403b6d4da11e124eb71fa (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.txt | 55 |
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 | |||
41 | gpio_chip" (see linux/gpio/driver.h for its complete definition) with members | 41 | gpio_chip" (see linux/gpio/driver.h for its complete definition) with members |
42 | common to each controller of that type: | 42 | common 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 | ||
52 | The code implementing a gpio_chip should support multiple instances of the | 54 | The code implementing a gpio_chip should support multiple instances of the |
53 | controller, possibly using the driver model. That code will configure each | 55 | controller, possibly using the driver model. That code will configure each |
54 | gpio_chip and issue gpiochip_add(). Removing a GPIO controller should be rare; | 56 | gpio_chip and issue gpiochip_add[_data]() or devm_gpiochip_add_data(). |
55 | use gpiochip_remove() when it is unavoidable. | 57 | Removing a GPIO controller should be rare; use [devm_]gpiochip_remove() when |
58 | it is unavoidable. | ||
56 | 59 | ||
57 | Most often a gpio_chip is part of an instance-specific structure with state not | 60 | Often a gpio_chip is part of an instance-specific structure with states not |
58 | exposed by the GPIO interfaces, such as addressing, power management, and more. | 61 | exposed by the GPIO interfaces, such as addressing, power management, and more. |
59 | Chips such as codecs will have complex non-GPIO state. | 62 | Chips such as audio codecs will have complex non-GPIO states. |
60 | 63 | ||
61 | Any debugfs dump method should normally ignore signals which haven't been | 64 | Any debugfs dump method should normally ignore signals which haven't been |
62 | requested as GPIOs. They can use gpiochip_is_requested(), which returns either | 65 | requested as GPIOs. They can use gpiochip_is_requested(), which returns either |
63 | NULL or the label associated with that GPIO when it was requested. | 66 | NULL or the label associated with that GPIO when it was requested. |
64 | 67 | ||
65 | RT_FULL: GPIO driver should not use spinlock_t or any sleepable APIs | 68 | RT_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 |
67 | control callbacks) if it is expected to call GPIO APIs from atomic context | 70 | control callbacks) if it is expected to call GPIO APIs from atomic context |
68 | on -RT (inside hard IRQ handlers and similar contexts). Normally this should | 71 | on -RT (inside hard IRQ handlers and similar contexts). Normally this should |
69 | not be required. | 72 | not be required. |
70 | 73 | ||
71 | 74 | ||
75 | GPIO electrical configuration | ||
76 | ----------------------------- | ||
77 | |||
78 | GPIOs can be configured for several electrical modes of operation by using the | ||
79 | .set_config() callback. Currently this API supports setting debouncing and | ||
80 | single-ended modes (open drain/open source). These settings are described | ||
81 | below. | ||
82 | |||
83 | The .set_config() callback uses the same enumerators and configuration | ||
84 | semantics as the generic pin control drivers. This is not a coincidence: it is | ||
85 | possible to assign the .set_config() to the function gpiochip_generic_config() | ||
86 | which will result in pinctrl_gpio_set_config() being called and eventually | ||
87 | ending up in the pin control back-end "behind" the GPIO controller, usually | ||
88 | closer to the actual pins. This way the pin controller can manage the below | ||
89 | listed GPIO configurations. | ||
90 | |||
91 | |||
92 | GPIOs with debounce support | ||
93 | --------------------------- | ||
94 | |||
95 | Debouncing is a configuration set to a pin indicating that it is connected to | ||
96 | a mechanical switch or button, or similar that may bounce. Bouncing means the | ||
97 | line is pulled high/low quickly at very short intervals for mechanical | ||
98 | reasons. This can result in the value being unstable or irqs fireing repeatedly | ||
99 | unless the line is debounced. | ||
100 | |||
101 | Debouncing in practice involves setting up a timer when something happens on | ||
102 | the line, wait a little while and then sample the line again, so see if it | ||
103 | still has the same value (low or high). This could also be repeated by a clever | ||
104 | state machine, waiting for a line to become stable. In either case, it sets | ||
105 | a certain number of milliseconds for debouncing, or just "on/off" if that time | ||
106 | is not configurable. | ||
107 | |||
108 | |||
72 | GPIOs with open drain/source support | 109 | GPIOs with open drain/source support |
73 | ------------------------------------ | 110 | ------------------------------------ |
74 | 111 | ||