pinctrl: samsung: Allow grouping multiple pinmux/pinconf nodes
[cascardo/linux.git] / Documentation / devicetree / bindings / pinctrl / samsung-pinctrl.txt
1 Samsung GPIO and Pin Mux/Config controller
2
3 Samsung's ARM based SoC's integrates a GPIO and Pin mux/config hardware
4 controller. It controls the input/output settings on the available pads/pins
5 and also provides ability to multiplex and configure the output of various
6 on-chip controllers onto these pads.
7
8 Required Properties:
9 - compatible: should be one of the following.
10   - "samsung,s3c2412-pinctrl": for S3C2412-compatible pin-controller,
11   - "samsung,s3c2416-pinctrl": for S3C2416-compatible pin-controller,
12   - "samsung,s3c2440-pinctrl": for S3C2440-compatible pin-controller,
13   - "samsung,s3c2450-pinctrl": for S3C2450-compatible pin-controller,
14   - "samsung,s3c64xx-pinctrl": for S3C64xx-compatible pin-controller,
15   - "samsung,s5pv210-pinctrl": for S5PV210-compatible pin-controller,
16   - "samsung,exynos4210-pinctrl": for Exynos4210 compatible pin-controller.
17   - "samsung,exynos4x12-pinctrl": for Exynos4x12 compatible pin-controller.
18   - "samsung,exynos5250-pinctrl": for Exynos5250 compatible pin-controller.
19   - "samsung,exynos5260-pinctrl": for Exynos5260 compatible pin-controller.
20   - "samsung,exynos5420-pinctrl": for Exynos5420 compatible pin-controller.
21
22 - reg: Base address of the pin controller hardware module and length of
23   the address space it occupies.
24
25 - Pin banks as child nodes: Pin banks of the controller are represented by child
26   nodes of the controller node. Bank name is taken from name of the node. Each
27   bank node must contain following properties:
28
29   - gpio-controller: identifies the node as a gpio controller and pin bank.
30   - #gpio-cells: number of cells in GPIO specifier. Since the generic GPIO
31     binding is used, the amount of cells must be specified as 2. See the below
32     mentioned gpio binding representation for description of particular cells.
33
34         Eg: <&gpx2 6 0>
35         <[phandle of the gpio controller node]
36         [pin number within the gpio controller]
37         [flags]>
38
39         Values for gpio specifier:
40         - Pin number: is a value between 0 to 7.
41         - Flags: 0 - Active High
42                  1 - Active Low
43
44 - Pin mux/config groups as child nodes: The pin mux (selecting pin function
45   mode) and pin config (pull up/down, driver strength) settings are represented
46   as child nodes of the pin-controller node. There should be atleast one
47   child node and there is no limit on the count of these child nodes. It is
48   also possible for a child node to consist of several further child nodes
49   to allow grouping multiple pinctrl groups into one. The format of second
50   level child nodes is exactly the same as for first level ones and is
51   described below.
52
53   The child node should contain a list of pin(s) on which a particular pin
54   function selection or pin configuration (or both) have to applied. This
55   list of pins is specified using the property name "samsung,pins". There
56   should be atleast one pin specfied for this property and there is no upper
57   limit on the count of pins that can be specified. The pins are specified
58   using pin names which are derived from the hardware manual of the SoC. As
59   an example, the pins in GPA0 bank of the pin controller can be represented
60   as "gpa0-0", "gpa0-1", "gpa0-2" and so on. The names should be in lower case.
61   The format of the pin names should be (as per the hardware manual)
62   "[pin bank name]-[pin number within the bank]".
63
64   The pin function selection that should be applied on the pins listed in the
65   child node is specified using the "samsung,pin-function" property. The value
66   of this property that should be applied to each of the pins listed in the
67   "samsung,pins" property should be picked from the hardware manual of the SoC
68   for the specified pin group. This property is optional in the child node if
69   no specific function selection is desired for the pins listed in the child
70   node. The value of this property is used as-is to program the pin-controller
71   function selector register of the pin-bank.
72
73   The child node can also optionally specify one or more of the pin
74   configuration that should be applied on all the pins listed in the
75   "samsung,pins" property of the child node. The following pin configuration
76   properties are supported.
77
78   - samsung,pin-pud: Pull up/down configuration.
79   - samsung,pin-drv: Drive strength configuration.
80   - samsung,pin-pud-pdn: Pull up/down configuration in power down mode.
81   - samsung,pin-drv-pdn: Drive strength configuration in power down mode.
82
83   The values specified by these config properties should be derived from the
84   hardware manual and these values are programmed as-is into the pin
85   pull up/down and driver strength register of the pin-controller.
86
87   Note: A child should include atleast a pin function selection property or
88   pin configuration property (one or more) or both.
89
90   The client nodes that require a particular pin function selection and/or
91   pin configuration should use the bindings listed in the "pinctrl-bindings.txt"
92   file.
93
94 External GPIO and Wakeup Interrupts:
95
96 The controller supports two types of external interrupts over gpio. The first
97 is the external gpio interrupt and second is the external wakeup interrupts.
98 The difference between the two is that the external wakeup interrupts can be
99 used as system wakeup events.
100
101 A. External GPIO Interrupts: For supporting external gpio interrupts, the
102    following properties should be specified in the pin-controller device node.
103
104    - interrupt-parent: phandle of the interrupt parent to which the external
105      GPIO interrupts are forwarded to.
106    - interrupts: interrupt specifier for the controller. The format and value of
107      the interrupt specifier depends on the interrupt parent for the controller.
108
109    In addition, following properties must be present in node of every bank
110    of pins supporting GPIO interrupts:
111
112    - interrupt-controller: identifies the controller node as interrupt-parent.
113    - #interrupt-cells: the value of this property should be 2.
114      - First Cell: represents the external gpio interrupt number local to the
115        external gpio interrupt space of the controller.
116      - Second Cell: flags to identify the type of the interrupt
117        - 1 = rising edge triggered
118        - 2 = falling edge triggered
119        - 3 = rising and falling edge triggered
120        - 4 = high level triggered
121        - 8 = low level triggered
122
123 B. External Wakeup Interrupts: For supporting external wakeup interrupts, a
124    child node representing the external wakeup interrupt controller should be
125    included in the pin-controller device node. This child node should include
126    the following properties.
127
128    - compatible: identifies the type of the external wakeup interrupt controller
129      The possible values are:
130      - samsung,s3c2410-wakeup-eint: represents wakeup interrupt controller
131        found on Samsung S3C24xx SoCs except S3C2412 and S3C2413,
132      - samsung,s3c2412-wakeup-eint: represents wakeup interrupt controller
133        found on Samsung S3C2412 and S3C2413 SoCs,
134      - samsung,s3c64xx-wakeup-eint: represents wakeup interrupt controller
135        found on Samsung S3C64xx SoCs,
136      - samsung,exynos4210-wakeup-eint: represents wakeup interrupt controller
137        found on Samsung Exynos4210 and S5PC110/S5PV210 SoCs.
138    - interrupt-parent: phandle of the interrupt parent to which the external
139      wakeup interrupts are forwarded to.
140    - interrupts: interrupt used by multiplexed wakeup interrupts.
141
142    In addition, following properties must be present in node of every bank
143    of pins supporting wake-up interrupts:
144
145    - interrupt-controller: identifies the node as interrupt-parent.
146    - #interrupt-cells: the value of this property should be 2
147      - First Cell: represents the external wakeup interrupt number local to
148        the external wakeup interrupt space of the controller.
149      - Second Cell: flags to identify the type of the interrupt
150        - 1 = rising edge triggered
151        - 2 = falling edge triggered
152        - 3 = rising and falling edge triggered
153        - 4 = high level triggered
154        - 8 = low level triggered
155
156    Node of every bank of pins supporting direct wake-up interrupts (without
157    multiplexing) must contain following properties:
158
159    - interrupt-parent: phandle of the interrupt parent to which the external
160      wakeup interrupts are forwarded to.
161    - interrupts: interrupts of the interrupt parent which are used for external
162      wakeup interrupts from pins of the bank, must contain interrupts for all
163      pins of the bank.
164
165 Aliases:
166
167 All the pin controller nodes should be represented in the aliases node using
168 the following format 'pinctrl{n}' where n is a unique number for the alias.
169
170 Example: A pin-controller node with pin banks:
171
172         pinctrl_0: pinctrl@11400000 {
173                 compatible = "samsung,exynos4210-pinctrl";
174                 reg = <0x11400000 0x1000>;
175                 interrupts = <0 47 0>;
176
177                 /* ... */
178
179                 /* Pin bank without external interrupts */
180                 gpy0: gpy0 {
181                         gpio-controller;
182                         #gpio-cells = <2>;
183                 };
184
185                 /* ... */
186
187                 /* Pin bank with external GPIO or muxed wake-up interrupts */
188                 gpj0: gpj0 {
189                         gpio-controller;
190                         #gpio-cells = <2>;
191
192                         interrupt-controller;
193                         #interrupt-cells = <2>;
194                 };
195
196                 /* ... */
197
198                 /* Pin bank with external direct wake-up interrupts */
199                 gpx0: gpx0 {
200                         gpio-controller;
201                         #gpio-cells = <2>;
202
203                         interrupt-controller;
204                         interrupt-parent = <&gic>;
205                         interrupts = <0 16 0>, <0 17 0>, <0 18 0>, <0 19 0>,
206                                      <0 20 0>, <0 21 0>, <0 22 0>, <0 23 0>;
207                         #interrupt-cells = <2>;
208                 };
209
210                 /* ... */
211         };
212
213 Example 1: A pin-controller node with pin groups.
214
215         pinctrl_0: pinctrl@11400000 {
216                 compatible = "samsung,exynos4210-pinctrl";
217                 reg = <0x11400000 0x1000>;
218                 interrupts = <0 47 0>;
219
220                 /* ... */
221
222                 uart0_data: uart0-data {
223                         samsung,pins = "gpa0-0", "gpa0-1";
224                         samsung,pin-function = <2>;
225                         samsung,pin-pud = <0>;
226                         samsung,pin-drv = <0>;
227                 };
228
229                 uart0_fctl: uart0-fctl {
230                         samsung,pins = "gpa0-2", "gpa0-3";
231                         samsung,pin-function = <2>;
232                         samsung,pin-pud = <0>;
233                         samsung,pin-drv = <0>;
234                 };
235
236                 uart1_data: uart1-data {
237                         samsung,pins = "gpa0-4", "gpa0-5";
238                         samsung,pin-function = <2>;
239                         samsung,pin-pud = <0>;
240                         samsung,pin-drv = <0>;
241                 };
242
243                 uart1_fctl: uart1-fctl {
244                         samsung,pins = "gpa0-6", "gpa0-7";
245                         samsung,pin-function = <2>;
246                         samsung,pin-pud = <0>;
247                         samsung,pin-drv = <0>;
248                 };
249
250                 i2c2_bus: i2c2-bus {
251                         samsung,pins = "gpa0-6", "gpa0-7";
252                         samsung,pin-function = <3>;
253                         samsung,pin-pud = <3>;
254                         samsung,pin-drv = <0>;
255                 };
256
257                 sd4_bus8: sd4-bus-width8 {
258                         part-1 {
259                                 samsung,pins = "gpk0-3", "gpk0-4",
260                                                 "gpk0-5", "gpk0-6";
261                                 samsung,pin-function = <3>;
262                                 samsung,pin-pud = <3>;
263                                 samsung,pin-drv = <3>;
264                         };
265                         part-2 {
266                                 samsung,pins = "gpk1-3", "gpk1-4",
267                                                 "gpk1-5", "gpk1-6";
268                                 samsung,pin-function = <4>;
269                                 samsung,pin-pud = <4>;
270                                 samsung,pin-drv = <3>;
271                         };
272                 };
273         };
274
275 Example 2: A pin-controller node with external wakeup interrupt controller node.
276
277         pinctrl_1: pinctrl@11000000 {
278                 compatible = "samsung,exynos4210-pinctrl";
279                 reg = <0x11000000 0x1000>;
280                 interrupts = <0 46 0>
281
282                 /* ... */
283
284                 wakeup-interrupt-controller {
285                         compatible = "samsung,exynos4210-wakeup-eint";
286                         interrupt-parent = <&gic>;
287                         interrupts = <0 32 0>;
288                 };
289         };
290
291 Example 3: A uart client node that supports 'default' and 'flow-control' states.
292
293         uart@13800000 {
294                 compatible = "samsung,exynos4210-uart";
295                 reg = <0x13800000 0x100>;
296                 interrupts = <0 52 0>;
297                 pinctrl-names = "default", "flow-control;
298                 pinctrl-0 = <&uart0_data>;
299                 pinctrl-1 = <&uart0_data &uart0_fctl>;
300         };
301
302 Example 4: Set up the default pin state for uart controller.
303
304         static int s3c24xx_serial_probe(struct platform_device *pdev) {
305                 struct pinctrl *pinctrl;
306
307                 /* ... */
308
309                 pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
310         }
311
312 Example 5: A display port client node that supports 'default' pinctrl state
313            and gpio binding.
314
315         display-port-controller {
316                 /* ... */
317
318                 samsung,hpd-gpio = <&gpx2 6 0>;
319                 pinctrl-names = "default";
320                 pinctrl-0 = <&dp_hpd>;
321         };
322
323 Example 6: Request the gpio for display port controller
324
325         static int exynos_dp_probe(struct platform_device *pdev)
326         {
327                 int hpd_gpio, ret;
328                 struct device *dev = &pdev->dev;
329                 struct device_node *dp_node = dev->of_node;
330
331                 /* ... */
332
333                 hpd_gpio = of_get_named_gpio(dp_node, "samsung,hpd-gpio", 0);
334
335                 /* ... */
336
337                 ret = devm_gpio_request_one(&pdev->dev, hpd_gpio, GPIOF_IN,
338                                             "hpd_gpio");
339                 /* ... */
340         }