Commit | Line | Data |
---|---|---|
394349f7 LW |
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. | |
a2df4269 JH |
32 | * @PIN_CONFIG_BIAS_BUS_HOLD: the pin will be set to weakly latch so that it |
33 | * weakly drives the last value on a tristate bus, also known as a "bus | |
34 | * holder", "bus keeper" or "repeater". This allows another device on the | |
35 | * bus to change the value by driving the bus high or low and switching to | |
36 | * tristate. The argument is ignored. | |
394349f7 LW |
37 | * @PIN_CONFIG_BIAS_PULL_UP: the pin will be pulled up (usually with high |
38 | * impedance to VDD). If the argument is != 0 pull-up is enabled, | |
39 | * if it is 0, pull-up is disabled. | |
40 | * @PIN_CONFIG_BIAS_PULL_DOWN: the pin will be pulled down (usually with high | |
41 | * impedance to GROUND). If the argument is != 0 pull-down is enabled, | |
42 | * if it is 0, pull-down is disabled. | |
7970cb77 HS |
43 | * @PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: the pin will be pulled up or down based |
44 | * on embedded knowledge of the controller, like current mux function. | |
45 | * If the argument is != 0 pull up/down is enabled, if it is 0, | |
46 | * the pull is disabled. | |
394349f7 LW |
47 | * @PIN_CONFIG_DRIVE_PUSH_PULL: the pin will be driven actively high and |
48 | * low, this is the most typical case and is typically achieved with two | |
63ad9cbf | 49 | * active transistors on the output. Setting this config will enable |
394349f7 LW |
50 | * push-pull mode, the argument is ignored. |
51 | * @PIN_CONFIG_DRIVE_OPEN_DRAIN: the pin will be driven with open drain (open | |
52 | * collector) which means it is usually wired with other output ports | |
63ad9cbf LP |
53 | * which are then pulled up with an external resistor. Setting this |
54 | * config will enable open drain mode, the argument is ignored. | |
394349f7 | 55 | * @PIN_CONFIG_DRIVE_OPEN_SOURCE: the pin will be driven with open source |
63ad9cbf | 56 | * (open emitter). Setting this config will enable open drain mode, the |
394349f7 | 57 | * argument is ignored. |
63ad9cbf LP |
58 | * @PIN_CONFIG_DRIVE_STRENGTH: the pin will sink or source at most the current |
59 | * passed as argument. The argument is in mA. | |
ea27c396 HZ |
60 | * @PIN_CONFIG_INPUT_SCHMITT_ENABLE: control schmitt-trigger mode on the pin. |
61 | * If the argument != 0, schmitt-trigger mode is enabled. If it's 0, | |
62 | * schmitt-trigger mode is disabled. | |
394349f7 LW |
63 | * @PIN_CONFIG_INPUT_SCHMITT: this will configure an input pin to run in |
64 | * schmitt-trigger mode. If the schmitt-trigger has adjustable hysteresis, | |
65 | * the threshold value is given on a custom format as argument when | |
2ccb0bcf | 66 | * setting pins to this mode. |
394349f7 LW |
67 | * @PIN_CONFIG_INPUT_DEBOUNCE: this will configure the pin to debounce mode, |
68 | * which means it will wait for signals to settle when reading inputs. The | |
69 | * argument gives the debounce time on a custom format. Setting the | |
70 | * argument to zero turns debouncing off. | |
71 | * @PIN_CONFIG_POWER_SOURCE: if the pin can select between different power | |
72 | * supplies, the argument to this parameter (on a custom format) tells | |
73 | * the driver which alternative power source to use. | |
684697cb HZ |
74 | * @PIN_CONFIG_SLEW_RATE: if the pin can select slew rate, the argument to |
75 | * this parameter (on a custom format) tells the driver which alternative | |
76 | * slew rate to use. | |
394349f7 LW |
77 | * @PIN_CONFIG_LOW_POWER_MODE: this will configure the pin for low power |
78 | * operation, if several modes of operation are supported these can be | |
79 | * passed in the argument on a custom form, else just use argument 1 | |
80 | * to indicate low power mode, argument 0 turns low power mode off. | |
483f33f6 LW |
81 | * @PIN_CONFIG_OUTPUT: this will configure the pin in output, use argument |
82 | * 1 to indicate high level, argument 0 to indicate low level. | |
394349f7 LW |
83 | * @PIN_CONFIG_END: this is the last enumerator for pin configurations, if |
84 | * you need to pass in custom configurations to the pin controller, use | |
85 | * PIN_CONFIG_END+1 as the base offset. | |
86 | */ | |
87 | enum pin_config_param { | |
88 | PIN_CONFIG_BIAS_DISABLE, | |
89 | PIN_CONFIG_BIAS_HIGH_IMPEDANCE, | |
a2df4269 | 90 | PIN_CONFIG_BIAS_BUS_HOLD, |
394349f7 LW |
91 | PIN_CONFIG_BIAS_PULL_UP, |
92 | PIN_CONFIG_BIAS_PULL_DOWN, | |
7970cb77 | 93 | PIN_CONFIG_BIAS_PULL_PIN_DEFAULT, |
394349f7 LW |
94 | PIN_CONFIG_DRIVE_PUSH_PULL, |
95 | PIN_CONFIG_DRIVE_OPEN_DRAIN, | |
96 | PIN_CONFIG_DRIVE_OPEN_SOURCE, | |
f868ef99 | 97 | PIN_CONFIG_DRIVE_STRENGTH, |
ea27c396 | 98 | PIN_CONFIG_INPUT_SCHMITT_ENABLE, |
394349f7 LW |
99 | PIN_CONFIG_INPUT_SCHMITT, |
100 | PIN_CONFIG_INPUT_DEBOUNCE, | |
101 | PIN_CONFIG_POWER_SOURCE, | |
684697cb | 102 | PIN_CONFIG_SLEW_RATE, |
394349f7 | 103 | PIN_CONFIG_LOW_POWER_MODE, |
483f33f6 | 104 | PIN_CONFIG_OUTPUT, |
394349f7 LW |
105 | PIN_CONFIG_END = 0x7FFF, |
106 | }; | |
107 | ||
108 | /* | |
109 | * Helpful configuration macro to be used in tables etc. | |
110 | */ | |
111 | #define PIN_CONF_PACKED(p, a) ((a << 16) | ((unsigned long) p & 0xffffUL)) | |
112 | ||
113 | /* | |
114 | * The following inlines stuffs a configuration parameter and data value | |
115 | * into and out of an unsigned long argument, as used by the generic pin config | |
116 | * system. We put the parameter in the lower 16 bits and the argument in the | |
117 | * upper 16 bits. | |
118 | */ | |
119 | ||
120 | static inline enum pin_config_param pinconf_to_config_param(unsigned long config) | |
121 | { | |
122 | return (enum pin_config_param) (config & 0xffffUL); | |
123 | } | |
124 | ||
125 | static inline u16 pinconf_to_config_argument(unsigned long config) | |
126 | { | |
127 | return (enum pin_config_param) ((config >> 16) & 0xffffUL); | |
128 | } | |
129 | ||
130 | static inline unsigned long pinconf_to_config_packed(enum pin_config_param param, | |
131 | u16 argument) | |
132 | { | |
133 | return PIN_CONF_PACKED(param, argument); | |
134 | } | |
135 | ||
136 | #endif /* CONFIG_GENERIC_PINCONF */ | |
137 | ||
138 | #endif /* __LINUX_PINCTRL_PINCONF_GENERIC_H */ |