xref: /rk3399_rockchip-uboot/doc/device-tree-bindings/pinctrl/pinctrl-bindings.txt (revision 386f9d4cdc1bf882b1c9fda58e195f3017bf3b71)
161101e05SSimon Glass== Introduction ==
261101e05SSimon Glass
361101e05SSimon GlassHardware modules that control pin multiplexing or configuration parameters
461101e05SSimon Glasssuch as pull-up/down, tri-state, drive-strength etc are designated as pin
561101e05SSimon Glasscontrollers. Each pin controller must be represented as a node in device tree,
661101e05SSimon Glassjust like any other hardware module.
761101e05SSimon Glass
861101e05SSimon GlassHardware modules whose signals are affected by pin configuration are
961101e05SSimon Glassdesignated client devices. Again, each client device must be represented as a
1061101e05SSimon Glassnode in device tree, just like any other hardware module.
1161101e05SSimon Glass
1261101e05SSimon GlassFor a client device to operate correctly, certain pin controllers must
1361101e05SSimon Glassset up certain specific pin configurations. Some client devices need a
1461101e05SSimon Glasssingle static pin configuration, e.g. set up during initialization. Others
1561101e05SSimon Glassneed to reconfigure pins at run-time, for example to tri-state pins when the
1661101e05SSimon Glassdevice is inactive. Hence, each client device can define a set of named
1761101e05SSimon Glassstates. The number and names of those states is defined by the client device's
1861101e05SSimon Glassown binding.
1961101e05SSimon Glass
2061101e05SSimon GlassThe common pinctrl bindings defined in this file provide an infrastructure
2161101e05SSimon Glassfor client device device tree nodes to map those state names to the pin
2261101e05SSimon Glassconfiguration used by those states.
2361101e05SSimon Glass
2461101e05SSimon GlassNote that pin controllers themselves may also be client devices of themselves.
2561101e05SSimon GlassFor example, a pin controller may set up its own "active" state when the
2661101e05SSimon Glassdriver loads. This would allow representing a board's static pin configuration
2761101e05SSimon Glassin a single place, rather than splitting it across multiple client device
2861101e05SSimon Glassnodes. The decision to do this or not somewhat rests with the author of
2961101e05SSimon Glassindividual board device tree files, and any requirements imposed by the
3061101e05SSimon Glassbindings for the individual client devices in use by that board, i.e. whether
3161101e05SSimon Glassthey require certain specific named states for dynamic pin configuration.
3261101e05SSimon Glass
3361101e05SSimon Glass== Pinctrl client devices ==
3461101e05SSimon Glass
3561101e05SSimon GlassFor each client device individually, every pin state is assigned an integer
3661101e05SSimon GlassID. These numbers start at 0, and are contiguous. For each state ID, a unique
3761101e05SSimon Glassproperty exists to define the pin configuration. Each state may also be
3861101e05SSimon Glassassigned a name. When names are used, another property exists to map from
3961101e05SSimon Glassthose names to the integer IDs.
4061101e05SSimon Glass
4161101e05SSimon GlassEach client device's own binding determines the set of states that must be
4261101e05SSimon Glassdefined in its device tree node, and whether to define the set of state
4361101e05SSimon GlassIDs that must be provided, or whether to define the set of state names that
4461101e05SSimon Glassmust be provided.
4561101e05SSimon Glass
4661101e05SSimon GlassRequired properties:
4761101e05SSimon Glasspinctrl-0:	List of phandles, each pointing at a pin configuration
4861101e05SSimon Glass		node. These referenced pin configuration nodes must be child
4961101e05SSimon Glass		nodes of the pin controller that they configure. Multiple
5061101e05SSimon Glass		entries may exist in this list so that multiple pin
5161101e05SSimon Glass		controllers may be configured, or so that a state may be built
5261101e05SSimon Glass		from multiple nodes for a single pin controller, each
5361101e05SSimon Glass		contributing part of the overall configuration. See the next
5461101e05SSimon Glass		section of this document for details of the format of these
5561101e05SSimon Glass		pin configuration nodes.
5661101e05SSimon Glass
5761101e05SSimon Glass		In some cases, it may be useful to define a state, but for it
5861101e05SSimon Glass		to be empty. This may be required when a common IP block is
5961101e05SSimon Glass		used in an SoC either without a pin controller, or where the
6061101e05SSimon Glass		pin controller does not affect the HW module in question. If
6161101e05SSimon Glass		the binding for that IP block requires certain pin states to
6261101e05SSimon Glass		exist, they must still be defined, but may be left empty.
6361101e05SSimon Glass
6461101e05SSimon GlassOptional properties:
6561101e05SSimon Glasspinctrl-1:	List of phandles, each pointing at a pin configuration
6661101e05SSimon Glass		node within a pin controller.
6761101e05SSimon Glass...
6861101e05SSimon Glasspinctrl-n:	List of phandles, each pointing at a pin configuration
6961101e05SSimon Glass		node within a pin controller.
7061101e05SSimon Glasspinctrl-names:	The list of names to assign states. List entry 0 defines the
7161101e05SSimon Glass		name for integer state ID 0, list entry 1 for state ID 1, and
7261101e05SSimon Glass		so on.
7361101e05SSimon Glass
7461101e05SSimon GlassFor example:
7561101e05SSimon Glass
7661101e05SSimon Glass	/* For a client device requiring named states */
7761101e05SSimon Glass	device {
7861101e05SSimon Glass		pinctrl-names = "active", "idle";
7961101e05SSimon Glass		pinctrl-0 = <&state_0_node_a>;
8061101e05SSimon Glass		pinctrl-1 = <&state_1_node_a &state_1_node_b>;
8161101e05SSimon Glass	};
8261101e05SSimon Glass
8361101e05SSimon Glass	/* For the same device if using state IDs */
8461101e05SSimon Glass	device {
8561101e05SSimon Glass		pinctrl-0 = <&state_0_node_a>;
8661101e05SSimon Glass		pinctrl-1 = <&state_1_node_a &state_1_node_b>;
8761101e05SSimon Glass	};
8861101e05SSimon Glass
8961101e05SSimon Glass	/*
9061101e05SSimon Glass	 * For an IP block whose binding supports pin configuration,
9161101e05SSimon Glass	 * but in use on an SoC that doesn't have any pin control hardware
9261101e05SSimon Glass	 */
9361101e05SSimon Glass	device {
9461101e05SSimon Glass		pinctrl-names = "active", "idle";
9561101e05SSimon Glass		pinctrl-0 = <>;
9661101e05SSimon Glass		pinctrl-1 = <>;
9761101e05SSimon Glass	};
9861101e05SSimon Glass
9961101e05SSimon Glass== Pin controller devices ==
10061101e05SSimon Glass
10161101e05SSimon GlassPin controller devices should contain the pin configuration nodes that client
10261101e05SSimon Glassdevices reference.
10361101e05SSimon Glass
10461101e05SSimon GlassFor example:
10561101e05SSimon Glass
10661101e05SSimon Glass	pincontroller {
10761101e05SSimon Glass		... /* Standard DT properties for the device itself elided */
10861101e05SSimon Glass
10961101e05SSimon Glass		state_0_node_a {
11061101e05SSimon Glass			...
11161101e05SSimon Glass		};
11261101e05SSimon Glass		state_1_node_a {
11361101e05SSimon Glass			...
11461101e05SSimon Glass		};
11561101e05SSimon Glass		state_1_node_b {
11661101e05SSimon Glass			...
11761101e05SSimon Glass		};
11861101e05SSimon Glass	}
11961101e05SSimon Glass
12061101e05SSimon GlassThe contents of each of those pin configuration child nodes is defined
12161101e05SSimon Glassentirely by the binding for the individual pin controller device. There
122*386f9d4cSSean Andersonexists no common standard for this content. The pinctrl framework only
123*386f9d4cSSean Andersonprovides generic helper bindings that the pin controller driver can use.
12461101e05SSimon Glass
12561101e05SSimon GlassThe pin configuration nodes need not be direct children of the pin controller
12661101e05SSimon Glassdevice; they may be grandchildren, for example. Whether this is legal, and
12761101e05SSimon Glasswhether there is any interaction between the child and intermediate parent
12861101e05SSimon Glassnodes, is again defined entirely by the binding for the individual pin
12961101e05SSimon Glasscontroller device.
13061101e05SSimon Glass
13161101e05SSimon Glass== Generic pin multiplexing node content ==
13261101e05SSimon Glass
13361101e05SSimon Glasspin multiplexing nodes:
13461101e05SSimon Glass
13561101e05SSimon Glassfunction		- the mux function to select
13661101e05SSimon Glassgroups			- the list of groups to select with this function
13761101e05SSimon Glass			  (either this or "pins" must be specified)
13861101e05SSimon Glasspins			- the list of pins to select with this function (either
13961101e05SSimon Glass			  this or "groups" must be specified)
14061101e05SSimon Glass
14161101e05SSimon GlassExample:
14261101e05SSimon Glass
14361101e05SSimon Glassstate_0_node_a {
14461101e05SSimon Glass	uart0 {
14561101e05SSimon Glass		function = "uart0";
14661101e05SSimon Glass		groups = "u0rxtx", "u0rtscts";
14761101e05SSimon Glass	};
14861101e05SSimon Glass};
14961101e05SSimon Glassstate_1_node_a {
15061101e05SSimon Glass	spi0 {
15161101e05SSimon Glass		function = "spi0";
15261101e05SSimon Glass		groups = "spi0pins";
15361101e05SSimon Glass	};
15461101e05SSimon Glass};
15561101e05SSimon Glassstate_2_node_a {
15661101e05SSimon Glass	function = "i2c0";
15761101e05SSimon Glass	pins = "mfio29", "mfio30";
15861101e05SSimon Glass};
15961101e05SSimon Glass
160*386f9d4cSSean AndersonFor hardware where pin multiplexing configurations have to be specified for
161*386f9d4cSSean Andersoneach single pin the number of required sub-nodes containing "pin" and
162*386f9d4cSSean Anderson"function" properties can quickly escalate and become hard to write and
163*386f9d4cSSean Andersonmaintain.
164*386f9d4cSSean Anderson
165*386f9d4cSSean AndersonFor cases like this, the pin controller driver may use the pinmux helper
166*386f9d4cSSean Andersonproperty, where the pin identifier is provided with mux configuration settings
167*386f9d4cSSean Andersonin a pinmux group. A pinmux group consists of the pin identifier and mux
168*386f9d4cSSean Andersonsettings represented as a single integer or an array of integers.
169*386f9d4cSSean Anderson
170*386f9d4cSSean AndersonThe pinmux property accepts an array of pinmux groups, each of them describing
171*386f9d4cSSean Andersona single pin multiplexing configuration.
172*386f9d4cSSean Anderson
173*386f9d4cSSean Andersonpincontroller {
174*386f9d4cSSean Anderson	state_0_node_a {
175*386f9d4cSSean Anderson		pinmux = <PINMUX_GROUP>, <PINMUX_GROUP>, ...;
176*386f9d4cSSean Anderson	};
177*386f9d4cSSean Anderson};
178*386f9d4cSSean Anderson
179*386f9d4cSSean AndersonEach individual pin controller driver bindings documentation shall specify
180*386f9d4cSSean Andersonhow pin IDs and pin multiplexing configuration are defined and assembled
181*386f9d4cSSean Andersontogether in a pinmux group.
182*386f9d4cSSean Anderson
18361101e05SSimon Glass== Generic pin configuration node content ==
18461101e05SSimon Glass
18561101e05SSimon GlassMany data items that are represented in a pin configuration node are common
18661101e05SSimon Glassand generic. Pin control bindings should use the properties defined below
18761101e05SSimon Glasswhere they are applicable; not all of these properties are relevant or useful
18861101e05SSimon Glassfor all hardware or binding structures. Each individual binding document
18961101e05SSimon Glassshould state which of these generic properties, if any, are used, and the
19061101e05SSimon Glassstructure of the DT nodes that contain these properties.
19161101e05SSimon Glass
19261101e05SSimon GlassSupported generic properties are:
19361101e05SSimon Glass
19461101e05SSimon Glasspins			- the list of pins that properties in the node
195*386f9d4cSSean Anderson			  apply to (either this, "group" or "pinmux" has to be
19661101e05SSimon Glass			  specified)
19761101e05SSimon Glassgroup			- the group to apply the properties to, if the driver
19861101e05SSimon Glass			  supports configuration of whole groups rather than
199*386f9d4cSSean Anderson			  individual pins (either this, "pins" or "pinmux" has
200*386f9d4cSSean Anderson			  to be specified)
201*386f9d4cSSean Andersonpinmux			- the list of numeric pin ids and their mux settings
202*386f9d4cSSean Anderson			  that properties in the node apply to (either this,
203*386f9d4cSSean Anderson			  "pins" or "groups" have to be specified)
20461101e05SSimon Glassbias-disable		- disable any pin bias
20561101e05SSimon Glassbias-high-impedance	- high impedance mode ("third-state", "floating")
20661101e05SSimon Glassbias-bus-hold		- latch weakly
20761101e05SSimon Glassbias-pull-up		- pull up the pin
20861101e05SSimon Glassbias-pull-down		- pull down the pin
20961101e05SSimon Glassbias-pull-pin-default	- use pin-default pull state
21061101e05SSimon Glassdrive-push-pull		- drive actively high and low
21161101e05SSimon Glassdrive-open-drain	- drive with open drain
21261101e05SSimon Glassdrive-open-source	- drive with open source
21361101e05SSimon Glassdrive-strength		- sink or source at most X mA
214*386f9d4cSSean Andersondrive-strength-microamp	- sink or source at most X uA
215*386f9d4cSSean Andersoninput-enable		- enable input on pin (no effect on output, such as
216*386f9d4cSSean Anderson			  enabling an input buffer)
217*386f9d4cSSean Andersoninput-disable		- disable input on pin (no effect on output, such as
218*386f9d4cSSean Anderson			  disabling an input buffer)
21961101e05SSimon Glassinput-schmitt-enable	- enable schmitt-trigger mode
22061101e05SSimon Glassinput-schmitt-disable	- disable schmitt-trigger mode
22161101e05SSimon Glassinput-debounce		- debounce mode with debound time X
22261101e05SSimon Glasspower-source		- select between different power supplies
22361101e05SSimon Glasslow-power-enable	- enable low power mode
22461101e05SSimon Glasslow-power-disable	- disable low power mode
225*386f9d4cSSean Andersonoutput-disable		- disable output on a pin (such as disable an output
226*386f9d4cSSean Anderson			  buffer)
227*386f9d4cSSean Andersonoutput-enable		- enable output on a pin without actively driving it
228*386f9d4cSSean Anderson			  (such as enabling an output buffer)
22961101e05SSimon Glassoutput-low		- set the pin to output mode with low level
23061101e05SSimon Glassoutput-high		- set the pin to output mode with high level
231*386f9d4cSSean Andersonsleep-hardware-state	- indicate this is sleep related state which will be programmed
232*386f9d4cSSean Anderson			  into the registers for the sleep state.
23361101e05SSimon Glassslew-rate		- set the slew rate
234*386f9d4cSSean Andersonskew-delay		- this affects the expected clock skew on input pins
235*386f9d4cSSean Anderson			  and the delay before latching a value to an output
236*386f9d4cSSean Anderson			  pin. Typically indicates how many double-inverters are
237*386f9d4cSSean Anderson			  used to delay the signal.
23861101e05SSimon Glass
23961101e05SSimon GlassFor example:
24061101e05SSimon Glass
24161101e05SSimon Glassstate_0_node_a {
24261101e05SSimon Glass	cts_rxd {
24361101e05SSimon Glass		pins = "GPIO0_AJ5", "GPIO2_AH4"; /* CTS+RXD */
24461101e05SSimon Glass		bias-pull-up;
24561101e05SSimon Glass	};
24661101e05SSimon Glass};
24761101e05SSimon Glassstate_1_node_a {
24861101e05SSimon Glass	rts_txd {
24961101e05SSimon Glass		pins = "GPIO1_AJ3", "GPIO3_AH3"; /* RTS+TXD */
25061101e05SSimon Glass		output-high;
25161101e05SSimon Glass	};
25261101e05SSimon Glass};
25361101e05SSimon Glassstate_2_node_a {
25461101e05SSimon Glass	foo {
25561101e05SSimon Glass		group = "foo-group";
25661101e05SSimon Glass		bias-pull-up;
25761101e05SSimon Glass	};
25861101e05SSimon Glass};
259*386f9d4cSSean Andersonstate_3_node_a {
260*386f9d4cSSean Anderson	mux {
261*386f9d4cSSean Anderson		pinmux = <GPIOx_PINm_MUXn>, <GPIOx_PINj_MUXk)>;
262*386f9d4cSSean Anderson		input-enable;
263*386f9d4cSSean Anderson	};
264*386f9d4cSSean Anderson};
26561101e05SSimon Glass
26661101e05SSimon GlassSome of the generic properties take arguments. For those that do, the
26761101e05SSimon Glassarguments are described below.
26861101e05SSimon Glass
26961101e05SSimon Glass- pins takes a list of pin names or IDs as a required argument. The specific
27061101e05SSimon Glass  binding for the hardware defines:
27161101e05SSimon Glass  - Whether the entries are integers or strings, and their meaning.
27261101e05SSimon Glass
273*386f9d4cSSean Anderson- pinmux takes a list of pin IDs and mux settings as required argument. The
274*386f9d4cSSean Anderson  specific bindings for the hardware defines:
275*386f9d4cSSean Anderson  - How pin IDs and mux settings are defined and assembled together in a single
276*386f9d4cSSean Anderson    integer or an array of integers.
277*386f9d4cSSean Anderson
27861101e05SSimon Glass- bias-pull-up, -down and -pin-default take as optional argument on hardware
27961101e05SSimon Glass  supporting it the pull strength in Ohm. bias-disable will disable the pull.
28061101e05SSimon Glass
28161101e05SSimon Glass- drive-strength takes as argument the target strength in mA.
28261101e05SSimon Glass
283*386f9d4cSSean Anderson- drive-strength-microamp takes as argument the target strength in uA.
284*386f9d4cSSean Anderson
28561101e05SSimon Glass- input-debounce takes the debounce time in usec as argument
28661101e05SSimon Glass  or 0 to disable debouncing
28761101e05SSimon Glass
28861101e05SSimon GlassMore in-depth documentation on these parameters can be found in
28961101e05SSimon Glass<include/linux/pinctrl/pinconf-generic.h>
290