aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/pinctrl/pinconf-generic.h
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2011-11-24 12:27:15 -0500
committerLinus Walleij <linus.walleij@linaro.org>2012-03-12 17:49:02 -0400
commit394349f7789fdfcdc74b61afcac84046535c40b7 (patch)
tree20dd88e7a1f2dba0a1c227f53960013bf956fa43 /include/linux/pinctrl/pinconf-generic.h
parent70b36378d44d7f5e62458a830b1a9bb1c570f28a (diff)
pinctrl: introduce generic pin config
This is a split-off from the earlier patch set which adds generic pin configuration for the pin controllers that want it. Since we may have a system with mixed generic and custom pin controllers, we pass a boolean in the pin controller ops vtable to indicate if it is generic. ChangeLog v1->v5: - Follow parent patch versioning number system. - Document the semantic meaning of return values from pin config get functions, so we can iterate over pins and check their properties from debugfs as part of the generic config code. - Use proper cast functions in the generic debugfs pin config file. - Expand generic config to optionally cover groups too. ChangeLog v5->v6: - Update to match underlying changes. ChangeLog v6->v7: - Drop DRIVE_OFF parameter, use bias high impedance for this - Delete argument for drive modes push-pull, od and os. These are now just state transitions. - Delete slew rate rising/falling due to discussions on on proper semantics - Drop config wakeup, struct irq_chip does this for now, add back if need be. - Set PIN_CONFIG_END to 0x7fff making room for custom config parameters from 0x8000 and up. - Prefix accessor functions with pinconf_
Diffstat (limited to 'include/linux/pinctrl/pinconf-generic.h')
-rw-r--r--include/linux/pinctrl/pinconf-generic.h114
1 files changed, 114 insertions, 0 deletions
diff --git a/include/linux/pinctrl/pinconf-generic.h b/include/linux/pinctrl/pinconf-generic.h
new file mode 100644
index 000000000000..4f0abb9f1c09
--- /dev/null
+++ b/include/linux/pinctrl/pinconf-generic.h
@@ -0,0 +1,114 @@
1/*
2 * Interface the generic pinconfig portions of the pinctrl subsystem
3 *
4 * Copyright (C) 2011 ST-Ericsson SA
5 * Written on behalf of Linaro for ST-Ericsson
6 * This interface is used in the core to keep track of pins.
7 *
8 * Author: Linus Walleij <linus.walleij@linaro.org>
9 *
10 * License terms: GNU General Public License (GPL) version 2
11 */
12#ifndef __LINUX_PINCTRL_PINCONF_GENERIC_H
13#define __LINUX_PINCTRL_PINCONF_GENERIC_H
14
15/*
16 * You shouldn't even be able to compile with these enums etc unless you're
17 * using generic pin config. That is why this is defined out.
18 */
19#ifdef CONFIG_GENERIC_PINCONF
20
21/**
22 * enum pin_config_param - possible pin configuration parameters
23 * @PIN_CONFIG_BIAS_DISABLE: disable any pin bias on the pin, a
24 * transition from say pull-up to pull-down implies that you disable
25 * pull-up in the process, this setting disables all biasing.
26 * @PIN_CONFIG_BIAS_HIGH_IMPEDANCE: the pin will be set to a high impedance
27 * mode, also know as "third-state" (tristate) or "high-Z" or "floating".
28 * On output pins this effectively disconnects the pin, which is useful
29 * if for example some other pin is going to drive the signal connected
30 * to it for a while. Pins used for input are usually always high
31 * impedance.
32 * @PIN_CONFIG_BIAS_PULL_UP: the pin will be pulled up (usually with high
33 * impedance to VDD). If the argument is != 0 pull-up is enabled,
34 * if it is 0, pull-up is disabled.
35 * @PIN_CONFIG_BIAS_PULL_DOWN: the pin will be pulled down (usually with high
36 * impedance to GROUND). If the argument is != 0 pull-down is enabled,
37 * if it is 0, pull-down is disabled.
38 * @PIN_CONFIG_DRIVE_PUSH_PULL: the pin will be driven actively high and
39 * low, this is the most typical case and is typically achieved with two
40 * active transistors on the output. Sending this config will enabale
41 * push-pull mode, the argument is ignored.
42 * @PIN_CONFIG_DRIVE_OPEN_DRAIN: the pin will be driven with open drain (open
43 * collector) which means it is usually wired with other output ports
44 * which are then pulled up with an external resistor. Sending this
45 * config will enabale open drain mode, the argument is ignored.
46 * @PIN_CONFIG_DRIVE_OPEN_SOURCE: the pin will be driven with open source
47 * (open emitter). Sending this config will enabale open drain mode, the
48 * argument is ignored.
49 * @PIN_CONFIG_INPUT_SCHMITT: this will configure an input pin to run in
50 * schmitt-trigger mode. If the schmitt-trigger has adjustable hysteresis,
51 * the threshold value is given on a custom format as argument when
52 * setting pins to this mode. The argument zero turns the schmitt trigger
53 * off.
54 * @PIN_CONFIG_INPUT_DEBOUNCE: this will configure the pin to debounce mode,
55 * which means it will wait for signals to settle when reading inputs. The
56 * argument gives the debounce time on a custom format. Setting the
57 * argument to zero turns debouncing off.
58 * @PIN_CONFIG_POWER_SOURCE: if the pin can select between different power
59 * supplies, the argument to this parameter (on a custom format) tells
60 * the driver which alternative power source to use.
61 * @PIN_CONFIG_LOW_POWER_MODE: this will configure the pin for low power
62 * operation, if several modes of operation are supported these can be
63 * passed in the argument on a custom form, else just use argument 1
64 * to indicate low power mode, argument 0 turns low power mode off.
65 * @PIN_CONFIG_END: this is the last enumerator for pin configurations, if
66 * you need to pass in custom configurations to the pin controller, use
67 * PIN_CONFIG_END+1 as the base offset.
68 */
69enum pin_config_param {
70 PIN_CONFIG_BIAS_DISABLE,
71 PIN_CONFIG_BIAS_HIGH_IMPEDANCE,
72 PIN_CONFIG_BIAS_PULL_UP,
73 PIN_CONFIG_BIAS_PULL_DOWN,
74 PIN_CONFIG_DRIVE_PUSH_PULL,
75 PIN_CONFIG_DRIVE_OPEN_DRAIN,
76 PIN_CONFIG_DRIVE_OPEN_SOURCE,
77 PIN_CONFIG_INPUT_SCHMITT,
78 PIN_CONFIG_INPUT_DEBOUNCE,
79 PIN_CONFIG_POWER_SOURCE,
80 PIN_CONFIG_LOW_POWER_MODE,
81 PIN_CONFIG_END = 0x7FFF,
82};
83
84/*
85 * Helpful configuration macro to be used in tables etc.
86 */
87#define PIN_CONF_PACKED(p, a) ((a << 16) | ((unsigned long) p & 0xffffUL))
88
89/*
90 * The following inlines stuffs a configuration parameter and data value
91 * into and out of an unsigned long argument, as used by the generic pin config
92 * system. We put the parameter in the lower 16 bits and the argument in the
93 * upper 16 bits.
94 */
95
96static inline enum pin_config_param pinconf_to_config_param(unsigned long config)
97{
98 return (enum pin_config_param) (config & 0xffffUL);
99}
100
101static inline u16 pinconf_to_config_argument(unsigned long config)
102{
103 return (enum pin_config_param) ((config >> 16) & 0xffffUL);
104}
105
106static inline unsigned long pinconf_to_config_packed(enum pin_config_param param,
107 u16 argument)
108{
109 return PIN_CONF_PACKED(param, argument);
110}
111
112#endif /* CONFIG_GENERIC_PINCONF */
113
114#endif /* __LINUX_PINCTRL_PINCONF_GENERIC_H */