162306a36Sopenharmony_ci== Introduction ==
262306a36Sopenharmony_ci
362306a36Sopenharmony_ciHardware modules that control pin multiplexing or configuration parameters
462306a36Sopenharmony_cisuch as pull-up/down, tri-state, drive-strength etc are designated as pin
562306a36Sopenharmony_cicontrollers. Each pin controller must be represented as a node in device tree,
662306a36Sopenharmony_cijust like any other hardware module.
762306a36Sopenharmony_ci
862306a36Sopenharmony_ciHardware modules whose signals are affected by pin configuration are
962306a36Sopenharmony_cidesignated client devices. Again, each client device must be represented as a
1062306a36Sopenharmony_cinode in device tree, just like any other hardware module.
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ciFor a client device to operate correctly, certain pin controllers must
1362306a36Sopenharmony_ciset up certain specific pin configurations. Some client devices need a
1462306a36Sopenharmony_cisingle static pin configuration, e.g. set up during initialization. Others
1562306a36Sopenharmony_cineed to reconfigure pins at run-time, for example to tri-state pins when the
1662306a36Sopenharmony_cidevice is inactive. Hence, each client device can define a set of named
1762306a36Sopenharmony_cistates. The number and names of those states is defined by the client device's
1862306a36Sopenharmony_ciown binding.
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ciThe common pinctrl bindings defined in this file provide an infrastructure
2162306a36Sopenharmony_cifor client device device tree nodes to map those state names to the pin
2262306a36Sopenharmony_ciconfiguration used by those states.
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ciNote that pin controllers themselves may also be client devices of themselves.
2562306a36Sopenharmony_ciFor example, a pin controller may set up its own "active" state when the
2662306a36Sopenharmony_cidriver loads. This would allow representing a board's static pin configuration
2762306a36Sopenharmony_ciin a single place, rather than splitting it across multiple client device
2862306a36Sopenharmony_cinodes. The decision to do this or not somewhat rests with the author of
2962306a36Sopenharmony_ciindividual board device tree files, and any requirements imposed by the
3062306a36Sopenharmony_cibindings for the individual client devices in use by that board, i.e. whether
3162306a36Sopenharmony_cithey require certain specific named states for dynamic pin configuration.
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci== Pinctrl client devices ==
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ciFor each client device individually, every pin state is assigned an integer
3662306a36Sopenharmony_ciID. These numbers start at 0, and are contiguous. For each state ID, a unique
3762306a36Sopenharmony_ciproperty exists to define the pin configuration. Each state may also be
3862306a36Sopenharmony_ciassigned a name. When names are used, another property exists to map from
3962306a36Sopenharmony_cithose names to the integer IDs.
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ciEach client device's own binding determines the set of states that must be
4262306a36Sopenharmony_cidefined in its device tree node, and whether to define the set of state
4362306a36Sopenharmony_ciIDs that must be provided, or whether to define the set of state names that
4462306a36Sopenharmony_cimust be provided.
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ciRequired properties:
4762306a36Sopenharmony_cipinctrl-0:	List of phandles, each pointing at a pin configuration
4862306a36Sopenharmony_ci		node. These referenced pin configuration nodes must be child
4962306a36Sopenharmony_ci		nodes of the pin controller that they configure. Multiple
5062306a36Sopenharmony_ci		entries may exist in this list so that multiple pin
5162306a36Sopenharmony_ci		controllers may be configured, or so that a state may be built
5262306a36Sopenharmony_ci		from multiple nodes for a single pin controller, each
5362306a36Sopenharmony_ci		contributing part of the overall configuration. See the next
5462306a36Sopenharmony_ci		section of this document for details of the format of these
5562306a36Sopenharmony_ci		pin configuration nodes.
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci		In some cases, it may be useful to define a state, but for it
5862306a36Sopenharmony_ci		to be empty. This may be required when a common IP block is
5962306a36Sopenharmony_ci		used in an SoC either without a pin controller, or where the
6062306a36Sopenharmony_ci		pin controller does not affect the HW module in question. If
6162306a36Sopenharmony_ci		the binding for that IP block requires certain pin states to
6262306a36Sopenharmony_ci		exist, they must still be defined, but may be left empty.
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ciOptional properties:
6562306a36Sopenharmony_cipinctrl-1:	List of phandles, each pointing at a pin configuration
6662306a36Sopenharmony_ci		node within a pin controller.
6762306a36Sopenharmony_ci...
6862306a36Sopenharmony_cipinctrl-n:	List of phandles, each pointing at a pin configuration
6962306a36Sopenharmony_ci		node within a pin controller.
7062306a36Sopenharmony_cipinctrl-names:	The list of names to assign states. List entry 0 defines the
7162306a36Sopenharmony_ci		name for integer state ID 0, list entry 1 for state ID 1, and
7262306a36Sopenharmony_ci		so on.
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ciFor example:
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci	/* For a client device requiring named states */
7762306a36Sopenharmony_ci	device {
7862306a36Sopenharmony_ci		pinctrl-names = "active", "idle";
7962306a36Sopenharmony_ci		pinctrl-0 = <&state_0_node_a>;
8062306a36Sopenharmony_ci		pinctrl-1 = <&state_1_node_a>, <&state_1_node_b>;
8162306a36Sopenharmony_ci	};
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci	/* For the same device if using state IDs */
8462306a36Sopenharmony_ci	device {
8562306a36Sopenharmony_ci		pinctrl-0 = <&state_0_node_a>;
8662306a36Sopenharmony_ci		pinctrl-1 = <&state_1_node_a>, <&state_1_node_b>;
8762306a36Sopenharmony_ci	};
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci	/*
9062306a36Sopenharmony_ci	 * For an IP block whose binding supports pin configuration,
9162306a36Sopenharmony_ci	 * but in use on an SoC that doesn't have any pin control hardware
9262306a36Sopenharmony_ci	 */
9362306a36Sopenharmony_ci	device {
9462306a36Sopenharmony_ci		pinctrl-names = "active", "idle";
9562306a36Sopenharmony_ci		pinctrl-0 = <>;
9662306a36Sopenharmony_ci		pinctrl-1 = <>;
9762306a36Sopenharmony_ci	};
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci== Pin controller devices ==
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ciSee pinctrl.yaml
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci== Generic pin multiplexing node content ==
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ciSee pinmux-node.yaml
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci== Generic pin configuration node content ==
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ciSee pincfg-node.yaml
110