2 * Marvell Armada 370 pinctrl driver based on mvebu pinctrl core
4 * Copyright (C) 2012 Marvell
6 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
14 #include <linux/err.h>
15 #include <linux/init.h>
17 #include <linux/module.h>
18 #include <linux/platform_device.h>
19 #include <linux/clk.h>
21 #include <linux/of_device.h>
22 #include <linux/pinctrl/pinctrl.h>
24 #include "pinctrl-mvebu.h"
26 static struct mvebu_mpp_mode mv88f6710_mpp_modes
[] = {
28 MPP_FUNCTION(0x0, "gpio", NULL
),
29 MPP_FUNCTION(0x1, "uart0", "rxd")),
31 MPP_FUNCTION(0x0, "gpo", NULL
),
32 MPP_FUNCTION(0x1, "uart0", "txd")),
34 MPP_FUNCTION(0x0, "gpio", NULL
),
35 MPP_FUNCTION(0x1, "i2c0", "sck"),
36 MPP_FUNCTION(0x2, "uart0", "txd")),
38 MPP_FUNCTION(0x0, "gpio", NULL
),
39 MPP_FUNCTION(0x1, "i2c0", "sda"),
40 MPP_FUNCTION(0x2, "uart0", "rxd")),
42 MPP_FUNCTION(0x0, "gpio", NULL
),
43 MPP_FUNCTION(0x1, "cpu_pd", "vdd")),
45 MPP_FUNCTION(0x0, "gpo", NULL
),
46 MPP_FUNCTION(0x1, "ge0", "txclko"),
47 MPP_FUNCTION(0x2, "uart1", "txd"),
48 MPP_FUNCTION(0x4, "spi1", "clk"),
49 MPP_FUNCTION(0x5, "audio", "mclk")),
51 MPP_FUNCTION(0x0, "gpio", NULL
),
52 MPP_FUNCTION(0x1, "ge0", "txd0"),
53 MPP_FUNCTION(0x2, "sata0", "prsnt"),
54 MPP_FUNCTION(0x4, "tdm", "rst"),
55 MPP_FUNCTION(0x5, "audio", "sdo")),
57 MPP_FUNCTION(0x0, "gpo", NULL
),
58 MPP_FUNCTION(0x1, "ge0", "txd1"),
59 MPP_FUNCTION(0x4, "tdm", "tdx"),
60 MPP_FUNCTION(0x5, "audio", "lrclk")),
62 MPP_FUNCTION(0x0, "gpio", NULL
),
63 MPP_FUNCTION(0x1, "ge0", "txd2"),
64 MPP_FUNCTION(0x2, "uart0", "rts"),
65 MPP_FUNCTION(0x4, "tdm", "drx"),
66 MPP_FUNCTION(0x5, "audio", "bclk")),
68 MPP_FUNCTION(0x0, "gpo", NULL
),
69 MPP_FUNCTION(0x1, "ge0", "txd3"),
70 MPP_FUNCTION(0x2, "uart1", "txd"),
71 MPP_FUNCTION(0x3, "sd0", "clk"),
72 MPP_FUNCTION(0x5, "audio", "spdifo")),
74 MPP_FUNCTION(0x0, "gpio", NULL
),
75 MPP_FUNCTION(0x1, "ge0", "txctl"),
76 MPP_FUNCTION(0x2, "uart0", "cts"),
77 MPP_FUNCTION(0x4, "tdm", "fsync"),
78 MPP_FUNCTION(0x5, "audio", "sdi")),
80 MPP_FUNCTION(0x0, "gpio", NULL
),
81 MPP_FUNCTION(0x1, "ge0", "rxd0"),
82 MPP_FUNCTION(0x2, "uart1", "rxd"),
83 MPP_FUNCTION(0x3, "sd0", "cmd"),
84 MPP_FUNCTION(0x4, "spi0", "cs1"),
85 MPP_FUNCTION(0x5, "sata1", "prsnt"),
86 MPP_FUNCTION(0x6, "spi1", "cs1")),
88 MPP_FUNCTION(0x0, "gpio", NULL
),
89 MPP_FUNCTION(0x1, "ge0", "rxd1"),
90 MPP_FUNCTION(0x2, "i2c1", "sda"),
91 MPP_FUNCTION(0x3, "sd0", "d0"),
92 MPP_FUNCTION(0x4, "spi1", "cs0"),
93 MPP_FUNCTION(0x5, "audio", "spdifi")),
95 MPP_FUNCTION(0x0, "gpio", NULL
),
96 MPP_FUNCTION(0x1, "ge0", "rxd2"),
97 MPP_FUNCTION(0x2, "i2c1", "sck"),
98 MPP_FUNCTION(0x3, "sd0", "d1"),
99 MPP_FUNCTION(0x4, "tdm", "pclk"),
100 MPP_FUNCTION(0x5, "audio", "rmclk")),
102 MPP_FUNCTION(0x0, "gpio", NULL
),
103 MPP_FUNCTION(0x1, "ge0", "rxd3"),
104 MPP_FUNCTION(0x2, "pcie", "clkreq0"),
105 MPP_FUNCTION(0x3, "sd0", "d2"),
106 MPP_FUNCTION(0x4, "spi1", "mosi"),
107 MPP_FUNCTION(0x5, "spi0", "cs2")),
109 MPP_FUNCTION(0x0, "gpio", NULL
),
110 MPP_FUNCTION(0x1, "ge0", "rxctl"),
111 MPP_FUNCTION(0x2, "pcie", "clkreq1"),
112 MPP_FUNCTION(0x3, "sd0", "d3"),
113 MPP_FUNCTION(0x4, "spi1", "miso"),
114 MPP_FUNCTION(0x5, "spi0", "cs3")),
116 MPP_FUNCTION(0x0, "gpio", NULL
),
117 MPP_FUNCTION(0x1, "ge0", "rxclk"),
118 MPP_FUNCTION(0x2, "uart1", "rxd"),
119 MPP_FUNCTION(0x4, "tdm", "int"),
120 MPP_FUNCTION(0x5, "audio", "extclk")),
122 MPP_FUNCTION(0x0, "gpo", NULL
),
123 MPP_FUNCTION(0x1, "ge", "mdc")),
125 MPP_FUNCTION(0x0, "gpio", NULL
),
126 MPP_FUNCTION(0x1, "ge", "mdio")),
128 MPP_FUNCTION(0x0, "gpio", NULL
),
129 MPP_FUNCTION(0x1, "ge0", "txclk"),
130 MPP_FUNCTION(0x2, "ge1", "txclkout"),
131 MPP_FUNCTION(0x4, "tdm", "pclk")),
133 MPP_FUNCTION(0x0, "gpo", NULL
),
134 MPP_FUNCTION(0x1, "ge0", "txd4"),
135 MPP_FUNCTION(0x2, "ge1", "txd0")),
137 MPP_FUNCTION(0x0, "gpo", NULL
),
138 MPP_FUNCTION(0x1, "ge0", "txd5"),
139 MPP_FUNCTION(0x2, "ge1", "txd1"),
140 MPP_FUNCTION(0x4, "uart1", "txd")),
142 MPP_FUNCTION(0x0, "gpo", NULL
),
143 MPP_FUNCTION(0x1, "ge0", "txd6"),
144 MPP_FUNCTION(0x2, "ge1", "txd2"),
145 MPP_FUNCTION(0x4, "uart0", "rts")),
147 MPP_FUNCTION(0x0, "gpo", NULL
),
148 MPP_FUNCTION(0x1, "ge0", "txd7"),
149 MPP_FUNCTION(0x2, "ge1", "txd3"),
150 MPP_FUNCTION(0x4, "spi1", "mosi")),
152 MPP_FUNCTION(0x0, "gpio", NULL
),
153 MPP_FUNCTION(0x1, "ge0", "col"),
154 MPP_FUNCTION(0x2, "ge1", "txctl"),
155 MPP_FUNCTION(0x4, "spi1", "cs0")),
157 MPP_FUNCTION(0x0, "gpio", NULL
),
158 MPP_FUNCTION(0x1, "ge0", "rxerr"),
159 MPP_FUNCTION(0x2, "ge1", "rxd0"),
160 MPP_FUNCTION(0x4, "uart1", "rxd")),
162 MPP_FUNCTION(0x0, "gpio", NULL
),
163 MPP_FUNCTION(0x1, "ge0", "crs"),
164 MPP_FUNCTION(0x2, "ge1", "rxd1"),
165 MPP_FUNCTION(0x4, "spi1", "miso")),
167 MPP_FUNCTION(0x0, "gpio", NULL
),
168 MPP_FUNCTION(0x1, "ge0", "rxd4"),
169 MPP_FUNCTION(0x2, "ge1", "rxd2"),
170 MPP_FUNCTION(0x4, "uart0", "cts")),
172 MPP_FUNCTION(0x0, "gpio", NULL
),
173 MPP_FUNCTION(0x1, "ge0", "rxd5"),
174 MPP_FUNCTION(0x2, "ge1", "rxd3")),
176 MPP_FUNCTION(0x0, "gpio", NULL
),
177 MPP_FUNCTION(0x1, "ge0", "rxd6"),
178 MPP_FUNCTION(0x2, "ge1", "rxctl"),
179 MPP_FUNCTION(0x4, "i2c1", "sda")),
181 MPP_FUNCTION(0x0, "gpio", NULL
),
182 MPP_FUNCTION(0x1, "ge0", "rxd7"),
183 MPP_FUNCTION(0x2, "ge1", "rxclk"),
184 MPP_FUNCTION(0x4, "i2c1", "sck")),
186 MPP_FUNCTION(0x0, "gpio", NULL
),
187 MPP_FUNCTION(0x3, "tclk", NULL
),
188 MPP_FUNCTION(0x4, "ge0", "txerr")),
190 MPP_FUNCTION(0x0, "gpio", NULL
),
191 MPP_FUNCTION(0x1, "spi0", "cs0")),
193 MPP_FUNCTION(0x0, "gpio", NULL
),
194 MPP_FUNCTION(0x1, "dev", "bootcs"),
195 MPP_FUNCTION(0x2, "spi0", "cs0")),
197 MPP_FUNCTION(0x0, "gpo", NULL
),
198 MPP_FUNCTION(0x1, "dev", "wen0"),
199 MPP_FUNCTION(0x2, "spi0", "mosi")),
201 MPP_FUNCTION(0x0, "gpo", NULL
),
202 MPP_FUNCTION(0x1, "dev", "oen"),
203 MPP_FUNCTION(0x2, "spi0", "sck")),
205 MPP_FUNCTION(0x0, "gpo", NULL
),
206 MPP_FUNCTION(0x1, "dev", "a1"),
207 MPP_FUNCTION(0x2, "spi0", "miso")),
209 MPP_FUNCTION(0x0, "gpo", NULL
),
210 MPP_FUNCTION(0x1, "dev", "a0"),
211 MPP_FUNCTION(0x2, "sata0", "prsnt")),
213 MPP_FUNCTION(0x0, "gpio", NULL
),
214 MPP_FUNCTION(0x1, "dev", "ready"),
215 MPP_FUNCTION(0x2, "uart1", "cts"),
216 MPP_FUNCTION(0x3, "uart0", "cts")),
218 MPP_FUNCTION(0x0, "gpo", NULL
),
219 MPP_FUNCTION(0x1, "dev", "ad0"),
220 MPP_FUNCTION(0x2, "audio", "spdifo")),
222 MPP_FUNCTION(0x0, "gpio", NULL
),
223 MPP_FUNCTION(0x1, "dev", "ad1"),
224 MPP_FUNCTION(0x2, "uart1", "rts"),
225 MPP_FUNCTION(0x3, "uart0", "rts")),
227 MPP_FUNCTION(0x0, "gpio", NULL
),
228 MPP_FUNCTION(0x1, "dev", "ad2"),
229 MPP_FUNCTION(0x2, "uart1", "rxd")),
231 MPP_FUNCTION(0x0, "gpo", NULL
),
232 MPP_FUNCTION(0x1, "dev", "ad3"),
233 MPP_FUNCTION(0x2, "uart1", "txd")),
235 MPP_FUNCTION(0x0, "gpo", NULL
),
236 MPP_FUNCTION(0x1, "dev", "ad4"),
237 MPP_FUNCTION(0x2, "audio", "bclk")),
239 MPP_FUNCTION(0x0, "gpo", NULL
),
240 MPP_FUNCTION(0x1, "dev", "ad5"),
241 MPP_FUNCTION(0x2, "audio", "mclk")),
243 MPP_FUNCTION(0x0, "gpo", NULL
),
244 MPP_FUNCTION(0x1, "dev", "ad6"),
245 MPP_FUNCTION(0x2, "audio", "lrclk")),
247 MPP_FUNCTION(0x0, "gpo", NULL
),
248 MPP_FUNCTION(0x1, "dev", "ad7"),
249 MPP_FUNCTION(0x2, "audio", "sdo")),
251 MPP_FUNCTION(0x0, "gpo", NULL
),
252 MPP_FUNCTION(0x1, "dev", "ad8"),
253 MPP_FUNCTION(0x3, "sd0", "clk"),
254 MPP_FUNCTION(0x5, "audio", "spdifo")),
256 MPP_FUNCTION(0x0, "gpio", NULL
),
257 MPP_FUNCTION(0x1, "dev", "ad9"),
258 MPP_FUNCTION(0x2, "uart0", "rts"),
259 MPP_FUNCTION(0x3, "sd0", "cmd"),
260 MPP_FUNCTION(0x4, "sata1", "prsnt"),
261 MPP_FUNCTION(0x5, "spi0", "cs1")),
263 MPP_FUNCTION(0x0, "gpio", NULL
),
264 MPP_FUNCTION(0x1, "dev", "ad10"),
265 MPP_FUNCTION(0x2, "pcie", "clkreq1"),
266 MPP_FUNCTION(0x3, "sd0", "d0"),
267 MPP_FUNCTION(0x4, "spi1", "cs0"),
268 MPP_FUNCTION(0x5, "audio", "spdifi")),
270 MPP_FUNCTION(0x0, "gpio", NULL
),
271 MPP_FUNCTION(0x1, "dev", "ad11"),
272 MPP_FUNCTION(0x2, "uart0", "cts"),
273 MPP_FUNCTION(0x3, "sd0", "d1"),
274 MPP_FUNCTION(0x4, "spi1", "miso"),
275 MPP_FUNCTION(0x5, "audio", "rmclk")),
277 MPP_FUNCTION(0x0, "gpio", NULL
),
278 MPP_FUNCTION(0x1, "dev", "ad12"),
279 MPP_FUNCTION(0x2, "i2c1", "sda"),
280 MPP_FUNCTION(0x3, "sd0", "d2"),
281 MPP_FUNCTION(0x4, "spi1", "mosi")),
283 MPP_FUNCTION(0x0, "gpio", NULL
),
284 MPP_FUNCTION(0x1, "dev", "ad13"),
285 MPP_FUNCTION(0x2, "i2c1", "sck"),
286 MPP_FUNCTION(0x3, "sd0", "d3"),
287 MPP_FUNCTION(0x4, "spi1", "sck")),
289 MPP_FUNCTION(0x0, "gpio", NULL
),
290 MPP_FUNCTION(0x1, "dev", "ad14"),
291 MPP_FUNCTION(0x2, "sd0", "clk"),
292 MPP_FUNCTION(0x3, "tdm", "pclk"),
293 MPP_FUNCTION(0x4, "spi0", "cs2"),
294 MPP_FUNCTION(0x5, "pcie", "clkreq1")),
296 MPP_FUNCTION(0x0, "gpo", NULL
),
297 MPP_FUNCTION(0x1, "dev", "ad15"),
298 MPP_FUNCTION(0x3, "tdm", "dtx")),
300 MPP_FUNCTION(0x0, "gpio", NULL
),
301 MPP_FUNCTION(0x1, "dev", "cs1"),
302 MPP_FUNCTION(0x2, "uart1", "txd"),
303 MPP_FUNCTION(0x3, "tdm", "rst"),
304 MPP_FUNCTION(0x4, "sata1", "prsnt"),
305 MPP_FUNCTION(0x5, "sata0", "prsnt")),
307 MPP_FUNCTION(0x0, "gpio", NULL
),
308 MPP_FUNCTION(0x1, "dev", "cs2"),
309 MPP_FUNCTION(0x2, "uart1", "cts"),
310 MPP_FUNCTION(0x3, "uart0", "cts"),
311 MPP_FUNCTION(0x4, "spi0", "cs3"),
312 MPP_FUNCTION(0x5, "pcie", "clkreq0"),
313 MPP_FUNCTION(0x6, "spi1", "cs1")),
315 MPP_FUNCTION(0x0, "gpio", NULL
),
316 MPP_FUNCTION(0x1, "dev", "cs3"),
317 MPP_FUNCTION(0x2, "uart1", "rxd"),
318 MPP_FUNCTION(0x3, "tdm", "fsync"),
319 MPP_FUNCTION(0x4, "sata0", "prsnt"),
320 MPP_FUNCTION(0x5, "audio", "sdo")),
322 MPP_FUNCTION(0x0, "gpio", NULL
),
323 MPP_FUNCTION(0x1, "dev", "cs0"),
324 MPP_FUNCTION(0x2, "uart1", "rts"),
325 MPP_FUNCTION(0x3, "tdm", "int"),
326 MPP_FUNCTION(0x5, "audio", "extclk"),
327 MPP_FUNCTION(0x6, "uart0", "rts")),
329 MPP_FUNCTION(0x0, "gpo", NULL
),
330 MPP_FUNCTION(0x1, "dev", "ale0"),
331 MPP_FUNCTION(0x2, "uart1", "rts"),
332 MPP_FUNCTION(0x3, "uart0", "rts"),
333 MPP_FUNCTION(0x5, "audio", "bclk")),
335 MPP_FUNCTION(0x0, "gpio", NULL
),
336 MPP_FUNCTION(0x1, "dev", "ale1"),
337 MPP_FUNCTION(0x2, "uart1", "rxd"),
338 MPP_FUNCTION(0x3, "sata0", "prsnt"),
339 MPP_FUNCTION(0x4, "pcie", "rst-out"),
340 MPP_FUNCTION(0x5, "audio", "sdi")),
342 MPP_FUNCTION(0x0, "gpo", NULL
),
343 MPP_FUNCTION(0x1, "dev", "wen1"),
344 MPP_FUNCTION(0x2, "uart1", "txd"),
345 MPP_FUNCTION(0x5, "audio", "rclk")),
347 MPP_FUNCTION(0x0, "gpio", NULL
),
348 MPP_FUNCTION(0x1, "dev", "a2"),
349 MPP_FUNCTION(0x2, "uart1", "cts"),
350 MPP_FUNCTION(0x3, "tdm", "drx"),
351 MPP_FUNCTION(0x4, "pcie", "clkreq0"),
352 MPP_FUNCTION(0x5, "audio", "mclk"),
353 MPP_FUNCTION(0x6, "uart0", "cts")),
355 MPP_FUNCTION(0x0, "gpo", NULL
),
356 MPP_FUNCTION(0x1, "spi0", "sck"),
357 MPP_FUNCTION(0x2, "tclk", NULL
)),
359 MPP_FUNCTION(0x0, "gpio", NULL
),
360 MPP_FUNCTION(0x1, "spi0", "miso"),
361 MPP_FUNCTION(0x2, "spi0-1", "cs1")),
363 MPP_FUNCTION(0x0, "gpio", NULL
),
364 MPP_FUNCTION(0x1, "spi0", "mosi"),
365 MPP_FUNCTION(0x2, "spi0-1", "cs2")),
368 static struct mvebu_pinctrl_soc_info armada_370_pinctrl_info
;
370 static struct of_device_id armada_370_pinctrl_of_match
[] = {
371 { .compatible
= "marvell,mv88f6710-pinctrl" },
375 static struct mvebu_mpp_ctrl mv88f6710_mpp_controls
[] = {
379 static struct pinctrl_gpio_range mv88f6710_mpp_gpio_ranges
[] = {
380 MPP_GPIO_RANGE(0, 0, 0, 32),
381 MPP_GPIO_RANGE(1, 32, 32, 32),
382 MPP_GPIO_RANGE(2, 64, 64, 2),
385 static int armada_370_pinctrl_probe(struct platform_device
*pdev
)
387 struct mvebu_pinctrl_soc_info
*soc
= &armada_370_pinctrl_info
;
389 soc
->variant
= 0; /* no variants for Armada 370 */
390 soc
->controls
= mv88f6710_mpp_controls
;
391 soc
->ncontrols
= ARRAY_SIZE(mv88f6710_mpp_controls
);
392 soc
->modes
= mv88f6710_mpp_modes
;
393 soc
->nmodes
= ARRAY_SIZE(mv88f6710_mpp_modes
);
394 soc
->gpioranges
= mv88f6710_mpp_gpio_ranges
;
395 soc
->ngpioranges
= ARRAY_SIZE(mv88f6710_mpp_gpio_ranges
);
397 pdev
->dev
.platform_data
= soc
;
399 return mvebu_pinctrl_probe(pdev
);
402 static int armada_370_pinctrl_remove(struct platform_device
*pdev
)
404 return mvebu_pinctrl_remove(pdev
);
407 static struct platform_driver armada_370_pinctrl_driver
= {
409 .name
= "armada-370-pinctrl",
410 .owner
= THIS_MODULE
,
411 .of_match_table
= armada_370_pinctrl_of_match
,
413 .probe
= armada_370_pinctrl_probe
,
414 .remove
= armada_370_pinctrl_remove
,
417 module_platform_driver(armada_370_pinctrl_driver
);
419 MODULE_AUTHOR("Thomas Petazzoni <thomas.petazzoni@free-electrons.com>");
420 MODULE_DESCRIPTION("Marvell Armada 370 pinctrl driver");
421 MODULE_LICENSE("GPL v2");