xref: /openbmc/linux/drivers/pinctrl/mvebu/pinctrl-armada-38x.c (revision 56544d29c3a0e383c0d819fefc9570b2803db193)
1 /*
2  * Marvell Armada 380/385 pinctrl driver based on mvebu pinctrl core
3  *
4  * Copyright (C) 2013 Marvell
5  *
6  * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
7  *
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.
12  */
13 
14 #include <linux/err.h>
15 #include <linux/init.h>
16 #include <linux/io.h>
17 #include <linux/module.h>
18 #include <linux/platform_device.h>
19 #include <linux/of.h>
20 #include <linux/of_device.h>
21 #include <linux/pinctrl/pinctrl.h>
22 
23 #include "pinctrl-mvebu.h"
24 
25 static void __iomem *mpp_base;
26 
27 static int armada_38x_mpp_ctrl_get(unsigned pid, unsigned long *config)
28 {
29 	return default_mpp_ctrl_get(mpp_base, pid, config);
30 }
31 
32 static int armada_38x_mpp_ctrl_set(unsigned pid, unsigned long config)
33 {
34 	return default_mpp_ctrl_set(mpp_base, pid, config);
35 }
36 
37 enum {
38 	V_88F6810 = BIT(0),
39 	V_88F6820 = BIT(1),
40 	V_88F6828 = BIT(2),
41 	V_88F6810_PLUS = (V_88F6810 | V_88F6820 | V_88F6828),
42 	V_88F6820_PLUS = (V_88F6820 | V_88F6828),
43 };
44 
45 static struct mvebu_mpp_mode armada_38x_mpp_modes[] = {
46 	MPP_MODE(0,
47 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
48 		 MPP_VAR_FUNCTION(1, "ua0",   "rxd",        V_88F6810_PLUS)),
49 	MPP_MODE(1,
50 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
51 		 MPP_VAR_FUNCTION(1, "ua0",   "txd",        V_88F6810_PLUS)),
52 	MPP_MODE(2,
53 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
54 		 MPP_VAR_FUNCTION(1, "i2c0",  "sck",        V_88F6810_PLUS)),
55 	MPP_MODE(3,
56 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
57 		 MPP_VAR_FUNCTION(1, "i2c0",  "sda",        V_88F6810_PLUS)),
58 	MPP_MODE(4,
59 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
60 		 MPP_VAR_FUNCTION(1, "ge",    "mdc",        V_88F6810_PLUS),
61 		 MPP_VAR_FUNCTION(2, "ua1",   "txd",        V_88F6810_PLUS),
62 		 MPP_VAR_FUNCTION(3, "ua0",   "rts",        V_88F6810_PLUS)),
63 	MPP_MODE(5,
64 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
65 		 MPP_VAR_FUNCTION(1, "ge",    "mdio",       V_88F6810_PLUS),
66 		 MPP_VAR_FUNCTION(2, "ua1",   "rxd",        V_88F6810_PLUS),
67 		 MPP_VAR_FUNCTION(3, "ua0",   "cts",        V_88F6810_PLUS)),
68 	MPP_MODE(6,
69 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
70 		 MPP_VAR_FUNCTION(1, "ge0",   "txclkout",   V_88F6810_PLUS),
71 		 MPP_VAR_FUNCTION(2, "ge0",   "crs",        V_88F6810_PLUS),
72 		 MPP_VAR_FUNCTION(5, "dev",   "cs3",        V_88F6810_PLUS)),
73 	MPP_MODE(7,
74 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
75 		 MPP_VAR_FUNCTION(1, "ge0",   "txd0",       V_88F6810_PLUS),
76 		 MPP_VAR_FUNCTION(5, "dev",   "ad9",        V_88F6810_PLUS)),
77 	MPP_MODE(8,
78 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
79 		 MPP_VAR_FUNCTION(1, "ge0",   "txd1",       V_88F6810_PLUS),
80 		 MPP_VAR_FUNCTION(5, "dev",   "ad10",       V_88F6810_PLUS)),
81 	MPP_MODE(9,
82 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
83 		 MPP_VAR_FUNCTION(1, "ge0",   "txd2",       V_88F6810_PLUS),
84 		 MPP_VAR_FUNCTION(5, "dev",   "ad11",       V_88F6810_PLUS)),
85 	MPP_MODE(10,
86 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
87 		 MPP_VAR_FUNCTION(1, "ge0",   "txd3",       V_88F6810_PLUS),
88 		 MPP_VAR_FUNCTION(5, "dev",   "ad12",       V_88F6810_PLUS)),
89 	MPP_MODE(11,
90 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
91 		 MPP_VAR_FUNCTION(1, "ge0",   "txctl",      V_88F6810_PLUS),
92 		 MPP_VAR_FUNCTION(5, "dev",   "ad13",       V_88F6810_PLUS)),
93 	MPP_MODE(12,
94 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
95 		 MPP_VAR_FUNCTION(1, "ge0",   "rxd0",       V_88F6810_PLUS),
96 		 MPP_VAR_FUNCTION(2, "pcie0", "rstout",     V_88F6810_PLUS),
97 		 MPP_VAR_FUNCTION(3, "pcie1", "rstout",     V_88F6820_PLUS),
98 		 MPP_VAR_FUNCTION(4, "spi0",  "cs1",        V_88F6810_PLUS),
99 		 MPP_VAR_FUNCTION(5, "dev",   "ad14",       V_88F6810_PLUS)),
100 	MPP_MODE(13,
101 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
102 		 MPP_VAR_FUNCTION(1, "ge0",   "rxd1",       V_88F6810_PLUS),
103 		 MPP_VAR_FUNCTION(2, "pcie0", "clkreq",     V_88F6810_PLUS),
104 		 MPP_VAR_FUNCTION(3, "pcie1", "clkreq",     V_88F6820_PLUS),
105 		 MPP_VAR_FUNCTION(4, "spi0",  "cs2",        V_88F6810_PLUS),
106 		 MPP_VAR_FUNCTION(5, "dev",   "ad15",       V_88F6810_PLUS)),
107 	MPP_MODE(14,
108 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
109 		 MPP_VAR_FUNCTION(1, "ge0",   "rxd2",       V_88F6810_PLUS),
110 		 MPP_VAR_FUNCTION(2, "ptp",   "clk",        V_88F6810_PLUS),
111 		 MPP_VAR_FUNCTION(3, "m",     "vtt_ctrl",   V_88F6810_PLUS),
112 		 MPP_VAR_FUNCTION(4, "spi0",  "cs3",        V_88F6810_PLUS),
113 		 MPP_VAR_FUNCTION(5, "dev",   "wen1",       V_88F6810_PLUS)),
114 	MPP_MODE(15,
115 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
116 		 MPP_VAR_FUNCTION(1, "ge0",   "rxd3",       V_88F6810_PLUS),
117 		 MPP_VAR_FUNCTION(2, "ge",    "mdc slave",  V_88F6810_PLUS),
118 		 MPP_VAR_FUNCTION(3, "pcie0", "rstout",     V_88F6810_PLUS),
119 		 MPP_VAR_FUNCTION(4, "spi0",  "mosi",       V_88F6810_PLUS),
120 		 MPP_VAR_FUNCTION(5, "pcie1", "rstout",     V_88F6820_PLUS)),
121 	MPP_MODE(16,
122 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
123 		 MPP_VAR_FUNCTION(1, "ge0",   "rxctl",      V_88F6810_PLUS),
124 		 MPP_VAR_FUNCTION(2, "ge",    "mdio slave", V_88F6810_PLUS),
125 		 MPP_VAR_FUNCTION(3, "m",     "decc_err",   V_88F6810_PLUS),
126 		 MPP_VAR_FUNCTION(4, "spi0",  "miso",       V_88F6810_PLUS),
127 		 MPP_VAR_FUNCTION(5, "pcie0", "clkreq",     V_88F6810_PLUS)),
128 	MPP_MODE(17,
129 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
130 		 MPP_VAR_FUNCTION(1, "ge0",   "rxclk",      V_88F6810_PLUS),
131 		 MPP_VAR_FUNCTION(2, "ptp",   "clk",        V_88F6810_PLUS),
132 		 MPP_VAR_FUNCTION(3, "ua1",   "rxd",        V_88F6810_PLUS),
133 		 MPP_VAR_FUNCTION(4, "spi0",  "sck",        V_88F6810_PLUS),
134 		 MPP_VAR_FUNCTION(5, "sata1", "prsnt",      V_88F6810_PLUS)),
135 	MPP_MODE(18,
136 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
137 		 MPP_VAR_FUNCTION(1, "ge0",   "rxerr",      V_88F6810_PLUS),
138 		 MPP_VAR_FUNCTION(2, "ptp",   "trig_gen",   V_88F6810_PLUS),
139 		 MPP_VAR_FUNCTION(3, "ua1",   "txd",        V_88F6810_PLUS),
140 		 MPP_VAR_FUNCTION(4, "spi0",  "cs0",        V_88F6810_PLUS),
141 		 MPP_VAR_FUNCTION(5, "pcie1", "rstout",     V_88F6820_PLUS)),
142 	MPP_MODE(19,
143 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
144 		 MPP_VAR_FUNCTION(1, "ge0",   "col",        V_88F6810_PLUS),
145 		 MPP_VAR_FUNCTION(2, "ptp",   "event_req",  V_88F6810_PLUS),
146 		 MPP_VAR_FUNCTION(3, "pcie0", "clkreq",     V_88F6810_PLUS),
147 		 MPP_VAR_FUNCTION(4, "sata1", "prsnt",      V_88F6810_PLUS),
148 		 MPP_VAR_FUNCTION(5, "ua0",   "cts",        V_88F6810_PLUS),
149 		 MPP_VAR_FUNCTION(6, "ua1",   "rxd",        V_88F6810_PLUS)),
150 	MPP_MODE(20,
151 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
152 		 MPP_VAR_FUNCTION(1, "ge0",   "txclk",      V_88F6810_PLUS),
153 		 MPP_VAR_FUNCTION(2, "ptp",   "clk",        V_88F6810_PLUS),
154 		 MPP_VAR_FUNCTION(3, "pcie1", "rstout",     V_88F6820_PLUS),
155 		 MPP_VAR_FUNCTION(4, "sata0", "prsnt",      V_88F6810_PLUS),
156 		 MPP_VAR_FUNCTION(5, "ua0",   "rts",        V_88F6810_PLUS),
157 		 MPP_VAR_FUNCTION(6, "ua1",   "txd",        V_88F6810_PLUS)),
158 	MPP_MODE(21,
159 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
160 		 MPP_VAR_FUNCTION(1, "spi0",  "cs1",        V_88F6810_PLUS),
161 		 MPP_VAR_FUNCTION(2, "ge1",   "rxd0",       V_88F6810_PLUS),
162 		 MPP_VAR_FUNCTION(3, "sata0", "prsnt",      V_88F6810_PLUS),
163 		 MPP_VAR_FUNCTION(4, "sd0",   "cmd",        V_88F6810_PLUS),
164 		 MPP_VAR_FUNCTION(5, "dev",   "bootcs",     V_88F6810_PLUS)),
165 	MPP_MODE(22,
166 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
167 		 MPP_VAR_FUNCTION(1, "spi0",  "mosi",       V_88F6810_PLUS),
168 		 MPP_VAR_FUNCTION(5, "dev",   "ad0",        V_88F6810_PLUS)),
169 	MPP_MODE(23,
170 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
171 		 MPP_VAR_FUNCTION(1, "spi0",  "sck",        V_88F6810_PLUS),
172 		 MPP_VAR_FUNCTION(5, "dev",   "ad2",        V_88F6810_PLUS)),
173 	MPP_MODE(24,
174 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
175 		 MPP_VAR_FUNCTION(1, "spi0",  "miso",       V_88F6810_PLUS),
176 		 MPP_VAR_FUNCTION(2, "ua0",   "cts",        V_88F6810_PLUS),
177 		 MPP_VAR_FUNCTION(3, "ua1",   "rxd",        V_88F6810_PLUS),
178 		 MPP_VAR_FUNCTION(4, "sd0",   "d4",         V_88F6810_PLUS),
179 		 MPP_VAR_FUNCTION(5, "dev",   "ready",      V_88F6810_PLUS)),
180 	MPP_MODE(25,
181 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
182 		 MPP_VAR_FUNCTION(1, "spi0",  "cs0",        V_88F6810_PLUS),
183 		 MPP_VAR_FUNCTION(2, "ua0",   "rts",        V_88F6810_PLUS),
184 		 MPP_VAR_FUNCTION(3, "ua1",   "txd",        V_88F6810_PLUS),
185 		 MPP_VAR_FUNCTION(4, "sd0",   "d5",         V_88F6810_PLUS),
186 		 MPP_VAR_FUNCTION(5, "dev",   "cs0",        V_88F6810_PLUS)),
187 	MPP_MODE(26,
188 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
189 		 MPP_VAR_FUNCTION(1, "spi0",  "cs2",        V_88F6810_PLUS),
190 		 MPP_VAR_FUNCTION(3, "i2c1",  "sck",        V_88F6810_PLUS),
191 		 MPP_VAR_FUNCTION(4, "sd0",   "d6",         V_88F6810_PLUS),
192 		 MPP_VAR_FUNCTION(5, "dev",   "cs1",        V_88F6810_PLUS)),
193 	MPP_MODE(27,
194 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
195 		 MPP_VAR_FUNCTION(1, "spi0",  "cs3",        V_88F6810_PLUS),
196 		 MPP_VAR_FUNCTION(2, "ge1",   "txclkout",   V_88F6810_PLUS),
197 		 MPP_VAR_FUNCTION(3, "i2c1",  "sda",        V_88F6810_PLUS),
198 		 MPP_VAR_FUNCTION(4, "sd0",   "d7",         V_88F6810_PLUS),
199 		 MPP_VAR_FUNCTION(5, "dev",   "cs2",        V_88F6810_PLUS)),
200 	MPP_MODE(28,
201 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
202 		 MPP_VAR_FUNCTION(2, "ge1",   "txd0",       V_88F6810_PLUS),
203 		 MPP_VAR_FUNCTION(4, "sd0",   "clk",        V_88F6810_PLUS),
204 		 MPP_VAR_FUNCTION(5, "dev",   "ad5",        V_88F6810_PLUS)),
205 	MPP_MODE(29,
206 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
207 		 MPP_VAR_FUNCTION(2, "ge1",   "txd1",       V_88F6810_PLUS),
208 		 MPP_VAR_FUNCTION(5, "dev",   "ale0",       V_88F6810_PLUS)),
209 	MPP_MODE(30,
210 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
211 		 MPP_VAR_FUNCTION(2, "ge1",   "txd2",       V_88F6810_PLUS),
212 		 MPP_VAR_FUNCTION(5, "dev",   "oen",        V_88F6810_PLUS)),
213 	MPP_MODE(31,
214 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
215 		 MPP_VAR_FUNCTION(2, "ge1",   "txd3",       V_88F6810_PLUS),
216 		 MPP_VAR_FUNCTION(5, "dev",   "ale1",       V_88F6810_PLUS)),
217 	MPP_MODE(32,
218 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
219 		 MPP_VAR_FUNCTION(2, "ge1",   "txctl",      V_88F6810_PLUS),
220 		 MPP_VAR_FUNCTION(5, "dev",   "wen0",       V_88F6810_PLUS)),
221 	MPP_MODE(33,
222 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
223 		 MPP_VAR_FUNCTION(1, "m",     "decc_err",   V_88F6810_PLUS),
224 		 MPP_VAR_FUNCTION(5, "dev",   "ad3",        V_88F6810_PLUS)),
225 	MPP_MODE(34,
226 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
227 		 MPP_VAR_FUNCTION(5, "dev",   "ad1",        V_88F6810_PLUS)),
228 	MPP_MODE(35,
229 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
230 		 MPP_VAR_FUNCTION(1, "ref",   "clk_out1",   V_88F6810_PLUS),
231 		 MPP_VAR_FUNCTION(5, "dev",   "a1",         V_88F6810_PLUS)),
232 	MPP_MODE(36,
233 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
234 		 MPP_VAR_FUNCTION(1, "ptp",   "trig_gen",   V_88F6810_PLUS),
235 		 MPP_VAR_FUNCTION(5, "dev",   "a0",         V_88F6810_PLUS)),
236 	MPP_MODE(37,
237 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
238 		 MPP_VAR_FUNCTION(1, "ptp",   "clk",        V_88F6810_PLUS),
239 		 MPP_VAR_FUNCTION(2, "ge1",   "rxclk",      V_88F6810_PLUS),
240 		 MPP_VAR_FUNCTION(4, "sd0",   "d3",         V_88F6810_PLUS),
241 		 MPP_VAR_FUNCTION(5, "dev",   "ad8",        V_88F6810_PLUS)),
242 	MPP_MODE(38,
243 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
244 		 MPP_VAR_FUNCTION(1, "ptp",   "event_req",  V_88F6810_PLUS),
245 		 MPP_VAR_FUNCTION(2, "ge1",   "rxd1",       V_88F6810_PLUS),
246 		 MPP_VAR_FUNCTION(3, "ref",   "clk_out0",   V_88F6810_PLUS),
247 		 MPP_VAR_FUNCTION(4, "sd0",   "d0",         V_88F6810_PLUS),
248 		 MPP_VAR_FUNCTION(5, "dev",   "ad4",        V_88F6810_PLUS)),
249 	MPP_MODE(39,
250 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
251 		 MPP_VAR_FUNCTION(1, "i2c1",  "sck",        V_88F6810_PLUS),
252 		 MPP_VAR_FUNCTION(2, "ge1",   "rxd2",       V_88F6810_PLUS),
253 		 MPP_VAR_FUNCTION(3, "ua0",   "cts",        V_88F6810_PLUS),
254 		 MPP_VAR_FUNCTION(4, "sd0",   "d1",         V_88F6810_PLUS),
255 		 MPP_VAR_FUNCTION(5, "dev",   "a2",         V_88F6810_PLUS)),
256 	MPP_MODE(40,
257 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
258 		 MPP_VAR_FUNCTION(1, "i2c1",  "sda",        V_88F6810_PLUS),
259 		 MPP_VAR_FUNCTION(2, "ge1",   "rxd3",       V_88F6810_PLUS),
260 		 MPP_VAR_FUNCTION(3, "ua0",   "rts",        V_88F6810_PLUS),
261 		 MPP_VAR_FUNCTION(4, "sd0",   "d2",         V_88F6810_PLUS),
262 		 MPP_VAR_FUNCTION(5, "dev",   "ad6",        V_88F6810_PLUS)),
263 	MPP_MODE(41,
264 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
265 		 MPP_VAR_FUNCTION(1, "ua1",   "rxd",        V_88F6810_PLUS),
266 		 MPP_VAR_FUNCTION(2, "ge1",   "rxctl",      V_88F6810_PLUS),
267 		 MPP_VAR_FUNCTION(3, "ua0",   "cts",        V_88F6810_PLUS),
268 		 MPP_VAR_FUNCTION(4, "spi1",  "cs3",        V_88F6810_PLUS),
269 		 MPP_VAR_FUNCTION(5, "dev",   "burst/last", V_88F6810_PLUS)),
270 	MPP_MODE(42,
271 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
272 		 MPP_VAR_FUNCTION(1, "ua1",   "txd",        V_88F6810_PLUS),
273 		 MPP_VAR_FUNCTION(3, "ua0",   "rts",        V_88F6810_PLUS),
274 		 MPP_VAR_FUNCTION(5, "dev",   "ad7",        V_88F6810_PLUS)),
275 	MPP_MODE(43,
276 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
277 		 MPP_VAR_FUNCTION(1, "pcie0", "clkreq",     V_88F6810_PLUS),
278 		 MPP_VAR_FUNCTION(2, "m",     "vtt_ctrl",   V_88F6810_PLUS),
279 		 MPP_VAR_FUNCTION(3, "m",     "decc_err",   V_88F6810_PLUS),
280 		 MPP_VAR_FUNCTION(4, "pcie0", "rstout",     V_88F6810_PLUS),
281 		 MPP_VAR_FUNCTION(5, "dev",   "clkout",     V_88F6810_PLUS)),
282 	MPP_MODE(44,
283 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
284 		 MPP_VAR_FUNCTION(1, "sata0", "prsnt",      V_88F6810_PLUS),
285 		 MPP_VAR_FUNCTION(2, "sata1", "prsnt",      V_88F6810_PLUS),
286 		 MPP_VAR_FUNCTION(3, "sata2", "prsnt",      V_88F6828),
287 		 MPP_VAR_FUNCTION(4, "sata3", "prsnt",      V_88F6828),
288 		 MPP_VAR_FUNCTION(5, "pcie0", "rstout",     V_88F6810_PLUS)),
289 	MPP_MODE(45,
290 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
291 		 MPP_VAR_FUNCTION(1, "ref",   "clk_out0",   V_88F6810_PLUS),
292 		 MPP_VAR_FUNCTION(2, "pcie0", "rstout",     V_88F6810_PLUS),
293 		 MPP_VAR_FUNCTION(3, "pcie1", "rstout",     V_88F6820_PLUS),
294 		 MPP_VAR_FUNCTION(4, "pcie2", "rstout",     V_88F6810_PLUS),
295 		 MPP_VAR_FUNCTION(5, "pcie3", "rstout",     V_88F6810_PLUS)),
296 	MPP_MODE(46,
297 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
298 		 MPP_VAR_FUNCTION(1, "ref",   "clk_out1",   V_88F6810_PLUS),
299 		 MPP_VAR_FUNCTION(2, "pcie0", "rstout",     V_88F6810_PLUS),
300 		 MPP_VAR_FUNCTION(3, "pcie1", "rstout",     V_88F6820_PLUS),
301 		 MPP_VAR_FUNCTION(4, "pcie2", "rstout",     V_88F6810_PLUS),
302 		 MPP_VAR_FUNCTION(5, "pcie3", "rstout",     V_88F6810_PLUS)),
303 	MPP_MODE(47,
304 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
305 		 MPP_VAR_FUNCTION(1, "sata0", "prsnt",      V_88F6810_PLUS),
306 		 MPP_VAR_FUNCTION(2, "sata1", "prsnt",      V_88F6810_PLUS),
307 		 MPP_VAR_FUNCTION(3, "sata2", "prsnt",      V_88F6828),
308 		 MPP_VAR_FUNCTION(4, "spi1",  "cs2",        V_88F6810_PLUS),
309 		 MPP_VAR_FUNCTION(5, "sata3", "prsnt",      V_88F6828)),
310 	MPP_MODE(48,
311 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
312 		 MPP_VAR_FUNCTION(1, "sata0", "prsnt",      V_88F6810_PLUS),
313 		 MPP_VAR_FUNCTION(2, "m",     "vtt_ctrl",   V_88F6810_PLUS),
314 		 MPP_VAR_FUNCTION(3, "tdm2c", "pclk",       V_88F6810_PLUS),
315 		 MPP_VAR_FUNCTION(4, "audio", "mclk",       V_88F6810_PLUS),
316 		 MPP_VAR_FUNCTION(5, "sd0",   "d4",         V_88F6810_PLUS)),
317 	MPP_MODE(49,
318 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
319 		 MPP_VAR_FUNCTION(1, "sata2", "prsnt",      V_88F6828),
320 		 MPP_VAR_FUNCTION(2, "sata3", "prsnt",      V_88F6828),
321 		 MPP_VAR_FUNCTION(3, "tdm2c", "fsync",      V_88F6810_PLUS),
322 		 MPP_VAR_FUNCTION(4, "audio", "lrclk",      V_88F6810_PLUS),
323 		 MPP_VAR_FUNCTION(5, "sd0",   "d5",         V_88F6810_PLUS)),
324 	MPP_MODE(50,
325 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
326 		 MPP_VAR_FUNCTION(1, "pcie0", "rstout",     V_88F6810_PLUS),
327 		 MPP_VAR_FUNCTION(2, "pcie1", "rstout",     V_88F6820_PLUS),
328 		 MPP_VAR_FUNCTION(3, "tdm2c", "drx",        V_88F6810_PLUS),
329 		 MPP_VAR_FUNCTION(4, "audio", "extclk",     V_88F6810_PLUS),
330 		 MPP_VAR_FUNCTION(5, "sd0",   "cmd",        V_88F6810_PLUS)),
331 	MPP_MODE(51,
332 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
333 		 MPP_VAR_FUNCTION(3, "tdm2c", "dtx",        V_88F6810_PLUS),
334 		 MPP_VAR_FUNCTION(4, "audio", "sdo",        V_88F6810_PLUS),
335 		 MPP_VAR_FUNCTION(5, "m",     "decc_err",   V_88F6810_PLUS)),
336 	MPP_MODE(52,
337 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
338 		 MPP_VAR_FUNCTION(1, "pcie0", "rstout",     V_88F6810_PLUS),
339 		 MPP_VAR_FUNCTION(2, "pcie1", "rstout",     V_88F6820_PLUS),
340 		 MPP_VAR_FUNCTION(3, "tdm2c", "intn",       V_88F6810_PLUS),
341 		 MPP_VAR_FUNCTION(4, "audio", "sdi",        V_88F6810_PLUS),
342 		 MPP_VAR_FUNCTION(5, "sd0",   "d6",         V_88F6810_PLUS)),
343 	MPP_MODE(53,
344 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
345 		 MPP_VAR_FUNCTION(1, "sata1", "prsnt",      V_88F6810_PLUS),
346 		 MPP_VAR_FUNCTION(2, "sata0", "prsnt",      V_88F6810_PLUS),
347 		 MPP_VAR_FUNCTION(3, "tdm2c", "rstn",       V_88F6810_PLUS),
348 		 MPP_VAR_FUNCTION(4, "audio", "bclk",       V_88F6810_PLUS),
349 		 MPP_VAR_FUNCTION(5, "sd0",   "d7",         V_88F6810_PLUS)),
350 	MPP_MODE(54,
351 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
352 		 MPP_VAR_FUNCTION(1, "sata0", "prsnt",      V_88F6810_PLUS),
353 		 MPP_VAR_FUNCTION(2, "sata1", "prsnt",      V_88F6810_PLUS),
354 		 MPP_VAR_FUNCTION(3, "pcie0", "rstout",     V_88F6810_PLUS),
355 		 MPP_VAR_FUNCTION(4, "pcie1", "rstout",     V_88F6820_PLUS),
356 		 MPP_VAR_FUNCTION(5, "sd0",   "d3",         V_88F6810_PLUS)),
357 	MPP_MODE(55,
358 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
359 		 MPP_VAR_FUNCTION(1, "ua1",   "cts",        V_88F6810_PLUS),
360 		 MPP_VAR_FUNCTION(2, "ge",    "mdio",       V_88F6810_PLUS),
361 		 MPP_VAR_FUNCTION(3, "pcie1", "clkreq",     V_88F6820_PLUS),
362 		 MPP_VAR_FUNCTION(4, "spi1",  "cs1",        V_88F6810_PLUS),
363 		 MPP_VAR_FUNCTION(5, "sd0",   "d0",         V_88F6810_PLUS)),
364 	MPP_MODE(56,
365 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
366 		 MPP_VAR_FUNCTION(1, "ua1",   "rts",        V_88F6810_PLUS),
367 		 MPP_VAR_FUNCTION(2, "ge",    "mdc",        V_88F6810_PLUS),
368 		 MPP_VAR_FUNCTION(3, "m",     "decc_err",   V_88F6810_PLUS),
369 		 MPP_VAR_FUNCTION(4, "spi1",  "mosi",       V_88F6810_PLUS)),
370 	MPP_MODE(57,
371 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
372 		 MPP_VAR_FUNCTION(4, "spi1",  "sck",        V_88F6810_PLUS),
373 		 MPP_VAR_FUNCTION(5, "sd0",   "clk",        V_88F6810_PLUS)),
374 	MPP_MODE(58,
375 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
376 		 MPP_VAR_FUNCTION(1, "pcie1", "clkreq",     V_88F6820_PLUS),
377 		 MPP_VAR_FUNCTION(2, "i2c1",  "sck",        V_88F6810_PLUS),
378 		 MPP_VAR_FUNCTION(3, "pcie2", "clkreq",     V_88F6810_PLUS),
379 		 MPP_VAR_FUNCTION(4, "spi1",  "miso",       V_88F6810_PLUS),
380 		 MPP_VAR_FUNCTION(5, "sd0",   "d1",         V_88F6810_PLUS)),
381 	MPP_MODE(59,
382 		 MPP_VAR_FUNCTION(0, "gpio",  NULL,         V_88F6810_PLUS),
383 		 MPP_VAR_FUNCTION(1, "pcie0", "rstout",     V_88F6810_PLUS),
384 		 MPP_VAR_FUNCTION(2, "i2c1",  "sda",        V_88F6810_PLUS),
385 		 MPP_VAR_FUNCTION(3, "pcie1", "rstout",     V_88F6820_PLUS),
386 		 MPP_VAR_FUNCTION(4, "spi1",  "cs0",        V_88F6810_PLUS),
387 		 MPP_VAR_FUNCTION(5, "sd0",   "d2",         V_88F6810_PLUS)),
388 };
389 
390 static struct mvebu_pinctrl_soc_info armada_38x_pinctrl_info;
391 
392 static struct of_device_id armada_38x_pinctrl_of_match[] = {
393 	{
394 		.compatible = "marvell,mv88f6810-pinctrl",
395 		.data       = (void *) V_88F6810,
396 	},
397 	{
398 		.compatible = "marvell,mv88f6820-pinctrl",
399 		.data       = (void *) V_88F6820,
400 	},
401 	{
402 		.compatible = "marvell,mv88f6828-pinctrl",
403 		.data       = (void *) V_88F6828,
404 	},
405 	{ },
406 };
407 
408 static struct mvebu_mpp_ctrl armada_38x_mpp_controls[] = {
409 	MPP_FUNC_CTRL(0, 59, NULL, armada_38x_mpp_ctrl),
410 };
411 
412 static struct pinctrl_gpio_range armada_38x_mpp_gpio_ranges[] = {
413 	MPP_GPIO_RANGE(0,   0,  0, 32),
414 	MPP_GPIO_RANGE(1,  32, 32, 27),
415 };
416 
417 static int armada_38x_pinctrl_probe(struct platform_device *pdev)
418 {
419 	struct mvebu_pinctrl_soc_info *soc = &armada_38x_pinctrl_info;
420 	const struct of_device_id *match =
421 		of_match_device(armada_38x_pinctrl_of_match, &pdev->dev);
422 	struct resource *res;
423 
424 	if (!match)
425 		return -ENODEV;
426 
427 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
428 	mpp_base = devm_ioremap_resource(&pdev->dev, res);
429 	if (IS_ERR(mpp_base))
430 		return PTR_ERR(mpp_base);
431 
432 	soc->variant = (unsigned) match->data & 0xff;
433 	soc->controls = armada_38x_mpp_controls;
434 	soc->ncontrols = ARRAY_SIZE(armada_38x_mpp_controls);
435 	soc->gpioranges = armada_38x_mpp_gpio_ranges;
436 	soc->ngpioranges = ARRAY_SIZE(armada_38x_mpp_gpio_ranges);
437 	soc->modes = armada_38x_mpp_modes;
438 	soc->nmodes = armada_38x_mpp_controls[0].npins;
439 
440 	pdev->dev.platform_data = soc;
441 
442 	return mvebu_pinctrl_probe(pdev);
443 }
444 
445 static int armada_38x_pinctrl_remove(struct platform_device *pdev)
446 {
447 	return mvebu_pinctrl_remove(pdev);
448 }
449 
450 static struct platform_driver armada_38x_pinctrl_driver = {
451 	.driver = {
452 		.name = "armada-38x-pinctrl",
453 		.of_match_table = of_match_ptr(armada_38x_pinctrl_of_match),
454 	},
455 	.probe = armada_38x_pinctrl_probe,
456 	.remove = armada_38x_pinctrl_remove,
457 };
458 
459 module_platform_driver(armada_38x_pinctrl_driver);
460 
461 MODULE_AUTHOR("Thomas Petazzoni <thomas.petazzoni@free-electrons.com>");
462 MODULE_DESCRIPTION("Marvell Armada 38x pinctrl driver");
463 MODULE_LICENSE("GPL v2");
464