xref: /freebsd/sys/contrib/device-tree/Bindings/pinctrl/renesas,rza1-pinctrl.txt (revision c66ec88fed842fbaad62c30d510644ceb7bd2d71)
1*c66ec88fSEmmanuel VadotRenesas RZ/A1 combined Pin and GPIO controller
2*c66ec88fSEmmanuel Vadot
3*c66ec88fSEmmanuel VadotThe Renesas SoCs of the RZ/A1 family feature a combined Pin and GPIO controller,
4*c66ec88fSEmmanuel Vadotnamed "Ports" in the hardware reference manual.
5*c66ec88fSEmmanuel VadotPin multiplexing and GPIO configuration is performed on a per-pin basis
6*c66ec88fSEmmanuel Vadotwriting configuration values to per-port register sets.
7*c66ec88fSEmmanuel VadotEach "port" features up to 16 pins, each of them configurable for GPIO
8*c66ec88fSEmmanuel Vadotfunction (port mode) or in alternate function mode.
9*c66ec88fSEmmanuel VadotUp to 8 different alternate function modes exist for each single pin.
10*c66ec88fSEmmanuel Vadot
11*c66ec88fSEmmanuel VadotPin controller node
12*c66ec88fSEmmanuel Vadot-------------------
13*c66ec88fSEmmanuel Vadot
14*c66ec88fSEmmanuel VadotRequired properties:
15*c66ec88fSEmmanuel Vadot  - compatible: should be:
16*c66ec88fSEmmanuel Vadot    - "renesas,r7s72100-ports": for RZ/A1H
17*c66ec88fSEmmanuel Vadot    - "renesas,r7s72101-ports", "renesas,r7s72100-ports": for RZ/A1M
18*c66ec88fSEmmanuel Vadot    - "renesas,r7s72102-ports": for RZ/A1L
19*c66ec88fSEmmanuel Vadot
20*c66ec88fSEmmanuel Vadot  - reg
21*c66ec88fSEmmanuel Vadot    address base and length of the memory area where the pin controller
22*c66ec88fSEmmanuel Vadot    hardware is mapped to.
23*c66ec88fSEmmanuel Vadot
24*c66ec88fSEmmanuel VadotExample:
25*c66ec88fSEmmanuel VadotPin controller node for RZ/A1H SoC (r7s72100)
26*c66ec88fSEmmanuel Vadot
27*c66ec88fSEmmanuel Vadotpinctrl: pin-controller@fcfe3000 {
28*c66ec88fSEmmanuel Vadot	compatible = "renesas,r7s72100-ports";
29*c66ec88fSEmmanuel Vadot
30*c66ec88fSEmmanuel Vadot	reg = <0xfcfe3000 0x4230>;
31*c66ec88fSEmmanuel Vadot};
32*c66ec88fSEmmanuel Vadot
33*c66ec88fSEmmanuel VadotSub-nodes
34*c66ec88fSEmmanuel Vadot---------
35*c66ec88fSEmmanuel Vadot
36*c66ec88fSEmmanuel VadotThe child nodes of the pin controller node describe a pin multiplexing
37*c66ec88fSEmmanuel Vadotfunction or a GPIO controller alternatively.
38*c66ec88fSEmmanuel Vadot
39*c66ec88fSEmmanuel Vadot- Pin multiplexing sub-nodes:
40*c66ec88fSEmmanuel Vadot  A pin multiplexing sub-node describes how to configure a set of
41*c66ec88fSEmmanuel Vadot  (or a single) pin in some desired alternate function mode.
42*c66ec88fSEmmanuel Vadot  A single sub-node may define several pin configurations.
43*c66ec88fSEmmanuel Vadot  A few alternate function require special pin configuration flags to be
44*c66ec88fSEmmanuel Vadot  supplied along with the alternate function configuration number.
45*c66ec88fSEmmanuel Vadot  The hardware reference manual specifies when a pin function requires
46*c66ec88fSEmmanuel Vadot  "software IO driven" mode to be specified. To do so use the generic
47*c66ec88fSEmmanuel Vadot  properties from the <include/linux/pinctrl/pinconf_generic.h> header file
48*c66ec88fSEmmanuel Vadot  to instruct the pin controller to perform the desired pin configuration
49*c66ec88fSEmmanuel Vadot  operation.
50*c66ec88fSEmmanuel Vadot  Please refer to pinctrl-bindings.txt to get to know more on generic
51*c66ec88fSEmmanuel Vadot  pin properties usage.
52*c66ec88fSEmmanuel Vadot
53*c66ec88fSEmmanuel Vadot  The allowed generic formats for a pin multiplexing sub-node are the
54*c66ec88fSEmmanuel Vadot  following ones:
55*c66ec88fSEmmanuel Vadot
56*c66ec88fSEmmanuel Vadot  node-1 {
57*c66ec88fSEmmanuel Vadot      pinmux = <PIN_ID_AND_MUX>, <PIN_ID_AND_MUX>, ... ;
58*c66ec88fSEmmanuel Vadot      GENERIC_PINCONFIG;
59*c66ec88fSEmmanuel Vadot  };
60*c66ec88fSEmmanuel Vadot
61*c66ec88fSEmmanuel Vadot  node-2 {
62*c66ec88fSEmmanuel Vadot      sub-node-1 {
63*c66ec88fSEmmanuel Vadot          pinmux = <PIN_ID_AND_MUX>, <PIN_ID_AND_MUX>, ... ;
64*c66ec88fSEmmanuel Vadot          GENERIC_PINCONFIG;
65*c66ec88fSEmmanuel Vadot      };
66*c66ec88fSEmmanuel Vadot
67*c66ec88fSEmmanuel Vadot      sub-node-2 {
68*c66ec88fSEmmanuel Vadot          pinmux = <PIN_ID_AND_MUX>, <PIN_ID_AND_MUX>, ... ;
69*c66ec88fSEmmanuel Vadot          GENERIC_PINCONFIG;
70*c66ec88fSEmmanuel Vadot      };
71*c66ec88fSEmmanuel Vadot
72*c66ec88fSEmmanuel Vadot      ...
73*c66ec88fSEmmanuel Vadot
74*c66ec88fSEmmanuel Vadot      sub-node-n {
75*c66ec88fSEmmanuel Vadot          pinmux = <PIN_ID_AND_MUX>, <PIN_ID_AND_MUX>, ... ;
76*c66ec88fSEmmanuel Vadot          GENERIC_PINCONFIG;
77*c66ec88fSEmmanuel Vadot      };
78*c66ec88fSEmmanuel Vadot  };
79*c66ec88fSEmmanuel Vadot
80*c66ec88fSEmmanuel Vadot  Use the second format when pins part of the same logical group need to have
81*c66ec88fSEmmanuel Vadot  different generic pin configuration flags applied.
82*c66ec88fSEmmanuel Vadot
83*c66ec88fSEmmanuel Vadot  Client sub-nodes shall refer to pin multiplexing sub-nodes using the phandle
84*c66ec88fSEmmanuel Vadot  of the most external one.
85*c66ec88fSEmmanuel Vadot
86*c66ec88fSEmmanuel Vadot  Eg.
87*c66ec88fSEmmanuel Vadot
88*c66ec88fSEmmanuel Vadot  client-1 {
89*c66ec88fSEmmanuel Vadot      ...
90*c66ec88fSEmmanuel Vadot      pinctrl-0 = <&node-1>;
91*c66ec88fSEmmanuel Vadot      ...
92*c66ec88fSEmmanuel Vadot  };
93*c66ec88fSEmmanuel Vadot
94*c66ec88fSEmmanuel Vadot  client-2 {
95*c66ec88fSEmmanuel Vadot      ...
96*c66ec88fSEmmanuel Vadot      pinctrl-0 = <&node-2>;
97*c66ec88fSEmmanuel Vadot      ...
98*c66ec88fSEmmanuel Vadot  };
99*c66ec88fSEmmanuel Vadot
100*c66ec88fSEmmanuel Vadot  Required properties:
101*c66ec88fSEmmanuel Vadot    - pinmux:
102*c66ec88fSEmmanuel Vadot      integer array representing pin number and pin multiplexing configuration.
103*c66ec88fSEmmanuel Vadot      When a pin has to be configured in alternate function mode, use this
104*c66ec88fSEmmanuel Vadot      property to identify the pin by its global index, and provide its
105*c66ec88fSEmmanuel Vadot      alternate function configuration number along with it.
106*c66ec88fSEmmanuel Vadot      When multiple pins are required to be configured as part of the same
107*c66ec88fSEmmanuel Vadot      alternate function they shall be specified as members of the same
108*c66ec88fSEmmanuel Vadot      argument list of a single "pinmux" property.
109*c66ec88fSEmmanuel Vadot      Helper macros to ease assembling the pin index from its position
110*c66ec88fSEmmanuel Vadot      (port where it sits on and pin number) and alternate function identifier
111*c66ec88fSEmmanuel Vadot      are provided by the pin controller header file at:
112*c66ec88fSEmmanuel Vadot      <include/dt-bindings/pinctrl/r7s72100-pinctrl.h>
113*c66ec88fSEmmanuel Vadot      Integers values in "pinmux" argument list are assembled as:
114*c66ec88fSEmmanuel Vadot      ((PORT * 16 + PIN) | MUX_FUNC << 16)
115*c66ec88fSEmmanuel Vadot
116*c66ec88fSEmmanuel Vadot  Optional generic properties:
117*c66ec88fSEmmanuel Vadot    - input-enable:
118*c66ec88fSEmmanuel Vadot      enable input bufer for pins requiring software driven IO input
119*c66ec88fSEmmanuel Vadot      operations.
120*c66ec88fSEmmanuel Vadot    - output-high:
121*c66ec88fSEmmanuel Vadot      enable output buffer for pins requiring software driven IO output
122*c66ec88fSEmmanuel Vadot      operations. output-low can be used alternatively, as line value is
123*c66ec88fSEmmanuel Vadot      ignored by the driver.
124*c66ec88fSEmmanuel Vadot
125*c66ec88fSEmmanuel Vadot  The hardware reference manual specifies when a pin has to be configured to
126*c66ec88fSEmmanuel Vadot  work in bi-directional mode and when the IO direction has to be specified
127*c66ec88fSEmmanuel Vadot  by software. Bi-directional pins are managed by the pin controller driver
128*c66ec88fSEmmanuel Vadot  internally, while software driven IO direction has to be explicitly
129*c66ec88fSEmmanuel Vadot  selected when multiple options are available.
130*c66ec88fSEmmanuel Vadot
131*c66ec88fSEmmanuel Vadot  Example:
132*c66ec88fSEmmanuel Vadot  A serial communication interface with a TX output pin and an RX input pin.
133*c66ec88fSEmmanuel Vadot
134*c66ec88fSEmmanuel Vadot  &pinctrl {
135*c66ec88fSEmmanuel Vadot	scif2_pins: serial2 {
136*c66ec88fSEmmanuel Vadot		pinmux = <RZA1_PINMUX(3, 0, 6)>, <RZA1_PINMUX(3, 2, 4)>;
137*c66ec88fSEmmanuel Vadot	};
138*c66ec88fSEmmanuel Vadot  };
139*c66ec88fSEmmanuel Vadot
140*c66ec88fSEmmanuel Vadot  Pin #0 on port #3 is configured as alternate function #6.
141*c66ec88fSEmmanuel Vadot  Pin #2 on port #3 is configured as alternate function #4.
142*c66ec88fSEmmanuel Vadot
143*c66ec88fSEmmanuel Vadot  Example 2:
144*c66ec88fSEmmanuel Vadot  I2c master: both SDA and SCL pins need bi-directional operations
145*c66ec88fSEmmanuel Vadot
146*c66ec88fSEmmanuel Vadot  &pinctrl {
147*c66ec88fSEmmanuel Vadot	i2c2_pins: i2c2 {
148*c66ec88fSEmmanuel Vadot		pinmux = <RZA1_PINMUX(1, 4, 1)>, <RZA1_PINMUX(1, 5, 1)>;
149*c66ec88fSEmmanuel Vadot	};
150*c66ec88fSEmmanuel Vadot  };
151*c66ec88fSEmmanuel Vadot
152*c66ec88fSEmmanuel Vadot  Pin #4 on port #1 is configured as alternate function #1.
153*c66ec88fSEmmanuel Vadot  Pin #5 on port #1 is configured as alternate function #1.
154*c66ec88fSEmmanuel Vadot  Both need to work in bi-directional mode, the driver manages this internally.
155*c66ec88fSEmmanuel Vadot
156*c66ec88fSEmmanuel Vadot  Example 3:
157*c66ec88fSEmmanuel Vadot  Multi-function timer input and output compare pins.
158*c66ec88fSEmmanuel Vadot  Configure TIOC0A as software driven input and TIOC0B as software driven
159*c66ec88fSEmmanuel Vadot  output.
160*c66ec88fSEmmanuel Vadot
161*c66ec88fSEmmanuel Vadot  &pinctrl {
162*c66ec88fSEmmanuel Vadot	tioc0_pins: tioc0 {
163*c66ec88fSEmmanuel Vadot		tioc0_input_pins {
164*c66ec88fSEmmanuel Vadot			pinumx = <RZA1_PINMUX(4, 0, 2)>;
165*c66ec88fSEmmanuel Vadot			input-enable;
166*c66ec88fSEmmanuel Vadot		};
167*c66ec88fSEmmanuel Vadot
168*c66ec88fSEmmanuel Vadot		tioc0_output_pins {
169*c66ec88fSEmmanuel Vadot			pinmux = <RZA1_PINMUX(4, 1, 1)>;
170*c66ec88fSEmmanuel Vadot			output-enable;
171*c66ec88fSEmmanuel Vadot		};
172*c66ec88fSEmmanuel Vadot	};
173*c66ec88fSEmmanuel Vadot  };
174*c66ec88fSEmmanuel Vadot
175*c66ec88fSEmmanuel Vadot  &tioc0 {
176*c66ec88fSEmmanuel Vadot	...
177*c66ec88fSEmmanuel Vadot	pinctrl-0 = <&tioc0_pins>;
178*c66ec88fSEmmanuel Vadot	...
179*c66ec88fSEmmanuel Vadot  };
180*c66ec88fSEmmanuel Vadot
181*c66ec88fSEmmanuel Vadot  Pin #0 on port #4 is configured as alternate function #2 with IO direction
182*c66ec88fSEmmanuel Vadot  specified by software as input.
183*c66ec88fSEmmanuel Vadot  Pin #1 on port #4 is configured as alternate function #1 with IO direction
184*c66ec88fSEmmanuel Vadot  specified by software as output.
185*c66ec88fSEmmanuel Vadot
186*c66ec88fSEmmanuel Vadot- GPIO controller sub-nodes:
187*c66ec88fSEmmanuel Vadot  Each port of the r7s72100 pin controller hardware is itself a GPIO controller.
188*c66ec88fSEmmanuel Vadot  Different SoCs have different numbers of available pins per port, but
189*c66ec88fSEmmanuel Vadot  generally speaking, each of them can be configured in GPIO ("port") mode
190*c66ec88fSEmmanuel Vadot  on this hardware.
191*c66ec88fSEmmanuel Vadot  Describe GPIO controllers using sub-nodes with the following properties.
192*c66ec88fSEmmanuel Vadot
193*c66ec88fSEmmanuel Vadot  Required properties:
194*c66ec88fSEmmanuel Vadot    - gpio-controller
195*c66ec88fSEmmanuel Vadot      empty property as defined by the GPIO bindings documentation.
196*c66ec88fSEmmanuel Vadot    - #gpio-cells
197*c66ec88fSEmmanuel Vadot      number of cells required to identify and configure a GPIO.
198*c66ec88fSEmmanuel Vadot      Shall be 2.
199*c66ec88fSEmmanuel Vadot    - gpio-ranges
200*c66ec88fSEmmanuel Vadot      Describes a GPIO controller specifying its specific pin base, the pin
201*c66ec88fSEmmanuel Vadot      base in the global pin numbering space, and the number of controlled
202*c66ec88fSEmmanuel Vadot      pins, as defined by the GPIO bindings documentation. Refer to
203*c66ec88fSEmmanuel Vadot      Documentation/devicetree/bindings/gpio/gpio.txt file for a more detailed
204*c66ec88fSEmmanuel Vadot      description.
205*c66ec88fSEmmanuel Vadot
206*c66ec88fSEmmanuel Vadot  Example:
207*c66ec88fSEmmanuel Vadot  A GPIO controller node, controlling 16 pins indexed from 0.
208*c66ec88fSEmmanuel Vadot  The GPIO controller base in the global pin indexing space is pin 48, thus
209*c66ec88fSEmmanuel Vadot  pins [0 - 15] on this controller map to pins [48 - 63] in the global pin
210*c66ec88fSEmmanuel Vadot  indexing space.
211*c66ec88fSEmmanuel Vadot
212*c66ec88fSEmmanuel Vadot  port3: gpio-3 {
213*c66ec88fSEmmanuel Vadot	gpio-controller;
214*c66ec88fSEmmanuel Vadot	#gpio-cells = <2>;
215*c66ec88fSEmmanuel Vadot	gpio-ranges = <&pinctrl 0 48 16>;
216*c66ec88fSEmmanuel Vadot  };
217*c66ec88fSEmmanuel Vadot
218*c66ec88fSEmmanuel Vadot  A device node willing to use pins controlled by this GPIO controller, shall
219*c66ec88fSEmmanuel Vadot  refer to it as follows:
220*c66ec88fSEmmanuel Vadot
221*c66ec88fSEmmanuel Vadot  led1 {
222*c66ec88fSEmmanuel Vadot	gpios = <&port3 10 GPIO_ACTIVE_LOW>;
223*c66ec88fSEmmanuel Vadot  };
224