diff options
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/pinctrl.txt | 96 |
1 files changed, 90 insertions, 6 deletions
diff --git a/Documentation/pinctrl.txt b/Documentation/pinctrl.txt index c8fd136eac83..6d23fa84ee47 100644 --- a/Documentation/pinctrl.txt +++ b/Documentation/pinctrl.txt | |||
@@ -7,12 +7,9 @@ This subsystem deals with: | |||
7 | 7 | ||
8 | - Multiplexing of pins, pads, fingers (etc) see below for details | 8 | - Multiplexing of pins, pads, fingers (etc) see below for details |
9 | 9 | ||
10 | The intention is to also deal with: | 10 | - Configuration of pins, pads, fingers (etc), such as software-controlled |
11 | 11 | biasing and driving mode specific pins, such as pull-up/down, open drain, | |
12 | - Software-controlled biasing and driving mode specific pins, such as | 12 | load capacitance etc. |
13 | pull-up/down, open drain etc, load capacitance configuration when controlled | ||
14 | by software, etc. | ||
15 | |||
16 | 13 | ||
17 | Top-level interface | 14 | Top-level interface |
18 | =================== | 15 | =================== |
@@ -88,6 +85,11 @@ int __init foo_probe(void) | |||
88 | pr_err("could not register foo pin driver\n"); | 85 | pr_err("could not register foo pin driver\n"); |
89 | } | 86 | } |
90 | 87 | ||
88 | To enable the pinctrl subsystem and the subgroups for PINMUX and PINCONF and | ||
89 | selected drivers, you need to select them from your machine's Kconfig entry, | ||
90 | since these are so tightly integrated with the machines they are used on. | ||
91 | See for example arch/arm/mach-u300/Kconfig for an example. | ||
92 | |||
91 | Pins usually have fancier names than this. You can find these in the dataheet | 93 | Pins usually have fancier names than this. You can find these in the dataheet |
92 | for your chip. Notice that the core pinctrl.h file provides a fancy macro | 94 | for your chip. Notice that the core pinctrl.h file provides a fancy macro |
93 | called PINCTRL_PIN() to create the struct entries. As you can see I enumerated | 95 | called PINCTRL_PIN() to create the struct entries. As you can see I enumerated |
@@ -193,6 +195,88 @@ structure, for example specific register ranges associated with each group | |||
193 | and so on. | 195 | and so on. |
194 | 196 | ||
195 | 197 | ||
198 | Pin configuration | ||
199 | ================= | ||
200 | |||
201 | Pins can sometimes be software-configured in an various ways, mostly related | ||
202 | to their electronic properties when used as inputs or outputs. For example you | ||
203 | may be able to make an output pin high impedance, or "tristate" meaning it is | ||
204 | effectively disconnected. You may be able to connect an input pin to VDD or GND | ||
205 | using a certain resistor value - pull up and pull down - so that the pin has a | ||
206 | stable value when nothing is driving the rail it is connected to, or when it's | ||
207 | unconnected. | ||
208 | |||
209 | For example, a platform may do this: | ||
210 | |||
211 | ret = pin_config_set(dev, "FOO_GPIO_PIN", PLATFORM_X_PULL_UP); | ||
212 | |||
213 | To pull up a pin to VDD. The pin configuration driver implements callbacks for | ||
214 | changing pin configuration in the pin controller ops like this: | ||
215 | |||
216 | #include <linux/pinctrl/pinctrl.h> | ||
217 | #include <linux/pinctrl/pinconf.h> | ||
218 | #include "platform_x_pindefs.h" | ||
219 | |||
220 | int foo_pin_config_get(struct pinctrl_dev *pctldev, | ||
221 | unsigned offset, | ||
222 | unsigned long *config) | ||
223 | { | ||
224 | struct my_conftype conf; | ||
225 | |||
226 | ... Find setting for pin @ offset ... | ||
227 | |||
228 | *config = (unsigned long) conf; | ||
229 | } | ||
230 | |||
231 | int foo_pin_config_set(struct pinctrl_dev *pctldev, | ||
232 | unsigned offset, | ||
233 | unsigned long config) | ||
234 | { | ||
235 | struct my_conftype *conf = (struct my_conftype *) config; | ||
236 | |||
237 | switch (conf) { | ||
238 | case PLATFORM_X_PULL_UP: | ||
239 | ... | ||
240 | } | ||
241 | } | ||
242 | } | ||
243 | |||
244 | int foo_pin_config_group_get (struct pinctrl_dev *pctldev, | ||
245 | unsigned selector, | ||
246 | unsigned long *config) | ||
247 | { | ||
248 | ... | ||
249 | } | ||
250 | |||
251 | int foo_pin_config_group_set (struct pinctrl_dev *pctldev, | ||
252 | unsigned selector, | ||
253 | unsigned long config) | ||
254 | { | ||
255 | ... | ||
256 | } | ||
257 | |||
258 | static struct pinconf_ops foo_pconf_ops = { | ||
259 | .pin_config_get = foo_pin_config_get, | ||
260 | .pin_config_set = foo_pin_config_set, | ||
261 | .pin_config_group_get = foo_pin_config_group_get, | ||
262 | .pin_config_group_set = foo_pin_config_group_set, | ||
263 | }; | ||
264 | |||
265 | /* Pin config operations are handled by some pin controller */ | ||
266 | static struct pinctrl_desc foo_desc = { | ||
267 | ... | ||
268 | .confops = &foo_pconf_ops, | ||
269 | }; | ||
270 | |||
271 | Since some controllers have special logic for handling entire groups of pins | ||
272 | they can exploit the special whole-group pin control function. The | ||
273 | pin_config_group_set() callback is allowed to return the error code -EAGAIN, | ||
274 | for groups it does not want to handle, or if it just wants to do some | ||
275 | group-level handling and then fall through to iterate over all pins, in which | ||
276 | case each individual pin will be treated by separate pin_config_set() calls as | ||
277 | well. | ||
278 | |||
279 | |||
196 | Interaction with the GPIO subsystem | 280 | Interaction with the GPIO subsystem |
197 | =================================== | 281 | =================================== |
198 | 282 | ||