1 /*
2  * Copyright (C) 2015-2017 Socionext Inc.
3  *   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  */
15 
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/pinctrl/pinctrl.h>
19 #include <linux/platform_device.h>
20 
21 #include "pinctrl-uniphier.h"
22 
23 static const struct pinctrl_pin_desc uniphier_sld8_pins[] = {
24 	UNIPHIER_PINCTRL_PIN(0, "PCA00", 0,
25 			     15, UNIPHIER_PIN_DRV_1BIT,
26 			     15, UNIPHIER_PIN_PULL_DOWN),
27 	UNIPHIER_PINCTRL_PIN(1, "PCA01", 0,
28 			     16, UNIPHIER_PIN_DRV_1BIT,
29 			     16, UNIPHIER_PIN_PULL_DOWN),
30 	UNIPHIER_PINCTRL_PIN(2, "PCA02", 0,
31 			     17, UNIPHIER_PIN_DRV_1BIT,
32 			     17, UNIPHIER_PIN_PULL_DOWN),
33 	UNIPHIER_PINCTRL_PIN(3, "PCA03", 0,
34 			     18, UNIPHIER_PIN_DRV_1BIT,
35 			     18, UNIPHIER_PIN_PULL_DOWN),
36 	UNIPHIER_PINCTRL_PIN(4, "PCA04", 0,
37 			     19, UNIPHIER_PIN_DRV_1BIT,
38 			     19, UNIPHIER_PIN_PULL_DOWN),
39 	UNIPHIER_PINCTRL_PIN(5, "PCA05", 0,
40 			     20, UNIPHIER_PIN_DRV_1BIT,
41 			     20, UNIPHIER_PIN_PULL_DOWN),
42 	UNIPHIER_PINCTRL_PIN(6, "PCA06", 0,
43 			     21, UNIPHIER_PIN_DRV_1BIT,
44 			     21, UNIPHIER_PIN_PULL_DOWN),
45 	UNIPHIER_PINCTRL_PIN(7, "PCA07", 0,
46 			     22, UNIPHIER_PIN_DRV_1BIT,
47 			     22, UNIPHIER_PIN_PULL_DOWN),
48 	UNIPHIER_PINCTRL_PIN(8, "PCA08", 0,
49 			     23, UNIPHIER_PIN_DRV_1BIT,
50 			     23, UNIPHIER_PIN_PULL_DOWN),
51 	UNIPHIER_PINCTRL_PIN(9, "PCA09", 0,
52 			     24, UNIPHIER_PIN_DRV_1BIT,
53 			     24, UNIPHIER_PIN_PULL_DOWN),
54 	UNIPHIER_PINCTRL_PIN(10, "PCA10", 0,
55 			     25, UNIPHIER_PIN_DRV_1BIT,
56 			     25, UNIPHIER_PIN_PULL_DOWN),
57 	UNIPHIER_PINCTRL_PIN(11, "PCA11", 0,
58 			     26, UNIPHIER_PIN_DRV_1BIT,
59 			     26, UNIPHIER_PIN_PULL_DOWN),
60 	UNIPHIER_PINCTRL_PIN(12, "PCA12", 0,
61 			     27, UNIPHIER_PIN_DRV_1BIT,
62 			     27, UNIPHIER_PIN_PULL_DOWN),
63 	UNIPHIER_PINCTRL_PIN(13, "PCA13", 0,
64 			     28, UNIPHIER_PIN_DRV_1BIT,
65 			     28, UNIPHIER_PIN_PULL_DOWN),
66 	UNIPHIER_PINCTRL_PIN(14, "PCA14", 0,
67 			     29, UNIPHIER_PIN_DRV_1BIT,
68 			     29, UNIPHIER_PIN_PULL_DOWN),
69 	UNIPHIER_PINCTRL_PIN(15, "XNFRE_GB", UNIPHIER_PIN_IECTRL_NONE,
70 			     30, UNIPHIER_PIN_DRV_1BIT,
71 			     30, UNIPHIER_PIN_PULL_UP),
72 	UNIPHIER_PINCTRL_PIN(16, "XNFWE_GB", UNIPHIER_PIN_IECTRL_NONE,
73 			     31, UNIPHIER_PIN_DRV_1BIT,
74 			     31, UNIPHIER_PIN_PULL_UP),
75 	UNIPHIER_PINCTRL_PIN(17, "NFALE_GB", UNIPHIER_PIN_IECTRL_NONE,
76 			     32, UNIPHIER_PIN_DRV_1BIT,
77 			     32, UNIPHIER_PIN_PULL_DOWN),
78 	UNIPHIER_PINCTRL_PIN(18, "NFCLE_GB", UNIPHIER_PIN_IECTRL_NONE,
79 			     33, UNIPHIER_PIN_DRV_1BIT,
80 			     33, UNIPHIER_PIN_PULL_DOWN),
81 	UNIPHIER_PINCTRL_PIN(19, "XNFWP_GB", UNIPHIER_PIN_IECTRL_NONE,
82 			     34, UNIPHIER_PIN_DRV_1BIT,
83 			     34, UNIPHIER_PIN_PULL_DOWN),
84 	UNIPHIER_PINCTRL_PIN(20, "XNFCE0_GB", UNIPHIER_PIN_IECTRL_NONE,
85 			     35, UNIPHIER_PIN_DRV_1BIT,
86 			     35, UNIPHIER_PIN_PULL_UP),
87 	UNIPHIER_PINCTRL_PIN(21, "NANDRYBY0_GB", UNIPHIER_PIN_IECTRL_NONE,
88 			     36, UNIPHIER_PIN_DRV_1BIT,
89 			     36, UNIPHIER_PIN_PULL_UP),
90 	UNIPHIER_PINCTRL_PIN(22, "XNFCE1_GB", UNIPHIER_PIN_IECTRL_NONE,
91 			     0, UNIPHIER_PIN_DRV_2BIT,
92 			     119, UNIPHIER_PIN_PULL_UP),
93 	UNIPHIER_PINCTRL_PIN(23, "NANDRYBY1_GB", UNIPHIER_PIN_IECTRL_NONE,
94 			     1, UNIPHIER_PIN_DRV_2BIT,
95 			     120, UNIPHIER_PIN_PULL_UP),
96 	UNIPHIER_PINCTRL_PIN(24, "NFD0_GB", UNIPHIER_PIN_IECTRL_NONE,
97 			     2, UNIPHIER_PIN_DRV_2BIT,
98 			     121, UNIPHIER_PIN_PULL_UP),
99 	UNIPHIER_PINCTRL_PIN(25, "NFD1_GB", UNIPHIER_PIN_IECTRL_NONE,
100 			     3, UNIPHIER_PIN_DRV_2BIT,
101 			     122, UNIPHIER_PIN_PULL_UP),
102 	UNIPHIER_PINCTRL_PIN(26, "NFD2_GB", UNIPHIER_PIN_IECTRL_NONE,
103 			     4, UNIPHIER_PIN_DRV_2BIT,
104 			     123, UNIPHIER_PIN_PULL_UP),
105 	UNIPHIER_PINCTRL_PIN(27, "NFD3_GB", UNIPHIER_PIN_IECTRL_NONE,
106 			     5, UNIPHIER_PIN_DRV_2BIT,
107 			     124, UNIPHIER_PIN_PULL_UP),
108 	UNIPHIER_PINCTRL_PIN(28, "NFD4_GB", UNIPHIER_PIN_IECTRL_NONE,
109 			     6, UNIPHIER_PIN_DRV_2BIT,
110 			     125, UNIPHIER_PIN_PULL_UP),
111 	UNIPHIER_PINCTRL_PIN(29, "NFD5_GB", UNIPHIER_PIN_IECTRL_NONE,
112 			     7, UNIPHIER_PIN_DRV_2BIT,
113 			     126, UNIPHIER_PIN_PULL_UP),
114 	UNIPHIER_PINCTRL_PIN(30, "NFD6_GB", UNIPHIER_PIN_IECTRL_NONE,
115 			     8, UNIPHIER_PIN_DRV_2BIT,
116 			     127, UNIPHIER_PIN_PULL_UP),
117 	UNIPHIER_PINCTRL_PIN(31, "NFD7_GB", UNIPHIER_PIN_IECTRL_NONE,
118 			     9, UNIPHIER_PIN_DRV_2BIT,
119 			     128, UNIPHIER_PIN_PULL_UP),
120 	UNIPHIER_PINCTRL_PIN(32, "SDCLK", 8,
121 			     10, UNIPHIER_PIN_DRV_2BIT,
122 			     -1, UNIPHIER_PIN_PULL_NONE),
123 	UNIPHIER_PINCTRL_PIN(33, "SDCMD", 8,
124 			     11, UNIPHIER_PIN_DRV_2BIT,
125 			     -1, UNIPHIER_PIN_PULL_NONE),
126 	UNIPHIER_PINCTRL_PIN(34, "SDDAT0", 8,
127 			     12, UNIPHIER_PIN_DRV_2BIT,
128 			     -1, UNIPHIER_PIN_PULL_NONE),
129 	UNIPHIER_PINCTRL_PIN(35, "SDDAT1", 8,
130 			     13, UNIPHIER_PIN_DRV_2BIT,
131 			     -1, UNIPHIER_PIN_PULL_NONE),
132 	UNIPHIER_PINCTRL_PIN(36, "SDDAT2", 8,
133 			     14, UNIPHIER_PIN_DRV_2BIT,
134 			     -1, UNIPHIER_PIN_PULL_NONE),
135 	UNIPHIER_PINCTRL_PIN(37, "SDDAT3", 8,
136 			     15, UNIPHIER_PIN_DRV_2BIT,
137 			     -1, UNIPHIER_PIN_PULL_NONE),
138 	UNIPHIER_PINCTRL_PIN(38, "SDCD", 8,
139 			     -1, UNIPHIER_PIN_DRV_FIXED4,
140 			     129, UNIPHIER_PIN_PULL_DOWN),
141 	UNIPHIER_PINCTRL_PIN(39, "SDWP", 8,
142 			     -1, UNIPHIER_PIN_DRV_FIXED4,
143 			     130, UNIPHIER_PIN_PULL_DOWN),
144 	UNIPHIER_PINCTRL_PIN(40, "SDVOLC", 9,
145 			     -1, UNIPHIER_PIN_DRV_FIXED4,
146 			     131, UNIPHIER_PIN_PULL_DOWN),
147 	UNIPHIER_PINCTRL_PIN(41, "USB0VBUS", 0,
148 			     37, UNIPHIER_PIN_DRV_1BIT,
149 			     37, UNIPHIER_PIN_PULL_DOWN),
150 	UNIPHIER_PINCTRL_PIN(42, "USB0OD", 0,
151 			     38, UNIPHIER_PIN_DRV_1BIT,
152 			     38, UNIPHIER_PIN_PULL_DOWN),
153 	UNIPHIER_PINCTRL_PIN(43, "USB1VBUS", 0,
154 			     39, UNIPHIER_PIN_DRV_1BIT,
155 			     39, UNIPHIER_PIN_PULL_DOWN),
156 	UNIPHIER_PINCTRL_PIN(44, "USB1OD", 0,
157 			     40, UNIPHIER_PIN_DRV_1BIT,
158 			     40, UNIPHIER_PIN_PULL_DOWN),
159 	UNIPHIER_PINCTRL_PIN(45, "PCRESET", 0,
160 			     41, UNIPHIER_PIN_DRV_1BIT,
161 			     41, UNIPHIER_PIN_PULL_DOWN),
162 	UNIPHIER_PINCTRL_PIN(46, "PCREG", 0,
163 			     42, UNIPHIER_PIN_DRV_1BIT,
164 			     42, UNIPHIER_PIN_PULL_DOWN),
165 	UNIPHIER_PINCTRL_PIN(47, "PCCE2", 0,
166 			     43, UNIPHIER_PIN_DRV_1BIT,
167 			     43, UNIPHIER_PIN_PULL_DOWN),
168 	UNIPHIER_PINCTRL_PIN(48, "PCVS1", 0,
169 			     44, UNIPHIER_PIN_DRV_1BIT,
170 			     44, UNIPHIER_PIN_PULL_DOWN),
171 	UNIPHIER_PINCTRL_PIN(49, "PCCD2", 0,
172 			     45, UNIPHIER_PIN_DRV_1BIT,
173 			     45, UNIPHIER_PIN_PULL_DOWN),
174 	UNIPHIER_PINCTRL_PIN(50, "PCCD1", 0,
175 			     46, UNIPHIER_PIN_DRV_1BIT,
176 			     46, UNIPHIER_PIN_PULL_DOWN),
177 	UNIPHIER_PINCTRL_PIN(51, "PCREADY", 0,
178 			     47, UNIPHIER_PIN_DRV_1BIT,
179 			     47, UNIPHIER_PIN_PULL_DOWN),
180 	UNIPHIER_PINCTRL_PIN(52, "PCDOE", 0,
181 			     48, UNIPHIER_PIN_DRV_1BIT,
182 			     48, UNIPHIER_PIN_PULL_DOWN),
183 	UNIPHIER_PINCTRL_PIN(53, "PCCE1", 0,
184 			     49, UNIPHIER_PIN_DRV_1BIT,
185 			     49, UNIPHIER_PIN_PULL_DOWN),
186 	UNIPHIER_PINCTRL_PIN(54, "PCWE", 0,
187 			     50, UNIPHIER_PIN_DRV_1BIT,
188 			     50, UNIPHIER_PIN_PULL_DOWN),
189 	UNIPHIER_PINCTRL_PIN(55, "PCOE", 0,
190 			     51, UNIPHIER_PIN_DRV_1BIT,
191 			     51, UNIPHIER_PIN_PULL_DOWN),
192 	UNIPHIER_PINCTRL_PIN(56, "PCWAIT", 0,
193 			     52, UNIPHIER_PIN_DRV_1BIT,
194 			     52, UNIPHIER_PIN_PULL_DOWN),
195 	UNIPHIER_PINCTRL_PIN(57, "PCIOWR", 0,
196 			     53, UNIPHIER_PIN_DRV_1BIT,
197 			     53, UNIPHIER_PIN_PULL_DOWN),
198 	UNIPHIER_PINCTRL_PIN(58, "PCIORD", 0,
199 			     54, UNIPHIER_PIN_DRV_1BIT,
200 			     54, UNIPHIER_PIN_PULL_DOWN),
201 	UNIPHIER_PINCTRL_PIN(59, "HS0DIN0", 0,
202 			     55, UNIPHIER_PIN_DRV_1BIT,
203 			     55, UNIPHIER_PIN_PULL_DOWN),
204 	UNIPHIER_PINCTRL_PIN(60, "HS0DIN1", 0,
205 			     56, UNIPHIER_PIN_DRV_1BIT,
206 			     56, UNIPHIER_PIN_PULL_DOWN),
207 	UNIPHIER_PINCTRL_PIN(61, "HS0DIN2", 0,
208 			     57, UNIPHIER_PIN_DRV_1BIT,
209 			     57, UNIPHIER_PIN_PULL_DOWN),
210 	UNIPHIER_PINCTRL_PIN(62, "HS0DIN3", 0,
211 			     58, UNIPHIER_PIN_DRV_1BIT,
212 			     58, UNIPHIER_PIN_PULL_DOWN),
213 	UNIPHIER_PINCTRL_PIN(63, "HS0DIN4", 0,
214 			     59, UNIPHIER_PIN_DRV_1BIT,
215 			     59, UNIPHIER_PIN_PULL_DOWN),
216 	UNIPHIER_PINCTRL_PIN(64, "HS0DIN5", 0,
217 			     60, UNIPHIER_PIN_DRV_1BIT,
218 			     60, UNIPHIER_PIN_PULL_DOWN),
219 	UNIPHIER_PINCTRL_PIN(65, "HS0DIN6", 0,
220 			     61, UNIPHIER_PIN_DRV_1BIT,
221 			     61, UNIPHIER_PIN_PULL_DOWN),
222 	UNIPHIER_PINCTRL_PIN(66, "HS0DIN7", 0,
223 			     62, UNIPHIER_PIN_DRV_1BIT,
224 			     62, UNIPHIER_PIN_PULL_DOWN),
225 	UNIPHIER_PINCTRL_PIN(67, "HS0BCLKIN", 0,
226 			     63, UNIPHIER_PIN_DRV_1BIT,
227 			     63, UNIPHIER_PIN_PULL_DOWN),
228 	UNIPHIER_PINCTRL_PIN(68, "HS0VALIN", 0,
229 			     64, UNIPHIER_PIN_DRV_1BIT,
230 			     64, UNIPHIER_PIN_PULL_DOWN),
231 	UNIPHIER_PINCTRL_PIN(69, "HS0SYNCIN", 0,
232 			     65, UNIPHIER_PIN_DRV_1BIT,
233 			     65, UNIPHIER_PIN_PULL_DOWN),
234 	UNIPHIER_PINCTRL_PIN(70, "HSDOUT0", 0,
235 			     66, UNIPHIER_PIN_DRV_1BIT,
236 			     66, UNIPHIER_PIN_PULL_DOWN),
237 	UNIPHIER_PINCTRL_PIN(71, "HSDOUT1", 0,
238 			     67, UNIPHIER_PIN_DRV_1BIT,
239 			     67, UNIPHIER_PIN_PULL_DOWN),
240 	UNIPHIER_PINCTRL_PIN(72, "HSDOUT2", 0,
241 			     68, UNIPHIER_PIN_DRV_1BIT,
242 			     68, UNIPHIER_PIN_PULL_DOWN),
243 	UNIPHIER_PINCTRL_PIN(73, "HSDOUT3", 0,
244 			     69, UNIPHIER_PIN_DRV_1BIT,
245 			     69, UNIPHIER_PIN_PULL_DOWN),
246 	UNIPHIER_PINCTRL_PIN(74, "HSDOUT4", 0,
247 			     70, UNIPHIER_PIN_DRV_1BIT,
248 			     70, UNIPHIER_PIN_PULL_DOWN),
249 	UNIPHIER_PINCTRL_PIN(75, "HSDOUT5", 0,
250 			     71, UNIPHIER_PIN_DRV_1BIT,
251 			     71, UNIPHIER_PIN_PULL_DOWN),
252 	UNIPHIER_PINCTRL_PIN(76, "HSDOUT6", 0,
253 			     72, UNIPHIER_PIN_DRV_1BIT,
254 			     72, UNIPHIER_PIN_PULL_DOWN),
255 	UNIPHIER_PINCTRL_PIN(77, "HSDOUT7", 0,
256 			     73, UNIPHIER_PIN_DRV_1BIT,
257 			     73, UNIPHIER_PIN_PULL_DOWN),
258 	UNIPHIER_PINCTRL_PIN(78, "HSBCLKOUT", 0,
259 			     74, UNIPHIER_PIN_DRV_1BIT,
260 			     74, UNIPHIER_PIN_PULL_DOWN),
261 	UNIPHIER_PINCTRL_PIN(79, "HSVALOUT", 0,
262 			     75, UNIPHIER_PIN_DRV_1BIT,
263 			     75, UNIPHIER_PIN_PULL_DOWN),
264 	UNIPHIER_PINCTRL_PIN(80, "HSSYNCOUT", 0,
265 			     76, UNIPHIER_PIN_DRV_1BIT,
266 			     76, UNIPHIER_PIN_PULL_DOWN),
267 	UNIPHIER_PINCTRL_PIN(81, "HS1DIN0", 0,
268 			     77, UNIPHIER_PIN_DRV_1BIT,
269 			     77, UNIPHIER_PIN_PULL_DOWN),
270 	UNIPHIER_PINCTRL_PIN(82, "HS1DIN1", 0,
271 			     78, UNIPHIER_PIN_DRV_1BIT,
272 			     78, UNIPHIER_PIN_PULL_DOWN),
273 	UNIPHIER_PINCTRL_PIN(83, "HS1DIN2", 0,
274 			     79, UNIPHIER_PIN_DRV_1BIT,
275 			     79, UNIPHIER_PIN_PULL_DOWN),
276 	UNIPHIER_PINCTRL_PIN(84, "HS1DIN3", 0,
277 			     80, UNIPHIER_PIN_DRV_1BIT,
278 			     80, UNIPHIER_PIN_PULL_DOWN),
279 	UNIPHIER_PINCTRL_PIN(85, "HS1DIN4", 0,
280 			     81, UNIPHIER_PIN_DRV_1BIT,
281 			     81, UNIPHIER_PIN_PULL_DOWN),
282 	UNIPHIER_PINCTRL_PIN(86, "HS1DIN5", 0,
283 			     82, UNIPHIER_PIN_DRV_1BIT,
284 			     82, UNIPHIER_PIN_PULL_DOWN),
285 	UNIPHIER_PINCTRL_PIN(87, "HS1DIN6", 0,
286 			     83, UNIPHIER_PIN_DRV_1BIT,
287 			     83, UNIPHIER_PIN_PULL_DOWN),
288 	UNIPHIER_PINCTRL_PIN(88, "HS1DIN7", 0,
289 			     84, UNIPHIER_PIN_DRV_1BIT,
290 			     84, UNIPHIER_PIN_PULL_DOWN),
291 	UNIPHIER_PINCTRL_PIN(89, "HS1BCLKIN", 0,
292 			     85, UNIPHIER_PIN_DRV_1BIT,
293 			     85, UNIPHIER_PIN_PULL_DOWN),
294 	UNIPHIER_PINCTRL_PIN(90, "HS1VALIN", 0,
295 			     86, UNIPHIER_PIN_DRV_1BIT,
296 			     86, UNIPHIER_PIN_PULL_DOWN),
297 	UNIPHIER_PINCTRL_PIN(91, "HS1SYNCIN", 0,
298 			     87, UNIPHIER_PIN_DRV_1BIT,
299 			     87, UNIPHIER_PIN_PULL_DOWN),
300 	UNIPHIER_PINCTRL_PIN(92, "AGCI", 3,
301 			     -1, UNIPHIER_PIN_DRV_FIXED4,
302 			     132, UNIPHIER_PIN_PULL_DOWN),
303 	UNIPHIER_PINCTRL_PIN(93, "AGCR", 4,
304 			     -1, UNIPHIER_PIN_DRV_FIXED4,
305 			     133, UNIPHIER_PIN_PULL_DOWN),
306 	UNIPHIER_PINCTRL_PIN(94, "AGCBS", 5,
307 			     -1, UNIPHIER_PIN_DRV_FIXED4,
308 			     134, UNIPHIER_PIN_PULL_DOWN),
309 	UNIPHIER_PINCTRL_PIN(95, "IECOUT", 0,
310 			     88, UNIPHIER_PIN_DRV_1BIT,
311 			     88, UNIPHIER_PIN_PULL_DOWN),
312 	UNIPHIER_PINCTRL_PIN(96, "ASMCK", 0,
313 			     89, UNIPHIER_PIN_DRV_1BIT,
314 			     89, UNIPHIER_PIN_PULL_DOWN),
315 	UNIPHIER_PINCTRL_PIN(97, "ABCKO", UNIPHIER_PIN_IECTRL_NONE,
316 			     90, UNIPHIER_PIN_DRV_1BIT,
317 			     90, UNIPHIER_PIN_PULL_DOWN),
318 	UNIPHIER_PINCTRL_PIN(98, "ALRCKO", UNIPHIER_PIN_IECTRL_NONE,
319 			     91, UNIPHIER_PIN_DRV_1BIT,
320 			     91, UNIPHIER_PIN_PULL_DOWN),
321 	UNIPHIER_PINCTRL_PIN(99, "ASDOUT0", UNIPHIER_PIN_IECTRL_NONE,
322 			     92, UNIPHIER_PIN_DRV_1BIT,
323 			     92, UNIPHIER_PIN_PULL_DOWN),
324 	UNIPHIER_PINCTRL_PIN(100, "ASDOUT1", UNIPHIER_PIN_IECTRL_NONE,
325 			     93, UNIPHIER_PIN_DRV_1BIT,
326 			     93, UNIPHIER_PIN_PULL_UP),
327 	UNIPHIER_PINCTRL_PIN(101, "ARCOUT", 0,
328 			     94, UNIPHIER_PIN_DRV_1BIT,
329 			     94, UNIPHIER_PIN_PULL_DOWN),
330 	UNIPHIER_PINCTRL_PIN(102, "SDA0", 10,
331 			     -1, UNIPHIER_PIN_DRV_FIXED4,
332 			     -1, UNIPHIER_PIN_PULL_NONE),
333 	UNIPHIER_PINCTRL_PIN(103, "SCL0", 10,
334 			     -1, UNIPHIER_PIN_DRV_FIXED4,
335 			     -1, UNIPHIER_PIN_PULL_NONE),
336 	UNIPHIER_PINCTRL_PIN(104, "SDA1", 11,
337 			     -1, UNIPHIER_PIN_DRV_FIXED4,
338 			     -1, UNIPHIER_PIN_PULL_NONE),
339 	UNIPHIER_PINCTRL_PIN(105, "SCL1", 11,
340 			     -1, UNIPHIER_PIN_DRV_FIXED4,
341 			     -1, UNIPHIER_PIN_PULL_NONE),
342 	UNIPHIER_PINCTRL_PIN(106, "DMDSDA0", 12,
343 			     -1, UNIPHIER_PIN_DRV_FIXED4,
344 			     -1, UNIPHIER_PIN_PULL_NONE),
345 	UNIPHIER_PINCTRL_PIN(107, "DMDSCL0", 12,
346 			     -1, UNIPHIER_PIN_DRV_FIXED4,
347 			     -1, UNIPHIER_PIN_PULL_NONE),
348 	UNIPHIER_PINCTRL_PIN(108, "DMDSDA1", 13,
349 			     -1, UNIPHIER_PIN_DRV_FIXED4,
350 			     -1, UNIPHIER_PIN_PULL_NONE),
351 	UNIPHIER_PINCTRL_PIN(109, "DMDSCL1", 13,
352 			     -1, UNIPHIER_PIN_DRV_FIXED4,
353 			     -1, UNIPHIER_PIN_PULL_NONE),
354 	UNIPHIER_PINCTRL_PIN(110, "SBO0", UNIPHIER_PIN_IECTRL_NONE,
355 			     95, UNIPHIER_PIN_DRV_1BIT,
356 			     95, UNIPHIER_PIN_PULL_UP),
357 	UNIPHIER_PINCTRL_PIN(111, "SBI0", UNIPHIER_PIN_IECTRL_NONE,
358 			     96, UNIPHIER_PIN_DRV_1BIT,
359 			     96, UNIPHIER_PIN_PULL_UP),
360 	UNIPHIER_PINCTRL_PIN(112, "SBO1", 0,
361 			     97, UNIPHIER_PIN_DRV_1BIT,
362 			     97, UNIPHIER_PIN_PULL_UP),
363 	UNIPHIER_PINCTRL_PIN(113, "SBI1", 0,
364 			     98, UNIPHIER_PIN_DRV_1BIT,
365 			     98, UNIPHIER_PIN_PULL_UP),
366 	UNIPHIER_PINCTRL_PIN(114, "TXD1", 0,
367 			     99, UNIPHIER_PIN_DRV_1BIT,
368 			     99, UNIPHIER_PIN_PULL_UP),
369 	UNIPHIER_PINCTRL_PIN(115, "RXD1", 0,
370 			     100, UNIPHIER_PIN_DRV_1BIT,
371 			     100, UNIPHIER_PIN_PULL_UP),
372 	UNIPHIER_PINCTRL_PIN(116, "HIN", 1,
373 			     -1, UNIPHIER_PIN_DRV_FIXED5,
374 			     -1, UNIPHIER_PIN_PULL_NONE),
375 	UNIPHIER_PINCTRL_PIN(117, "VIN", 2,
376 			     -1, UNIPHIER_PIN_DRV_FIXED5,
377 			     -1, UNIPHIER_PIN_PULL_NONE),
378 	UNIPHIER_PINCTRL_PIN(118, "TCON0", 0,
379 			     101, UNIPHIER_PIN_DRV_1BIT,
380 			     101, UNIPHIER_PIN_PULL_DOWN),
381 	UNIPHIER_PINCTRL_PIN(119, "TCON1", 0,
382 			     102, UNIPHIER_PIN_DRV_1BIT,
383 			     102, UNIPHIER_PIN_PULL_DOWN),
384 	UNIPHIER_PINCTRL_PIN(120, "TCON2", 0,
385 			     103, UNIPHIER_PIN_DRV_1BIT,
386 			     103, UNIPHIER_PIN_PULL_DOWN),
387 	UNIPHIER_PINCTRL_PIN(121, "TCON3", 0,
388 			     104, UNIPHIER_PIN_DRV_1BIT,
389 			     104, UNIPHIER_PIN_PULL_DOWN),
390 	UNIPHIER_PINCTRL_PIN(122, "TCON4", 0,
391 			     105, UNIPHIER_PIN_DRV_1BIT,
392 			     105, UNIPHIER_PIN_PULL_DOWN),
393 	UNIPHIER_PINCTRL_PIN(123, "TCON5", 0,
394 			     106, UNIPHIER_PIN_DRV_1BIT,
395 			     106, UNIPHIER_PIN_PULL_DOWN),
396 	UNIPHIER_PINCTRL_PIN(124, "TCON6", 0,
397 			     107, UNIPHIER_PIN_DRV_1BIT,
398 			     107, UNIPHIER_PIN_PULL_DOWN),
399 	UNIPHIER_PINCTRL_PIN(125, "TCON7", 0,
400 			     108, UNIPHIER_PIN_DRV_1BIT,
401 			     108, UNIPHIER_PIN_PULL_DOWN),
402 	UNIPHIER_PINCTRL_PIN(126, "TCON8", 0,
403 			     109, UNIPHIER_PIN_DRV_1BIT,
404 			     109, UNIPHIER_PIN_PULL_DOWN),
405 	UNIPHIER_PINCTRL_PIN(127, "PWMA", 0,
406 			     110, UNIPHIER_PIN_DRV_1BIT,
407 			     110, UNIPHIER_PIN_PULL_DOWN),
408 	UNIPHIER_PINCTRL_PIN(128, "XIRQ0", 0,
409 			     111, UNIPHIER_PIN_DRV_1BIT,
410 			     111, UNIPHIER_PIN_PULL_DOWN),
411 	UNIPHIER_PINCTRL_PIN(129, "XIRQ1", 0,
412 			     112, UNIPHIER_PIN_DRV_1BIT,
413 			     112, UNIPHIER_PIN_PULL_DOWN),
414 	UNIPHIER_PINCTRL_PIN(130, "XIRQ2", 0,
415 			     113, UNIPHIER_PIN_DRV_1BIT,
416 			     113, UNIPHIER_PIN_PULL_DOWN),
417 	UNIPHIER_PINCTRL_PIN(131, "XIRQ3", 0,
418 			     114, UNIPHIER_PIN_DRV_1BIT,
419 			     114, UNIPHIER_PIN_PULL_DOWN),
420 	UNIPHIER_PINCTRL_PIN(132, "XIRQ4", 0,
421 			     115, UNIPHIER_PIN_DRV_1BIT,
422 			     115, UNIPHIER_PIN_PULL_DOWN),
423 	UNIPHIER_PINCTRL_PIN(133, "XIRQ5", 0,
424 			     116, UNIPHIER_PIN_DRV_1BIT,
425 			     116, UNIPHIER_PIN_PULL_DOWN),
426 	UNIPHIER_PINCTRL_PIN(134, "XIRQ6", 0,
427 			     117, UNIPHIER_PIN_DRV_1BIT,
428 			     117, UNIPHIER_PIN_PULL_DOWN),
429 	UNIPHIER_PINCTRL_PIN(135, "XIRQ7", 0,
430 			     118, UNIPHIER_PIN_DRV_1BIT,
431 			     118, UNIPHIER_PIN_PULL_DOWN),
432 	/* dedicated pins */
433 	UNIPHIER_PINCTRL_PIN(136, "ED0", -1,
434 			     0, UNIPHIER_PIN_DRV_1BIT,
435 			     0, UNIPHIER_PIN_PULL_DOWN),
436 	UNIPHIER_PINCTRL_PIN(137, "ED1", -1,
437 			     1, UNIPHIER_PIN_DRV_1BIT,
438 			     1, UNIPHIER_PIN_PULL_DOWN),
439 	UNIPHIER_PINCTRL_PIN(138, "ED2", -1,
440 			     2, UNIPHIER_PIN_DRV_1BIT,
441 			     2, UNIPHIER_PIN_PULL_DOWN),
442 	UNIPHIER_PINCTRL_PIN(139, "ED3", -1,
443 			     3, UNIPHIER_PIN_DRV_1BIT,
444 			     3, UNIPHIER_PIN_PULL_DOWN),
445 	UNIPHIER_PINCTRL_PIN(140, "ED4", -1,
446 			     4, UNIPHIER_PIN_DRV_1BIT,
447 			     4, UNIPHIER_PIN_PULL_DOWN),
448 	UNIPHIER_PINCTRL_PIN(141, "ED5", -1,
449 			     5, UNIPHIER_PIN_DRV_1BIT,
450 			     5, UNIPHIER_PIN_PULL_DOWN),
451 	UNIPHIER_PINCTRL_PIN(142, "ED6", -1,
452 			     6, UNIPHIER_PIN_DRV_1BIT,
453 			     6, UNIPHIER_PIN_PULL_DOWN),
454 	UNIPHIER_PINCTRL_PIN(143, "ED7", -1,
455 			     7, UNIPHIER_PIN_DRV_1BIT,
456 			     7, UNIPHIER_PIN_PULL_DOWN),
457 	UNIPHIER_PINCTRL_PIN(144, "XERWE0", -1,
458 			     8, UNIPHIER_PIN_DRV_1BIT,
459 			     8, UNIPHIER_PIN_PULL_UP),
460 	UNIPHIER_PINCTRL_PIN(145, "XERWE1", -1,
461 			     9, UNIPHIER_PIN_DRV_1BIT,
462 			     9, UNIPHIER_PIN_PULL_UP),
463 	UNIPHIER_PINCTRL_PIN(146, "ERXW", -1,
464 			     10, UNIPHIER_PIN_DRV_1BIT,
465 			     10, UNIPHIER_PIN_PULL_UP),
466 	UNIPHIER_PINCTRL_PIN(147, "ES0", -1,
467 			     11, UNIPHIER_PIN_DRV_1BIT,
468 			     11, UNIPHIER_PIN_PULL_UP),
469 	UNIPHIER_PINCTRL_PIN(148, "ES1", -1,
470 			     12, UNIPHIER_PIN_DRV_1BIT,
471 			     12, UNIPHIER_PIN_PULL_UP),
472 	UNIPHIER_PINCTRL_PIN(149, "ES2", -1,
473 			     13, UNIPHIER_PIN_DRV_1BIT,
474 			     13, UNIPHIER_PIN_PULL_UP),
475 	UNIPHIER_PINCTRL_PIN(150, "XECS1", -1,
476 			     14, UNIPHIER_PIN_DRV_1BIT,
477 			     14, UNIPHIER_PIN_PULL_DOWN),
478 };
479 
480 static const unsigned emmc_pins[] = {21, 22, 23, 24, 25, 26, 27};
481 static const int emmc_muxvals[] = {1, 1, 1, 1, 1, 1, 1};
482 static const unsigned emmc_dat8_pins[] = {28, 29, 30, 31};
483 static const int emmc_dat8_muxvals[] = {1, 1, 1, 1};
484 static const unsigned ether_mii_pins[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 13, 14,
485 					  61, 63, 64, 65, 66, 67, 68};
486 static const int ether_mii_muxvals[] = {13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
487 					13, 13, 27, 27, 27, 27, 27, 27, 27};
488 static const unsigned ether_rmii_pins[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 13,
489 					   14};
490 static const int ether_rmii_muxvals[] = {13, 13, 13, 13, 13, 13, 13, 13, 13,
491 					 13, 13, 13};
492 static const unsigned i2c0_pins[] = {102, 103};
493 static const int i2c0_muxvals[] = {0, 0};
494 static const unsigned i2c1_pins[] = {104, 105};
495 static const int i2c1_muxvals[] = {0, 0};
496 static const unsigned i2c2_pins[] = {108, 109};
497 static const int i2c2_muxvals[] = {2, 2};
498 static const unsigned i2c3_pins[] = {108, 109};
499 static const int i2c3_muxvals[] = {3, 3};
500 static const unsigned nand_pins[] = {15, 16, 17, 18, 19, 20, 21, 24, 25, 26,
501 				     27, 28, 29, 30, 31};
502 static const int nand_muxvals[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
503 static const unsigned nand_cs1_pins[] = {22, 23};
504 static const int nand_cs1_muxvals[] = {0, 0};
505 static const unsigned sd_pins[] = {32, 33, 34, 35, 36, 37, 38, 39, 40};
506 static const int sd_muxvals[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
507 static const unsigned system_bus_pins[] = {136, 137, 138, 139, 140, 141, 142,
508 					   143, 144, 145, 146, 147, 148, 149};
509 static const int system_bus_muxvals[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1,
510 					 -1, -1, -1, -1, -1};
511 static const unsigned system_bus_cs1_pins[] = {150};
512 static const int system_bus_cs1_muxvals[] = {-1};
513 static const unsigned system_bus_cs2_pins[] = {10};
514 static const int system_bus_cs2_muxvals[] = {1};
515 static const unsigned system_bus_cs3_pins[] = {11};
516 static const int system_bus_cs3_muxvals[] = {1};
517 static const unsigned system_bus_cs4_pins[] = {12};
518 static const int system_bus_cs4_muxvals[] = {1};
519 static const unsigned system_bus_cs5_pins[] = {13};
520 static const int system_bus_cs5_muxvals[] = {1};
521 static const unsigned uart0_pins[] = {70, 71};
522 static const int uart0_muxvals[] = {3, 3};
523 static const unsigned uart1_pins[] = {114, 115};
524 static const int uart1_muxvals[] = {0, 0};
525 static const unsigned uart2_pins[] = {112, 113};
526 static const int uart2_muxvals[] = {1, 1};
527 static const unsigned uart3_pins[] = {110, 111};
528 static const int uart3_muxvals[] = {1, 1};
529 static const unsigned usb0_pins[] = {41, 42};
530 static const int usb0_muxvals[] = {0, 0};
531 static const unsigned usb1_pins[] = {43, 44};
532 static const int usb1_muxvals[] = {0, 0};
533 static const unsigned usb2_pins[] = {114, 115};
534 static const int usb2_muxvals[] = {1, 1};
535 static const unsigned int gpio_range0_pins[] = {
536 	0, 1, 2, 3, 4, 5, 6, 7,			/* PORT0x */
537 	8, 9, 10, 11, 12, 13, 14, 15,		/* PORT1x */
538 	32, 33, 34, 35, 36, 37, 38, 39,		/* PORT2x */
539 	59, 60, 61, 62, 63, 64, 65, 66,		/* PORT3x */
540 	95, 96, 97, 98, 99, 100, 101, 57,	/* PORT4x */
541 	70, 71, 72, 73, 74, 75, 76, 77,		/* PORT5x */
542 	81, 83, 84, 85, 86, 89, 90, 91,		/* PORT6x */
543 	118, 119, 120, 121, 122, 53, 54, 55,	/* PORT7x */
544 	41, 42, 43, 44, 79, 80, 18, 19,		/* PORT8x */
545 	110, 111, 112, 113, 114, 115, 16, 17,	/* PORT9x */
546 	40, 67, 68, 69, 78, 92, 93, 94,		/* PORT10x */
547 	48, 49, 46, 45, 123, 124, 125, 126,	/* PORT11x */
548 	47, 127, 20, 56, 22,			/* PORT120-124 */
549 };
550 static const unsigned int gpio_range1_pins[] = {
551 	116, 117,				/* PORT130-131 */
552 };
553 static const unsigned int gpio_range2_pins[] = {
554 	102, 103, 104, 105, 106, 107, 108, 109,	/* PORT14x */
555 	128, 129, 130, 131, 132, 133, 134, 135,	/* XIRQ0-7 */
556 	82, 87, 88, 50, 51, 23, 52, 58,	      /* XIRQ8-12, PORT165, XIRQ14-15 */
557 };
558 
559 static const struct uniphier_pinctrl_group uniphier_sld8_groups[] = {
560 	UNIPHIER_PINCTRL_GROUP(emmc),
561 	UNIPHIER_PINCTRL_GROUP(emmc_dat8),
562 	UNIPHIER_PINCTRL_GROUP(ether_mii),
563 	UNIPHIER_PINCTRL_GROUP(ether_rmii),
564 	UNIPHIER_PINCTRL_GROUP(i2c0),
565 	UNIPHIER_PINCTRL_GROUP(i2c1),
566 	UNIPHIER_PINCTRL_GROUP(i2c2),
567 	UNIPHIER_PINCTRL_GROUP(i2c3),
568 	UNIPHIER_PINCTRL_GROUP(nand),
569 	UNIPHIER_PINCTRL_GROUP(nand_cs1),
570 	UNIPHIER_PINCTRL_GROUP(sd),
571 	UNIPHIER_PINCTRL_GROUP(system_bus),
572 	UNIPHIER_PINCTRL_GROUP(system_bus_cs1),
573 	UNIPHIER_PINCTRL_GROUP(system_bus_cs2),
574 	UNIPHIER_PINCTRL_GROUP(system_bus_cs3),
575 	UNIPHIER_PINCTRL_GROUP(system_bus_cs4),
576 	UNIPHIER_PINCTRL_GROUP(system_bus_cs5),
577 	UNIPHIER_PINCTRL_GROUP(uart0),
578 	UNIPHIER_PINCTRL_GROUP(uart1),
579 	UNIPHIER_PINCTRL_GROUP(uart2),
580 	UNIPHIER_PINCTRL_GROUP(uart3),
581 	UNIPHIER_PINCTRL_GROUP(usb0),
582 	UNIPHIER_PINCTRL_GROUP(usb1),
583 	UNIPHIER_PINCTRL_GROUP(usb2),
584 	UNIPHIER_PINCTRL_GROUP_GPIO(gpio_range0),
585 	UNIPHIER_PINCTRL_GROUP_GPIO(gpio_range1),
586 	UNIPHIER_PINCTRL_GROUP_GPIO(gpio_range2),
587 };
588 
589 static const char * const emmc_groups[] = {"emmc", "emmc_dat8"};
590 static const char * const ether_mii_groups[] = {"ether_mii"};
591 static const char * const ether_rmii_groups[] = {"ether_rmii"};
592 static const char * const i2c0_groups[] = {"i2c0"};
593 static const char * const i2c1_groups[] = {"i2c1"};
594 static const char * const i2c2_groups[] = {"i2c2"};
595 static const char * const i2c3_groups[] = {"i2c3"};
596 static const char * const nand_groups[] = {"nand", "nand_cs1"};
597 static const char * const sd_groups[] = {"sd"};
598 static const char * const system_bus_groups[] = {"system_bus",
599 						 "system_bus_cs1",
600 						 "system_bus_cs2",
601 						 "system_bus_cs3",
602 						 "system_bus_cs4",
603 						 "system_bus_cs5"};
604 static const char * const uart0_groups[] = {"uart0"};
605 static const char * const uart1_groups[] = {"uart1"};
606 static const char * const uart2_groups[] = {"uart2"};
607 static const char * const uart3_groups[] = {"uart3"};
608 static const char * const usb0_groups[] = {"usb0"};
609 static const char * const usb1_groups[] = {"usb1"};
610 static const char * const usb2_groups[] = {"usb2"};
611 
612 static const struct uniphier_pinmux_function uniphier_sld8_functions[] = {
613 	UNIPHIER_PINMUX_FUNCTION(emmc),
614 	UNIPHIER_PINMUX_FUNCTION(ether_mii),
615 	UNIPHIER_PINMUX_FUNCTION(ether_rmii),
616 	UNIPHIER_PINMUX_FUNCTION(i2c0),
617 	UNIPHIER_PINMUX_FUNCTION(i2c1),
618 	UNIPHIER_PINMUX_FUNCTION(i2c2),
619 	UNIPHIER_PINMUX_FUNCTION(i2c3),
620 	UNIPHIER_PINMUX_FUNCTION(nand),
621 	UNIPHIER_PINMUX_FUNCTION(sd),
622 	UNIPHIER_PINMUX_FUNCTION(system_bus),
623 	UNIPHIER_PINMUX_FUNCTION(uart0),
624 	UNIPHIER_PINMUX_FUNCTION(uart1),
625 	UNIPHIER_PINMUX_FUNCTION(uart2),
626 	UNIPHIER_PINMUX_FUNCTION(uart3),
627 	UNIPHIER_PINMUX_FUNCTION(usb0),
628 	UNIPHIER_PINMUX_FUNCTION(usb1),
629 	UNIPHIER_PINMUX_FUNCTION(usb2),
630 };
631 
632 static int uniphier_sld8_get_gpio_muxval(unsigned int pin,
633 					 unsigned int gpio_offset)
634 {
635 	switch (gpio_offset) {
636 	case 120 ... 127:	/* XIRQ0-XIRQ7 */
637 		return 0;
638 	case 128 ... 132:	/* XIRQ8-12 */
639 	case 134 ... 135:	/* XIRQ14-15 */
640 		return 14;
641 	default:
642 		return 15;
643 	}
644 }
645 
646 static struct uniphier_pinctrl_socdata uniphier_sld8_pindata = {
647 	.pins = uniphier_sld8_pins,
648 	.npins = ARRAY_SIZE(uniphier_sld8_pins),
649 	.groups = uniphier_sld8_groups,
650 	.groups_count = ARRAY_SIZE(uniphier_sld8_groups),
651 	.functions = uniphier_sld8_functions,
652 	.functions_count = ARRAY_SIZE(uniphier_sld8_functions),
653 	.get_gpio_muxval = uniphier_sld8_get_gpio_muxval,
654 	.caps = 0,
655 };
656 
657 static int uniphier_sld8_pinctrl_probe(struct platform_device *pdev)
658 {
659 	return uniphier_pinctrl_probe(pdev, &uniphier_sld8_pindata);
660 }
661 
662 static const struct of_device_id uniphier_sld8_pinctrl_match[] = {
663 	{ .compatible = "socionext,uniphier-sld8-pinctrl" },
664 	{ /* sentinel */ }
665 };
666 
667 static struct platform_driver uniphier_sld8_pinctrl_driver = {
668 	.probe = uniphier_sld8_pinctrl_probe,
669 	.driver = {
670 		.name = "uniphier-sld8-pinctrl",
671 		.of_match_table = uniphier_sld8_pinctrl_match,
672 		.pm = &uniphier_pinctrl_pm_ops,
673 	},
674 };
675 builtin_platform_driver(uniphier_sld8_pinctrl_driver);
676