Merge branch 'for-linus' of git://git.open-osd.org/linux-open-osd
[profile/ivi/kernel-x86-ivi.git] / drivers / pinctrl / pinctrl-imx25.c
1 /*
2  * imx25 pinctrl driver.
3  *
4  * Copyright 2013 EukrĂ©a Electromatique <denis@eukrea.com>
5  *
6  * This driver was mostly copied from the imx51 pinctrl driver which has:
7  *
8  * Copyright (C) 2012 Freescale Semiconductor, Inc.
9  * Copyright (C) 2012 Linaro, Inc.
10  *
11  * Author: Denis Carikli <denis@eukrea.com>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License version 2 as published
15  * by the Free Software Foundation.
16  */
17
18 #include <linux/err.h>
19 #include <linux/init.h>
20 #include <linux/io.h>
21 #include <linux/module.h>
22 #include <linux/of.h>
23 #include <linux/of_device.h>
24 #include <linux/pinctrl/pinctrl.h>
25
26 #include "pinctrl-imx.h"
27
28 enum imx25_pads {
29         MX25_PAD_RESERVE0 = 1,
30         MX25_PAD_RESERVE1 = 2,
31         MX25_PAD_A10 = 3,
32         MX25_PAD_A13 = 4,
33         MX25_PAD_A14 = 5,
34         MX25_PAD_A15 = 6,
35         MX25_PAD_A16 = 7,
36         MX25_PAD_A17 = 8,
37         MX25_PAD_A18 = 9,
38         MX25_PAD_A19 = 10,
39         MX25_PAD_A20 = 11,
40         MX25_PAD_A21 = 12,
41         MX25_PAD_A22 = 13,
42         MX25_PAD_A23 = 14,
43         MX25_PAD_A24 = 15,
44         MX25_PAD_A25 = 16,
45         MX25_PAD_EB0 = 17,
46         MX25_PAD_EB1 = 18,
47         MX25_PAD_OE = 19,
48         MX25_PAD_CS0 = 20,
49         MX25_PAD_CS1 = 21,
50         MX25_PAD_CS4 = 22,
51         MX25_PAD_CS5 = 23,
52         MX25_PAD_NF_CE0 = 24,
53         MX25_PAD_ECB = 25,
54         MX25_PAD_LBA = 26,
55         MX25_PAD_BCLK = 27,
56         MX25_PAD_RW = 28,
57         MX25_PAD_NFWE_B = 29,
58         MX25_PAD_NFRE_B = 30,
59         MX25_PAD_NFALE = 31,
60         MX25_PAD_NFCLE = 32,
61         MX25_PAD_NFWP_B = 33,
62         MX25_PAD_NFRB = 34,
63         MX25_PAD_D15 = 35,
64         MX25_PAD_D14 = 36,
65         MX25_PAD_D13 = 37,
66         MX25_PAD_D12 = 38,
67         MX25_PAD_D11 = 39,
68         MX25_PAD_D10 = 40,
69         MX25_PAD_D9 = 41,
70         MX25_PAD_D8 = 42,
71         MX25_PAD_D7 = 43,
72         MX25_PAD_D6 = 44,
73         MX25_PAD_D5 = 45,
74         MX25_PAD_D4 = 46,
75         MX25_PAD_D3 = 47,
76         MX25_PAD_D2 = 48,
77         MX25_PAD_D1 = 49,
78         MX25_PAD_D0 = 50,
79         MX25_PAD_LD0 = 51,
80         MX25_PAD_LD1 = 52,
81         MX25_PAD_LD2 = 53,
82         MX25_PAD_LD3 = 54,
83         MX25_PAD_LD4 = 55,
84         MX25_PAD_LD5 = 56,
85         MX25_PAD_LD6 = 57,
86         MX25_PAD_LD7 = 58,
87         MX25_PAD_LD8 = 59,
88         MX25_PAD_LD9 = 60,
89         MX25_PAD_LD10 = 61,
90         MX25_PAD_LD11 = 62,
91         MX25_PAD_LD12 = 63,
92         MX25_PAD_LD13 = 64,
93         MX25_PAD_LD14 = 65,
94         MX25_PAD_LD15 = 66,
95         MX25_PAD_HSYNC = 67,
96         MX25_PAD_VSYNC = 68,
97         MX25_PAD_LSCLK = 69,
98         MX25_PAD_OE_ACD = 70,
99         MX25_PAD_CONTRAST = 71,
100         MX25_PAD_PWM = 72,
101         MX25_PAD_CSI_D2 = 73,
102         MX25_PAD_CSI_D3 = 74,
103         MX25_PAD_CSI_D4 = 75,
104         MX25_PAD_CSI_D5 = 76,
105         MX25_PAD_CSI_D6 = 77,
106         MX25_PAD_CSI_D7 = 78,
107         MX25_PAD_CSI_D8 = 79,
108         MX25_PAD_CSI_D9 = 80,
109         MX25_PAD_CSI_MCLK = 81,
110         MX25_PAD_CSI_VSYNC = 82,
111         MX25_PAD_CSI_HSYNC = 83,
112         MX25_PAD_CSI_PIXCLK = 84,
113         MX25_PAD_I2C1_CLK = 85,
114         MX25_PAD_I2C1_DAT = 86,
115         MX25_PAD_CSPI1_MOSI = 87,
116         MX25_PAD_CSPI1_MISO = 88,
117         MX25_PAD_CSPI1_SS0 = 89,
118         MX25_PAD_CSPI1_SS1 = 90,
119         MX25_PAD_CSPI1_SCLK = 91,
120         MX25_PAD_CSPI1_RDY = 92,
121         MX25_PAD_UART1_RXD = 93,
122         MX25_PAD_UART1_TXD = 94,
123         MX25_PAD_UART1_RTS = 95,
124         MX25_PAD_UART1_CTS = 96,
125         MX25_PAD_UART2_RXD = 97,
126         MX25_PAD_UART2_TXD = 98,
127         MX25_PAD_UART2_RTS = 99,
128         MX25_PAD_UART2_CTS = 100,
129         MX25_PAD_SD1_CMD = 101,
130         MX25_PAD_SD1_CLK = 102,
131         MX25_PAD_SD1_DATA0 = 103,
132         MX25_PAD_SD1_DATA1 = 104,
133         MX25_PAD_SD1_DATA2 = 105,
134         MX25_PAD_SD1_DATA3 = 106,
135         MX25_PAD_KPP_ROW0 = 107,
136         MX25_PAD_KPP_ROW1 = 108,
137         MX25_PAD_KPP_ROW2 = 109,
138         MX25_PAD_KPP_ROW3 = 110,
139         MX25_PAD_KPP_COL0 = 111,
140         MX25_PAD_KPP_COL1 = 112,
141         MX25_PAD_KPP_COL2 = 113,
142         MX25_PAD_KPP_COL3 = 114,
143         MX25_PAD_FEC_MDC = 115,
144         MX25_PAD_FEC_MDIO = 116,
145         MX25_PAD_FEC_TDATA0 = 117,
146         MX25_PAD_FEC_TDATA1 = 118,
147         MX25_PAD_FEC_TX_EN = 119,
148         MX25_PAD_FEC_RDATA0 = 120,
149         MX25_PAD_FEC_RDATA1 = 121,
150         MX25_PAD_FEC_RX_DV = 122,
151         MX25_PAD_FEC_TX_CLK = 123,
152         MX25_PAD_RTCK = 124,
153         MX25_PAD_DE_B = 125,
154         MX25_PAD_GPIO_A = 126,
155         MX25_PAD_GPIO_B = 127,
156         MX25_PAD_GPIO_C = 128,
157         MX25_PAD_GPIO_D = 129,
158         MX25_PAD_GPIO_E = 130,
159         MX25_PAD_GPIO_F = 131,
160         MX25_PAD_EXT_ARMCLK = 132,
161         MX25_PAD_UPLL_BYPCLK = 133,
162         MX25_PAD_VSTBY_REQ = 134,
163         MX25_PAD_VSTBY_ACK = 135,
164         MX25_PAD_POWER_FAIL  = 136,
165         MX25_PAD_CLKO = 137,
166         MX25_PAD_BOOT_MODE0 = 138,
167         MX25_PAD_BOOT_MODE1 = 139,
168 };
169
170 /* Pad names for the pinmux subsystem */
171 static const struct pinctrl_pin_desc imx25_pinctrl_pads[] = {
172         IMX_PINCTRL_PIN(MX25_PAD_RESERVE0),
173         IMX_PINCTRL_PIN(MX25_PAD_RESERVE1),
174         IMX_PINCTRL_PIN(MX25_PAD_A10),
175         IMX_PINCTRL_PIN(MX25_PAD_A13),
176         IMX_PINCTRL_PIN(MX25_PAD_A14),
177         IMX_PINCTRL_PIN(MX25_PAD_A15),
178         IMX_PINCTRL_PIN(MX25_PAD_A16),
179         IMX_PINCTRL_PIN(MX25_PAD_A17),
180         IMX_PINCTRL_PIN(MX25_PAD_A18),
181         IMX_PINCTRL_PIN(MX25_PAD_A19),
182         IMX_PINCTRL_PIN(MX25_PAD_A20),
183         IMX_PINCTRL_PIN(MX25_PAD_A21),
184         IMX_PINCTRL_PIN(MX25_PAD_A22),
185         IMX_PINCTRL_PIN(MX25_PAD_A23),
186         IMX_PINCTRL_PIN(MX25_PAD_A24),
187         IMX_PINCTRL_PIN(MX25_PAD_A25),
188         IMX_PINCTRL_PIN(MX25_PAD_EB0),
189         IMX_PINCTRL_PIN(MX25_PAD_EB1),
190         IMX_PINCTRL_PIN(MX25_PAD_OE),
191         IMX_PINCTRL_PIN(MX25_PAD_CS0),
192         IMX_PINCTRL_PIN(MX25_PAD_CS1),
193         IMX_PINCTRL_PIN(MX25_PAD_CS4),
194         IMX_PINCTRL_PIN(MX25_PAD_CS5),
195         IMX_PINCTRL_PIN(MX25_PAD_NF_CE0),
196         IMX_PINCTRL_PIN(MX25_PAD_ECB),
197         IMX_PINCTRL_PIN(MX25_PAD_LBA),
198         IMX_PINCTRL_PIN(MX25_PAD_BCLK),
199         IMX_PINCTRL_PIN(MX25_PAD_RW),
200         IMX_PINCTRL_PIN(MX25_PAD_NFWE_B),
201         IMX_PINCTRL_PIN(MX25_PAD_NFRE_B),
202         IMX_PINCTRL_PIN(MX25_PAD_NFALE),
203         IMX_PINCTRL_PIN(MX25_PAD_NFCLE),
204         IMX_PINCTRL_PIN(MX25_PAD_NFWP_B),
205         IMX_PINCTRL_PIN(MX25_PAD_NFRB),
206         IMX_PINCTRL_PIN(MX25_PAD_D15),
207         IMX_PINCTRL_PIN(MX25_PAD_D14),
208         IMX_PINCTRL_PIN(MX25_PAD_D13),
209         IMX_PINCTRL_PIN(MX25_PAD_D12),
210         IMX_PINCTRL_PIN(MX25_PAD_D11),
211         IMX_PINCTRL_PIN(MX25_PAD_D10),
212         IMX_PINCTRL_PIN(MX25_PAD_D9),
213         IMX_PINCTRL_PIN(MX25_PAD_D8),
214         IMX_PINCTRL_PIN(MX25_PAD_D7),
215         IMX_PINCTRL_PIN(MX25_PAD_D6),
216         IMX_PINCTRL_PIN(MX25_PAD_D5),
217         IMX_PINCTRL_PIN(MX25_PAD_D4),
218         IMX_PINCTRL_PIN(MX25_PAD_D3),
219         IMX_PINCTRL_PIN(MX25_PAD_D2),
220         IMX_PINCTRL_PIN(MX25_PAD_D1),
221         IMX_PINCTRL_PIN(MX25_PAD_D0),
222         IMX_PINCTRL_PIN(MX25_PAD_LD0),
223         IMX_PINCTRL_PIN(MX25_PAD_LD1),
224         IMX_PINCTRL_PIN(MX25_PAD_LD2),
225         IMX_PINCTRL_PIN(MX25_PAD_LD3),
226         IMX_PINCTRL_PIN(MX25_PAD_LD4),
227         IMX_PINCTRL_PIN(MX25_PAD_LD5),
228         IMX_PINCTRL_PIN(MX25_PAD_LD6),
229         IMX_PINCTRL_PIN(MX25_PAD_LD7),
230         IMX_PINCTRL_PIN(MX25_PAD_LD8),
231         IMX_PINCTRL_PIN(MX25_PAD_LD9),
232         IMX_PINCTRL_PIN(MX25_PAD_LD10),
233         IMX_PINCTRL_PIN(MX25_PAD_LD11),
234         IMX_PINCTRL_PIN(MX25_PAD_LD12),
235         IMX_PINCTRL_PIN(MX25_PAD_LD13),
236         IMX_PINCTRL_PIN(MX25_PAD_LD14),
237         IMX_PINCTRL_PIN(MX25_PAD_LD15),
238         IMX_PINCTRL_PIN(MX25_PAD_HSYNC),
239         IMX_PINCTRL_PIN(MX25_PAD_VSYNC),
240         IMX_PINCTRL_PIN(MX25_PAD_LSCLK),
241         IMX_PINCTRL_PIN(MX25_PAD_OE_ACD),
242         IMX_PINCTRL_PIN(MX25_PAD_CONTRAST),
243         IMX_PINCTRL_PIN(MX25_PAD_PWM),
244         IMX_PINCTRL_PIN(MX25_PAD_CSI_D2),
245         IMX_PINCTRL_PIN(MX25_PAD_CSI_D3),
246         IMX_PINCTRL_PIN(MX25_PAD_CSI_D4),
247         IMX_PINCTRL_PIN(MX25_PAD_CSI_D5),
248         IMX_PINCTRL_PIN(MX25_PAD_CSI_D6),
249         IMX_PINCTRL_PIN(MX25_PAD_CSI_D7),
250         IMX_PINCTRL_PIN(MX25_PAD_CSI_D8),
251         IMX_PINCTRL_PIN(MX25_PAD_CSI_D9),
252         IMX_PINCTRL_PIN(MX25_PAD_CSI_MCLK),
253         IMX_PINCTRL_PIN(MX25_PAD_CSI_VSYNC),
254         IMX_PINCTRL_PIN(MX25_PAD_CSI_HSYNC),
255         IMX_PINCTRL_PIN(MX25_PAD_CSI_PIXCLK),
256         IMX_PINCTRL_PIN(MX25_PAD_I2C1_CLK),
257         IMX_PINCTRL_PIN(MX25_PAD_I2C1_DAT),
258         IMX_PINCTRL_PIN(MX25_PAD_CSPI1_MOSI),
259         IMX_PINCTRL_PIN(MX25_PAD_CSPI1_MISO),
260         IMX_PINCTRL_PIN(MX25_PAD_CSPI1_SS0),
261         IMX_PINCTRL_PIN(MX25_PAD_CSPI1_SS1),
262         IMX_PINCTRL_PIN(MX25_PAD_CSPI1_SCLK),
263         IMX_PINCTRL_PIN(MX25_PAD_CSPI1_RDY),
264         IMX_PINCTRL_PIN(MX25_PAD_UART1_RXD),
265         IMX_PINCTRL_PIN(MX25_PAD_UART1_TXD),
266         IMX_PINCTRL_PIN(MX25_PAD_UART1_RTS),
267         IMX_PINCTRL_PIN(MX25_PAD_UART1_CTS),
268         IMX_PINCTRL_PIN(MX25_PAD_UART2_RXD),
269         IMX_PINCTRL_PIN(MX25_PAD_UART2_TXD),
270         IMX_PINCTRL_PIN(MX25_PAD_UART2_RTS),
271         IMX_PINCTRL_PIN(MX25_PAD_UART2_CTS),
272         IMX_PINCTRL_PIN(MX25_PAD_SD1_CMD),
273         IMX_PINCTRL_PIN(MX25_PAD_SD1_CLK),
274         IMX_PINCTRL_PIN(MX25_PAD_SD1_DATA0),
275         IMX_PINCTRL_PIN(MX25_PAD_SD1_DATA1),
276         IMX_PINCTRL_PIN(MX25_PAD_SD1_DATA2),
277         IMX_PINCTRL_PIN(MX25_PAD_SD1_DATA3),
278         IMX_PINCTRL_PIN(MX25_PAD_KPP_ROW0),
279         IMX_PINCTRL_PIN(MX25_PAD_KPP_ROW1),
280         IMX_PINCTRL_PIN(MX25_PAD_KPP_ROW2),
281         IMX_PINCTRL_PIN(MX25_PAD_KPP_ROW3),
282         IMX_PINCTRL_PIN(MX25_PAD_KPP_COL0),
283         IMX_PINCTRL_PIN(MX25_PAD_KPP_COL1),
284         IMX_PINCTRL_PIN(MX25_PAD_KPP_COL2),
285         IMX_PINCTRL_PIN(MX25_PAD_KPP_COL3),
286         IMX_PINCTRL_PIN(MX25_PAD_FEC_MDC),
287         IMX_PINCTRL_PIN(MX25_PAD_FEC_MDIO),
288         IMX_PINCTRL_PIN(MX25_PAD_FEC_TDATA0),
289         IMX_PINCTRL_PIN(MX25_PAD_FEC_TDATA1),
290         IMX_PINCTRL_PIN(MX25_PAD_FEC_TX_EN),
291         IMX_PINCTRL_PIN(MX25_PAD_FEC_RDATA0),
292         IMX_PINCTRL_PIN(MX25_PAD_FEC_RDATA1),
293         IMX_PINCTRL_PIN(MX25_PAD_FEC_RX_DV),
294         IMX_PINCTRL_PIN(MX25_PAD_FEC_TX_CLK),
295         IMX_PINCTRL_PIN(MX25_PAD_RTCK),
296         IMX_PINCTRL_PIN(MX25_PAD_DE_B),
297         IMX_PINCTRL_PIN(MX25_PAD_GPIO_A),
298         IMX_PINCTRL_PIN(MX25_PAD_GPIO_B),
299         IMX_PINCTRL_PIN(MX25_PAD_GPIO_C),
300         IMX_PINCTRL_PIN(MX25_PAD_GPIO_D),
301         IMX_PINCTRL_PIN(MX25_PAD_GPIO_E),
302         IMX_PINCTRL_PIN(MX25_PAD_GPIO_F),
303         IMX_PINCTRL_PIN(MX25_PAD_EXT_ARMCLK),
304         IMX_PINCTRL_PIN(MX25_PAD_UPLL_BYPCLK),
305         IMX_PINCTRL_PIN(MX25_PAD_VSTBY_REQ),
306         IMX_PINCTRL_PIN(MX25_PAD_VSTBY_ACK),
307         IMX_PINCTRL_PIN(MX25_PAD_POWER_FAIL),
308         IMX_PINCTRL_PIN(MX25_PAD_CLKO),
309         IMX_PINCTRL_PIN(MX25_PAD_BOOT_MODE0),
310         IMX_PINCTRL_PIN(MX25_PAD_BOOT_MODE1),
311 };
312
313 static struct imx_pinctrl_soc_info imx25_pinctrl_info = {
314         .pins = imx25_pinctrl_pads,
315         .npins = ARRAY_SIZE(imx25_pinctrl_pads),
316 };
317
318 static struct of_device_id imx25_pinctrl_of_match[] = {
319         { .compatible = "fsl,imx25-iomuxc", },
320         { /* sentinel */ }
321 };
322
323 static int imx25_pinctrl_probe(struct platform_device *pdev)
324 {
325         return imx_pinctrl_probe(pdev, &imx25_pinctrl_info);
326 }
327
328 static struct platform_driver imx25_pinctrl_driver = {
329         .driver = {
330                 .name = "imx25-pinctrl",
331                 .owner = THIS_MODULE,
332                 .of_match_table = of_match_ptr(imx25_pinctrl_of_match),
333         },
334         .probe = imx25_pinctrl_probe,
335         .remove = imx_pinctrl_remove,
336 };
337
338 static int __init imx25_pinctrl_init(void)
339 {
340         return platform_driver_register(&imx25_pinctrl_driver);
341 }
342 arch_initcall(imx25_pinctrl_init);
343
344 static void __exit imx25_pinctrl_exit(void)
345 {
346         platform_driver_unregister(&imx25_pinctrl_driver);
347 }
348 module_exit(imx25_pinctrl_exit);
349 MODULE_AUTHOR("Denis Carikli <denis@eukrea.com>");
350 MODULE_DESCRIPTION("Freescale IMX25 pinctrl driver");
351 MODULE_LICENSE("GPL v2");