xref: /freebsd/sys/contrib/device-tree/Bindings/gpio/gpio.txt (revision fac71e4e09885bb2afa3d984a0c239a52e1a7418)
1c66ec88fSEmmanuel VadotSpecifying GPIO information for devices
2c66ec88fSEmmanuel Vadot=======================================
3c66ec88fSEmmanuel Vadot
4c66ec88fSEmmanuel Vadot1) gpios property
5c66ec88fSEmmanuel Vadot-----------------
6c66ec88fSEmmanuel Vadot
7c66ec88fSEmmanuel VadotGPIO properties should be named "[<name>-]gpios", with <name> being the purpose
8c66ec88fSEmmanuel Vadotof this GPIO for the device. While a non-existent <name> is considered valid
9c66ec88fSEmmanuel Vadotfor compatibility reasons (resolving to the "gpios" property), it is not allowed
10c66ec88fSEmmanuel Vadotfor new bindings. Also, GPIO properties named "[<name>-]gpio" are valid and old
11c66ec88fSEmmanuel Vadotbindings use it, but are only supported for compatibility reasons and should not
12c66ec88fSEmmanuel Vadotbe used for newer bindings since it has been deprecated.
13c66ec88fSEmmanuel Vadot
14c66ec88fSEmmanuel VadotGPIO properties can contain one or more GPIO phandles, but only in exceptional
15c66ec88fSEmmanuel Vadotcases should they contain more than one. If your device uses several GPIOs with
16c66ec88fSEmmanuel Vadotdistinct functions, reference each of them under its own property, giving it a
17c66ec88fSEmmanuel Vadotmeaningful name. The only case where an array of GPIOs is accepted is when
18c66ec88fSEmmanuel Vadotseveral GPIOs serve the same function (e.g. a parallel data line).
19c66ec88fSEmmanuel Vadot
20c66ec88fSEmmanuel VadotThe exact purpose of each gpios property must be documented in the device tree
21c66ec88fSEmmanuel Vadotbinding of the device.
22c66ec88fSEmmanuel Vadot
23c66ec88fSEmmanuel VadotThe following example could be used to describe GPIO pins used as device enable
24c66ec88fSEmmanuel Vadotand bit-banged data signals:
25c66ec88fSEmmanuel Vadot
26c66ec88fSEmmanuel Vadot	gpio1: gpio1 {
27c66ec88fSEmmanuel Vadot		gpio-controller;
28c66ec88fSEmmanuel Vadot		#gpio-cells = <2>;
29c66ec88fSEmmanuel Vadot	};
30c66ec88fSEmmanuel Vadot	[...]
31c66ec88fSEmmanuel Vadot
32c66ec88fSEmmanuel Vadot	data-gpios = <&gpio1 12 0>,
33c66ec88fSEmmanuel Vadot		     <&gpio1 13 0>,
34c66ec88fSEmmanuel Vadot		     <&gpio1 14 0>,
35c66ec88fSEmmanuel Vadot		     <&gpio1 15 0>;
36c66ec88fSEmmanuel Vadot
37c66ec88fSEmmanuel VadotIn the above example, &gpio1 uses 2 cells to specify a gpio. The first cell is
38c66ec88fSEmmanuel Vadota local offset to the GPIO line and the second cell represent consumer flags,
39c66ec88fSEmmanuel Vadotsuch as if the consumer desire the line to be active low (inverted) or open
40c66ec88fSEmmanuel Vadotdrain. This is the recommended practice.
41c66ec88fSEmmanuel Vadot
42c66ec88fSEmmanuel VadotThe exact meaning of each specifier cell is controller specific, and must be
43c66ec88fSEmmanuel Vadotdocumented in the device tree binding for the device, but it is strongly
44c66ec88fSEmmanuel Vadotrecommended to use the two-cell approach.
45c66ec88fSEmmanuel Vadot
46c66ec88fSEmmanuel VadotMost controllers are specifying a generic flag bitfield in the last cell, so
47c66ec88fSEmmanuel Vadotfor these, use the macros defined in
48c66ec88fSEmmanuel Vadotinclude/dt-bindings/gpio/gpio.h whenever possible:
49c66ec88fSEmmanuel Vadot
50c66ec88fSEmmanuel VadotExample of a node using GPIOs:
51c66ec88fSEmmanuel Vadot
52c66ec88fSEmmanuel Vadot	node {
53c66ec88fSEmmanuel Vadot		enable-gpios = <&qe_pio_e 18 GPIO_ACTIVE_HIGH>;
54c66ec88fSEmmanuel Vadot	};
55c66ec88fSEmmanuel Vadot
56c66ec88fSEmmanuel VadotGPIO_ACTIVE_HIGH is 0, so in this example gpio-specifier is "18 0" and encodes
57c66ec88fSEmmanuel VadotGPIO pin number, and GPIO flags as accepted by the "qe_pio_e" gpio-controller.
58c66ec88fSEmmanuel Vadot
59c66ec88fSEmmanuel VadotOptional standard bitfield specifiers for the last cell:
60c66ec88fSEmmanuel Vadot
61c66ec88fSEmmanuel Vadot- Bit 0: 0 means active high, 1 means active low
62c66ec88fSEmmanuel Vadot- Bit 1: 0 mean push-pull wiring, see:
63c66ec88fSEmmanuel Vadot           https://en.wikipedia.org/wiki/Push-pull_output
64c66ec88fSEmmanuel Vadot         1 means single-ended wiring, see:
65c66ec88fSEmmanuel Vadot           https://en.wikipedia.org/wiki/Single-ended_triode
66c66ec88fSEmmanuel Vadot- Bit 2: 0 means open-source, 1 means open drain, see:
67c66ec88fSEmmanuel Vadot           https://en.wikipedia.org/wiki/Open_collector
68c66ec88fSEmmanuel Vadot- Bit 3: 0 means the output should be maintained during sleep/low-power mode
69c66ec88fSEmmanuel Vadot         1 means the output state can be lost during sleep/low-power mode
70c66ec88fSEmmanuel Vadot- Bit 4: 0 means no pull-up resistor should be enabled
71c66ec88fSEmmanuel Vadot         1 means a pull-up resistor should be enabled
72c66ec88fSEmmanuel Vadot         This setting only applies to hardware with a simple on/off
73c66ec88fSEmmanuel Vadot         control for pull-up configuration. If the hardware has more
74c66ec88fSEmmanuel Vadot         elaborate pull-up configuration, it should be represented
75c66ec88fSEmmanuel Vadot         using a pin control binding.
76c66ec88fSEmmanuel Vadot- Bit 5: 0 means no pull-down resistor should be enabled
77c66ec88fSEmmanuel Vadot         1 means a pull-down resistor should be enabled
78c66ec88fSEmmanuel Vadot         This setting only applies to hardware with a simple on/off
79c66ec88fSEmmanuel Vadot         control for pull-down configuration. If the hardware has more
80c66ec88fSEmmanuel Vadot         elaborate pull-down configuration, it should be represented
81c66ec88fSEmmanuel Vadot         using a pin control binding.
82c66ec88fSEmmanuel Vadot
83c66ec88fSEmmanuel Vadot1.1) GPIO specifier best practices
84c66ec88fSEmmanuel Vadot----------------------------------
85c66ec88fSEmmanuel Vadot
86c66ec88fSEmmanuel VadotA gpio-specifier should contain a flag indicating the GPIO polarity; active-
87c66ec88fSEmmanuel Vadothigh or active-low. If it does, the following best practices should be
88c66ec88fSEmmanuel Vadotfollowed:
89c66ec88fSEmmanuel Vadot
90c66ec88fSEmmanuel VadotThe gpio-specifier's polarity flag should represent the physical level at the
91c66ec88fSEmmanuel VadotGPIO controller that achieves (or represents, for inputs) a logically asserted
92c66ec88fSEmmanuel Vadotvalue at the device. The exact definition of logically asserted should be
93c66ec88fSEmmanuel Vadotdefined by the binding for the device. If the board inverts the signal between
94c66ec88fSEmmanuel Vadotthe GPIO controller and the device, then the gpio-specifier will represent the
95c66ec88fSEmmanuel Vadotopposite physical level than the signal at the device's pin.
96c66ec88fSEmmanuel Vadot
97c66ec88fSEmmanuel VadotWhen the device's signal polarity is configurable, the binding for the
98c66ec88fSEmmanuel Vadotdevice must either:
99c66ec88fSEmmanuel Vadot
100c66ec88fSEmmanuel Vadota) Define a single static polarity for the signal, with the expectation that
101c66ec88fSEmmanuel Vadotany software using that binding would statically program the device to use
102c66ec88fSEmmanuel Vadotthat signal polarity.
103c66ec88fSEmmanuel Vadot
104c66ec88fSEmmanuel VadotThe static choice of polarity may be either:
105c66ec88fSEmmanuel Vadot
106c66ec88fSEmmanuel Vadota1) (Preferred) Dictated by a binding-specific DT property.
107c66ec88fSEmmanuel Vadot
108c66ec88fSEmmanuel Vadotor:
109c66ec88fSEmmanuel Vadot
110c66ec88fSEmmanuel Vadota2) Defined statically by the DT binding itself.
111c66ec88fSEmmanuel Vadot
112c66ec88fSEmmanuel VadotIn particular, the polarity cannot be derived from the gpio-specifier, since
113c66ec88fSEmmanuel Vadotthat would prevent the DT from separately representing the two orthogonal
114c66ec88fSEmmanuel Vadotconcepts of configurable signal polarity in the device, and possible board-
115c66ec88fSEmmanuel Vadotlevel signal inversion.
116c66ec88fSEmmanuel Vadot
117c66ec88fSEmmanuel Vadotor:
118c66ec88fSEmmanuel Vadot
119c66ec88fSEmmanuel Vadotb) Pick a single option for device signal polarity, and document this choice
120c66ec88fSEmmanuel Vadotin the binding. The gpio-specifier should represent the polarity of the signal
121c66ec88fSEmmanuel Vadot(at the GPIO controller) assuming that the device is configured for this
122c66ec88fSEmmanuel Vadotparticular signal polarity choice. If software chooses to program the device
123c66ec88fSEmmanuel Vadotto generate or receive a signal of the opposite polarity, software will be
124c66ec88fSEmmanuel Vadotresponsible for correctly interpreting (inverting) the GPIO signal at the GPIO
125c66ec88fSEmmanuel Vadotcontroller.
126c66ec88fSEmmanuel Vadot
127c66ec88fSEmmanuel Vadot2) gpio-controller nodes
128c66ec88fSEmmanuel Vadot------------------------
129c66ec88fSEmmanuel Vadot
130c66ec88fSEmmanuel VadotEvery GPIO controller node must contain both an empty "gpio-controller"
131c66ec88fSEmmanuel Vadotproperty, and a #gpio-cells integer property, which indicates the number of
132c66ec88fSEmmanuel Vadotcells in a gpio-specifier.
133c66ec88fSEmmanuel Vadot
134c66ec88fSEmmanuel VadotSome system-on-chips (SoCs) use the concept of GPIO banks. A GPIO bank is an
135c66ec88fSEmmanuel Vadotinstance of a hardware IP core on a silicon die, usually exposed to the
136c66ec88fSEmmanuel Vadotprogrammer as a coherent range of I/O addresses. Usually each such bank is
137c66ec88fSEmmanuel Vadotexposed in the device tree as an individual gpio-controller node, reflecting
138c66ec88fSEmmanuel Vadotthe fact that the hardware was synthesized by reusing the same IP block a
139c66ec88fSEmmanuel Vadotfew times over.
140c66ec88fSEmmanuel Vadot
141c66ec88fSEmmanuel VadotOptionally, a GPIO controller may have a "ngpios" property. This property
142c66ec88fSEmmanuel Vadotindicates the number of in-use slots of available slots for GPIOs. The
143c66ec88fSEmmanuel Vadottypical example is something like this: the hardware register is 32 bits
144c66ec88fSEmmanuel Vadotwide, but only 18 of the bits have a physical counterpart. The driver is
145c66ec88fSEmmanuel Vadotgenerally written so that all 32 bits can be used, but the IP block is reused
146c66ec88fSEmmanuel Vadotin a lot of designs, some using all 32 bits, some using 18 and some using
147c66ec88fSEmmanuel Vadot12. In this case, setting "ngpios = <18>;" informs the driver that only the
148c66ec88fSEmmanuel Vadotfirst 18 GPIOs, at local offset 0 .. 17, are in use.
149c66ec88fSEmmanuel Vadot
150c66ec88fSEmmanuel VadotIf these GPIOs do not happen to be the first N GPIOs at offset 0...N-1, an
151c66ec88fSEmmanuel Vadotadditional set of tuples is needed to specify which GPIOs are unusable, with
152c66ec88fSEmmanuel Vadotthe gpio-reserved-ranges binding. This property indicates the start and size
153c66ec88fSEmmanuel Vadotof the GPIOs that can't be used.
154c66ec88fSEmmanuel Vadot
155c66ec88fSEmmanuel VadotOptionally, a GPIO controller may have a "gpio-line-names" property. This is
156c66ec88fSEmmanuel Vadotan array of strings defining the names of the GPIO lines going out of the
157*fac71e4eSEmmanuel VadotGPIO controller.
158*fac71e4eSEmmanuel Vadot
159*fac71e4eSEmmanuel VadotFor lines which are routed to on-board devices, this name should be
160*fac71e4eSEmmanuel Vadotthe most meaningful producer name for the system, such as a rail name
161*fac71e4eSEmmanuel Vadotindicating the usage. Package names, such as a pin name, are discouraged:
162*fac71e4eSEmmanuel Vadotsuch lines have opaque names (since they are by definition general-purpose)
163*fac71e4eSEmmanuel Vadotand such names are usually not very helpful. For example "MMC-CD", "Red LED
164*fac71e4eSEmmanuel VadotVdd" and "ethernet reset" are reasonable line names as they describe what
165*fac71e4eSEmmanuel Vadotthe line is used for. "GPIO0" is not a good name to give to a GPIO line
166*fac71e4eSEmmanuel Vadotthat is hard-wired to a specific device.
167*fac71e4eSEmmanuel Vadot
168*fac71e4eSEmmanuel VadotHowever, in the case of lines that are routed to a general purpose header
169*fac71e4eSEmmanuel Vadot(e.g. the Raspberry Pi 40-pin header), and therefore are not hard-wired to
170*fac71e4eSEmmanuel Vadotspecific devices, using a pin number or the names on the header is fine
171*fac71e4eSEmmanuel Vadotprovided these are real (preferably unique) names. Using an SoC's pad name
172*fac71e4eSEmmanuel Vadotor package name, or names made up from kernel-internal software constructs,
173*fac71e4eSEmmanuel Vadotare strongly discouraged. For example "pin8 [gpio14/uart0_txd]" is fine
174*fac71e4eSEmmanuel Vadotif the board's documentation labels pin 8 as such. However "PortB_24" (an
175*fac71e4eSEmmanuel Vadotexample of a name from an SoC's reference manual) would not be desirable.
176*fac71e4eSEmmanuel Vadot
177*fac71e4eSEmmanuel VadotIn either case placeholders are discouraged: rather use the "" (blank
178*fac71e4eSEmmanuel Vadotstring) if the use of the GPIO line is undefined in your design. Ideally,
179*fac71e4eSEmmanuel Vadottry to add comments to the dts file describing the naming the convention
180*fac71e4eSEmmanuel Vadotyou have chosen, and specifying from where the names are derived.
181*fac71e4eSEmmanuel Vadot
182*fac71e4eSEmmanuel VadotThe names are assigned starting from line offset 0, from left to right,
183*fac71e4eSEmmanuel Vadotfrom the passed array. An incomplete array (where the number of passed
184*fac71e4eSEmmanuel Vadotnames is less than ngpios) will be used up until the last provided valid
185*fac71e4eSEmmanuel Vadotline index.
186c66ec88fSEmmanuel Vadot
187c66ec88fSEmmanuel VadotExample:
188c66ec88fSEmmanuel Vadot
189c66ec88fSEmmanuel Vadotgpio-controller@00000000 {
190c66ec88fSEmmanuel Vadot	compatible = "foo";
191c66ec88fSEmmanuel Vadot	reg = <0x00000000 0x1000>;
192c66ec88fSEmmanuel Vadot	gpio-controller;
193c66ec88fSEmmanuel Vadot	#gpio-cells = <2>;
194c66ec88fSEmmanuel Vadot	ngpios = <18>;
195c66ec88fSEmmanuel Vadot	gpio-reserved-ranges = <0 4>, <12 2>;
196c66ec88fSEmmanuel Vadot	gpio-line-names = "MMC-CD", "MMC-WP", "VDD eth", "RST eth", "LED R",
197c66ec88fSEmmanuel Vadot		"LED G", "LED B", "Col A", "Col B", "Col C", "Col D",
198c66ec88fSEmmanuel Vadot		"Row A", "Row B", "Row C", "Row D", "NMI button",
199c66ec88fSEmmanuel Vadot		"poweroff", "reset";
200c66ec88fSEmmanuel Vadot}
201c66ec88fSEmmanuel Vadot
202c66ec88fSEmmanuel VadotThe GPIO chip may contain GPIO hog definitions. GPIO hogging is a mechanism
203c66ec88fSEmmanuel Vadotproviding automatic GPIO request and configuration as part of the
204c66ec88fSEmmanuel Vadotgpio-controller's driver probe function.
205c66ec88fSEmmanuel Vadot
206c66ec88fSEmmanuel VadotEach GPIO hog definition is represented as a child node of the GPIO controller.
207c66ec88fSEmmanuel VadotRequired properties:
208c66ec88fSEmmanuel Vadot- gpio-hog:   A property specifying that this child node represents a GPIO hog.
209c66ec88fSEmmanuel Vadot- gpios:      Store the GPIO information (id, flags, ...) for each GPIO to
210c66ec88fSEmmanuel Vadot	      affect. Shall contain an integer multiple of the number of cells
211c66ec88fSEmmanuel Vadot	      specified in its parent node (GPIO controller node).
212c66ec88fSEmmanuel VadotOnly one of the following properties scanned in the order shown below.
213c66ec88fSEmmanuel VadotThis means that when multiple properties are present they will be searched
214c66ec88fSEmmanuel Vadotin the order presented below and the first match is taken as the intended
215c66ec88fSEmmanuel Vadotconfiguration.
216c66ec88fSEmmanuel Vadot- input:      A property specifying to set the GPIO direction as input.
217c66ec88fSEmmanuel Vadot- output-low  A property specifying to set the GPIO direction as output with
218c66ec88fSEmmanuel Vadot	      the value low.
219c66ec88fSEmmanuel Vadot- output-high A property specifying to set the GPIO direction as output with
220c66ec88fSEmmanuel Vadot	      the value high.
221c66ec88fSEmmanuel Vadot
222c66ec88fSEmmanuel VadotOptional properties:
223c66ec88fSEmmanuel Vadot- line-name:  The GPIO label name. If not present the node name is used.
224c66ec88fSEmmanuel Vadot
225c66ec88fSEmmanuel VadotExample of two SOC GPIO banks defined as gpio-controller nodes:
226c66ec88fSEmmanuel Vadot
227c66ec88fSEmmanuel Vadot	qe_pio_a: gpio-controller@1400 {
228c66ec88fSEmmanuel Vadot		compatible = "fsl,qe-pario-bank-a", "fsl,qe-pario-bank";
229c66ec88fSEmmanuel Vadot		reg = <0x1400 0x18>;
230c66ec88fSEmmanuel Vadot		gpio-controller;
231c66ec88fSEmmanuel Vadot		#gpio-cells = <2>;
232c66ec88fSEmmanuel Vadot
233c9ccf3a3SEmmanuel Vadot		line_b-hog {
234c66ec88fSEmmanuel Vadot			gpio-hog;
235c66ec88fSEmmanuel Vadot			gpios = <6 0>;
236c66ec88fSEmmanuel Vadot			output-low;
237c66ec88fSEmmanuel Vadot			line-name = "foo-bar-gpio";
238c66ec88fSEmmanuel Vadot		};
239c66ec88fSEmmanuel Vadot	};
240c66ec88fSEmmanuel Vadot
241c66ec88fSEmmanuel Vadot	qe_pio_e: gpio-controller@1460 {
242c66ec88fSEmmanuel Vadot		compatible = "fsl,qe-pario-bank-e", "fsl,qe-pario-bank";
243c66ec88fSEmmanuel Vadot		reg = <0x1460 0x18>;
244c66ec88fSEmmanuel Vadot		gpio-controller;
245c66ec88fSEmmanuel Vadot		#gpio-cells = <2>;
246c66ec88fSEmmanuel Vadot	};
247c66ec88fSEmmanuel Vadot
248c66ec88fSEmmanuel Vadot2.1) gpio- and pin-controller interaction
249c66ec88fSEmmanuel Vadot-----------------------------------------
250c66ec88fSEmmanuel Vadot
251c66ec88fSEmmanuel VadotSome or all of the GPIOs provided by a GPIO controller may be routed to pins
252c66ec88fSEmmanuel Vadoton the package via a pin controller. This allows muxing those pins between
253c66ec88fSEmmanuel VadotGPIO and other functions. It is a fairly common practice among silicon
254c66ec88fSEmmanuel Vadotengineers.
255c66ec88fSEmmanuel Vadot
256c66ec88fSEmmanuel Vadot2.2) Ordinary (numerical) GPIO ranges
257c66ec88fSEmmanuel Vadot-------------------------------------
258c66ec88fSEmmanuel Vadot
259c66ec88fSEmmanuel VadotIt is useful to represent which GPIOs correspond to which pins on which pin
260c66ec88fSEmmanuel Vadotcontrollers. The gpio-ranges property described below represents this with
261c66ec88fSEmmanuel Vadota discrete set of ranges mapping pins from the pin controller local number space
262c66ec88fSEmmanuel Vadotto pins in the GPIO controller local number space.
263c66ec88fSEmmanuel Vadot
264c66ec88fSEmmanuel VadotThe format is: <[pin controller phandle], [GPIO controller offset],
265c66ec88fSEmmanuel Vadot                [pin controller offset], [number of pins]>;
266c66ec88fSEmmanuel Vadot
267c66ec88fSEmmanuel VadotThe GPIO controller offset pertains to the GPIO controller node containing the
268c66ec88fSEmmanuel Vadotrange definition.
269c66ec88fSEmmanuel Vadot
270c66ec88fSEmmanuel VadotThe pin controller node referenced by the phandle must conform to the bindings
271c66ec88fSEmmanuel Vadotdescribed in pinctrl/pinctrl-bindings.txt.
272c66ec88fSEmmanuel Vadot
273c66ec88fSEmmanuel VadotEach offset runs from 0 to N. It is perfectly fine to pile any number of
274c66ec88fSEmmanuel Vadotranges with just one pin-to-GPIO line mapping if the ranges are concocted, but
275c66ec88fSEmmanuel Vadotin practice these ranges are often lumped in discrete sets.
276c66ec88fSEmmanuel Vadot
277c66ec88fSEmmanuel VadotExample:
278c66ec88fSEmmanuel Vadot
279c66ec88fSEmmanuel Vadot    gpio-ranges = <&foo 0 20 10>, <&bar 10 50 20>;
280c66ec88fSEmmanuel Vadot
281c66ec88fSEmmanuel VadotThis means:
282c66ec88fSEmmanuel Vadot- pins 20..29 on pin controller "foo" is mapped to GPIO line 0..9 and
283c66ec88fSEmmanuel Vadot- pins 50..69 on pin controller "bar" is mapped to GPIO line 10..29
284c66ec88fSEmmanuel Vadot
285c66ec88fSEmmanuel Vadot
286c66ec88fSEmmanuel VadotVerbose example:
287c66ec88fSEmmanuel Vadot
288c66ec88fSEmmanuel Vadot	qe_pio_e: gpio-controller@1460 {
289c66ec88fSEmmanuel Vadot		#gpio-cells = <2>;
290c66ec88fSEmmanuel Vadot		compatible = "fsl,qe-pario-bank-e", "fsl,qe-pario-bank";
291c66ec88fSEmmanuel Vadot		reg = <0x1460 0x18>;
292c66ec88fSEmmanuel Vadot		gpio-controller;
293c66ec88fSEmmanuel Vadot		gpio-ranges = <&pinctrl1 0 20 10>, <&pinctrl2 10 50 20>;
294c66ec88fSEmmanuel Vadot	};
295c66ec88fSEmmanuel Vadot
296c66ec88fSEmmanuel VadotHere, a single GPIO controller has GPIOs 0..9 routed to pin controller
297c66ec88fSEmmanuel Vadotpinctrl1's pins 20..29, and GPIOs 10..29 routed to pin controller pinctrl2's
298c66ec88fSEmmanuel Vadotpins 50..69.
299c66ec88fSEmmanuel Vadot
300c66ec88fSEmmanuel Vadot
301c66ec88fSEmmanuel Vadot2.3) GPIO ranges from named pin groups
302c66ec88fSEmmanuel Vadot--------------------------------------
303c66ec88fSEmmanuel Vadot
304c66ec88fSEmmanuel VadotIt is also possible to use pin groups for gpio ranges when pin groups are the
305c66ec88fSEmmanuel Vadoteasiest and most convenient mapping.
306c66ec88fSEmmanuel Vadot
307c66ec88fSEmmanuel VadotBoth both <pinctrl-base> and <count> must set to 0 when using named pin groups
308c66ec88fSEmmanuel Vadotnames.
309c66ec88fSEmmanuel Vadot
310c66ec88fSEmmanuel VadotThe property gpio-ranges-group-names must contain exactly one string for each
311c66ec88fSEmmanuel Vadotrange.
312c66ec88fSEmmanuel Vadot
313c66ec88fSEmmanuel VadotElements of gpio-ranges-group-names must contain the name of a pin group
314c66ec88fSEmmanuel Vadotdefined in the respective pin controller. The number of pins/GPIO lines in the
315c66ec88fSEmmanuel Vadotrange is the number of pins in that pin group. The number of pins of that
316c66ec88fSEmmanuel Vadotgroup is defined int the implementation and not in the device tree.
317c66ec88fSEmmanuel Vadot
318c66ec88fSEmmanuel VadotIf numerical and named pin groups are mixed, the string corresponding to a
319c66ec88fSEmmanuel Vadotnumerical pin range in gpio-ranges-group-names must be empty.
320c66ec88fSEmmanuel Vadot
321c66ec88fSEmmanuel VadotExample:
322c66ec88fSEmmanuel Vadot
323c66ec88fSEmmanuel Vadot	gpio_pio_i: gpio-controller@14b0 {
324c66ec88fSEmmanuel Vadot		#gpio-cells = <2>;
325c66ec88fSEmmanuel Vadot		compatible = "fsl,qe-pario-bank-e", "fsl,qe-pario-bank";
326c66ec88fSEmmanuel Vadot		reg = <0x1480 0x18>;
327c66ec88fSEmmanuel Vadot		gpio-controller;
328c66ec88fSEmmanuel Vadot		gpio-ranges =			<&pinctrl1 0 20 10>,
329c66ec88fSEmmanuel Vadot						<&pinctrl2 10 0 0>,
330c66ec88fSEmmanuel Vadot						<&pinctrl1 15 0 10>,
331c66ec88fSEmmanuel Vadot						<&pinctrl2 25 0 0>;
332c66ec88fSEmmanuel Vadot		gpio-ranges-group-names =	"",
333c66ec88fSEmmanuel Vadot						"foo",
334c66ec88fSEmmanuel Vadot						"",
335c66ec88fSEmmanuel Vadot						"bar";
336c66ec88fSEmmanuel Vadot	};
337c66ec88fSEmmanuel Vadot
338c66ec88fSEmmanuel VadotHere, three GPIO ranges are defined referring to two pin controllers.
339c66ec88fSEmmanuel Vadot
340c66ec88fSEmmanuel Vadotpinctrl1 GPIO ranges are defined using pin numbers whereas the GPIO ranges
341c66ec88fSEmmanuel Vadotin pinctrl2 are defined using the pin groups named "foo" and "bar".
342c66ec88fSEmmanuel Vadot
343c66ec88fSEmmanuel VadotPrevious versions of this binding required all pin controller nodes that
344c66ec88fSEmmanuel Vadotwere referenced by any gpio-ranges property to contain a property named
345c66ec88fSEmmanuel Vadot#gpio-range-cells with value <3>. This requirement is now deprecated.
346c66ec88fSEmmanuel VadotHowever, that property may still exist in older device trees for
347c66ec88fSEmmanuel Vadotcompatibility reasons, and would still be required even in new device
348c66ec88fSEmmanuel Vadottrees that need to be compatible with older software.
349