2 * Marvell Armada 375 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 void __iomem
*mpp_base
;
28 static int armada_375_mpp_ctrl_get(unsigned pid
, unsigned long *config
)
30 return default_mpp_ctrl_get(mpp_base
, pid
, config
);
33 static int armada_375_mpp_ctrl_set(unsigned pid
, unsigned long config
)
35 return default_mpp_ctrl_set(mpp_base
, pid
, config
);
38 static struct mvebu_mpp_mode mv88f6720_mpp_modes
[] = {
40 MPP_FUNCTION(0x0, "gpio", NULL
),
41 MPP_FUNCTION(0x1, "dev", "ad2"),
42 MPP_FUNCTION(0x2, "spi0", "cs1"),
43 MPP_FUNCTION(0x3, "spi1", "cs1"),
44 MPP_FUNCTION(0x5, "nand", "io2")),
46 MPP_FUNCTION(0x0, "gpio", NULL
),
47 MPP_FUNCTION(0x1, "dev", "ad3"),
48 MPP_FUNCTION(0x2, "spi0", "mosi"),
49 MPP_FUNCTION(0x3, "spi1", "mosi"),
50 MPP_FUNCTION(0x5, "nand", "io3")),
52 MPP_FUNCTION(0x0, "gpio", NULL
),
53 MPP_FUNCTION(0x1, "dev", "ad4"),
54 MPP_FUNCTION(0x2, "ptp", "eventreq"),
55 MPP_FUNCTION(0x3, "led", "c0"),
56 MPP_FUNCTION(0x4, "audio", "sdi"),
57 MPP_FUNCTION(0x5, "nand", "io4"),
58 MPP_FUNCTION(0x6, "spi1", "mosi")),
60 MPP_FUNCTION(0x0, "gpio", NULL
),
61 MPP_FUNCTION(0x1, "dev", "ad5"),
62 MPP_FUNCTION(0x2, "ptp", "triggen"),
63 MPP_FUNCTION(0x3, "led", "p3"),
64 MPP_FUNCTION(0x4, "audio", "mclk"),
65 MPP_FUNCTION(0x5, "nand", "io5"),
66 MPP_FUNCTION(0x6, "spi1", "miso")),
68 MPP_FUNCTION(0x0, "gpio", NULL
),
69 MPP_FUNCTION(0x1, "dev", "ad6"),
70 MPP_FUNCTION(0x2, "spi0", "miso"),
71 MPP_FUNCTION(0x3, "spi1", "miso"),
72 MPP_FUNCTION(0x5, "nand", "io6")),
74 MPP_FUNCTION(0x0, "gpio", NULL
),
75 MPP_FUNCTION(0x1, "dev", "ad7"),
76 MPP_FUNCTION(0x2, "spi0", "cs2"),
77 MPP_FUNCTION(0x3, "spi1", "cs2"),
78 MPP_FUNCTION(0x5, "nand", "io7"),
79 MPP_FUNCTION(0x6, "spi1", "miso")),
81 MPP_FUNCTION(0x0, "gpio", NULL
),
82 MPP_FUNCTION(0x1, "dev", "ad0"),
83 MPP_FUNCTION(0x3, "led", "p1"),
84 MPP_FUNCTION(0x4, "audio", "rclk"),
85 MPP_FUNCTION(0x5, "nand", "io0")),
87 MPP_FUNCTION(0x0, "gpio", NULL
),
88 MPP_FUNCTION(0x1, "dev", "ad1"),
89 MPP_FUNCTION(0x2, "ptp", "clk"),
90 MPP_FUNCTION(0x3, "led", "p2"),
91 MPP_FUNCTION(0x4, "audio", "extclk"),
92 MPP_FUNCTION(0x5, "nand", "io1")),
94 MPP_FUNCTION(0x0, "gpio", NULL
),
95 MPP_FUNCTION(0x1, "dev ", "bootcs"),
96 MPP_FUNCTION(0x2, "spi0", "cs0"),
97 MPP_FUNCTION(0x3, "spi1", "cs0"),
98 MPP_FUNCTION(0x5, "nand", "ce")),
100 MPP_FUNCTION(0x0, "gpio", NULL
),
101 MPP_FUNCTION(0x1, "nf", "wen"),
102 MPP_FUNCTION(0x2, "spi0", "sck"),
103 MPP_FUNCTION(0x3, "spi1", "sck"),
104 MPP_FUNCTION(0x5, "nand", "we")),
106 MPP_FUNCTION(0x0, "gpio", NULL
),
107 MPP_FUNCTION(0x1, "nf", "ren"),
108 MPP_FUNCTION(0x2, "dram", "vttctrl"),
109 MPP_FUNCTION(0x3, "led", "c1"),
110 MPP_FUNCTION(0x5, "nand", "re"),
111 MPP_FUNCTION(0x6, "spi1", "sck")),
113 MPP_FUNCTION(0x0, "gpio", NULL
),
114 MPP_FUNCTION(0x1, "dev", "a0"),
115 MPP_FUNCTION(0x3, "led", "c2"),
116 MPP_FUNCTION(0x4, "audio", "sdo"),
117 MPP_FUNCTION(0x5, "nand", "cle")),
119 MPP_FUNCTION(0x0, "gpio", NULL
),
120 MPP_FUNCTION(0x1, "dev", "a1"),
121 MPP_FUNCTION(0x4, "audio", "bclk"),
122 MPP_FUNCTION(0x5, "nand", "ale")),
124 MPP_FUNCTION(0x0, "gpio", NULL
),
125 MPP_FUNCTION(0x1, "dev", "readyn"),
126 MPP_FUNCTION(0x2, "pcie0", "rstoutn"),
127 MPP_FUNCTION(0x3, "pcie1", "rstoutn"),
128 MPP_FUNCTION(0x5, "nand", "rb"),
129 MPP_FUNCTION(0x6, "spi1", "mosi")),
131 MPP_FUNCTION(0x0, "gpio", NULL
),
132 MPP_FUNCTION(0x2, "i2c0", "sda"),
133 MPP_FUNCTION(0x3, "uart1", "txd")),
135 MPP_FUNCTION(0x0, "gpio", NULL
),
136 MPP_FUNCTION(0x2, "i2c0", "sck"),
137 MPP_FUNCTION(0x3, "uart1", "rxd")),
139 MPP_FUNCTION(0x0, "gpio", NULL
),
140 MPP_FUNCTION(0x2, "uart0", "txd")),
142 MPP_FUNCTION(0x0, "gpio", NULL
),
143 MPP_FUNCTION(0x2, "uart0", "rxd")),
145 MPP_FUNCTION(0x0, "gpio", NULL
),
146 MPP_FUNCTION(0x2, "tdm", "intn")),
148 MPP_FUNCTION(0x0, "gpio", NULL
),
149 MPP_FUNCTION(0x2, "tdm", "rstn")),
151 MPP_FUNCTION(0x0, "gpio", NULL
),
152 MPP_FUNCTION(0x2, "tdm", "pclk")),
154 MPP_FUNCTION(0x0, "gpio", NULL
),
155 MPP_FUNCTION(0x2, "tdm", "fsync")),
157 MPP_FUNCTION(0x0, "gpio", NULL
),
158 MPP_FUNCTION(0x2, "tdm", "drx")),
160 MPP_FUNCTION(0x0, "gpio", NULL
),
161 MPP_FUNCTION(0x2, "tdm", "dtx")),
163 MPP_FUNCTION(0x0, "gpio", NULL
),
164 MPP_FUNCTION(0x1, "led", "p0"),
165 MPP_FUNCTION(0x2, "ge1", "rxd0"),
166 MPP_FUNCTION(0x3, "sd", "cmd"),
167 MPP_FUNCTION(0x4, "uart0", "rts"),
168 MPP_FUNCTION(0x5, "spi0", "cs0"),
169 MPP_FUNCTION(0x6, "dev", "cs1")),
171 MPP_FUNCTION(0x0, "gpio", NULL
),
172 MPP_FUNCTION(0x1, "led", "p2"),
173 MPP_FUNCTION(0x2, "ge1", "rxd1"),
174 MPP_FUNCTION(0x3, "sd", "d0"),
175 MPP_FUNCTION(0x4, "uart0", "cts"),
176 MPP_FUNCTION(0x5, "spi0", "mosi"),
177 MPP_FUNCTION(0x6, "dev", "cs2")),
179 MPP_FUNCTION(0x0, "gpio", NULL
),
180 MPP_FUNCTION(0x1, "pcie0", "clkreq"),
181 MPP_FUNCTION(0x2, "ge1", "rxd2"),
182 MPP_FUNCTION(0x3, "sd", "d2"),
183 MPP_FUNCTION(0x4, "uart1", "rts"),
184 MPP_FUNCTION(0x5, "spi0", "cs1"),
185 MPP_FUNCTION(0x6, "led", "c1")),
187 MPP_FUNCTION(0x0, "gpio", NULL
),
188 MPP_FUNCTION(0x1, "pcie1", "clkreq"),
189 MPP_FUNCTION(0x2, "ge1", "rxd3"),
190 MPP_FUNCTION(0x3, "sd", "d1"),
191 MPP_FUNCTION(0x4, "uart1", "cts"),
192 MPP_FUNCTION(0x5, "spi0", "miso"),
193 MPP_FUNCTION(0x6, "led", "c2")),
195 MPP_FUNCTION(0x0, "gpio", NULL
),
196 MPP_FUNCTION(0x1, "led", "p3"),
197 MPP_FUNCTION(0x2, "ge1", "txctl"),
198 MPP_FUNCTION(0x3, "sd", "clk"),
199 MPP_FUNCTION(0x5, "dram", "vttctrl")),
201 MPP_FUNCTION(0x0, "gpio", NULL
),
202 MPP_FUNCTION(0x1, "pcie1", "clkreq"),
203 MPP_FUNCTION(0x2, "ge1", "rxclk"),
204 MPP_FUNCTION(0x3, "sd", "d3"),
205 MPP_FUNCTION(0x5, "spi0", "sck"),
206 MPP_FUNCTION(0x6, "pcie0", "rstoutn")),
208 MPP_FUNCTION(0x0, "gpio", NULL
),
209 MPP_FUNCTION(0x2, "ge1", "txd0"),
210 MPP_FUNCTION(0x3, "spi1", "cs0"),
211 MPP_FUNCTION(0x5, "led", "p3"),
212 MPP_FUNCTION(0x6, "ptp", "eventreq")),
214 MPP_FUNCTION(0x0, "gpio", NULL
),
215 MPP_FUNCTION(0x2, "ge1", "txd1"),
216 MPP_FUNCTION(0x3, "spi1", "mosi"),
217 MPP_FUNCTION(0x5, "led", "p0")),
219 MPP_FUNCTION(0x0, "gpio", NULL
),
220 MPP_FUNCTION(0x2, "ge1", "txd2"),
221 MPP_FUNCTION(0x3, "spi1", "sck"),
222 MPP_FUNCTION(0x4, "ptp", "triggen"),
223 MPP_FUNCTION(0x5, "led", "c0")),
225 MPP_FUNCTION(0x0, "gpio", NULL
),
226 MPP_FUNCTION(0x2, "ge1", "txd3"),
227 MPP_FUNCTION(0x3, "spi1", "miso"),
228 MPP_FUNCTION(0x5, "led", "p2")),
230 MPP_FUNCTION(0x0, "gpio", NULL
),
231 MPP_FUNCTION(0x2, "ge1", "txclkout"),
232 MPP_FUNCTION(0x3, "spi1", "sck"),
233 MPP_FUNCTION(0x5, "led", "c1")),
235 MPP_FUNCTION(0x0, "gpio", NULL
),
236 MPP_FUNCTION(0x2, "ge1", "rxctl"),
237 MPP_FUNCTION(0x3, "spi1", "cs1"),
238 MPP_FUNCTION(0x4, "spi0", "cs2"),
239 MPP_FUNCTION(0x5, "led", "p1")),
241 MPP_FUNCTION(0x0, "gpio", NULL
),
242 MPP_FUNCTION(0x1, "pcie0", "clkreq"),
243 MPP_FUNCTION(0x5, "led", "c2")),
245 MPP_FUNCTION(0x0, "gpio", NULL
),
246 MPP_FUNCTION(0x1, "pcie0", "clkreq"),
247 MPP_FUNCTION(0x2, "tdm", "intn"),
248 MPP_FUNCTION(0x4, "ge", "mdc")),
250 MPP_FUNCTION(0x0, "gpio", NULL
),
251 MPP_FUNCTION(0x1, "pcie1", "clkreq"),
252 MPP_FUNCTION(0x4, "ge", "mdio")),
254 MPP_FUNCTION(0x0, "gpio", NULL
),
255 MPP_FUNCTION(0x4, "ref", "clkout"),
256 MPP_FUNCTION(0x5, "led", "p3")),
258 MPP_FUNCTION(0x0, "gpio", NULL
),
259 MPP_FUNCTION(0x4, "uart1", "txd"),
260 MPP_FUNCTION(0x5, "led", "p0")),
262 MPP_FUNCTION(0x0, "gpio", NULL
),
263 MPP_FUNCTION(0x4, "uart1", "rxd"),
264 MPP_FUNCTION(0x5, "led", "p1")),
266 MPP_FUNCTION(0x0, "gpio", NULL
),
267 MPP_FUNCTION(0x3, "spi1", "cs2"),
268 MPP_FUNCTION(0x4, "led", "c0"),
269 MPP_FUNCTION(0x6, "ptp", "clk")),
271 MPP_FUNCTION(0x0, "gpio", NULL
),
272 MPP_FUNCTION(0x2, "sata0", "prsnt"),
273 MPP_FUNCTION(0x4, "dram", "vttctrl"),
274 MPP_FUNCTION(0x5, "led", "c1")),
276 MPP_FUNCTION(0x0, "gpio", NULL
),
277 MPP_FUNCTION(0x4, "sata0", "prsnt")),
279 MPP_FUNCTION(0x0, "gpio", NULL
),
280 MPP_FUNCTION(0x2, "spi0", "cs2"),
281 MPP_FUNCTION(0x4, "pcie0", "rstoutn"),
282 MPP_FUNCTION(0x5, "led", "c2"),
283 MPP_FUNCTION(0x6, "spi1", "cs2")),
285 MPP_FUNCTION(0x0, "gpio", NULL
),
286 MPP_FUNCTION(0x1, "led", "p0"),
287 MPP_FUNCTION(0x2, "ge0", "txd0"),
288 MPP_FUNCTION(0x3, "ge1", "txd0"),
289 MPP_FUNCTION(0x6, "dev", "wen1")),
291 MPP_FUNCTION(0x0, "gpio", NULL
),
292 MPP_FUNCTION(0x1, "led", "p1"),
293 MPP_FUNCTION(0x2, "ge0", "txd1"),
294 MPP_FUNCTION(0x3, "ge1", "txd1"),
295 MPP_FUNCTION(0x5, "ptp", "triggen"),
296 MPP_FUNCTION(0x6, "dev", "ale0")),
298 MPP_FUNCTION(0x0, "gpio", NULL
),
299 MPP_FUNCTION(0x1, "led", "p2"),
300 MPP_FUNCTION(0x2, "ge0", "txd2"),
301 MPP_FUNCTION(0x3, "ge1", "txd2"),
302 MPP_FUNCTION(0x6, "dev", "ale1")),
304 MPP_FUNCTION(0x0, "gpio", NULL
),
305 MPP_FUNCTION(0x1, "led", "p3"),
306 MPP_FUNCTION(0x2, "ge0", "txd3"),
307 MPP_FUNCTION(0x3, "ge1", "txd3"),
308 MPP_FUNCTION(0x6, "dev", "a2")),
310 MPP_FUNCTION(0x0, "gpio", NULL
),
311 MPP_FUNCTION(0x1, "led", "c0"),
312 MPP_FUNCTION(0x2, "ge0", "rxd0"),
313 MPP_FUNCTION(0x3, "ge1", "rxd0"),
314 MPP_FUNCTION(0x5, "ptp", "eventreq"),
315 MPP_FUNCTION(0x6, "dev", "ad12")),
317 MPP_FUNCTION(0x0, "gpio", NULL
),
318 MPP_FUNCTION(0x1, "led", "c1"),
319 MPP_FUNCTION(0x2, "ge0", "rxd1"),
320 MPP_FUNCTION(0x3, "ge1", "rxd1"),
321 MPP_FUNCTION(0x6, "dev", "ad8")),
323 MPP_FUNCTION(0x0, "gpio", NULL
),
324 MPP_FUNCTION(0x1, "led", "c2"),
325 MPP_FUNCTION(0x2, "ge0", "rxd2"),
326 MPP_FUNCTION(0x3, "ge1", "rxd2"),
327 MPP_FUNCTION(0x5, "i2c0", "sda"),
328 MPP_FUNCTION(0x6, "dev", "ad9")),
330 MPP_FUNCTION(0x0, "gpio", NULL
),
331 MPP_FUNCTION(0x1, "pcie1", "rstoutn"),
332 MPP_FUNCTION(0x2, "ge0", "rxd3"),
333 MPP_FUNCTION(0x3, "ge1", "rxd3"),
334 MPP_FUNCTION(0x5, "i2c0", "sck"),
335 MPP_FUNCTION(0x6, "dev", "ad10")),
337 MPP_FUNCTION(0x0, "gpio", NULL
),
338 MPP_FUNCTION(0x1, "pcie0", "rstoutn"),
339 MPP_FUNCTION(0x2, "ge0", "rxctl"),
340 MPP_FUNCTION(0x3, "ge1", "rxctl"),
341 MPP_FUNCTION(0x6, "dev", "ad11")),
343 MPP_FUNCTION(0x0, "gpio", NULL
),
344 MPP_FUNCTION(0x2, "ge0", "rxclk"),
345 MPP_FUNCTION(0x3, "ge1", "rxclk"),
346 MPP_FUNCTION(0x6, "dev", "cs0")),
348 MPP_FUNCTION(0x0, "gpio", NULL
),
349 MPP_FUNCTION(0x2, "ge0", "txclkout"),
350 MPP_FUNCTION(0x3, "ge1", "txclkout"),
351 MPP_FUNCTION(0x6, "dev", "oe")),
353 MPP_FUNCTION(0x0, "gpio", NULL
),
354 MPP_FUNCTION(0x2, "ge0", "txctl"),
355 MPP_FUNCTION(0x3, "ge1", "txctl"),
356 MPP_FUNCTION(0x6, "dev", "wen0")),
358 MPP_FUNCTION(0x0, "gpio", NULL
),
359 MPP_FUNCTION(0x4, "led", "c0")),
361 MPP_FUNCTION(0x0, "gpio", NULL
),
362 MPP_FUNCTION(0x4, "led", "c1")),
364 MPP_FUNCTION(0x0, "gpio", NULL
),
365 MPP_FUNCTION(0x2, "uart1", "txd"),
366 MPP_FUNCTION(0x4, "led", "c2"),
367 MPP_FUNCTION(0x6, "dev", "ad13")),
369 MPP_FUNCTION(0x0, "gpio", NULL
),
370 MPP_FUNCTION(0x1, "i2c1", "sda"),
371 MPP_FUNCTION(0x2, "uart1", "rxd"),
372 MPP_FUNCTION(0x3, "spi1", "cs2"),
373 MPP_FUNCTION(0x4, "led", "p0"),
374 MPP_FUNCTION(0x6, "dev", "ad14")),
376 MPP_FUNCTION(0x0, "gpio", NULL
),
377 MPP_FUNCTION(0x1, "i2c1", "sck"),
378 MPP_FUNCTION(0x4, "led", "p1"),
379 MPP_FUNCTION(0x6, "dev", "ad15")),
381 MPP_FUNCTION(0x0, "gpio", NULL
),
382 MPP_FUNCTION(0x2, "ptp", "triggen"),
383 MPP_FUNCTION(0x4, "led", "p2"),
384 MPP_FUNCTION(0x6, "dev", "burst")),
386 MPP_FUNCTION(0x0, "gpio", NULL
),
387 MPP_FUNCTION(0x2, "dram", "vttctrl"),
388 MPP_FUNCTION(0x4, "led", "p3")),
390 MPP_FUNCTION(0x0, "gpio", NULL
),
391 MPP_FUNCTION(0x1, "sata1", "prsnt")),
393 MPP_FUNCTION(0x0, "gpio", NULL
),
394 MPP_FUNCTION(0x2, "ptp", "eventreq"),
395 MPP_FUNCTION(0x4, "spi1", "cs3"),
396 MPP_FUNCTION(0x5, "pcie0", "rstoutn"),
397 MPP_FUNCTION(0x6, "dev", "cs3")),
400 static struct mvebu_pinctrl_soc_info armada_375_pinctrl_info
;
402 static struct of_device_id armada_375_pinctrl_of_match
[] = {
403 { .compatible
= "marvell,mv88f6720-pinctrl" },
407 static struct mvebu_mpp_ctrl mv88f6720_mpp_controls
[] = {
408 MPP_FUNC_CTRL(0, 69, NULL
, armada_375_mpp_ctrl
),
411 static struct pinctrl_gpio_range mv88f6720_mpp_gpio_ranges
[] = {
412 MPP_GPIO_RANGE(0, 0, 0, 32),
413 MPP_GPIO_RANGE(1, 32, 32, 32),
414 MPP_GPIO_RANGE(2, 64, 64, 3),
417 static int armada_375_pinctrl_probe(struct platform_device
*pdev
)
419 struct mvebu_pinctrl_soc_info
*soc
= &armada_375_pinctrl_info
;
420 struct resource
*res
;
422 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
423 mpp_base
= devm_ioremap_resource(&pdev
->dev
, res
);
424 if (IS_ERR(mpp_base
))
425 return PTR_ERR(mpp_base
);
427 soc
->variant
= 0; /* no variants for Armada 375 */
428 soc
->controls
= mv88f6720_mpp_controls
;
429 soc
->ncontrols
= ARRAY_SIZE(mv88f6720_mpp_controls
);
430 soc
->modes
= mv88f6720_mpp_modes
;
431 soc
->nmodes
= ARRAY_SIZE(mv88f6720_mpp_modes
);
432 soc
->gpioranges
= mv88f6720_mpp_gpio_ranges
;
433 soc
->ngpioranges
= ARRAY_SIZE(mv88f6720_mpp_gpio_ranges
);
435 pdev
->dev
.platform_data
= soc
;
437 return mvebu_pinctrl_probe(pdev
);
440 static int armada_375_pinctrl_remove(struct platform_device
*pdev
)
442 return mvebu_pinctrl_remove(pdev
);
445 static struct platform_driver armada_375_pinctrl_driver
= {
447 .name
= "armada-375-pinctrl",
448 .owner
= THIS_MODULE
,
449 .of_match_table
= of_match_ptr(armada_375_pinctrl_of_match
),
451 .probe
= armada_375_pinctrl_probe
,
452 .remove
= armada_375_pinctrl_remove
,
455 module_platform_driver(armada_375_pinctrl_driver
);
457 MODULE_AUTHOR("Thomas Petazzoni <thomas.petazzoni@free-electrons.com>");
458 MODULE_DESCRIPTION("Marvell Armada 375 pinctrl driver");
459 MODULE_LICENSE("GPL v2");