1 // SPDX-License-Identifier: GPL-2.0+
2 //
3 // Copyright (C) 2019 Socionext Inc.
4 //   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
5 
6 #include <linux/init.h>
7 #include <linux/kernel.h>
8 #include <linux/mod_devicetable.h>
9 #include <linux/pinctrl/pinctrl.h>
10 #include <linux/platform_device.h>
11 
12 #include "pinctrl-uniphier.h"
13 
14 static const struct pinctrl_pin_desc uniphier_nx1_pins[] = {
15 	UNIPHIER_PINCTRL_PIN(0, "LPST", UNIPHIER_PIN_IECTRL_EXIST,
16 			     0, UNIPHIER_PIN_DRV_3BIT,
17 			     0, UNIPHIER_PIN_PULL_DOWN),
18 	UNIPHIER_PINCTRL_PIN(1, "SDCLK", UNIPHIER_PIN_IECTRL_EXIST,
19 			     12, UNIPHIER_PIN_DRV_2BIT,
20 			     1, UNIPHIER_PIN_PULL_UP),
21 	UNIPHIER_PINCTRL_PIN(2, "SDCMD", UNIPHIER_PIN_IECTRL_EXIST,
22 			     13, UNIPHIER_PIN_DRV_2BIT,
23 			     2, UNIPHIER_PIN_PULL_UP),
24 	UNIPHIER_PINCTRL_PIN(3, "SDDAT0", UNIPHIER_PIN_IECTRL_EXIST,
25 			     14, UNIPHIER_PIN_DRV_2BIT,
26 			     3, UNIPHIER_PIN_PULL_UP),
27 	UNIPHIER_PINCTRL_PIN(4, "SDDAT1", UNIPHIER_PIN_IECTRL_EXIST,
28 			     15, UNIPHIER_PIN_DRV_2BIT,
29 			     4, UNIPHIER_PIN_PULL_UP),
30 	UNIPHIER_PINCTRL_PIN(5, "SDDAT2", UNIPHIER_PIN_IECTRL_EXIST,
31 			     16, UNIPHIER_PIN_DRV_2BIT,
32 			     5, UNIPHIER_PIN_PULL_UP),
33 	UNIPHIER_PINCTRL_PIN(6, "SDDAT3", UNIPHIER_PIN_IECTRL_EXIST,
34 			     17, UNIPHIER_PIN_DRV_2BIT,
35 			     6, UNIPHIER_PIN_PULL_UP),
36 	UNIPHIER_PINCTRL_PIN(7, "SDCD", UNIPHIER_PIN_IECTRL_EXIST,
37 			     1, UNIPHIER_PIN_DRV_3BIT,
38 			     7, UNIPHIER_PIN_PULL_UP),
39 	UNIPHIER_PINCTRL_PIN(8, "SDWP", UNIPHIER_PIN_IECTRL_EXIST,
40 			     2, UNIPHIER_PIN_DRV_3BIT,
41 			     8, UNIPHIER_PIN_PULL_UP),
42 	UNIPHIER_PINCTRL_PIN(9, "SDVOLC", UNIPHIER_PIN_IECTRL_EXIST,
43 			     3, UNIPHIER_PIN_DRV_3BIT,
44 			     9, UNIPHIER_PIN_PULL_UP),
45 	UNIPHIER_PINCTRL_PIN(10, "XERST", UNIPHIER_PIN_IECTRL_EXIST,
46 			     0, UNIPHIER_PIN_DRV_2BIT,
47 			     10, UNIPHIER_PIN_PULL_DOWN),
48 	UNIPHIER_PINCTRL_PIN(11, "MDC", UNIPHIER_PIN_IECTRL_EXIST,
49 			     18, UNIPHIER_PIN_DRV_2BIT,
50 			     11, UNIPHIER_PIN_PULL_UP),
51 	UNIPHIER_PINCTRL_PIN(12, "MDIO", UNIPHIER_PIN_IECTRL_EXIST,
52 			     19, UNIPHIER_PIN_DRV_2BIT,
53 			     12, UNIPHIER_PIN_PULL_UP),
54 	UNIPHIER_PINCTRL_PIN(13, "MDIO_INTL", UNIPHIER_PIN_IECTRL_EXIST,
55 			     20, UNIPHIER_PIN_DRV_2BIT,
56 			     13, UNIPHIER_PIN_PULL_UP),
57 	UNIPHIER_PINCTRL_PIN(14, "PHYRSTL", UNIPHIER_PIN_IECTRL_EXIST,
58 			     -1, UNIPHIER_PIN_DRV_FIXED4,
59 			     -1, UNIPHIER_PIN_PULL_NONE),
60 	UNIPHIER_PINCTRL_PIN(15, "RGMII_RXCLK", UNIPHIER_PIN_IECTRL_EXIST,
61 			     22, UNIPHIER_PIN_DRV_2BIT,
62 			     15, UNIPHIER_PIN_PULL_UP),
63 	UNIPHIER_PINCTRL_PIN(16, "RGMII_RXD0", UNIPHIER_PIN_IECTRL_EXIST,
64 			     23, UNIPHIER_PIN_DRV_2BIT,
65 			     16, UNIPHIER_PIN_PULL_UP),
66 	UNIPHIER_PINCTRL_PIN(17, "RGMII_RXD1", UNIPHIER_PIN_IECTRL_EXIST,
67 			     24, UNIPHIER_PIN_DRV_2BIT,
68 			     17, UNIPHIER_PIN_PULL_UP),
69 	UNIPHIER_PINCTRL_PIN(18, "RGMII_RXD2", UNIPHIER_PIN_IECTRL_EXIST,
70 			     25, UNIPHIER_PIN_DRV_2BIT,
71 			     18, UNIPHIER_PIN_PULL_UP),
72 	UNIPHIER_PINCTRL_PIN(19, "RGMII_RXD3", UNIPHIER_PIN_IECTRL_EXIST,
73 			     26, UNIPHIER_PIN_DRV_2BIT,
74 			     19, UNIPHIER_PIN_PULL_UP),
75 	UNIPHIER_PINCTRL_PIN(20, "RGMII_RXCTL", UNIPHIER_PIN_IECTRL_EXIST,
76 			     27, UNIPHIER_PIN_DRV_2BIT,
77 			     20, UNIPHIER_PIN_PULL_UP),
78 	UNIPHIER_PINCTRL_PIN(21, "RGMII_TXCLK", UNIPHIER_PIN_IECTRL_EXIST,
79 			     28, UNIPHIER_PIN_DRV_2BIT,
80 			     21, UNIPHIER_PIN_PULL_DOWN),
81 	UNIPHIER_PINCTRL_PIN(22, "RGMII_TXD0", UNIPHIER_PIN_IECTRL_EXIST,
82 			     29, UNIPHIER_PIN_DRV_2BIT,
83 			     22, UNIPHIER_PIN_PULL_DOWN),
84 	UNIPHIER_PINCTRL_PIN(23, "RGMII_TXD1", UNIPHIER_PIN_IECTRL_EXIST,
85 			     30, UNIPHIER_PIN_DRV_2BIT,
86 			     23, UNIPHIER_PIN_PULL_DOWN),
87 	UNIPHIER_PINCTRL_PIN(24, "RGMII_TXD2", UNIPHIER_PIN_IECTRL_EXIST,
88 			     31, UNIPHIER_PIN_DRV_2BIT,
89 			     24, UNIPHIER_PIN_PULL_DOWN),
90 	UNIPHIER_PINCTRL_PIN(25, "RGMII_TXD3", UNIPHIER_PIN_IECTRL_EXIST,
91 			     32, UNIPHIER_PIN_DRV_2BIT,
92 			     25, UNIPHIER_PIN_PULL_DOWN),
93 	UNIPHIER_PINCTRL_PIN(26, "RGMII_TXCTL", UNIPHIER_PIN_IECTRL_EXIST,
94 			     33, UNIPHIER_PIN_DRV_2BIT,
95 			     26, UNIPHIER_PIN_PULL_DOWN),
96 	UNIPHIER_PINCTRL_PIN(27, "TXD0", UNIPHIER_PIN_IECTRL_EXIST,
97 			     4, UNIPHIER_PIN_DRV_3BIT,
98 			     27, UNIPHIER_PIN_PULL_UP),
99 	UNIPHIER_PINCTRL_PIN(28, "RXD0", UNIPHIER_PIN_IECTRL_EXIST,
100 			     5, UNIPHIER_PIN_DRV_3BIT,
101 			     28, UNIPHIER_PIN_PULL_UP),
102 	UNIPHIER_PINCTRL_PIN(29, "TXD1", UNIPHIER_PIN_IECTRL_EXIST,
103 			     6, UNIPHIER_PIN_DRV_3BIT,
104 			     29, UNIPHIER_PIN_PULL_UP),
105 	UNIPHIER_PINCTRL_PIN(30, "RXD1", UNIPHIER_PIN_IECTRL_EXIST,
106 			     7, UNIPHIER_PIN_DRV_3BIT,
107 			     30, UNIPHIER_PIN_PULL_UP),
108 	UNIPHIER_PINCTRL_PIN(31, "XRTS1", UNIPHIER_PIN_IECTRL_EXIST,
109 			     8, UNIPHIER_PIN_DRV_3BIT,
110 			     31, UNIPHIER_PIN_PULL_UP),
111 	UNIPHIER_PINCTRL_PIN(32, "XDTR1", UNIPHIER_PIN_IECTRL_EXIST,
112 			     9, UNIPHIER_PIN_DRV_3BIT,
113 			     32, UNIPHIER_PIN_PULL_UP),
114 	UNIPHIER_PINCTRL_PIN(33, "XCTS1", UNIPHIER_PIN_IECTRL_EXIST,
115 			     10, UNIPHIER_PIN_DRV_3BIT,
116 			     33, UNIPHIER_PIN_PULL_UP),
117 	UNIPHIER_PINCTRL_PIN(34, "XDSR1", UNIPHIER_PIN_IECTRL_EXIST,
118 			     11, UNIPHIER_PIN_DRV_3BIT,
119 			     34, UNIPHIER_PIN_PULL_UP),
120 	UNIPHIER_PINCTRL_PIN(35, "XDCD1", UNIPHIER_PIN_IECTRL_EXIST,
121 			     12, UNIPHIER_PIN_DRV_3BIT,
122 			     35, UNIPHIER_PIN_PULL_UP),
123 	UNIPHIER_PINCTRL_PIN(36, "TXD2", UNIPHIER_PIN_IECTRL_EXIST,
124 			     13, UNIPHIER_PIN_DRV_3BIT,
125 			     36, UNIPHIER_PIN_PULL_UP),
126 	UNIPHIER_PINCTRL_PIN(37, "RXD2", UNIPHIER_PIN_IECTRL_EXIST,
127 			     14, UNIPHIER_PIN_DRV_3BIT,
128 			     37, UNIPHIER_PIN_PULL_UP),
129 	UNIPHIER_PINCTRL_PIN(38, "XRTS2", UNIPHIER_PIN_IECTRL_EXIST,
130 			     15, UNIPHIER_PIN_DRV_3BIT,
131 			     38, UNIPHIER_PIN_PULL_UP),
132 	UNIPHIER_PINCTRL_PIN(39, "XCTS2", UNIPHIER_PIN_IECTRL_EXIST,
133 			     16, UNIPHIER_PIN_DRV_3BIT,
134 			     39, UNIPHIER_PIN_PULL_UP),
135 	UNIPHIER_PINCTRL_PIN(40, "TXD3", UNIPHIER_PIN_IECTRL_EXIST,
136 			     17, UNIPHIER_PIN_DRV_3BIT,
137 			     40, UNIPHIER_PIN_PULL_UP),
138 	UNIPHIER_PINCTRL_PIN(41, "RXD3", UNIPHIER_PIN_IECTRL_EXIST,
139 			     18, UNIPHIER_PIN_DRV_3BIT,
140 			     41, UNIPHIER_PIN_PULL_UP),
141 	UNIPHIER_PINCTRL_PIN(42, "SPISYNC0", UNIPHIER_PIN_IECTRL_EXIST,
142 			     19, UNIPHIER_PIN_DRV_3BIT,
143 			     42, UNIPHIER_PIN_PULL_UP),
144 	UNIPHIER_PINCTRL_PIN(43, "SPISCLK0", UNIPHIER_PIN_IECTRL_EXIST,
145 			     20, UNIPHIER_PIN_DRV_3BIT,
146 			     43, UNIPHIER_PIN_PULL_DOWN),
147 	UNIPHIER_PINCTRL_PIN(44, "SPITXD0", UNIPHIER_PIN_IECTRL_EXIST,
148 			     21, UNIPHIER_PIN_DRV_3BIT,
149 			     44, UNIPHIER_PIN_PULL_DOWN),
150 	UNIPHIER_PINCTRL_PIN(45, "SPIRXD0", UNIPHIER_PIN_IECTRL_EXIST,
151 			     22, UNIPHIER_PIN_DRV_3BIT,
152 			     45, UNIPHIER_PIN_PULL_DOWN),
153 	UNIPHIER_PINCTRL_PIN(46, "SPISYNC1", UNIPHIER_PIN_IECTRL_EXIST,
154 			     23, UNIPHIER_PIN_DRV_3BIT,
155 			     46, UNIPHIER_PIN_PULL_UP),
156 	UNIPHIER_PINCTRL_PIN(47, "SPISCLK1", UNIPHIER_PIN_IECTRL_EXIST,
157 			     24, UNIPHIER_PIN_DRV_3BIT,
158 			     47, UNIPHIER_PIN_PULL_DOWN),
159 	UNIPHIER_PINCTRL_PIN(48, "SPITXD1", UNIPHIER_PIN_IECTRL_EXIST,
160 			     25, UNIPHIER_PIN_DRV_3BIT,
161 			     48, UNIPHIER_PIN_PULL_DOWN),
162 	UNIPHIER_PINCTRL_PIN(49, "SPIRXD1", UNIPHIER_PIN_IECTRL_EXIST,
163 			     26, UNIPHIER_PIN_DRV_3BIT,
164 			     49, UNIPHIER_PIN_PULL_DOWN),
165 	UNIPHIER_PINCTRL_PIN(50, "SDA0", UNIPHIER_PIN_IECTRL_EXIST,
166 			     -1, UNIPHIER_PIN_DRV_FIXED4,
167 			     -1, UNIPHIER_PIN_PULL_NONE),
168 	UNIPHIER_PINCTRL_PIN(51, "SCL0", UNIPHIER_PIN_IECTRL_EXIST,
169 			     -1, UNIPHIER_PIN_DRV_FIXED4,
170 			     -1, UNIPHIER_PIN_PULL_NONE),
171 	UNIPHIER_PINCTRL_PIN(52, "SDA1", UNIPHIER_PIN_IECTRL_EXIST,
172 			     -1, UNIPHIER_PIN_DRV_FIXED4,
173 			     -1, UNIPHIER_PIN_PULL_NONE),
174 	UNIPHIER_PINCTRL_PIN(53, "SCL1", UNIPHIER_PIN_IECTRL_EXIST,
175 			     -1, UNIPHIER_PIN_DRV_FIXED4,
176 			     -1, UNIPHIER_PIN_PULL_NONE),
177 	UNIPHIER_PINCTRL_PIN(54, "SDA2", UNIPHIER_PIN_IECTRL_EXIST,
178 			     -1, UNIPHIER_PIN_DRV_FIXED4,
179 			     -1, UNIPHIER_PIN_PULL_NONE),
180 	UNIPHIER_PINCTRL_PIN(55, "SCL2", UNIPHIER_PIN_IECTRL_EXIST,
181 			     -1, UNIPHIER_PIN_DRV_FIXED4,
182 			     -1, UNIPHIER_PIN_PULL_NONE),
183 	UNIPHIER_PINCTRL_PIN(56, "SDA3", UNIPHIER_PIN_IECTRL_EXIST,
184 			     -1, UNIPHIER_PIN_DRV_FIXED4,
185 			     -1, UNIPHIER_PIN_PULL_NONE),
186 	UNIPHIER_PINCTRL_PIN(57, "SCL3", UNIPHIER_PIN_IECTRL_EXIST,
187 			     -1, UNIPHIER_PIN_DRV_FIXED4,
188 			     -1, UNIPHIER_PIN_PULL_NONE),
189 	UNIPHIER_PINCTRL_PIN(58, "XIRQ0", UNIPHIER_PIN_IECTRL_EXIST,
190 			     27, UNIPHIER_PIN_DRV_3BIT,
191 			     58, UNIPHIER_PIN_PULL_DOWN),
192 	UNIPHIER_PINCTRL_PIN(59, "XIRQ1", UNIPHIER_PIN_IECTRL_EXIST,
193 			     28, UNIPHIER_PIN_DRV_3BIT,
194 			     59, UNIPHIER_PIN_PULL_DOWN),
195 	UNIPHIER_PINCTRL_PIN(60, "XIRQ2", UNIPHIER_PIN_IECTRL_EXIST,
196 			     29, UNIPHIER_PIN_DRV_3BIT,
197 			     60, UNIPHIER_PIN_PULL_DOWN),
198 	UNIPHIER_PINCTRL_PIN(61, "XIRQ3", UNIPHIER_PIN_IECTRL_EXIST,
199 			     30, UNIPHIER_PIN_DRV_3BIT,
200 			     61, UNIPHIER_PIN_PULL_DOWN),
201 	UNIPHIER_PINCTRL_PIN(62, "XIRQ4", UNIPHIER_PIN_IECTRL_EXIST,
202 			     31, UNIPHIER_PIN_DRV_3BIT,
203 			     62, UNIPHIER_PIN_PULL_DOWN),
204 	UNIPHIER_PINCTRL_PIN(63, "XIRQ5", UNIPHIER_PIN_IECTRL_EXIST,
205 			     32, UNIPHIER_PIN_DRV_3BIT,
206 			     63, UNIPHIER_PIN_PULL_DOWN),
207 	UNIPHIER_PINCTRL_PIN(64, "PORT00", UNIPHIER_PIN_IECTRL_EXIST,
208 			     33, UNIPHIER_PIN_DRV_3BIT,
209 			     64, UNIPHIER_PIN_PULL_DOWN),
210 	UNIPHIER_PINCTRL_PIN(65, "PORT01", UNIPHIER_PIN_IECTRL_EXIST,
211 			     34, UNIPHIER_PIN_DRV_3BIT,
212 			     65, UNIPHIER_PIN_PULL_DOWN),
213 	UNIPHIER_PINCTRL_PIN(66, "PORT02", UNIPHIER_PIN_IECTRL_EXIST,
214 			     35, UNIPHIER_PIN_DRV_3BIT,
215 			     66, UNIPHIER_PIN_PULL_DOWN),
216 	UNIPHIER_PINCTRL_PIN(67, "PORT03", UNIPHIER_PIN_IECTRL_EXIST,
217 			     36, UNIPHIER_PIN_DRV_3BIT,
218 			     67, UNIPHIER_PIN_PULL_DOWN),
219 	UNIPHIER_PINCTRL_PIN(68, "PORT04", UNIPHIER_PIN_IECTRL_EXIST,
220 			     37, UNIPHIER_PIN_DRV_3BIT,
221 			     68, UNIPHIER_PIN_PULL_DOWN),
222 	UNIPHIER_PINCTRL_PIN(69, "PORT05", UNIPHIER_PIN_IECTRL_EXIST,
223 			     38, UNIPHIER_PIN_DRV_3BIT,
224 			     69, UNIPHIER_PIN_PULL_DOWN),
225 	UNIPHIER_PINCTRL_PIN(70, "PORT06", UNIPHIER_PIN_IECTRL_EXIST,
226 			     39, UNIPHIER_PIN_DRV_3BIT,
227 			     70, UNIPHIER_PIN_PULL_DOWN),
228 	UNIPHIER_PINCTRL_PIN(71, "PORT07", UNIPHIER_PIN_IECTRL_EXIST,
229 			     40, UNIPHIER_PIN_DRV_3BIT,
230 			     71, UNIPHIER_PIN_PULL_DOWN),
231 	UNIPHIER_PINCTRL_PIN(72, "PORT10", UNIPHIER_PIN_IECTRL_EXIST,
232 			     41, UNIPHIER_PIN_DRV_3BIT,
233 			     72, UNIPHIER_PIN_PULL_DOWN),
234 	UNIPHIER_PINCTRL_PIN(73, "PORT11", UNIPHIER_PIN_IECTRL_EXIST,
235 			     42, UNIPHIER_PIN_DRV_3BIT,
236 			     73, UNIPHIER_PIN_PULL_DOWN),
237 	UNIPHIER_PINCTRL_PIN(74, "PORT12", UNIPHIER_PIN_IECTRL_EXIST,
238 			     43, UNIPHIER_PIN_DRV_3BIT,
239 			     74, UNIPHIER_PIN_PULL_DOWN),
240 	UNIPHIER_PINCTRL_PIN(75, "PORT13", UNIPHIER_PIN_IECTRL_EXIST,
241 			     44, UNIPHIER_PIN_DRV_3BIT,
242 			     75, UNIPHIER_PIN_PULL_DOWN),
243 	UNIPHIER_PINCTRL_PIN(76, "PORT14", UNIPHIER_PIN_IECTRL_EXIST,
244 			     45, UNIPHIER_PIN_DRV_3BIT,
245 			     76, UNIPHIER_PIN_PULL_DOWN),
246 	UNIPHIER_PINCTRL_PIN(77, "PORT15", UNIPHIER_PIN_IECTRL_EXIST,
247 			     46, UNIPHIER_PIN_DRV_3BIT,
248 			     77, UNIPHIER_PIN_PULL_DOWN),
249 	UNIPHIER_PINCTRL_PIN(78, "USBAVBUS", UNIPHIER_PIN_IECTRL_EXIST,
250 			     47, UNIPHIER_PIN_DRV_3BIT,
251 			     78, UNIPHIER_PIN_PULL_DOWN),
252 	UNIPHIER_PINCTRL_PIN(79, "USBAOD", UNIPHIER_PIN_IECTRL_EXIST,
253 			     48, UNIPHIER_PIN_DRV_3BIT,
254 			     79, UNIPHIER_PIN_PULL_UP),
255 	UNIPHIER_PINCTRL_PIN(80, "USBBVBUS", UNIPHIER_PIN_IECTRL_EXIST,
256 			     49, UNIPHIER_PIN_DRV_3BIT,
257 			     80, UNIPHIER_PIN_PULL_DOWN),
258 	UNIPHIER_PINCTRL_PIN(81, "USBBOD", UNIPHIER_PIN_IECTRL_EXIST,
259 			     50, UNIPHIER_PIN_DRV_3BIT,
260 			     81, UNIPHIER_PIN_PULL_UP),
261 	UNIPHIER_PINCTRL_PIN(82, "HTDDCSDA0", UNIPHIER_PIN_IECTRL_EXIST,
262 			     -1, UNIPHIER_PIN_DRV_FIXED4,
263 			     -1, UNIPHIER_PIN_PULL_NONE),
264 	UNIPHIER_PINCTRL_PIN(83, "HTDDCSCL0", UNIPHIER_PIN_IECTRL_EXIST,
265 			     -1, UNIPHIER_PIN_DRV_FIXED4,
266 			     -1, UNIPHIER_PIN_PULL_NONE),
267 	UNIPHIER_PINCTRL_PIN(84, "HTHPDI0", UNIPHIER_PIN_IECTRL_EXIST,
268 			     -1, UNIPHIER_PIN_DRV_FIXED4,
269 			     -1, UNIPHIER_PIN_PULL_NONE),
270 	UNIPHIER_PINCTRL_PIN(85, "MMCCLK", UNIPHIER_PIN_IECTRL_EXIST,
271 			     1, UNIPHIER_PIN_DRV_2BIT,
272 			     85, UNIPHIER_PIN_PULL_DOWN),
273 	UNIPHIER_PINCTRL_PIN(86, "MMCCMD", UNIPHIER_PIN_IECTRL_EXIST,
274 			     2, UNIPHIER_PIN_DRV_2BIT,
275 			     86, UNIPHIER_PIN_PULL_UP),
276 	UNIPHIER_PINCTRL_PIN(87, "MMCDS", UNIPHIER_PIN_IECTRL_EXIST,
277 			     3, UNIPHIER_PIN_DRV_2BIT,
278 			     87, UNIPHIER_PIN_PULL_DOWN),
279 	UNIPHIER_PINCTRL_PIN(88, "MMCDAT0", UNIPHIER_PIN_IECTRL_EXIST,
280 			     4, UNIPHIER_PIN_DRV_2BIT,
281 			     88, UNIPHIER_PIN_PULL_UP),
282 	UNIPHIER_PINCTRL_PIN(89, "MMCDAT1", UNIPHIER_PIN_IECTRL_EXIST,
283 			     5, UNIPHIER_PIN_DRV_2BIT,
284 			     89, UNIPHIER_PIN_PULL_UP),
285 	UNIPHIER_PINCTRL_PIN(90, "MMCDAT2", UNIPHIER_PIN_IECTRL_EXIST,
286 			     6, UNIPHIER_PIN_DRV_2BIT,
287 			     90, UNIPHIER_PIN_PULL_UP),
288 	UNIPHIER_PINCTRL_PIN(91, "MMCDAT3", UNIPHIER_PIN_IECTRL_EXIST,
289 			     7, UNIPHIER_PIN_DRV_2BIT,
290 			     91, UNIPHIER_PIN_PULL_UP),
291 	UNIPHIER_PINCTRL_PIN(92, "MMCDAT4", UNIPHIER_PIN_IECTRL_EXIST,
292 			     8, UNIPHIER_PIN_DRV_2BIT,
293 			     92, UNIPHIER_PIN_PULL_UP),
294 	UNIPHIER_PINCTRL_PIN(93, "MMCDAT5", UNIPHIER_PIN_IECTRL_EXIST,
295 			     9, UNIPHIER_PIN_DRV_2BIT,
296 			     93, UNIPHIER_PIN_PULL_UP),
297 	UNIPHIER_PINCTRL_PIN(94, "MMCDAT6", UNIPHIER_PIN_IECTRL_EXIST,
298 			     10, UNIPHIER_PIN_DRV_2BIT,
299 			     94, UNIPHIER_PIN_PULL_UP),
300 	UNIPHIER_PINCTRL_PIN(95, "MMCDAT7", UNIPHIER_PIN_IECTRL_EXIST,
301 			     11, UNIPHIER_PIN_DRV_2BIT,
302 			     95, UNIPHIER_PIN_PULL_UP),
303 };
304 
305 static const unsigned int emmc_pins[] = {85, 86, 87, 88, 89, 90, 91};
306 static const int emmc_muxvals[] = {-1, -1, -1, -1, -1, -1, -1};
307 static const unsigned int emmc_dat8_pins[] = {92, 93, 94, 95};
308 static const int emmc_dat8_muxvals[] = {-1, -1, -1, -1};
309 static const unsigned int ether_rgmii_pins[] = {11, 12, 13, 14, 15, 16, 17, 18,
310 						19, 20, 21, 22, 23, 24, 25, 26};
311 static const int ether_rgmii_muxvals[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
312 					  0, 0, 0};
313 static const unsigned int ether_rmii_pins[] = {11, 12, 13, 14, 15, 16, 17, 18,
314 					       20, 22, 23, 26};
315 static const int ether_rmii_muxvals[] = {0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1};
316 static const unsigned int i2c0_pins[] = {50, 51};
317 static const int i2c0_muxvals[] = {0, 0};
318 static const unsigned int i2c1_pins[] = {52, 53};
319 static const int i2c1_muxvals[] = {0, 0};
320 static const unsigned int i2c2_pins[] = {54, 55};
321 static const int i2c2_muxvals[] = {0, 0};
322 static const unsigned int i2c3_pins[] = {56, 57};
323 static const int i2c3_muxvals[] = {0, 0};
324 static const unsigned int i2c4_pins[] = {72, 73};
325 static const int i2c4_muxvals[] = {1, 1};
326 static const unsigned int i2c5_pins[] = {74, 75};
327 static const int i2c5_muxvals[] = {1, 1};
328 static const unsigned int i2c6_pins[] = {82, 83};
329 static const int i2c6_muxvals[] = {1, 1};
330 static const unsigned int sd_pins[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
331 static const int sd_muxvals[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
332 static const unsigned spi0_pins[] = {42, 43, 44, 45};
333 static const int spi0_muxvals[] = {0, 0, 0, 0};
334 static const unsigned spi1_pins[] = {46, 47, 48, 49};
335 static const int spi1_muxvals[] = {0, 0, 0, 0};
336 static const unsigned int uart0_pins[] = {27, 28};
337 static const int uart0_muxvals[] = {0, 0};
338 static const unsigned int uart1_pins[] = {29, 30};
339 static const int uart1_muxvals[] = {0, 0};
340 static const unsigned int uart1_ctsrts_pins[] = {31, 33};
341 static const int uart1_ctsrts_muxvals[] = {0, 0};
342 static const unsigned int uart1_modem_pins[] = {32, 34, 35};
343 static const int uart1_modem_muxvals[] = {0, 0, 0};
344 static const unsigned int uart2_pins[] = {36, 37};
345 static const int uart2_muxvals[] = {0, 0};
346 static const unsigned int uart2_ctsrts_pins[] = {38, 39};
347 static const int uart2_ctsrts_muxvals[] = {0, 0};
348 static const unsigned int uart3_pins[] = {40, 41};
349 static const int uart3_muxvals[] = {0, 0};
350 static const unsigned int usb0_pins[] = {78, 79};
351 static const int usb0_muxvals[] = {0, 0};
352 static const unsigned int usb1_pins[] = {80, 81};
353 static const int usb1_muxvals[] = {0, 0};
354 static const unsigned int gpio_range0_pins[] = {
355 	64, 65, 66, 67, 68, 69, 70, 71,			/* PORT0x */
356 	72, 73, 74, 75, 76, 77, 0, 1,			/* PORT1x */
357 	2, 3, 4, 5, 6, 7, 8, 9,				/* PORT2x */
358 	10, 78, 79, 80, 81,				/* PORT30-34 */
359 };
360 static const unsigned int gpio_range1_pins[] = {
361 	11, 12, 13,					/* PORT61-63 */
362 };
363 static const unsigned int gpio_range2_pins[] = {
364 	15, 16, 17,					/* PORT65-67 */
365 	18, 19, 20, 21, 22, 23, 24, 25,			/* PORT7x */
366 	26, 27, 28, 29, 30, 31, 32, 33,			/* PORT8x */
367 	34, 35, 36, 37, 38, 39, 40, 41,			/* PORT9x */
368 	42, 43, 44, 45, 46, 47, 48, 49,			/* PORT10x */
369 };
370 static const unsigned int gpio_range3_pins[] = {
371 	58, 59, 60, 61, 62, 63,				/* PORT12x */
372 };
373 static const unsigned int gpio_range4_pins[] = {
374 	58, 59, 60, 61, 62, 63,				/* XIRQ0-5 */
375 };
376 
377 static const struct uniphier_pinctrl_group uniphier_nx1_groups[] = {
378 	UNIPHIER_PINCTRL_GROUP(emmc),
379 	UNIPHIER_PINCTRL_GROUP(emmc_dat8),
380 	UNIPHIER_PINCTRL_GROUP(ether_rgmii),
381 	UNIPHIER_PINCTRL_GROUP(ether_rmii),
382 	UNIPHIER_PINCTRL_GROUP(i2c0),
383 	UNIPHIER_PINCTRL_GROUP(i2c1),
384 	UNIPHIER_PINCTRL_GROUP(i2c2),
385 	UNIPHIER_PINCTRL_GROUP(i2c3),
386 	UNIPHIER_PINCTRL_GROUP(i2c4),
387 	UNIPHIER_PINCTRL_GROUP(i2c5),
388 	UNIPHIER_PINCTRL_GROUP(i2c6),
389 	UNIPHIER_PINCTRL_GROUP(sd),
390 	UNIPHIER_PINCTRL_GROUP(spi0),
391 	UNIPHIER_PINCTRL_GROUP(spi1),
392 	UNIPHIER_PINCTRL_GROUP(uart0),
393 	UNIPHIER_PINCTRL_GROUP(uart1),
394 	UNIPHIER_PINCTRL_GROUP(uart1_ctsrts),
395 	UNIPHIER_PINCTRL_GROUP(uart1_modem),
396 	UNIPHIER_PINCTRL_GROUP(uart2),
397 	UNIPHIER_PINCTRL_GROUP(uart2_ctsrts),
398 	UNIPHIER_PINCTRL_GROUP(uart3),
399 	UNIPHIER_PINCTRL_GROUP(usb0),
400 	UNIPHIER_PINCTRL_GROUP(usb1),
401 	UNIPHIER_PINCTRL_GROUP_GPIO(gpio_range0),
402 	UNIPHIER_PINCTRL_GROUP_GPIO(gpio_range1),
403 	UNIPHIER_PINCTRL_GROUP_GPIO(gpio_range2),
404 	UNIPHIER_PINCTRL_GROUP_GPIO(gpio_range3),
405 	UNIPHIER_PINCTRL_GROUP_GPIO(gpio_range4),
406 };
407 
408 static const char * const emmc_groups[] = {"emmc", "emmc_dat8"};
409 static const char * const ether_rgmii_groups[] = {"ether_rgmii"};
410 static const char * const ether_rmii_groups[] = {"ether_rmii"};
411 static const char * const i2c0_groups[] = {"i2c0"};
412 static const char * const i2c1_groups[] = {"i2c1"};
413 static const char * const i2c2_groups[] = {"i2c2"};
414 static const char * const i2c3_groups[] = {"i2c3"};
415 static const char * const i2c4_groups[] = {"i2c4"};
416 static const char * const i2c5_groups[] = {"i2c5"};
417 static const char * const i2c6_groups[] = {"i2c6"};
418 static const char * const sd_groups[] = {"sd"};
419 static const char * const spi0_groups[] = {"spi0"};
420 static const char * const spi1_groups[] = {"spi1"};
421 static const char * const uart0_groups[] = {"uart0"};
422 static const char * const uart1_groups[] = {"uart1", "uart1_ctsrts",
423 					    "uart1_modem"};
424 static const char * const uart2_groups[] = {"uart2", "uart2_ctsrts"};
425 static const char * const uart3_groups[] = {"uart3"};
426 static const char * const usb0_groups[] = {"usb0"};
427 static const char * const usb1_groups[] = {"usb1"};
428 
429 static const struct uniphier_pinmux_function uniphier_nx1_functions[] = {
430 	UNIPHIER_PINMUX_FUNCTION(emmc),
431 	UNIPHIER_PINMUX_FUNCTION(ether_rgmii),
432 	UNIPHIER_PINMUX_FUNCTION(ether_rmii),
433 	UNIPHIER_PINMUX_FUNCTION(i2c0),
434 	UNIPHIER_PINMUX_FUNCTION(i2c1),
435 	UNIPHIER_PINMUX_FUNCTION(i2c2),
436 	UNIPHIER_PINMUX_FUNCTION(i2c3),
437 	UNIPHIER_PINMUX_FUNCTION(i2c4),
438 	UNIPHIER_PINMUX_FUNCTION(i2c5),
439 	UNIPHIER_PINMUX_FUNCTION(i2c6),
440 	UNIPHIER_PINMUX_FUNCTION(sd),
441 	UNIPHIER_PINMUX_FUNCTION(spi0),
442 	UNIPHIER_PINMUX_FUNCTION(spi1),
443 	UNIPHIER_PINMUX_FUNCTION(uart0),
444 	UNIPHIER_PINMUX_FUNCTION(uart1),
445 	UNIPHIER_PINMUX_FUNCTION(uart2),
446 	UNIPHIER_PINMUX_FUNCTION(uart3),
447 	UNIPHIER_PINMUX_FUNCTION(usb0),
448 	UNIPHIER_PINMUX_FUNCTION(usb1),
449 };
450 
uniphier_nx1_get_gpio_muxval(unsigned int pin,unsigned int gpio_offset)451 static int uniphier_nx1_get_gpio_muxval(unsigned int pin,
452 					unsigned int gpio_offset)
453 {
454 	if (gpio_offset >= 120)	/* XIRQx */
455 		return 14;
456 
457 	return 15;
458 }
459 
460 static const struct uniphier_pinctrl_socdata uniphier_nx1_pindata = {
461 	.pins = uniphier_nx1_pins,
462 	.npins = ARRAY_SIZE(uniphier_nx1_pins),
463 	.groups = uniphier_nx1_groups,
464 	.groups_count = ARRAY_SIZE(uniphier_nx1_groups),
465 	.functions = uniphier_nx1_functions,
466 	.functions_count = ARRAY_SIZE(uniphier_nx1_functions),
467 	.get_gpio_muxval = uniphier_nx1_get_gpio_muxval,
468 	.caps = UNIPHIER_PINCTRL_CAPS_PERPIN_IECTRL,
469 };
470 
uniphier_nx1_pinctrl_probe(struct platform_device * pdev)471 static int uniphier_nx1_pinctrl_probe(struct platform_device *pdev)
472 {
473 	return uniphier_pinctrl_probe(pdev, &uniphier_nx1_pindata);
474 }
475 
476 static const struct of_device_id uniphier_nx1_pinctrl_match[] = {
477 	{ .compatible = "socionext,uniphier-nx1-pinctrl" },
478 	{ /* sentinel */ }
479 };
480 
481 static struct platform_driver uniphier_nx1_pinctrl_driver = {
482 	.probe = uniphier_nx1_pinctrl_probe,
483 	.driver = {
484 		.name = "uniphier-nx1-pinctrl",
485 		.of_match_table = uniphier_nx1_pinctrl_match,
486 		.pm = &uniphier_pinctrl_pm_ops,
487 	},
488 };
489 builtin_platform_driver(uniphier_nx1_pinctrl_driver);
490