aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/pinctrl.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/pinctrl.txt')
-rw-r--r--Documentation/pinctrl.txt96
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
10The 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
17Top-level interface 14Top-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
88To enable the pinctrl subsystem and the subgroups for PINMUX and PINCONF and
89selected drivers, you need to select them from your machine's Kconfig entry,
90since these are so tightly integrated with the machines they are used on.
91See for example arch/arm/mach-u300/Kconfig for an example.
92
91Pins usually have fancier names than this. You can find these in the dataheet 93Pins usually have fancier names than this. You can find these in the dataheet
92for your chip. Notice that the core pinctrl.h file provides a fancy macro 94for your chip. Notice that the core pinctrl.h file provides a fancy macro
93called PINCTRL_PIN() to create the struct entries. As you can see I enumerated 95called 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
193and so on. 195and so on.
194 196
195 197
198Pin configuration
199=================
200
201Pins can sometimes be software-configured in an various ways, mostly related
202to their electronic properties when used as inputs or outputs. For example you
203may be able to make an output pin high impedance, or "tristate" meaning it is
204effectively disconnected. You may be able to connect an input pin to VDD or GND
205using a certain resistor value - pull up and pull down - so that the pin has a
206stable value when nothing is driving the rail it is connected to, or when it's
207unconnected.
208
209For example, a platform may do this:
210
211ret = pin_config_set(dev, "FOO_GPIO_PIN", PLATFORM_X_PULL_UP);
212
213To pull up a pin to VDD. The pin configuration driver implements callbacks for
214changing 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
220int 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
231int 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
244int foo_pin_config_group_get (struct pinctrl_dev *pctldev,
245 unsigned selector,
246 unsigned long *config)
247{
248 ...
249}
250
251int foo_pin_config_group_set (struct pinctrl_dev *pctldev,
252 unsigned selector,
253 unsigned long config)
254{
255 ...
256}
257
258static 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 */
266static struct pinctrl_desc foo_desc = {
267 ...
268 .confops = &foo_pconf_ops,
269};
270
271Since some controllers have special logic for handling entire groups of pins
272they can exploit the special whole-group pin control function. The
273pin_config_group_set() callback is allowed to return the error code -EAGAIN,
274for groups it does not want to handle, or if it just wants to do some
275group-level handling and then fall through to iterate over all pins, in which
276case each individual pin will be treated by separate pin_config_set() calls as
277well.
278
279
196Interaction with the GPIO subsystem 280Interaction with the GPIO subsystem
197=================================== 281===================================
198 282