Simon Glass | dea7f2e | 2016-01-21 19:43:28 -0700 | [diff] [blame] | 1 | == Introduction == |
| 2 | |
| 3 | Hardware modules that control pin multiplexing or configuration parameters |
| 4 | such as pull-up/down, tri-state, drive-strength etc are designated as pin |
| 5 | controllers. Each pin controller must be represented as a node in device tree, |
| 6 | just like any other hardware module. |
| 7 | |
| 8 | Hardware modules whose signals are affected by pin configuration are |
| 9 | designated client devices. Again, each client device must be represented as a |
| 10 | node in device tree, just like any other hardware module. |
| 11 | |
| 12 | For a client device to operate correctly, certain pin controllers must |
| 13 | set up certain specific pin configurations. Some client devices need a |
| 14 | single static pin configuration, e.g. set up during initialization. Others |
| 15 | need to reconfigure pins at run-time, for example to tri-state pins when the |
| 16 | device is inactive. Hence, each client device can define a set of named |
| 17 | states. The number and names of those states is defined by the client device's |
| 18 | own binding. |
| 19 | |
| 20 | The common pinctrl bindings defined in this file provide an infrastructure |
| 21 | for client device device tree nodes to map those state names to the pin |
| 22 | configuration used by those states. |
| 23 | |
| 24 | Note that pin controllers themselves may also be client devices of themselves. |
| 25 | For example, a pin controller may set up its own "active" state when the |
| 26 | driver loads. This would allow representing a board's static pin configuration |
| 27 | in a single place, rather than splitting it across multiple client device |
| 28 | nodes. The decision to do this or not somewhat rests with the author of |
| 29 | individual board device tree files, and any requirements imposed by the |
| 30 | bindings for the individual client devices in use by that board, i.e. whether |
| 31 | they require certain specific named states for dynamic pin configuration. |
| 32 | |
| 33 | == Pinctrl client devices == |
| 34 | |
| 35 | For each client device individually, every pin state is assigned an integer |
| 36 | ID. These numbers start at 0, and are contiguous. For each state ID, a unique |
| 37 | property exists to define the pin configuration. Each state may also be |
| 38 | assigned a name. When names are used, another property exists to map from |
| 39 | those names to the integer IDs. |
| 40 | |
| 41 | Each client device's own binding determines the set of states that must be |
| 42 | defined in its device tree node, and whether to define the set of state |
| 43 | IDs that must be provided, or whether to define the set of state names that |
| 44 | must be provided. |
| 45 | |
| 46 | Required properties: |
| 47 | pinctrl-0: List of phandles, each pointing at a pin configuration |
| 48 | node. These referenced pin configuration nodes must be child |
| 49 | nodes of the pin controller that they configure. Multiple |
| 50 | entries may exist in this list so that multiple pin |
| 51 | controllers may be configured, or so that a state may be built |
| 52 | from multiple nodes for a single pin controller, each |
| 53 | contributing part of the overall configuration. See the next |
| 54 | section of this document for details of the format of these |
| 55 | pin configuration nodes. |
| 56 | |
| 57 | In some cases, it may be useful to define a state, but for it |
| 58 | to be empty. This may be required when a common IP block is |
| 59 | used in an SoC either without a pin controller, or where the |
| 60 | pin controller does not affect the HW module in question. If |
| 61 | the binding for that IP block requires certain pin states to |
| 62 | exist, they must still be defined, but may be left empty. |
| 63 | |
| 64 | Optional properties: |
| 65 | pinctrl-1: List of phandles, each pointing at a pin configuration |
| 66 | node within a pin controller. |
| 67 | ... |
| 68 | pinctrl-n: List of phandles, each pointing at a pin configuration |
| 69 | node within a pin controller. |
| 70 | pinctrl-names: The list of names to assign states. List entry 0 defines the |
| 71 | name for integer state ID 0, list entry 1 for state ID 1, and |
| 72 | so on. |
| 73 | |
| 74 | For example: |
| 75 | |
| 76 | /* For a client device requiring named states */ |
| 77 | device { |
| 78 | pinctrl-names = "active", "idle"; |
| 79 | pinctrl-0 = <&state_0_node_a>; |
| 80 | pinctrl-1 = <&state_1_node_a &state_1_node_b>; |
| 81 | }; |
| 82 | |
| 83 | /* For the same device if using state IDs */ |
| 84 | device { |
| 85 | pinctrl-0 = <&state_0_node_a>; |
| 86 | pinctrl-1 = <&state_1_node_a &state_1_node_b>; |
| 87 | }; |
| 88 | |
| 89 | /* |
| 90 | * For an IP block whose binding supports pin configuration, |
| 91 | * but in use on an SoC that doesn't have any pin control hardware |
| 92 | */ |
| 93 | device { |
| 94 | pinctrl-names = "active", "idle"; |
| 95 | pinctrl-0 = <>; |
| 96 | pinctrl-1 = <>; |
| 97 | }; |
| 98 | |
| 99 | == Pin controller devices == |
| 100 | |
| 101 | Pin controller devices should contain the pin configuration nodes that client |
| 102 | devices reference. |
| 103 | |
| 104 | For example: |
| 105 | |
| 106 | pincontroller { |
| 107 | ... /* Standard DT properties for the device itself elided */ |
| 108 | |
| 109 | state_0_node_a { |
| 110 | ... |
| 111 | }; |
| 112 | state_1_node_a { |
| 113 | ... |
| 114 | }; |
| 115 | state_1_node_b { |
| 116 | ... |
| 117 | }; |
| 118 | } |
| 119 | |
| 120 | The contents of each of those pin configuration child nodes is defined |
| 121 | entirely by the binding for the individual pin controller device. There |
Sean Anderson | 319ca70 | 2020-09-14 11:01:55 -0400 | [diff] [blame] | 122 | exists no common standard for this content. The pinctrl framework only |
| 123 | provides generic helper bindings that the pin controller driver can use. |
Simon Glass | dea7f2e | 2016-01-21 19:43:28 -0700 | [diff] [blame] | 124 | |
| 125 | The pin configuration nodes need not be direct children of the pin controller |
| 126 | device; they may be grandchildren, for example. Whether this is legal, and |
| 127 | whether there is any interaction between the child and intermediate parent |
| 128 | nodes, is again defined entirely by the binding for the individual pin |
| 129 | controller device. |
| 130 | |
| 131 | == Generic pin multiplexing node content == |
| 132 | |
| 133 | pin multiplexing nodes: |
| 134 | |
| 135 | function - the mux function to select |
| 136 | groups - the list of groups to select with this function |
| 137 | (either this or "pins" must be specified) |
| 138 | pins - the list of pins to select with this function (either |
| 139 | this or "groups" must be specified) |
| 140 | |
| 141 | Example: |
| 142 | |
| 143 | state_0_node_a { |
| 144 | uart0 { |
| 145 | function = "uart0"; |
| 146 | groups = "u0rxtx", "u0rtscts"; |
| 147 | }; |
| 148 | }; |
| 149 | state_1_node_a { |
| 150 | spi0 { |
| 151 | function = "spi0"; |
| 152 | groups = "spi0pins"; |
| 153 | }; |
| 154 | }; |
| 155 | state_2_node_a { |
| 156 | function = "i2c0"; |
| 157 | pins = "mfio29", "mfio30"; |
| 158 | }; |
| 159 | |
Sean Anderson | 319ca70 | 2020-09-14 11:01:55 -0400 | [diff] [blame] | 160 | For hardware where pin multiplexing configurations have to be specified for |
| 161 | each single pin the number of required sub-nodes containing "pin" and |
| 162 | "function" properties can quickly escalate and become hard to write and |
| 163 | maintain. |
| 164 | |
| 165 | For cases like this, the pin controller driver may use the pinmux helper |
| 166 | property, where the pin identifier is provided with mux configuration settings |
| 167 | in a pinmux group. A pinmux group consists of the pin identifier and mux |
| 168 | settings represented as a single integer or an array of integers. |
| 169 | |
| 170 | The pinmux property accepts an array of pinmux groups, each of them describing |
| 171 | a single pin multiplexing configuration. |
| 172 | |
| 173 | pincontroller { |
| 174 | state_0_node_a { |
| 175 | pinmux = <PINMUX_GROUP>, <PINMUX_GROUP>, ...; |
| 176 | }; |
| 177 | }; |
| 178 | |
| 179 | Each individual pin controller driver bindings documentation shall specify |
| 180 | how pin IDs and pin multiplexing configuration are defined and assembled |
| 181 | together in a pinmux group. |
| 182 | |
Simon Glass | dea7f2e | 2016-01-21 19:43:28 -0700 | [diff] [blame] | 183 | == Generic pin configuration node content == |
| 184 | |
| 185 | Many data items that are represented in a pin configuration node are common |
| 186 | and generic. Pin control bindings should use the properties defined below |
| 187 | where they are applicable; not all of these properties are relevant or useful |
| 188 | for all hardware or binding structures. Each individual binding document |
| 189 | should state which of these generic properties, if any, are used, and the |
| 190 | structure of the DT nodes that contain these properties. |
| 191 | |
| 192 | Supported generic properties are: |
| 193 | |
| 194 | pins - the list of pins that properties in the node |
Sean Anderson | 319ca70 | 2020-09-14 11:01:55 -0400 | [diff] [blame] | 195 | apply to (either this, "group" or "pinmux" has to be |
Simon Glass | dea7f2e | 2016-01-21 19:43:28 -0700 | [diff] [blame] | 196 | specified) |
| 197 | group - the group to apply the properties to, if the driver |
| 198 | supports configuration of whole groups rather than |
Sean Anderson | 319ca70 | 2020-09-14 11:01:55 -0400 | [diff] [blame] | 199 | individual pins (either this, "pins" or "pinmux" has |
| 200 | to be specified) |
| 201 | pinmux - the list of numeric pin ids and their mux settings |
| 202 | that properties in the node apply to (either this, |
| 203 | "pins" or "groups" have to be specified) |
Simon Glass | dea7f2e | 2016-01-21 19:43:28 -0700 | [diff] [blame] | 204 | bias-disable - disable any pin bias |
| 205 | bias-high-impedance - high impedance mode ("third-state", "floating") |
| 206 | bias-bus-hold - latch weakly |
| 207 | bias-pull-up - pull up the pin |
| 208 | bias-pull-down - pull down the pin |
| 209 | bias-pull-pin-default - use pin-default pull state |
| 210 | drive-push-pull - drive actively high and low |
| 211 | drive-open-drain - drive with open drain |
| 212 | drive-open-source - drive with open source |
| 213 | drive-strength - sink or source at most X mA |
Sean Anderson | 319ca70 | 2020-09-14 11:01:55 -0400 | [diff] [blame] | 214 | drive-strength-microamp - sink or source at most X uA |
| 215 | input-enable - enable input on pin (no effect on output, such as |
| 216 | enabling an input buffer) |
| 217 | input-disable - disable input on pin (no effect on output, such as |
| 218 | disabling an input buffer) |
Simon Glass | dea7f2e | 2016-01-21 19:43:28 -0700 | [diff] [blame] | 219 | input-schmitt-enable - enable schmitt-trigger mode |
| 220 | input-schmitt-disable - disable schmitt-trigger mode |
| 221 | input-debounce - debounce mode with debound time X |
| 222 | power-source - select between different power supplies |
| 223 | low-power-enable - enable low power mode |
| 224 | low-power-disable - disable low power mode |
Sean Anderson | 319ca70 | 2020-09-14 11:01:55 -0400 | [diff] [blame] | 225 | output-disable - disable output on a pin (such as disable an output |
| 226 | buffer) |
| 227 | output-enable - enable output on a pin without actively driving it |
| 228 | (such as enabling an output buffer) |
Simon Glass | dea7f2e | 2016-01-21 19:43:28 -0700 | [diff] [blame] | 229 | output-low - set the pin to output mode with low level |
| 230 | output-high - set the pin to output mode with high level |
Sean Anderson | 319ca70 | 2020-09-14 11:01:55 -0400 | [diff] [blame] | 231 | sleep-hardware-state - indicate this is sleep related state which will be programmed |
| 232 | into the registers for the sleep state. |
Simon Glass | dea7f2e | 2016-01-21 19:43:28 -0700 | [diff] [blame] | 233 | slew-rate - set the slew rate |
Sean Anderson | 319ca70 | 2020-09-14 11:01:55 -0400 | [diff] [blame] | 234 | skew-delay - this affects the expected clock skew on input pins |
| 235 | and the delay before latching a value to an output |
| 236 | pin. Typically indicates how many double-inverters are |
| 237 | used to delay the signal. |
Simon Glass | dea7f2e | 2016-01-21 19:43:28 -0700 | [diff] [blame] | 238 | |
| 239 | For example: |
| 240 | |
| 241 | state_0_node_a { |
| 242 | cts_rxd { |
| 243 | pins = "GPIO0_AJ5", "GPIO2_AH4"; /* CTS+RXD */ |
| 244 | bias-pull-up; |
| 245 | }; |
| 246 | }; |
| 247 | state_1_node_a { |
| 248 | rts_txd { |
| 249 | pins = "GPIO1_AJ3", "GPIO3_AH3"; /* RTS+TXD */ |
| 250 | output-high; |
| 251 | }; |
| 252 | }; |
| 253 | state_2_node_a { |
| 254 | foo { |
| 255 | group = "foo-group"; |
| 256 | bias-pull-up; |
| 257 | }; |
| 258 | }; |
Sean Anderson | 319ca70 | 2020-09-14 11:01:55 -0400 | [diff] [blame] | 259 | state_3_node_a { |
| 260 | mux { |
| 261 | pinmux = <GPIOx_PINm_MUXn>, <GPIOx_PINj_MUXk)>; |
| 262 | input-enable; |
| 263 | }; |
| 264 | }; |
Simon Glass | dea7f2e | 2016-01-21 19:43:28 -0700 | [diff] [blame] | 265 | |
| 266 | Some of the generic properties take arguments. For those that do, the |
| 267 | arguments are described below. |
| 268 | |
| 269 | - pins takes a list of pin names or IDs as a required argument. The specific |
| 270 | binding for the hardware defines: |
| 271 | - Whether the entries are integers or strings, and their meaning. |
| 272 | |
Sean Anderson | 319ca70 | 2020-09-14 11:01:55 -0400 | [diff] [blame] | 273 | - pinmux takes a list of pin IDs and mux settings as required argument. The |
| 274 | specific bindings for the hardware defines: |
| 275 | - How pin IDs and mux settings are defined and assembled together in a single |
| 276 | integer or an array of integers. |
| 277 | |
Simon Glass | dea7f2e | 2016-01-21 19:43:28 -0700 | [diff] [blame] | 278 | - bias-pull-up, -down and -pin-default take as optional argument on hardware |
| 279 | supporting it the pull strength in Ohm. bias-disable will disable the pull. |
| 280 | |
| 281 | - drive-strength takes as argument the target strength in mA. |
| 282 | |
Sean Anderson | 319ca70 | 2020-09-14 11:01:55 -0400 | [diff] [blame] | 283 | - drive-strength-microamp takes as argument the target strength in uA. |
| 284 | |
Simon Glass | dea7f2e | 2016-01-21 19:43:28 -0700 | [diff] [blame] | 285 | - input-debounce takes the debounce time in usec as argument |
| 286 | or 0 to disable debouncing |
| 287 | |
| 288 | More in-depth documentation on these parameters can be found in |
| 289 | <include/linux/pinctrl/pinconf-generic.h> |