xref: /freebsd/sys/contrib/device-tree/Bindings/pinctrl/pinmux-node.yaml (revision fac71e4e09885bb2afa3d984a0c239a52e1a7418)
1c66ec88fSEmmanuel Vadot# SPDX-License-Identifier: GPL-2.0-only
2c66ec88fSEmmanuel Vadot%YAML 1.2
3c66ec88fSEmmanuel Vadot---
4c66ec88fSEmmanuel Vadot$id: http://devicetree.org/schemas/pinctrl/pinmux-node.yaml#
5c66ec88fSEmmanuel Vadot$schema: http://devicetree.org/meta-schemas/core.yaml#
6c66ec88fSEmmanuel Vadot
78bab661aSEmmanuel Vadottitle: Generic Pin Multiplexing Node
8c66ec88fSEmmanuel Vadot
9c66ec88fSEmmanuel Vadotmaintainers:
10c66ec88fSEmmanuel Vadot  - Linus Walleij <linus.walleij@linaro.org>
11c66ec88fSEmmanuel Vadot
12c66ec88fSEmmanuel Vadotdescription: |
13c66ec88fSEmmanuel Vadot  The contents of the pin configuration child nodes are defined by the binding
14c66ec88fSEmmanuel Vadot  for the individual pin controller device. The pin configuration nodes need not
15c66ec88fSEmmanuel Vadot  be direct children of the pin controller device; they may be grandchildren,
16c66ec88fSEmmanuel Vadot  for example. Whether this is legal, and whether there is any interaction
17c66ec88fSEmmanuel Vadot  between the child and intermediate parent nodes, is again defined entirely by
18c66ec88fSEmmanuel Vadot  the binding for the individual pin controller device.
19c66ec88fSEmmanuel Vadot
20c66ec88fSEmmanuel Vadot  While not required to be used, there are 3 generic forms of pin muxing nodes
21c66ec88fSEmmanuel Vadot  which pin controller devices can use.
22c66ec88fSEmmanuel Vadot
23c66ec88fSEmmanuel Vadot  pin multiplexing nodes:
24c66ec88fSEmmanuel Vadot
25c66ec88fSEmmanuel Vadot  Example:
26c66ec88fSEmmanuel Vadot
27c66ec88fSEmmanuel Vadot  state_0_node_a {
28c66ec88fSEmmanuel Vadot    uart0 {
29c66ec88fSEmmanuel Vadot      function = "uart0";
30c66ec88fSEmmanuel Vadot      groups = "u0rxtx", "u0rtscts";
31c66ec88fSEmmanuel Vadot    };
32c66ec88fSEmmanuel Vadot  };
33c66ec88fSEmmanuel Vadot  state_1_node_a {
34*fac71e4eSEmmanuel Vadot    spi {
35c66ec88fSEmmanuel Vadot      function = "spi0";
36c66ec88fSEmmanuel Vadot      groups = "spi0pins";
37c66ec88fSEmmanuel Vadot    };
38c66ec88fSEmmanuel Vadot  };
39c66ec88fSEmmanuel Vadot  state_2_node_a {
40c66ec88fSEmmanuel Vadot    function = "i2c0";
41c66ec88fSEmmanuel Vadot    pins = "mfio29", "mfio30";
42c66ec88fSEmmanuel Vadot  };
43c66ec88fSEmmanuel Vadot
44c66ec88fSEmmanuel Vadot  Optionally an alternative binding can be used if more suitable depending on the
45c66ec88fSEmmanuel Vadot  pin controller hardware. For hardware where there is a large number of identical
46c66ec88fSEmmanuel Vadot  pin controller instances, naming each pin and function can easily become
47c66ec88fSEmmanuel Vadot  unmaintainable. This is especially the case if the same controller is used for
48c66ec88fSEmmanuel Vadot  different pins and functions depending on the SoC revision and packaging.
49c66ec88fSEmmanuel Vadot
50c66ec88fSEmmanuel Vadot  For cases like this, the pin controller driver may use pinctrl-pin-array helper
51c66ec88fSEmmanuel Vadot  binding with a hardware based index and a number of pin configuration values:
52c66ec88fSEmmanuel Vadot
53c66ec88fSEmmanuel Vadot  pincontroller {
54c66ec88fSEmmanuel Vadot    ... /* Standard DT properties for the device itself elided */
55c66ec88fSEmmanuel Vadot    #pinctrl-cells = <2>;
56c66ec88fSEmmanuel Vadot
57c66ec88fSEmmanuel Vadot    state_0_node_a {
58c66ec88fSEmmanuel Vadot      pinctrl-pin-array = <
59c66ec88fSEmmanuel Vadot        0 A_DELAY_PS(0) G_DELAY_PS(120)
60c66ec88fSEmmanuel Vadot        4 A_DELAY_PS(0) G_DELAY_PS(360)
61c66ec88fSEmmanuel Vadot        ...
62c66ec88fSEmmanuel Vadot        >;
63c66ec88fSEmmanuel Vadot    };
64c66ec88fSEmmanuel Vadot    ...
65c66ec88fSEmmanuel Vadot  };
66c66ec88fSEmmanuel Vadot
67c66ec88fSEmmanuel Vadot  Above #pinctrl-cells specifies the number of value cells in addition to the
68c66ec88fSEmmanuel Vadot  index of the registers. This is similar to the interrupts-extended binding with
69c66ec88fSEmmanuel Vadot  one exception. There is no need to specify the phandle for each entry as that
70c66ec88fSEmmanuel Vadot  is already known as the defined pins are always children of the pin controller
71c66ec88fSEmmanuel Vadot  node. Further having the phandle pointing to another pin controller would not
72c66ec88fSEmmanuel Vadot  currently work as the pinctrl framework uses named modes to group pins for each
73c66ec88fSEmmanuel Vadot  pin control device.
74c66ec88fSEmmanuel Vadot
75c66ec88fSEmmanuel Vadot  The index for pinctrl-pin-array must relate to the hardware for the pinctrl
76c66ec88fSEmmanuel Vadot  registers, and must not be a virtual index of pin instances. The reason for
77c66ec88fSEmmanuel Vadot  this is to avoid mapping of the index in the dts files and the pin controller
78c66ec88fSEmmanuel Vadot  driver as it can change.
79c66ec88fSEmmanuel Vadot
80c66ec88fSEmmanuel Vadot  For hardware where pin multiplexing configurations have to be specified for
81c66ec88fSEmmanuel Vadot  each single pin the number of required sub-nodes containing "pin" and
82c66ec88fSEmmanuel Vadot  "function" properties can quickly escalate and become hard to write and
83c66ec88fSEmmanuel Vadot  maintain.
84c66ec88fSEmmanuel Vadot
85c66ec88fSEmmanuel Vadot  For cases like this, the pin controller driver may use the pinmux helper
86c66ec88fSEmmanuel Vadot  property, where the pin identifier is provided with mux configuration settings
87c66ec88fSEmmanuel Vadot  in a pinmux group. A pinmux group consists of the pin identifier and mux
88c66ec88fSEmmanuel Vadot  settings represented as a single integer or an array of integers.
89c66ec88fSEmmanuel Vadot
90c66ec88fSEmmanuel Vadot  The pinmux property accepts an array of pinmux groups, each of them describing
91c66ec88fSEmmanuel Vadot  a single pin multiplexing configuration.
92c66ec88fSEmmanuel Vadot
93c66ec88fSEmmanuel Vadot  pincontroller {
94c66ec88fSEmmanuel Vadot    state_0_node_a {
95c66ec88fSEmmanuel Vadot      pinmux = <PINMUX_GROUP>, <PINMUX_GROUP>, ...;
96c66ec88fSEmmanuel Vadot    };
97c66ec88fSEmmanuel Vadot  };
98c66ec88fSEmmanuel Vadot
99c66ec88fSEmmanuel Vadot  Each individual pin controller driver bindings documentation shall specify
100c66ec88fSEmmanuel Vadot  how pin IDs and pin multiplexing configuration are defined and assembled
101c66ec88fSEmmanuel Vadot  together in a pinmux group.
102c66ec88fSEmmanuel Vadot
103c66ec88fSEmmanuel Vadotproperties:
104c66ec88fSEmmanuel Vadot  function:
105c66ec88fSEmmanuel Vadot    $ref: /schemas/types.yaml#/definitions/string
106c66ec88fSEmmanuel Vadot    description: The mux function to select
107c66ec88fSEmmanuel Vadot
108c66ec88fSEmmanuel Vadot  pins:
109c66ec88fSEmmanuel Vadot    oneOf:
110c66ec88fSEmmanuel Vadot      - $ref: /schemas/types.yaml#/definitions/uint32-array
111c66ec88fSEmmanuel Vadot      - $ref: /schemas/types.yaml#/definitions/string-array
112c66ec88fSEmmanuel Vadot    description:
113c66ec88fSEmmanuel Vadot      The list of pin identifiers that properties in the node apply to. The
114c66ec88fSEmmanuel Vadot      specific binding for the hardware defines whether the entries are integers
115c66ec88fSEmmanuel Vadot      or strings, and their meaning.
116c66ec88fSEmmanuel Vadot
117c66ec88fSEmmanuel Vadot  groups:
118c66ec88fSEmmanuel Vadot    $ref: /schemas/types.yaml#/definitions/string-array
119c66ec88fSEmmanuel Vadot    description:
120c66ec88fSEmmanuel Vadot      the group to apply the properties to, if the driver supports
121c66ec88fSEmmanuel Vadot      configuration of whole groups rather than individual pins (either
122c66ec88fSEmmanuel Vadot      this, "pins" or "pinmux" has to be specified)
123c66ec88fSEmmanuel Vadot
124c66ec88fSEmmanuel Vadot  pinmux:
125c66ec88fSEmmanuel Vadot    description:
126c66ec88fSEmmanuel Vadot      The list of numeric pin ids and their mux settings that properties in the
127c66ec88fSEmmanuel Vadot      node apply to (either this, "pins" or "groups" have to be specified)
128c66ec88fSEmmanuel Vadot    $ref: /schemas/types.yaml#/definitions/uint32-array
129c66ec88fSEmmanuel Vadot
130c66ec88fSEmmanuel Vadot  pinctrl-pin-array:
131c66ec88fSEmmanuel Vadot    $ref: /schemas/types.yaml#/definitions/uint32-array
1326be33864SEmmanuel Vadot
1336be33864SEmmanuel VadotadditionalProperties: true
134