1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * PIC32 pinctrl driver
4  *
5  * Joshua Henderson, <joshua.henderson@microchip.com>
6  * Copyright (C) 2015 Microchip Technology Inc.  All rights reserved.
7  */
8 #include <linux/clk.h>
9 #include <linux/gpio/driver.h>
10 #include <linux/interrupt.h>
11 #include <linux/io.h>
12 #include <linux/irq.h>
13 #include <linux/of.h>
14 #include <linux/pinctrl/pinconf.h>
15 #include <linux/pinctrl/pinconf-generic.h>
16 #include <linux/pinctrl/pinctrl.h>
17 #include <linux/pinctrl/pinmux.h>
18 #include <linux/platform_device.h>
19 #include <linux/seq_file.h>
20 #include <linux/slab.h>
21 #include <linux/spinlock.h>
22 
23 #include <asm/mach-pic32/pic32.h>
24 
25 #include "pinctrl-utils.h"
26 #include "pinctrl-pic32.h"
27 
28 #define PINS_PER_BANK		16
29 
30 #define PIC32_CNCON_EDGE	11
31 #define PIC32_CNCON_ON		15
32 
33 #define PIN_CONFIG_MICROCHIP_DIGITAL	(PIN_CONFIG_END + 1)
34 #define PIN_CONFIG_MICROCHIP_ANALOG	(PIN_CONFIG_END + 2)
35 
36 static const struct pinconf_generic_params pic32_mpp_bindings[] = {
37 	{"microchip,digital",	PIN_CONFIG_MICROCHIP_DIGITAL,	0},
38 	{"microchip,analog",	PIN_CONFIG_MICROCHIP_ANALOG,	0},
39 };
40 
41 #define GPIO_BANK_START(bank)		((bank) * PINS_PER_BANK)
42 
43 struct pic32_function {
44 	const char *name;
45 	const char * const *groups;
46 	unsigned int ngroups;
47 };
48 
49 struct pic32_pin_group {
50 	const char *name;
51 	unsigned int pin;
52 	struct pic32_desc_function *functions;
53 };
54 
55 struct pic32_desc_function {
56 	const char *name;
57 	u32 muxreg;
58 	u32 muxval;
59 };
60 
61 struct pic32_gpio_bank {
62 	void __iomem *reg_base;
63 	int instance;
64 	struct gpio_chip gpio_chip;
65 	struct clk *clk;
66 };
67 
68 struct pic32_pinctrl {
69 	void __iomem *reg_base;
70 	struct device *dev;
71 	struct pinctrl_dev *pctldev;
72 	const struct pinctrl_pin_desc *pins;
73 	unsigned int npins;
74 	const struct pic32_function *functions;
75 	unsigned int nfunctions;
76 	const struct pic32_pin_group *groups;
77 	unsigned int ngroups;
78 	struct pic32_gpio_bank *gpio_banks;
79 	unsigned int nbanks;
80 	struct clk *clk;
81 };
82 
83 static const struct pinctrl_pin_desc pic32_pins[] = {
84 	PINCTRL_PIN(0, "A0"),
85 	PINCTRL_PIN(1, "A1"),
86 	PINCTRL_PIN(2, "A2"),
87 	PINCTRL_PIN(3, "A3"),
88 	PINCTRL_PIN(4, "A4"),
89 	PINCTRL_PIN(5, "A5"),
90 	PINCTRL_PIN(6, "A6"),
91 	PINCTRL_PIN(7, "A7"),
92 	PINCTRL_PIN(8, "A8"),
93 	PINCTRL_PIN(9, "A9"),
94 	PINCTRL_PIN(10, "A10"),
95 	PINCTRL_PIN(11, "A11"),
96 	PINCTRL_PIN(12, "A12"),
97 	PINCTRL_PIN(13, "A13"),
98 	PINCTRL_PIN(14, "A14"),
99 	PINCTRL_PIN(15, "A15"),
100 	PINCTRL_PIN(16, "B0"),
101 	PINCTRL_PIN(17, "B1"),
102 	PINCTRL_PIN(18, "B2"),
103 	PINCTRL_PIN(19, "B3"),
104 	PINCTRL_PIN(20, "B4"),
105 	PINCTRL_PIN(21, "B5"),
106 	PINCTRL_PIN(22, "B6"),
107 	PINCTRL_PIN(23, "B7"),
108 	PINCTRL_PIN(24, "B8"),
109 	PINCTRL_PIN(25, "B9"),
110 	PINCTRL_PIN(26, "B10"),
111 	PINCTRL_PIN(27, "B11"),
112 	PINCTRL_PIN(28, "B12"),
113 	PINCTRL_PIN(29, "B13"),
114 	PINCTRL_PIN(30, "B14"),
115 	PINCTRL_PIN(31, "B15"),
116 	PINCTRL_PIN(33, "C1"),
117 	PINCTRL_PIN(34, "C2"),
118 	PINCTRL_PIN(35, "C3"),
119 	PINCTRL_PIN(36, "C4"),
120 	PINCTRL_PIN(44, "C12"),
121 	PINCTRL_PIN(45, "C13"),
122 	PINCTRL_PIN(46, "C14"),
123 	PINCTRL_PIN(47, "C15"),
124 	PINCTRL_PIN(48, "D0"),
125 	PINCTRL_PIN(49, "D1"),
126 	PINCTRL_PIN(50, "D2"),
127 	PINCTRL_PIN(51, "D3"),
128 	PINCTRL_PIN(52, "D4"),
129 	PINCTRL_PIN(53, "D5"),
130 	PINCTRL_PIN(54, "D6"),
131 	PINCTRL_PIN(55, "D7"),
132 	PINCTRL_PIN(57, "D9"),
133 	PINCTRL_PIN(58, "D10"),
134 	PINCTRL_PIN(59, "D11"),
135 	PINCTRL_PIN(60, "D12"),
136 	PINCTRL_PIN(61, "D13"),
137 	PINCTRL_PIN(62, "D14"),
138 	PINCTRL_PIN(63, "D15"),
139 	PINCTRL_PIN(64, "E0"),
140 	PINCTRL_PIN(65, "E1"),
141 	PINCTRL_PIN(66, "E2"),
142 	PINCTRL_PIN(67, "E3"),
143 	PINCTRL_PIN(68, "E4"),
144 	PINCTRL_PIN(69, "E5"),
145 	PINCTRL_PIN(70, "E6"),
146 	PINCTRL_PIN(71, "E7"),
147 	PINCTRL_PIN(72, "E8"),
148 	PINCTRL_PIN(73, "E9"),
149 	PINCTRL_PIN(80, "F0"),
150 	PINCTRL_PIN(81, "F1"),
151 	PINCTRL_PIN(82, "F2"),
152 	PINCTRL_PIN(83, "F3"),
153 	PINCTRL_PIN(84, "F4"),
154 	PINCTRL_PIN(85, "F5"),
155 	PINCTRL_PIN(88, "F8"),
156 	PINCTRL_PIN(92, "F12"),
157 	PINCTRL_PIN(93, "F13"),
158 	PINCTRL_PIN(96, "G0"),
159 	PINCTRL_PIN(97, "G1"),
160 	PINCTRL_PIN(102, "G6"),
161 	PINCTRL_PIN(103, "G7"),
162 	PINCTRL_PIN(104, "G8"),
163 	PINCTRL_PIN(105, "G9"),
164 	PINCTRL_PIN(108, "G12"),
165 	PINCTRL_PIN(109, "G13"),
166 	PINCTRL_PIN(110, "G14"),
167 	PINCTRL_PIN(111, "G15"),
168 	PINCTRL_PIN(112, "H0"),
169 	PINCTRL_PIN(113, "H1"),
170 	PINCTRL_PIN(114, "H2"),
171 	PINCTRL_PIN(115, "H3"),
172 	PINCTRL_PIN(116, "H4"),
173 	PINCTRL_PIN(117, "H5"),
174 	PINCTRL_PIN(118, "H6"),
175 	PINCTRL_PIN(119, "H7"),
176 	PINCTRL_PIN(120, "H8"),
177 	PINCTRL_PIN(121, "H9"),
178 	PINCTRL_PIN(122, "H10"),
179 	PINCTRL_PIN(123, "H11"),
180 	PINCTRL_PIN(124, "H12"),
181 	PINCTRL_PIN(125, "H13"),
182 	PINCTRL_PIN(126, "H14"),
183 	PINCTRL_PIN(127, "H15"),
184 	PINCTRL_PIN(128, "J0"),
185 	PINCTRL_PIN(129, "J1"),
186 	PINCTRL_PIN(130, "J2"),
187 	PINCTRL_PIN(131, "J3"),
188 	PINCTRL_PIN(132, "J4"),
189 	PINCTRL_PIN(133, "J5"),
190 	PINCTRL_PIN(134, "J6"),
191 	PINCTRL_PIN(135, "J7"),
192 	PINCTRL_PIN(136, "J8"),
193 	PINCTRL_PIN(137, "J9"),
194 	PINCTRL_PIN(138, "J10"),
195 	PINCTRL_PIN(139, "J11"),
196 	PINCTRL_PIN(140, "J12"),
197 	PINCTRL_PIN(141, "J13"),
198 	PINCTRL_PIN(142, "J14"),
199 	PINCTRL_PIN(143, "J15"),
200 	PINCTRL_PIN(144, "K0"),
201 	PINCTRL_PIN(145, "K1"),
202 	PINCTRL_PIN(146, "K2"),
203 	PINCTRL_PIN(147, "K3"),
204 	PINCTRL_PIN(148, "K4"),
205 	PINCTRL_PIN(149, "K5"),
206 	PINCTRL_PIN(150, "K6"),
207 	PINCTRL_PIN(151, "K7"),
208 };
209 
210 static const char * const pic32_input0_group[] = {
211 	"D2", "G8", "F4", "F1", "B9", "B10", "C14", "B5",
212 	"C1", "D14", "G1", "A14", "D6",
213 };
214 
215 static const char * const pic32_input1_group[] = {
216 	"D3", "G7", "F5", "D11", "F0", "B1", "E5", "C13",
217 	"B3", "C4", "G0", "A15", "D7",
218 };
219 
220 static const char * const pic32_input2_group[] = {
221 	"D9", "G6", "B8", "B15", "D4", "B0", "E3", "B7",
222 	"F12", "D12", "F8", "C3", "E9",
223 };
224 
225 static const char * const pic32_input3_group[] = {
226 	"G9", "B14", "D0", "B6", "D5", "B2", "F3", "F13",
227 	"F2", "C2", "E8",
228 };
229 
230 static const char * const pic32_output0_group[] = {
231 	"D2", "G8", "F4", "D10", "F1", "B9", "B10", "C14",
232 	"B5", "C1", "D14", "G1", "A14", "D6",
233 };
234 
235 static const char * const pic32_output0_1_group[] = {
236 	"D2", "G8", "F4", "D10", "F1", "B9", "B10", "C14",
237 	"B5", "C1", "D14", "G1", "A14", "D6",
238 	"D3", "G7", "F5", "D11", "F0", "B1", "E5", "C13",
239 	"B3", "C4", "D15", "G0", "A15", "D7",
240 };
241 
242 static const char *const pic32_output1_group[] = {
243 	"D3", "G7", "F5", "D11", "F0", "B1", "E5", "C13",
244 	"B3", "C4", "D15", "G0", "A15", "D7",
245 };
246 
247 static const char *const pic32_output1_3_group[] = {
248 	"D3", "G7", "F5", "D11", "F0", "B1", "E5", "C13",
249 	"B3", "C4", "D15", "G0", "A15", "D7",
250 	"G9", "B14", "D0", "B6", "D5", "B2", "F3", "F13",
251 	"C2", "E8", "F2",
252 };
253 
254 static const char * const pic32_output2_group[] = {
255 	"D9", "G6", "B8", "B15", "D4", "B0", "E3", "B7",
256 	"F12", "D12", "F8", "C3", "E9",
257 };
258 
259 static const char * const pic32_output2_3_group[] = {
260 	"D9", "G6", "B8", "B15", "D4", "B0", "E3", "B7",
261 	"F12", "D12", "F8", "C3", "E9",
262 	"G9", "B14", "D0", "B6", "D5", "B2", "F3", "F13",
263 	"C2", "E8", "F2",
264 };
265 
266 static const char * const pic32_output3_group[] = {
267 	"G9", "B14", "D0", "B6", "D5", "B2", "F3", "F13",
268 	"C2", "E8", "F2",
269 };
270 
271 #define FUNCTION(_name, _gr)					\
272 	{							\
273 		.name = #_name,					\
274 		.groups = pic32_##_gr##_group,			\
275 		.ngroups = ARRAY_SIZE(pic32_##_gr##_group),	\
276 	}
277 
278 static const struct pic32_function pic32_functions[] = {
279 	FUNCTION(INT3, input0),
280 	FUNCTION(T2CK, input0),
281 	FUNCTION(T6CK, input0),
282 	FUNCTION(IC3, input0),
283 	FUNCTION(IC7, input0),
284 	FUNCTION(U1RX, input0),
285 	FUNCTION(U2CTS, input0),
286 	FUNCTION(U5RX, input0),
287 	FUNCTION(U6CTS, input0),
288 	FUNCTION(SDI1, input0),
289 	FUNCTION(SDI3, input0),
290 	FUNCTION(SDI5, input0),
291 	FUNCTION(SS6IN, input0),
292 	FUNCTION(REFCLKI1, input0),
293 	FUNCTION(INT4, input1),
294 	FUNCTION(T5CK, input1),
295 	FUNCTION(T7CK, input1),
296 	FUNCTION(IC4, input1),
297 	FUNCTION(IC8, input1),
298 	FUNCTION(U3RX, input1),
299 	FUNCTION(U4CTS, input1),
300 	FUNCTION(SDI2, input1),
301 	FUNCTION(SDI4, input1),
302 	FUNCTION(C1RX, input1),
303 	FUNCTION(REFCLKI4, input1),
304 	FUNCTION(INT2, input2),
305 	FUNCTION(T3CK, input2),
306 	FUNCTION(T8CK, input2),
307 	FUNCTION(IC2, input2),
308 	FUNCTION(IC5, input2),
309 	FUNCTION(IC9, input2),
310 	FUNCTION(U1CTS, input2),
311 	FUNCTION(U2RX, input2),
312 	FUNCTION(U5CTS, input2),
313 	FUNCTION(SS1IN, input2),
314 	FUNCTION(SS3IN, input2),
315 	FUNCTION(SS4IN, input2),
316 	FUNCTION(SS5IN, input2),
317 	FUNCTION(C2RX, input2),
318 	FUNCTION(INT1, input3),
319 	FUNCTION(T4CK, input3),
320 	FUNCTION(T9CK, input3),
321 	FUNCTION(IC1, input3),
322 	FUNCTION(IC6, input3),
323 	FUNCTION(U3CTS, input3),
324 	FUNCTION(U4RX, input3),
325 	FUNCTION(U6RX, input3),
326 	FUNCTION(SS2IN, input3),
327 	FUNCTION(SDI6, input3),
328 	FUNCTION(OCFA, input3),
329 	FUNCTION(REFCLKI3, input3),
330 	FUNCTION(U3TX, output0),
331 	FUNCTION(U4RTS, output0),
332 	FUNCTION(SDO1, output0_1),
333 	FUNCTION(SDO2, output0_1),
334 	FUNCTION(SDO3, output0_1),
335 	FUNCTION(SDO5, output0_1),
336 	FUNCTION(SS6OUT, output0),
337 	FUNCTION(OC3, output0),
338 	FUNCTION(OC6, output0),
339 	FUNCTION(REFCLKO4, output0),
340 	FUNCTION(C2OUT, output0),
341 	FUNCTION(C1TX, output0),
342 	FUNCTION(U1TX, output1),
343 	FUNCTION(U2RTS, output1),
344 	FUNCTION(U5TX, output1),
345 	FUNCTION(U6RTS, output1),
346 	FUNCTION(SDO4, output1_3),
347 	FUNCTION(OC4, output1),
348 	FUNCTION(OC7, output1),
349 	FUNCTION(REFCLKO1, output1),
350 	FUNCTION(U3RTS, output2),
351 	FUNCTION(U4TX, output2),
352 	FUNCTION(U6TX, output2_3),
353 	FUNCTION(SS1OUT, output2),
354 	FUNCTION(SS3OUT, output2),
355 	FUNCTION(SS4OUT, output2),
356 	FUNCTION(SS5OUT, output2),
357 	FUNCTION(SDO6, output2_3),
358 	FUNCTION(OC5, output2),
359 	FUNCTION(OC8, output2),
360 	FUNCTION(C1OUT, output2),
361 	FUNCTION(REFCLKO3, output2),
362 	FUNCTION(U1RTS, output3),
363 	FUNCTION(U2TX, output3),
364 	FUNCTION(U5RTS, output3),
365 	FUNCTION(SS2OUT, output3),
366 	FUNCTION(OC2, output3),
367 	FUNCTION(OC1, output3),
368 	FUNCTION(OC9, output3),
369 	FUNCTION(C2TX, output3),
370 };
371 
372 #define PIC32_PINCTRL_GROUP(_pin, _name, ...)				\
373 	{								\
374 		.name = #_name,						\
375 		.pin = _pin,						\
376 		.functions = (struct pic32_desc_function[]){		\
377 			__VA_ARGS__, { } },				\
378 	}
379 
380 #define PIC32_PINCTRL_FUNCTION(_name, _muxreg, _muxval)	\
381 	{						\
382 		.name = #_name,				\
383 		.muxreg = _muxreg,			\
384 		.muxval = _muxval,			\
385 	}
386 
387 static const struct pic32_pin_group pic32_groups[] = {
388 	PIC32_PINCTRL_GROUP(14, A14,
389 			PIC32_PINCTRL_FUNCTION(INT3, INT3R, 13),
390 			PIC32_PINCTRL_FUNCTION(T2CK, T2CKR, 13),
391 			PIC32_PINCTRL_FUNCTION(T6CK, T6CKR, 13),
392 			PIC32_PINCTRL_FUNCTION(IC3, IC3R, 13),
393 			PIC32_PINCTRL_FUNCTION(IC7, IC7R, 13),
394 			PIC32_PINCTRL_FUNCTION(U1RX, U1RXR, 13),
395 			PIC32_PINCTRL_FUNCTION(U2CTS, U2CTSR, 13),
396 			PIC32_PINCTRL_FUNCTION(U5RX, U5RXR, 13),
397 			PIC32_PINCTRL_FUNCTION(U6CTS, U6CTSR, 13),
398 			PIC32_PINCTRL_FUNCTION(SDI1, SDI1R, 13),
399 			PIC32_PINCTRL_FUNCTION(SDI3, SDI3R, 13),
400 			PIC32_PINCTRL_FUNCTION(SDI5, SDI5R, 13),
401 			PIC32_PINCTRL_FUNCTION(SS6IN, SS6INR, 13),
402 			PIC32_PINCTRL_FUNCTION(REFCLKI1, REFCLKI1R, 13),
403 			PIC32_PINCTRL_FUNCTION(U3TX, RPA14R, 1),
404 			PIC32_PINCTRL_FUNCTION(U4RTS, RPA14R, 2),
405 			PIC32_PINCTRL_FUNCTION(SDO1, RPA14R, 5),
406 			PIC32_PINCTRL_FUNCTION(SDO2, RPA14R, 6),
407 			PIC32_PINCTRL_FUNCTION(SDO3, RPA14R, 7),
408 			PIC32_PINCTRL_FUNCTION(SDO5, RPA14R, 9),
409 			PIC32_PINCTRL_FUNCTION(SS6OUT, RPA14R, 10),
410 			PIC32_PINCTRL_FUNCTION(OC3, RPA14R, 11),
411 			PIC32_PINCTRL_FUNCTION(OC6, RPA14R, 12),
412 			PIC32_PINCTRL_FUNCTION(REFCLKO4, RPA14R, 13),
413 			PIC32_PINCTRL_FUNCTION(C2OUT, RPA14R, 14),
414 			PIC32_PINCTRL_FUNCTION(C1TX, RPA14R, 15)),
415 	PIC32_PINCTRL_GROUP(15, A15,
416 			PIC32_PINCTRL_FUNCTION(INT4, INT4R, 13),
417 			PIC32_PINCTRL_FUNCTION(T5CK, T5CKR, 13),
418 			PIC32_PINCTRL_FUNCTION(T7CK, T7CKR, 13),
419 			PIC32_PINCTRL_FUNCTION(IC4, IC4R, 13),
420 			PIC32_PINCTRL_FUNCTION(IC8, IC8R, 13),
421 			PIC32_PINCTRL_FUNCTION(U3RX, U3RXR, 13),
422 			PIC32_PINCTRL_FUNCTION(U4CTS, U4CTSR, 13),
423 			PIC32_PINCTRL_FUNCTION(SDI2, SDI2R, 13),
424 			PIC32_PINCTRL_FUNCTION(SDI4, SDI4R, 13),
425 			PIC32_PINCTRL_FUNCTION(C1RX, C1RXR, 13),
426 			PIC32_PINCTRL_FUNCTION(REFCLKI4, REFCLKI4R, 13),
427 			PIC32_PINCTRL_FUNCTION(U1TX, RPA15R, 1),
428 			PIC32_PINCTRL_FUNCTION(U2RTS, RPA15R, 2),
429 			PIC32_PINCTRL_FUNCTION(U5TX, RPA15R, 3),
430 			PIC32_PINCTRL_FUNCTION(U6RTS, RPA15R, 4),
431 			PIC32_PINCTRL_FUNCTION(SDO1, RPA15R, 5),
432 			PIC32_PINCTRL_FUNCTION(SDO2, RPA15R, 6),
433 			PIC32_PINCTRL_FUNCTION(SDO3, RPA15R, 7),
434 			PIC32_PINCTRL_FUNCTION(SDO4, RPA15R, 8),
435 			PIC32_PINCTRL_FUNCTION(SDO5, RPA15R, 9),
436 			PIC32_PINCTRL_FUNCTION(OC4, RPA15R, 11),
437 			PIC32_PINCTRL_FUNCTION(OC7, RPA15R, 12),
438 			PIC32_PINCTRL_FUNCTION(REFCLKO1, RPA15R, 15)),
439 	PIC32_PINCTRL_GROUP(16, B0,
440 			PIC32_PINCTRL_FUNCTION(INT2, INT2R, 5),
441 			PIC32_PINCTRL_FUNCTION(T3CK, T3CKR, 5),
442 			PIC32_PINCTRL_FUNCTION(T8CK, T8CKR, 5),
443 			PIC32_PINCTRL_FUNCTION(IC2, IC2R, 5),
444 			PIC32_PINCTRL_FUNCTION(IC5, IC5R, 5),
445 			PIC32_PINCTRL_FUNCTION(IC9, IC9R, 5),
446 			PIC32_PINCTRL_FUNCTION(U1CTS, U1CTSR, 5),
447 			PIC32_PINCTRL_FUNCTION(U2RX, U2RXR, 5),
448 			PIC32_PINCTRL_FUNCTION(U5CTS, U5CTSR, 5),
449 			PIC32_PINCTRL_FUNCTION(SS1IN, SS1INR, 5),
450 			PIC32_PINCTRL_FUNCTION(SS3IN, SS3INR, 5),
451 			PIC32_PINCTRL_FUNCTION(SS4IN, SS4INR, 5),
452 			PIC32_PINCTRL_FUNCTION(SS5IN, SS5INR, 5),
453 			PIC32_PINCTRL_FUNCTION(C2RX, C2RXR, 5),
454 			PIC32_PINCTRL_FUNCTION(U3RTS, RPB0R, 1),
455 			PIC32_PINCTRL_FUNCTION(U4TX, RPB0R, 2),
456 			PIC32_PINCTRL_FUNCTION(U6TX, RPB0R, 4),
457 			PIC32_PINCTRL_FUNCTION(SS1OUT, RPB0R, 5),
458 			PIC32_PINCTRL_FUNCTION(SS3OUT, RPB0R, 7),
459 			PIC32_PINCTRL_FUNCTION(SS4OUT, RPB0R, 8),
460 			PIC32_PINCTRL_FUNCTION(SS5OUT, RPB0R, 9),
461 			PIC32_PINCTRL_FUNCTION(SDO6, RPB0R, 10),
462 			PIC32_PINCTRL_FUNCTION(OC5, RPB0R, 11),
463 			PIC32_PINCTRL_FUNCTION(OC8, RPB0R, 12),
464 			PIC32_PINCTRL_FUNCTION(C1OUT, RPB0R, 14),
465 			PIC32_PINCTRL_FUNCTION(REFCLKO3, RPB0R, 15)),
466 	PIC32_PINCTRL_GROUP(17, B1,
467 			PIC32_PINCTRL_FUNCTION(INT4, INT4R, 5),
468 			PIC32_PINCTRL_FUNCTION(T5CK, T5CKR, 5),
469 			PIC32_PINCTRL_FUNCTION(T7CK, T7CKR, 5),
470 			PIC32_PINCTRL_FUNCTION(IC4, IC4R, 5),
471 			PIC32_PINCTRL_FUNCTION(IC8, IC8R, 5),
472 			PIC32_PINCTRL_FUNCTION(U3RX, U3RXR, 5),
473 			PIC32_PINCTRL_FUNCTION(U4CTS, U4CTSR, 5),
474 			PIC32_PINCTRL_FUNCTION(SDI2, SDI2R, 5),
475 			PIC32_PINCTRL_FUNCTION(SDI4, SDI4R, 5),
476 			PIC32_PINCTRL_FUNCTION(C1RX, C1RXR, 5),
477 			PIC32_PINCTRL_FUNCTION(REFCLKI4, REFCLKI4R, 5),
478 			PIC32_PINCTRL_FUNCTION(U1TX, RPB1R, 1),
479 			PIC32_PINCTRL_FUNCTION(U2RTS, RPB1R, 2),
480 			PIC32_PINCTRL_FUNCTION(U5TX, RPB1R, 3),
481 			PIC32_PINCTRL_FUNCTION(U6RTS, RPB1R, 4),
482 			PIC32_PINCTRL_FUNCTION(SDO1, RPB1R, 5),
483 			PIC32_PINCTRL_FUNCTION(SDO2, RPB1R, 6),
484 			PIC32_PINCTRL_FUNCTION(SDO3, RPB1R, 7),
485 			PIC32_PINCTRL_FUNCTION(SDO4, RPB1R, 8),
486 			PIC32_PINCTRL_FUNCTION(SDO5, RPB1R, 9),
487 			PIC32_PINCTRL_FUNCTION(OC4, RPB1R, 11),
488 			PIC32_PINCTRL_FUNCTION(OC7, RPB1R, 12),
489 			PIC32_PINCTRL_FUNCTION(REFCLKO1, RPB1R, 15)),
490 	PIC32_PINCTRL_GROUP(18, B2,
491 			PIC32_PINCTRL_FUNCTION(INT1, INT1R, 7),
492 			PIC32_PINCTRL_FUNCTION(T4CK, T4CKR, 7),
493 			PIC32_PINCTRL_FUNCTION(T9CK, T9CKR, 7),
494 			PIC32_PINCTRL_FUNCTION(IC1, IC1R, 7),
495 			PIC32_PINCTRL_FUNCTION(IC6, IC6R, 7),
496 			PIC32_PINCTRL_FUNCTION(U3CTS, U3CTSR, 7),
497 			PIC32_PINCTRL_FUNCTION(U4RX, U4RXR, 7),
498 			PIC32_PINCTRL_FUNCTION(U6RX, U6RXR, 7),
499 			PIC32_PINCTRL_FUNCTION(SS2IN, SS2INR, 7),
500 			PIC32_PINCTRL_FUNCTION(SDI6, SDI6R, 7),
501 			PIC32_PINCTRL_FUNCTION(OCFA, OCFAR, 7),
502 			PIC32_PINCTRL_FUNCTION(REFCLKI3, REFCLKI3R, 7),
503 			PIC32_PINCTRL_FUNCTION(U1RTS, RPB2R, 1),
504 			PIC32_PINCTRL_FUNCTION(U2TX, RPB2R, 2),
505 			PIC32_PINCTRL_FUNCTION(U5RTS, RPB2R, 3),
506 			PIC32_PINCTRL_FUNCTION(U6TX, RPB2R, 4),
507 			PIC32_PINCTRL_FUNCTION(SS2OUT, RPB2R, 6),
508 			PIC32_PINCTRL_FUNCTION(SDO4, RPB2R, 8),
509 			PIC32_PINCTRL_FUNCTION(SDO6, RPB2R, 10),
510 			PIC32_PINCTRL_FUNCTION(OC2, RPB2R, 11),
511 			PIC32_PINCTRL_FUNCTION(OC1, RPB2R, 12),
512 			PIC32_PINCTRL_FUNCTION(OC9, RPB2R, 13),
513 			PIC32_PINCTRL_FUNCTION(C2TX, RPB2R, 15)),
514 	PIC32_PINCTRL_GROUP(19, B3,
515 			PIC32_PINCTRL_FUNCTION(INT4, INT4R, 8),
516 			PIC32_PINCTRL_FUNCTION(T5CK, T5CKR, 8),
517 			PIC32_PINCTRL_FUNCTION(T7CK, T7CKR, 8),
518 			PIC32_PINCTRL_FUNCTION(IC4, IC4R, 8),
519 			PIC32_PINCTRL_FUNCTION(IC8, IC8R, 8),
520 			PIC32_PINCTRL_FUNCTION(U3RX, U3RXR, 8),
521 			PIC32_PINCTRL_FUNCTION(U4CTS, U4CTSR, 8),
522 			PIC32_PINCTRL_FUNCTION(SDI2, SDI2R, 8),
523 			PIC32_PINCTRL_FUNCTION(SDI4, SDI4R, 8),
524 			PIC32_PINCTRL_FUNCTION(C1RX, C1RXR, 8),
525 			PIC32_PINCTRL_FUNCTION(REFCLKI4, REFCLKI4R, 8),
526 			PIC32_PINCTRL_FUNCTION(U1TX, RPB3R, 1),
527 			PIC32_PINCTRL_FUNCTION(U2RTS, RPB3R, 2),
528 			PIC32_PINCTRL_FUNCTION(U5TX, RPB3R, 3),
529 			PIC32_PINCTRL_FUNCTION(U6RTS, RPB3R, 4),
530 			PIC32_PINCTRL_FUNCTION(SDO1, RPB3R, 5),
531 			PIC32_PINCTRL_FUNCTION(SDO2, RPB3R, 6),
532 			PIC32_PINCTRL_FUNCTION(SDO3, RPB3R, 7),
533 			PIC32_PINCTRL_FUNCTION(SDO4, RPB3R, 8),
534 			PIC32_PINCTRL_FUNCTION(SDO5, RPB3R, 9),
535 			PIC32_PINCTRL_FUNCTION(OC4, RPB3R, 11),
536 			PIC32_PINCTRL_FUNCTION(OC7, RPB3R, 12),
537 			PIC32_PINCTRL_FUNCTION(REFCLKO1, RPB3R, 15)),
538 	PIC32_PINCTRL_GROUP(21, B5,
539 			PIC32_PINCTRL_FUNCTION(INT3, INT3R, 8),
540 			PIC32_PINCTRL_FUNCTION(T2CK, T2CKR, 8),
541 			PIC32_PINCTRL_FUNCTION(T6CK, T6CKR, 8),
542 			PIC32_PINCTRL_FUNCTION(IC3, IC3R, 8),
543 			PIC32_PINCTRL_FUNCTION(IC7, IC7R, 8),
544 			PIC32_PINCTRL_FUNCTION(U1RX, U1RXR, 8),
545 			PIC32_PINCTRL_FUNCTION(U2CTS, U2CTSR, 8),
546 			PIC32_PINCTRL_FUNCTION(U5RX, U5RXR, 8),
547 			PIC32_PINCTRL_FUNCTION(U6CTS, U6CTSR, 8),
548 			PIC32_PINCTRL_FUNCTION(SDI1, SDI1R, 8),
549 			PIC32_PINCTRL_FUNCTION(SDI3, SDI3R, 8),
550 			PIC32_PINCTRL_FUNCTION(SDI5, SDI5R, 8),
551 			PIC32_PINCTRL_FUNCTION(SS6IN, SS6INR, 8),
552 			PIC32_PINCTRL_FUNCTION(REFCLKI1, REFCLKI1R, 8),
553 			PIC32_PINCTRL_FUNCTION(U3TX, RPB5R, 1),
554 			PIC32_PINCTRL_FUNCTION(U4RTS, RPB5R, 2),
555 			PIC32_PINCTRL_FUNCTION(SDO1, RPB5R, 5),
556 			PIC32_PINCTRL_FUNCTION(SDO2, RPB5R, 6),
557 			PIC32_PINCTRL_FUNCTION(SDO3, RPB5R, 7),
558 			PIC32_PINCTRL_FUNCTION(SDO5, RPB5R, 9),
559 			PIC32_PINCTRL_FUNCTION(SS6OUT, RPB5R, 10),
560 			PIC32_PINCTRL_FUNCTION(OC3, RPB5R, 11),
561 			PIC32_PINCTRL_FUNCTION(OC6, RPB5R, 12),
562 			PIC32_PINCTRL_FUNCTION(REFCLKO4, RPB5R, 13),
563 			PIC32_PINCTRL_FUNCTION(C2OUT, RPB5R, 14),
564 			PIC32_PINCTRL_FUNCTION(C1TX, RPB5R, 15)),
565 	PIC32_PINCTRL_GROUP(22, B6,
566 			PIC32_PINCTRL_FUNCTION(INT1, INT1R, 4),
567 			PIC32_PINCTRL_FUNCTION(T4CK, T4CKR, 4),
568 			PIC32_PINCTRL_FUNCTION(T9CK, T9CKR, 4),
569 			PIC32_PINCTRL_FUNCTION(IC1, IC1R, 4),
570 			PIC32_PINCTRL_FUNCTION(IC6, IC6R, 4),
571 			PIC32_PINCTRL_FUNCTION(U3CTS, U3CTSR, 4),
572 			PIC32_PINCTRL_FUNCTION(U4RX, U4RXR, 4),
573 			PIC32_PINCTRL_FUNCTION(U6RX, U6RXR, 4),
574 			PIC32_PINCTRL_FUNCTION(SS2IN, SS2INR, 4),
575 			PIC32_PINCTRL_FUNCTION(SDI6, SDI6R, 4),
576 			PIC32_PINCTRL_FUNCTION(OCFA, OCFAR, 4),
577 			PIC32_PINCTRL_FUNCTION(REFCLKI3, REFCLKI3R, 4),
578 			PIC32_PINCTRL_FUNCTION(U1RTS, RPB6R, 1),
579 			PIC32_PINCTRL_FUNCTION(U2TX, RPB6R, 2),
580 			PIC32_PINCTRL_FUNCTION(U5RTS, RPB6R, 3),
581 			PIC32_PINCTRL_FUNCTION(U6TX, RPB6R, 4),
582 			PIC32_PINCTRL_FUNCTION(SS2OUT, RPB6R, 6),
583 			PIC32_PINCTRL_FUNCTION(SDO4, RPB6R, 8),
584 			PIC32_PINCTRL_FUNCTION(SDO6, RPB6R, 10),
585 			PIC32_PINCTRL_FUNCTION(OC2, RPB6R, 11),
586 			PIC32_PINCTRL_FUNCTION(OC1, RPB6R, 12),
587 			PIC32_PINCTRL_FUNCTION(OC9, RPB6R, 13),
588 			PIC32_PINCTRL_FUNCTION(C2TX, RPB6R, 15)),
589 	PIC32_PINCTRL_GROUP(23, B7,
590 			PIC32_PINCTRL_FUNCTION(INT2, INT2R, 7),
591 			PIC32_PINCTRL_FUNCTION(T3CK, T3CKR, 7),
592 			PIC32_PINCTRL_FUNCTION(T8CK, T8CKR, 7),
593 			PIC32_PINCTRL_FUNCTION(IC2, IC2R, 7),
594 			PIC32_PINCTRL_FUNCTION(IC5, IC5R, 7),
595 			PIC32_PINCTRL_FUNCTION(IC9, IC9R, 7),
596 			PIC32_PINCTRL_FUNCTION(U1CTS, U1CTSR, 7),
597 			PIC32_PINCTRL_FUNCTION(U2RX, U2RXR, 7),
598 			PIC32_PINCTRL_FUNCTION(U5CTS, U5CTSR, 7),
599 			PIC32_PINCTRL_FUNCTION(SS1IN, SS1INR, 7),
600 			PIC32_PINCTRL_FUNCTION(SS3IN, SS3INR, 7),
601 			PIC32_PINCTRL_FUNCTION(SS4IN, SS4INR, 7),
602 			PIC32_PINCTRL_FUNCTION(SS5IN, SS5INR, 7),
603 			PIC32_PINCTRL_FUNCTION(C2RX, C2RXR, 7),
604 			PIC32_PINCTRL_FUNCTION(U3RTS, RPB7R, 1),
605 			PIC32_PINCTRL_FUNCTION(U4TX, RPB7R, 2),
606 			PIC32_PINCTRL_FUNCTION(U6TX, RPB7R, 4),
607 			PIC32_PINCTRL_FUNCTION(SS1OUT, RPB7R, 5),
608 			PIC32_PINCTRL_FUNCTION(SS3OUT, RPB7R, 7),
609 			PIC32_PINCTRL_FUNCTION(SS4OUT, RPB7R, 8),
610 			PIC32_PINCTRL_FUNCTION(SS5OUT, RPB7R, 9),
611 			PIC32_PINCTRL_FUNCTION(SDO6, RPB7R, 10),
612 			PIC32_PINCTRL_FUNCTION(OC5, RPB7R, 11),
613 			PIC32_PINCTRL_FUNCTION(OC8, RPB7R, 12),
614 			PIC32_PINCTRL_FUNCTION(C1OUT, RPB7R, 14),
615 			PIC32_PINCTRL_FUNCTION(REFCLKO3, RPB7R, 15)),
616 	PIC32_PINCTRL_GROUP(24, B8,
617 			PIC32_PINCTRL_FUNCTION(INT2, INT2R, 2),
618 			PIC32_PINCTRL_FUNCTION(T3CK, T3CKR, 2),
619 			PIC32_PINCTRL_FUNCTION(T8CK, T8CKR, 2),
620 			PIC32_PINCTRL_FUNCTION(IC2, IC2R, 2),
621 			PIC32_PINCTRL_FUNCTION(IC5, IC5R, 2),
622 			PIC32_PINCTRL_FUNCTION(IC9, IC9R, 2),
623 			PIC32_PINCTRL_FUNCTION(U1CTS, U1CTSR, 2),
624 			PIC32_PINCTRL_FUNCTION(U2RX, U2RXR, 2),
625 			PIC32_PINCTRL_FUNCTION(U5CTS, U5CTSR, 2),
626 			PIC32_PINCTRL_FUNCTION(SS1IN, SS1INR, 2),
627 			PIC32_PINCTRL_FUNCTION(SS3IN, SS3INR, 2),
628 			PIC32_PINCTRL_FUNCTION(SS4IN, SS4INR, 2),
629 			PIC32_PINCTRL_FUNCTION(SS5IN, SS5INR, 2),
630 			PIC32_PINCTRL_FUNCTION(C2RX, C2RXR, 2),
631 			PIC32_PINCTRL_FUNCTION(U3RTS, RPB8R, 1),
632 			PIC32_PINCTRL_FUNCTION(U4TX, RPB8R, 2),
633 			PIC32_PINCTRL_FUNCTION(U6TX, RPB8R, 4),
634 			PIC32_PINCTRL_FUNCTION(SS1OUT, RPB8R, 5),
635 			PIC32_PINCTRL_FUNCTION(SS3OUT, RPB8R, 7),
636 			PIC32_PINCTRL_FUNCTION(SS4OUT, RPB8R, 8),
637 			PIC32_PINCTRL_FUNCTION(SS5OUT, RPB8R, 9),
638 			PIC32_PINCTRL_FUNCTION(SDO6, RPB8R, 10),
639 			PIC32_PINCTRL_FUNCTION(OC5, RPB8R, 11),
640 			PIC32_PINCTRL_FUNCTION(OC8, RPB8R, 12),
641 			PIC32_PINCTRL_FUNCTION(C1OUT, RPB8R, 14),
642 			PIC32_PINCTRL_FUNCTION(REFCLKO3, RPB8R, 15)),
643 	PIC32_PINCTRL_GROUP(25, B9,
644 			PIC32_PINCTRL_FUNCTION(INT3, INT3R, 5),
645 			PIC32_PINCTRL_FUNCTION(T2CK, T2CKR, 5),
646 			PIC32_PINCTRL_FUNCTION(T6CK, T6CKR, 5),
647 			PIC32_PINCTRL_FUNCTION(IC3, IC3R, 5),
648 			PIC32_PINCTRL_FUNCTION(IC7, IC7R, 5),
649 			PIC32_PINCTRL_FUNCTION(U1RX, U1RXR, 5),
650 			PIC32_PINCTRL_FUNCTION(U2CTS, U2CTSR, 5),
651 			PIC32_PINCTRL_FUNCTION(U5RX, U5RXR, 5),
652 			PIC32_PINCTRL_FUNCTION(U6CTS, U6CTSR, 5),
653 			PIC32_PINCTRL_FUNCTION(SDI1, SDI1R, 5),
654 			PIC32_PINCTRL_FUNCTION(SDI3, SDI3R, 5),
655 			PIC32_PINCTRL_FUNCTION(SDI5, SDI5R, 5),
656 			PIC32_PINCTRL_FUNCTION(SS6IN, SS6INR, 5),
657 			PIC32_PINCTRL_FUNCTION(REFCLKI1, REFCLKI1R, 5),
658 			PIC32_PINCTRL_FUNCTION(U3TX, RPB9R, 1),
659 			PIC32_PINCTRL_FUNCTION(U4RTS, RPB9R, 2),
660 			PIC32_PINCTRL_FUNCTION(SDO1, RPB9R, 5),
661 			PIC32_PINCTRL_FUNCTION(SDO2, RPB9R, 6),
662 			PIC32_PINCTRL_FUNCTION(SDO3, RPB9R, 7),
663 			PIC32_PINCTRL_FUNCTION(SDO5, RPB9R, 9),
664 			PIC32_PINCTRL_FUNCTION(SS6OUT, RPB9R, 10),
665 			PIC32_PINCTRL_FUNCTION(OC3, RPB9R, 11),
666 			PIC32_PINCTRL_FUNCTION(OC6, RPB9R, 12),
667 			PIC32_PINCTRL_FUNCTION(REFCLKO4, RPB9R, 13),
668 			PIC32_PINCTRL_FUNCTION(C2OUT, RPB9R, 14),
669 			PIC32_PINCTRL_FUNCTION(C1TX, RPB9R, 15)),
670 	PIC32_PINCTRL_GROUP(26, B10,
671 			PIC32_PINCTRL_FUNCTION(INT3, INT3R, 6),
672 			PIC32_PINCTRL_FUNCTION(T2CK, T2CKR, 6),
673 			PIC32_PINCTRL_FUNCTION(T6CK, T6CKR, 6),
674 			PIC32_PINCTRL_FUNCTION(IC3, IC3R, 6),
675 			PIC32_PINCTRL_FUNCTION(IC7, IC7R, 6),
676 			PIC32_PINCTRL_FUNCTION(U1RX, U1RXR, 6),
677 			PIC32_PINCTRL_FUNCTION(U2CTS, U2CTSR, 6),
678 			PIC32_PINCTRL_FUNCTION(U5RX, U5RXR, 6),
679 			PIC32_PINCTRL_FUNCTION(U6CTS, U6CTSR, 6),
680 			PIC32_PINCTRL_FUNCTION(SDI1, SDI1R, 6),
681 			PIC32_PINCTRL_FUNCTION(SDI3, SDI3R, 6),
682 			PIC32_PINCTRL_FUNCTION(SDI5, SDI5R, 6),
683 			PIC32_PINCTRL_FUNCTION(SS6IN, SS6INR, 6),
684 			PIC32_PINCTRL_FUNCTION(REFCLKI1, REFCLKI1R, 6),
685 			PIC32_PINCTRL_FUNCTION(U3TX, RPB10R, 1),
686 			PIC32_PINCTRL_FUNCTION(U4RTS, RPB10R, 2),
687 			PIC32_PINCTRL_FUNCTION(SDO1, RPB10R, 5),
688 			PIC32_PINCTRL_FUNCTION(SDO2, RPB10R, 6),
689 			PIC32_PINCTRL_FUNCTION(SDO3, RPB10R, 7),
690 			PIC32_PINCTRL_FUNCTION(SDO5, RPB10R, 9),
691 			PIC32_PINCTRL_FUNCTION(SS6OUT, RPB10R, 10),
692 			PIC32_PINCTRL_FUNCTION(OC3, RPB10R, 11),
693 			PIC32_PINCTRL_FUNCTION(OC6, RPB10R, 12),
694 			PIC32_PINCTRL_FUNCTION(REFCLKO4, RPB10R, 13),
695 			PIC32_PINCTRL_FUNCTION(C2OUT, RPB10R, 14),
696 			PIC32_PINCTRL_FUNCTION(C1TX, RPB10R, 15)),
697 	PIC32_PINCTRL_GROUP(30, B14,
698 			PIC32_PINCTRL_FUNCTION(INT1, INT1R, 2),
699 			PIC32_PINCTRL_FUNCTION(T4CK, T4CKR, 2),
700 			PIC32_PINCTRL_FUNCTION(T9CK, T9CKR, 2),
701 			PIC32_PINCTRL_FUNCTION(IC1, IC1R, 2),
702 			PIC32_PINCTRL_FUNCTION(IC6, IC6R, 2),
703 			PIC32_PINCTRL_FUNCTION(U3CTS, U3CTSR, 2),
704 			PIC32_PINCTRL_FUNCTION(U4RX, U4RXR, 2),
705 			PIC32_PINCTRL_FUNCTION(U6RX, U6RXR, 2),
706 			PIC32_PINCTRL_FUNCTION(SS2IN, SS2INR, 2),
707 			PIC32_PINCTRL_FUNCTION(SDI6, SDI6R, 2),
708 			PIC32_PINCTRL_FUNCTION(OCFA, OCFAR, 2),
709 			PIC32_PINCTRL_FUNCTION(REFCLKI3, REFCLKI3R, 2),
710 			PIC32_PINCTRL_FUNCTION(U1RTS, RPB14R, 1),
711 			PIC32_PINCTRL_FUNCTION(U2TX, RPB14R, 2),
712 			PIC32_PINCTRL_FUNCTION(U5RTS, RPB14R, 3),
713 			PIC32_PINCTRL_FUNCTION(U6TX, RPB14R, 4),
714 			PIC32_PINCTRL_FUNCTION(SS2OUT, RPB14R, 6),
715 			PIC32_PINCTRL_FUNCTION(SDO4, RPB14R, 8),
716 			PIC32_PINCTRL_FUNCTION(SDO6, RPB14R, 10),
717 			PIC32_PINCTRL_FUNCTION(OC2, RPB14R, 11),
718 			PIC32_PINCTRL_FUNCTION(OC1, RPB14R, 12),
719 			PIC32_PINCTRL_FUNCTION(OC9, RPB14R, 13),
720 			PIC32_PINCTRL_FUNCTION(C2TX, RPB14R, 15)),
721 	PIC32_PINCTRL_GROUP(31, B15,
722 			PIC32_PINCTRL_FUNCTION(INT2, INT2R, 3),
723 			PIC32_PINCTRL_FUNCTION(T3CK, T3CKR, 3),
724 			PIC32_PINCTRL_FUNCTION(T8CK, T8CKR, 3),
725 			PIC32_PINCTRL_FUNCTION(IC2, IC2R, 3),
726 			PIC32_PINCTRL_FUNCTION(IC5, IC5R, 3),
727 			PIC32_PINCTRL_FUNCTION(IC9, IC9R, 3),
728 			PIC32_PINCTRL_FUNCTION(U1CTS, U1CTSR, 3),
729 			PIC32_PINCTRL_FUNCTION(U2RX, U2RXR, 3),
730 			PIC32_PINCTRL_FUNCTION(U5CTS, U5CTSR, 3),
731 			PIC32_PINCTRL_FUNCTION(SS1IN, SS1INR, 3),
732 			PIC32_PINCTRL_FUNCTION(SS3IN, SS3INR, 3),
733 			PIC32_PINCTRL_FUNCTION(SS4IN, SS4INR, 3),
734 			PIC32_PINCTRL_FUNCTION(SS5IN, SS5INR, 3),
735 			PIC32_PINCTRL_FUNCTION(C2RX, C2RXR, 3),
736 			PIC32_PINCTRL_FUNCTION(U3RTS, RPB15R, 1),
737 			PIC32_PINCTRL_FUNCTION(U4TX, RPB15R, 2),
738 			PIC32_PINCTRL_FUNCTION(U6TX, RPB15R, 4),
739 			PIC32_PINCTRL_FUNCTION(SS1OUT, RPB15R, 5),
740 			PIC32_PINCTRL_FUNCTION(SS3OUT, RPB15R, 7),
741 			PIC32_PINCTRL_FUNCTION(SS4OUT, RPB15R, 8),
742 			PIC32_PINCTRL_FUNCTION(SS5OUT, RPB15R, 9),
743 			PIC32_PINCTRL_FUNCTION(SDO6, RPB15R, 10),
744 			PIC32_PINCTRL_FUNCTION(OC5, RPB15R, 11),
745 			PIC32_PINCTRL_FUNCTION(OC8, RPB15R, 12),
746 			PIC32_PINCTRL_FUNCTION(C1OUT, RPB15R, 14),
747 			PIC32_PINCTRL_FUNCTION(REFCLKO3, RPB15R, 15)),
748 	PIC32_PINCTRL_GROUP(33, C1,
749 			PIC32_PINCTRL_FUNCTION(INT3, INT3R, 10),
750 			PIC32_PINCTRL_FUNCTION(T2CK, T2CKR, 10),
751 			PIC32_PINCTRL_FUNCTION(T6CK, T6CKR, 10),
752 			PIC32_PINCTRL_FUNCTION(IC3, IC3R, 10),
753 			PIC32_PINCTRL_FUNCTION(IC7, IC7R, 10),
754 			PIC32_PINCTRL_FUNCTION(U1RX, U1RXR, 10),
755 			PIC32_PINCTRL_FUNCTION(U2CTS, U2CTSR, 10),
756 			PIC32_PINCTRL_FUNCTION(U5RX, U5RXR, 10),
757 			PIC32_PINCTRL_FUNCTION(U6CTS, U6CTSR, 10),
758 			PIC32_PINCTRL_FUNCTION(SDI1, SDI1R, 10),
759 			PIC32_PINCTRL_FUNCTION(SDI3, SDI3R, 10),
760 			PIC32_PINCTRL_FUNCTION(SDI5, SDI5R, 10),
761 			PIC32_PINCTRL_FUNCTION(SS6IN, SS6INR, 10),
762 			PIC32_PINCTRL_FUNCTION(REFCLKI1, REFCLKI1R, 10),
763 			PIC32_PINCTRL_FUNCTION(U3TX, RPC1R, 1),
764 			PIC32_PINCTRL_FUNCTION(U4RTS, RPC1R, 2),
765 			PIC32_PINCTRL_FUNCTION(SDO1, RPC1R, 5),
766 			PIC32_PINCTRL_FUNCTION(SDO2, RPC1R, 6),
767 			PIC32_PINCTRL_FUNCTION(SDO3, RPC1R, 7),
768 			PIC32_PINCTRL_FUNCTION(SDO5, RPC1R, 9),
769 			PIC32_PINCTRL_FUNCTION(SS6OUT, RPC1R, 10),
770 			PIC32_PINCTRL_FUNCTION(OC3, RPC1R, 11),
771 			PIC32_PINCTRL_FUNCTION(OC6, RPC1R, 12),
772 			PIC32_PINCTRL_FUNCTION(REFCLKO4, RPC1R, 13),
773 			PIC32_PINCTRL_FUNCTION(C2OUT, RPC1R, 14),
774 			PIC32_PINCTRL_FUNCTION(C1TX, RPC1R, 15)),
775 	PIC32_PINCTRL_GROUP(34, C2,
776 			PIC32_PINCTRL_FUNCTION(INT1, INT1R, 12),
777 			PIC32_PINCTRL_FUNCTION(T4CK, T4CKR, 12),
778 			PIC32_PINCTRL_FUNCTION(T9CK, T9CKR, 12),
779 			PIC32_PINCTRL_FUNCTION(IC1, IC1R, 12),
780 			PIC32_PINCTRL_FUNCTION(IC6, IC6R, 12),
781 			PIC32_PINCTRL_FUNCTION(U3CTS, U3CTSR, 12),
782 			PIC32_PINCTRL_FUNCTION(U4RX, U4RXR, 12),
783 			PIC32_PINCTRL_FUNCTION(U6RX, U6RXR, 12),
784 			PIC32_PINCTRL_FUNCTION(SS2IN, SS2INR, 12),
785 			PIC32_PINCTRL_FUNCTION(SDI6, SDI6R, 12),
786 			PIC32_PINCTRL_FUNCTION(OCFA, OCFAR, 12),
787 			PIC32_PINCTRL_FUNCTION(REFCLKI3, REFCLKI3R, 12),
788 			PIC32_PINCTRL_FUNCTION(U1RTS, RPC2R, 1),
789 			PIC32_PINCTRL_FUNCTION(U2TX, RPC2R, 2),
790 			PIC32_PINCTRL_FUNCTION(U5RTS, RPC2R, 3),
791 			PIC32_PINCTRL_FUNCTION(U6TX, RPC2R, 4),
792 			PIC32_PINCTRL_FUNCTION(SS2OUT, RPC2R, 6),
793 			PIC32_PINCTRL_FUNCTION(SDO4, RPC2R, 8),
794 			PIC32_PINCTRL_FUNCTION(SDO6, RPC2R, 10),
795 			PIC32_PINCTRL_FUNCTION(OC2, RPC2R, 11),
796 			PIC32_PINCTRL_FUNCTION(OC1, RPC2R, 12),
797 			PIC32_PINCTRL_FUNCTION(OC9, RPC2R, 13),
798 			PIC32_PINCTRL_FUNCTION(C2TX, RPC2R, 15)),
799 	PIC32_PINCTRL_GROUP(35, C3,
800 			PIC32_PINCTRL_FUNCTION(INT2, INT2R, 12),
801 			PIC32_PINCTRL_FUNCTION(T3CK, T3CKR, 12),
802 			PIC32_PINCTRL_FUNCTION(T8CK, T8CKR, 12),
803 			PIC32_PINCTRL_FUNCTION(IC2, IC2R, 12),
804 			PIC32_PINCTRL_FUNCTION(IC5, IC5R, 12),
805 			PIC32_PINCTRL_FUNCTION(IC9, IC9R, 12),
806 			PIC32_PINCTRL_FUNCTION(U1CTS, U1CTSR, 12),
807 			PIC32_PINCTRL_FUNCTION(U2RX, U2RXR, 12),
808 			PIC32_PINCTRL_FUNCTION(U5CTS, U5CTSR, 12),
809 			PIC32_PINCTRL_FUNCTION(SS1IN, SS1INR, 12),
810 			PIC32_PINCTRL_FUNCTION(SS3IN, SS3INR, 12),
811 			PIC32_PINCTRL_FUNCTION(SS4IN, SS4INR, 12),
812 			PIC32_PINCTRL_FUNCTION(SS5IN, SS5INR, 12),
813 			PIC32_PINCTRL_FUNCTION(C2RX, C2RXR, 12),
814 			PIC32_PINCTRL_FUNCTION(U3RTS, RPC3R, 1),
815 			PIC32_PINCTRL_FUNCTION(U4TX, RPC3R, 2),
816 			PIC32_PINCTRL_FUNCTION(U6TX, RPC3R, 4),
817 			PIC32_PINCTRL_FUNCTION(SS1OUT, RPC3R, 5),
818 			PIC32_PINCTRL_FUNCTION(SS3OUT, RPC3R, 7),
819 			PIC32_PINCTRL_FUNCTION(SS4OUT, RPC3R, 8),
820 			PIC32_PINCTRL_FUNCTION(SS5OUT, RPC3R, 9),
821 			PIC32_PINCTRL_FUNCTION(SDO6, RPC3R, 10),
822 			PIC32_PINCTRL_FUNCTION(OC5, RPC3R, 11),
823 			PIC32_PINCTRL_FUNCTION(OC8, RPC3R, 12),
824 			PIC32_PINCTRL_FUNCTION(C1OUT, RPC3R, 14),
825 			PIC32_PINCTRL_FUNCTION(REFCLKO3, RPC3R, 15)),
826 	PIC32_PINCTRL_GROUP(36, C4,
827 			PIC32_PINCTRL_FUNCTION(INT4, INT4R, 10),
828 			PIC32_PINCTRL_FUNCTION(T5CK, T5CKR, 10),
829 			PIC32_PINCTRL_FUNCTION(T7CK, T7CKR, 10),
830 			PIC32_PINCTRL_FUNCTION(IC4, IC4R, 10),
831 			PIC32_PINCTRL_FUNCTION(IC8, IC8R, 10),
832 			PIC32_PINCTRL_FUNCTION(U3RX, U3RXR, 10),
833 			PIC32_PINCTRL_FUNCTION(U4CTS, U4CTSR, 10),
834 			PIC32_PINCTRL_FUNCTION(SDI2, SDI2R, 10),
835 			PIC32_PINCTRL_FUNCTION(SDI4, SDI4R, 10),
836 			PIC32_PINCTRL_FUNCTION(C1RX, C1RXR, 10),
837 			PIC32_PINCTRL_FUNCTION(REFCLKI4, REFCLKI4R, 10),
838 			PIC32_PINCTRL_FUNCTION(U1TX, RPC4R, 1),
839 			PIC32_PINCTRL_FUNCTION(U2RTS, RPC4R, 2),
840 			PIC32_PINCTRL_FUNCTION(U5TX, RPC4R, 3),
841 			PIC32_PINCTRL_FUNCTION(U6RTS, RPC4R, 4),
842 			PIC32_PINCTRL_FUNCTION(SDO1, RPC4R, 5),
843 			PIC32_PINCTRL_FUNCTION(SDO2, RPC4R, 6),
844 			PIC32_PINCTRL_FUNCTION(SDO3, RPC4R, 7),
845 			PIC32_PINCTRL_FUNCTION(SDO4, RPC4R, 8),
846 			PIC32_PINCTRL_FUNCTION(SDO5, RPC4R, 9),
847 			PIC32_PINCTRL_FUNCTION(OC4, RPC4R, 11),
848 			PIC32_PINCTRL_FUNCTION(OC7, RPC4R, 12),
849 			PIC32_PINCTRL_FUNCTION(REFCLKO1, RPC4R, 15)),
850 	PIC32_PINCTRL_GROUP(45, C13,
851 			PIC32_PINCTRL_FUNCTION(INT4, INT4R, 7),
852 			PIC32_PINCTRL_FUNCTION(T5CK, T5CKR, 7),
853 			PIC32_PINCTRL_FUNCTION(T7CK, T7CKR, 7),
854 			PIC32_PINCTRL_FUNCTION(IC4, IC4R, 7),
855 			PIC32_PINCTRL_FUNCTION(IC8, IC8R, 7),
856 			PIC32_PINCTRL_FUNCTION(U3RX, U3RXR, 7),
857 			PIC32_PINCTRL_FUNCTION(U4CTS, U4CTSR, 7),
858 			PIC32_PINCTRL_FUNCTION(SDI2, SDI2R, 7),
859 			PIC32_PINCTRL_FUNCTION(SDI4, SDI4R, 7),
860 			PIC32_PINCTRL_FUNCTION(C1RX, C1RXR, 7),
861 			PIC32_PINCTRL_FUNCTION(REFCLKI4, REFCLKI4R, 7),
862 			PIC32_PINCTRL_FUNCTION(U1TX, RPC13R, 1),
863 			PIC32_PINCTRL_FUNCTION(U2RTS, RPC13R, 2),
864 			PIC32_PINCTRL_FUNCTION(U5TX, RPC13R, 3),
865 			PIC32_PINCTRL_FUNCTION(U6RTS, RPC13R, 4),
866 			PIC32_PINCTRL_FUNCTION(SDO1, RPC13R, 5),
867 			PIC32_PINCTRL_FUNCTION(SDO2, RPC13R, 6),
868 			PIC32_PINCTRL_FUNCTION(SDO3, RPC13R, 7),
869 			PIC32_PINCTRL_FUNCTION(SDO4, RPC13R, 8),
870 			PIC32_PINCTRL_FUNCTION(SDO5, RPC13R, 9),
871 			PIC32_PINCTRL_FUNCTION(OC4, RPC13R, 11),
872 			PIC32_PINCTRL_FUNCTION(OC7, RPC13R, 12),
873 			PIC32_PINCTRL_FUNCTION(REFCLKO1, RPC13R, 15)),
874 	PIC32_PINCTRL_GROUP(46, C14,
875 			PIC32_PINCTRL_FUNCTION(INT3, INT3R, 7),
876 			PIC32_PINCTRL_FUNCTION(T2CK, T2CKR, 7),
877 			PIC32_PINCTRL_FUNCTION(T6CK, T6CKR, 7),
878 			PIC32_PINCTRL_FUNCTION(IC3, IC3R, 7),
879 			PIC32_PINCTRL_FUNCTION(IC7, IC7R, 7),
880 			PIC32_PINCTRL_FUNCTION(U1RX, U1RXR, 7),
881 			PIC32_PINCTRL_FUNCTION(U2CTS, U2CTSR, 7),
882 			PIC32_PINCTRL_FUNCTION(U5RX, U5RXR, 7),
883 			PIC32_PINCTRL_FUNCTION(U6CTS, U6CTSR, 7),
884 			PIC32_PINCTRL_FUNCTION(SDI1, SDI1R, 7),
885 			PIC32_PINCTRL_FUNCTION(SDI3, SDI3R, 7),
886 			PIC32_PINCTRL_FUNCTION(SDI5, SDI5R, 7),
887 			PIC32_PINCTRL_FUNCTION(SS6IN, SS6INR, 7),
888 			PIC32_PINCTRL_FUNCTION(REFCLKI1, REFCLKI1R, 7),
889 			PIC32_PINCTRL_FUNCTION(U3TX, RPC14R, 1),
890 			PIC32_PINCTRL_FUNCTION(U4RTS, RPC14R, 2),
891 			PIC32_PINCTRL_FUNCTION(SDO1, RPC14R, 5),
892 			PIC32_PINCTRL_FUNCTION(SDO2, RPC14R, 6),
893 			PIC32_PINCTRL_FUNCTION(SDO3, RPC14R, 7),
894 			PIC32_PINCTRL_FUNCTION(SDO5, RPC14R, 9),
895 			PIC32_PINCTRL_FUNCTION(SS6OUT, RPC14R, 10),
896 			PIC32_PINCTRL_FUNCTION(OC3, RPC14R, 11),
897 			PIC32_PINCTRL_FUNCTION(OC6, RPC14R, 12),
898 			PIC32_PINCTRL_FUNCTION(REFCLKO4, RPC14R, 13),
899 			PIC32_PINCTRL_FUNCTION(C2OUT, RPC14R, 14),
900 			PIC32_PINCTRL_FUNCTION(C1TX, RPC14R, 15)),
901 	PIC32_PINCTRL_GROUP(48, D0,
902 			PIC32_PINCTRL_FUNCTION(INT1, INT1R, 3),
903 			PIC32_PINCTRL_FUNCTION(T4CK, T4CKR, 3),
904 			PIC32_PINCTRL_FUNCTION(T9CK, T9CKR, 3),
905 			PIC32_PINCTRL_FUNCTION(IC1, IC1R, 3),
906 			PIC32_PINCTRL_FUNCTION(IC6, IC6R, 3),
907 			PIC32_PINCTRL_FUNCTION(U3CTS, U3CTSR, 3),
908 			PIC32_PINCTRL_FUNCTION(U4RX, U4RXR, 3),
909 			PIC32_PINCTRL_FUNCTION(U6RX, U6RXR, 3),
910 			PIC32_PINCTRL_FUNCTION(SS2IN, SS2INR, 3),
911 			PIC32_PINCTRL_FUNCTION(SDI6, SDI6R, 3),
912 			PIC32_PINCTRL_FUNCTION(OCFA, OCFAR, 3),
913 			PIC32_PINCTRL_FUNCTION(REFCLKI3, REFCLKI3R, 3),
914 			PIC32_PINCTRL_FUNCTION(U1RTS, RPD0R, 1),
915 			PIC32_PINCTRL_FUNCTION(U2TX, RPD0R, 2),
916 			PIC32_PINCTRL_FUNCTION(U5RTS, RPD0R, 3),
917 			PIC32_PINCTRL_FUNCTION(U6TX, RPD0R, 4),
918 			PIC32_PINCTRL_FUNCTION(SS2OUT, RPD0R, 6),
919 			PIC32_PINCTRL_FUNCTION(SDO4, RPD0R, 8),
920 			PIC32_PINCTRL_FUNCTION(SDO6, RPD0R, 10),
921 			PIC32_PINCTRL_FUNCTION(OC2, RPD0R, 11),
922 			PIC32_PINCTRL_FUNCTION(OC1, RPD0R, 12),
923 			PIC32_PINCTRL_FUNCTION(OC9, RPD0R, 13),
924 			PIC32_PINCTRL_FUNCTION(C2TX, RPD0R, 15)),
925 	PIC32_PINCTRL_GROUP(50, D2,
926 			PIC32_PINCTRL_FUNCTION(INT3, INT3R, 0),
927 			PIC32_PINCTRL_FUNCTION(T2CK, T2CKR, 0),
928 			PIC32_PINCTRL_FUNCTION(T6CK, T6CKR, 0),
929 			PIC32_PINCTRL_FUNCTION(IC3, IC3R, 0),
930 			PIC32_PINCTRL_FUNCTION(IC7, IC7R, 0),
931 			PIC32_PINCTRL_FUNCTION(U1RX, U1RXR, 0),
932 			PIC32_PINCTRL_FUNCTION(U2CTS, U2CTSR, 0),
933 			PIC32_PINCTRL_FUNCTION(U5RX, U5RXR, 0),
934 			PIC32_PINCTRL_FUNCTION(U6CTS, U6CTSR, 0),
935 			PIC32_PINCTRL_FUNCTION(SDI1, SDI1R, 0),
936 			PIC32_PINCTRL_FUNCTION(SDI3, SDI3R, 0),
937 			PIC32_PINCTRL_FUNCTION(SDI5, SDI5R, 0),
938 			PIC32_PINCTRL_FUNCTION(SS6IN, SS6INR, 0),
939 			PIC32_PINCTRL_FUNCTION(REFCLKI1, REFCLKI1R, 0),
940 			PIC32_PINCTRL_FUNCTION(U3TX, RPD2R, 1),
941 			PIC32_PINCTRL_FUNCTION(U4RTS, RPD2R, 2),
942 			PIC32_PINCTRL_FUNCTION(SDO1, RPD2R, 5),
943 			PIC32_PINCTRL_FUNCTION(SDO2, RPD2R, 6),
944 			PIC32_PINCTRL_FUNCTION(SDO3, RPD2R, 7),
945 			PIC32_PINCTRL_FUNCTION(SDO5, RPD2R, 9),
946 			PIC32_PINCTRL_FUNCTION(SS6OUT, RPD2R, 10),
947 			PIC32_PINCTRL_FUNCTION(OC3, RPD2R, 11),
948 			PIC32_PINCTRL_FUNCTION(OC6, RPD2R, 12),
949 			PIC32_PINCTRL_FUNCTION(REFCLKO4, RPD2R, 13),
950 			PIC32_PINCTRL_FUNCTION(C2OUT, RPD2R, 14),
951 			PIC32_PINCTRL_FUNCTION(C1TX, RPD2R, 15)),
952 	PIC32_PINCTRL_GROUP(51, D3,
953 			PIC32_PINCTRL_FUNCTION(INT4, INT4R, 0),
954 			PIC32_PINCTRL_FUNCTION(T5CK, T5CKR, 0),
955 			PIC32_PINCTRL_FUNCTION(T7CK, T7CKR, 0),
956 			PIC32_PINCTRL_FUNCTION(IC4, IC4R, 0),
957 			PIC32_PINCTRL_FUNCTION(IC8, IC8R, 0),
958 			PIC32_PINCTRL_FUNCTION(U3RX, U3RXR, 0),
959 			PIC32_PINCTRL_FUNCTION(U4CTS, U4CTSR, 0),
960 			PIC32_PINCTRL_FUNCTION(SDI2, SDI2R, 0),
961 			PIC32_PINCTRL_FUNCTION(SDI4, SDI4R, 0),
962 			PIC32_PINCTRL_FUNCTION(C1RX, C1RXR, 0),
963 			PIC32_PINCTRL_FUNCTION(REFCLKI4, REFCLKI4R, 0),
964 			PIC32_PINCTRL_FUNCTION(U1TX, RPD3R, 1),
965 			PIC32_PINCTRL_FUNCTION(U2RTS, RPD3R, 2),
966 			PIC32_PINCTRL_FUNCTION(U5TX, RPD3R, 3),
967 			PIC32_PINCTRL_FUNCTION(U6RTS, RPD3R, 4),
968 			PIC32_PINCTRL_FUNCTION(SDO1, RPD3R, 5),
969 			PIC32_PINCTRL_FUNCTION(SDO2, RPD3R, 6),
970 			PIC32_PINCTRL_FUNCTION(SDO3, RPD3R, 7),
971 			PIC32_PINCTRL_FUNCTION(SDO4, RPD3R, 8),
972 			PIC32_PINCTRL_FUNCTION(SDO5, RPD3R, 9),
973 			PIC32_PINCTRL_FUNCTION(OC4, RPD3R, 11),
974 			PIC32_PINCTRL_FUNCTION(OC7, RPD3R, 12),
975 			PIC32_PINCTRL_FUNCTION(REFCLKO1, RPD3R, 15)),
976 	PIC32_PINCTRL_GROUP(52, D4,
977 			PIC32_PINCTRL_FUNCTION(INT2, INT2R, 4),
978 			PIC32_PINCTRL_FUNCTION(T3CK, T3CKR, 4),
979 			PIC32_PINCTRL_FUNCTION(T8CK, T8CKR, 4),
980 			PIC32_PINCTRL_FUNCTION(IC2, IC2R, 4),
981 			PIC32_PINCTRL_FUNCTION(IC5, IC5R, 4),
982 			PIC32_PINCTRL_FUNCTION(IC9, IC9R, 4),
983 			PIC32_PINCTRL_FUNCTION(U1CTS, U1CTSR, 4),
984 			PIC32_PINCTRL_FUNCTION(U2RX, U2RXR, 4),
985 			PIC32_PINCTRL_FUNCTION(U5CTS, U5CTSR, 4),
986 			PIC32_PINCTRL_FUNCTION(SS1IN, SS1INR, 4),
987 			PIC32_PINCTRL_FUNCTION(SS3IN, SS3INR, 4),
988 			PIC32_PINCTRL_FUNCTION(SS4IN, SS4INR, 4),
989 			PIC32_PINCTRL_FUNCTION(SS5IN, SS5INR, 4),
990 			PIC32_PINCTRL_FUNCTION(C2RX, C2RXR, 4),
991 			PIC32_PINCTRL_FUNCTION(U3RTS, RPD4R, 1),
992 			PIC32_PINCTRL_FUNCTION(U4TX, RPD4R, 2),
993 			PIC32_PINCTRL_FUNCTION(U6TX, RPD4R, 4),
994 			PIC32_PINCTRL_FUNCTION(SS1OUT, RPD4R, 5),
995 			PIC32_PINCTRL_FUNCTION(SS3OUT, RPD4R, 7),
996 			PIC32_PINCTRL_FUNCTION(SS4OUT, RPD4R, 8),
997 			PIC32_PINCTRL_FUNCTION(SS5OUT, RPD4R, 9),
998 			PIC32_PINCTRL_FUNCTION(SDO6, RPD4R, 10),
999 			PIC32_PINCTRL_FUNCTION(OC5, RPD4R, 11),
1000 			PIC32_PINCTRL_FUNCTION(OC8, RPD4R, 12),
1001 			PIC32_PINCTRL_FUNCTION(C1OUT, RPD4R, 14),
1002 			PIC32_PINCTRL_FUNCTION(REFCLKO3, RPD4R, 15)),
1003 	PIC32_PINCTRL_GROUP(53, D5,
1004 			PIC32_PINCTRL_FUNCTION(INT1, INT1R, 6),
1005 			PIC32_PINCTRL_FUNCTION(T4CK, T4CKR, 6),
1006 			PIC32_PINCTRL_FUNCTION(T9CK, T9CKR, 6),
1007 			PIC32_PINCTRL_FUNCTION(IC1, IC1R, 6),
1008 			PIC32_PINCTRL_FUNCTION(IC6, IC6R, 6),
1009 			PIC32_PINCTRL_FUNCTION(U3CTS, U3CTSR, 6),
1010 			PIC32_PINCTRL_FUNCTION(U4RX, U4RXR, 6),
1011 			PIC32_PINCTRL_FUNCTION(U6RX, U6RXR, 6),
1012 			PIC32_PINCTRL_FUNCTION(SS2IN, SS2INR, 6),
1013 			PIC32_PINCTRL_FUNCTION(SDI6, SDI6R, 6),
1014 			PIC32_PINCTRL_FUNCTION(OCFA, OCFAR, 6),
1015 			PIC32_PINCTRL_FUNCTION(REFCLKI3, REFCLKI3R, 6),
1016 			PIC32_PINCTRL_FUNCTION(U1RTS, RPD5R, 1),
1017 			PIC32_PINCTRL_FUNCTION(U2TX, RPD5R, 2),
1018 			PIC32_PINCTRL_FUNCTION(U5RTS, RPD5R, 3),
1019 			PIC32_PINCTRL_FUNCTION(U6TX, RPD5R, 4),
1020 			PIC32_PINCTRL_FUNCTION(SS2OUT, RPD5R, 6),
1021 			PIC32_PINCTRL_FUNCTION(SDO4, RPD5R, 8),
1022 			PIC32_PINCTRL_FUNCTION(SDO6, RPD5R, 10),
1023 			PIC32_PINCTRL_FUNCTION(OC2, RPD5R, 11),
1024 			PIC32_PINCTRL_FUNCTION(OC1, RPD5R, 12),
1025 			PIC32_PINCTRL_FUNCTION(OC9, RPD5R, 13),
1026 			PIC32_PINCTRL_FUNCTION(C2TX, RPD5R, 15)),
1027 	PIC32_PINCTRL_GROUP(54, D6,
1028 			PIC32_PINCTRL_FUNCTION(INT3, INT3R, 14),
1029 			PIC32_PINCTRL_FUNCTION(T2CK, T2CKR, 14),
1030 			PIC32_PINCTRL_FUNCTION(T6CK, T6CKR, 14),
1031 			PIC32_PINCTRL_FUNCTION(IC3, IC3R, 14),
1032 			PIC32_PINCTRL_FUNCTION(IC7, IC7R, 14),
1033 			PIC32_PINCTRL_FUNCTION(U1RX, U1RXR, 14),
1034 			PIC32_PINCTRL_FUNCTION(U2CTS, U2CTSR, 14),
1035 			PIC32_PINCTRL_FUNCTION(U5RX, U5RXR, 14),
1036 			PIC32_PINCTRL_FUNCTION(U6CTS, U6CTSR, 14),
1037 			PIC32_PINCTRL_FUNCTION(SDI1, SDI1R, 14),
1038 			PIC32_PINCTRL_FUNCTION(SDI3, SDI3R, 14),
1039 			PIC32_PINCTRL_FUNCTION(SDI5, SDI5R, 14),
1040 			PIC32_PINCTRL_FUNCTION(SS6IN, SS6INR, 14),
1041 			PIC32_PINCTRL_FUNCTION(REFCLKI1, REFCLKI1R, 14),
1042 			PIC32_PINCTRL_FUNCTION(U3TX, RPD6R, 1),
1043 			PIC32_PINCTRL_FUNCTION(U4RTS, RPD6R, 2),
1044 			PIC32_PINCTRL_FUNCTION(SDO1, RPD6R, 5),
1045 			PIC32_PINCTRL_FUNCTION(SDO2, RPD6R, 6),
1046 			PIC32_PINCTRL_FUNCTION(SDO3, RPD6R, 7),
1047 			PIC32_PINCTRL_FUNCTION(SDO5, RPD6R, 9),
1048 			PIC32_PINCTRL_FUNCTION(SS6OUT, RPD6R, 10),
1049 			PIC32_PINCTRL_FUNCTION(OC3, RPD6R, 11),
1050 			PIC32_PINCTRL_FUNCTION(OC6, RPD6R, 12),
1051 			PIC32_PINCTRL_FUNCTION(REFCLKO4, RPD6R, 13),
1052 			PIC32_PINCTRL_FUNCTION(C2OUT, RPD6R, 14),
1053 			PIC32_PINCTRL_FUNCTION(C1TX, RPD6R, 15)),
1054 	PIC32_PINCTRL_GROUP(55, D7,
1055 			PIC32_PINCTRL_FUNCTION(INT4, INT4R, 14),
1056 			PIC32_PINCTRL_FUNCTION(T5CK, T5CKR, 14),
1057 			PIC32_PINCTRL_FUNCTION(T7CK, T7CKR, 14),
1058 			PIC32_PINCTRL_FUNCTION(IC4, IC4R, 14),
1059 			PIC32_PINCTRL_FUNCTION(IC8, IC8R, 14),
1060 			PIC32_PINCTRL_FUNCTION(U3RX, U3RXR, 14),
1061 			PIC32_PINCTRL_FUNCTION(U4CTS, U4CTSR, 14),
1062 			PIC32_PINCTRL_FUNCTION(SDI2, SDI2R, 14),
1063 			PIC32_PINCTRL_FUNCTION(SDI4, SDI4R, 14),
1064 			PIC32_PINCTRL_FUNCTION(C1RX, C1RXR, 14),
1065 			PIC32_PINCTRL_FUNCTION(REFCLKI4, REFCLKI4R, 14),
1066 			PIC32_PINCTRL_FUNCTION(U1TX, RPD7R, 1),
1067 			PIC32_PINCTRL_FUNCTION(U2RTS, RPD7R, 2),
1068 			PIC32_PINCTRL_FUNCTION(U5TX, RPD7R, 3),
1069 			PIC32_PINCTRL_FUNCTION(U6RTS, RPD7R, 4),
1070 			PIC32_PINCTRL_FUNCTION(SDO1, RPD7R, 5),
1071 			PIC32_PINCTRL_FUNCTION(SDO2, RPD7R, 6),
1072 			PIC32_PINCTRL_FUNCTION(SDO3, RPD7R, 7),
1073 			PIC32_PINCTRL_FUNCTION(SDO4, RPD7R, 8),
1074 			PIC32_PINCTRL_FUNCTION(SDO5, RPD7R, 9),
1075 			PIC32_PINCTRL_FUNCTION(OC4, RPD7R, 11),
1076 			PIC32_PINCTRL_FUNCTION(OC7, RPD7R, 12),
1077 			PIC32_PINCTRL_FUNCTION(REFCLKO1, RPD7R, 15)),
1078 	PIC32_PINCTRL_GROUP(57, D9,
1079 			PIC32_PINCTRL_FUNCTION(INT2, INT2R, 0),
1080 			PIC32_PINCTRL_FUNCTION(T3CK, T3CKR, 0),
1081 			PIC32_PINCTRL_FUNCTION(T8CK, T8CKR, 0),
1082 			PIC32_PINCTRL_FUNCTION(IC2, IC2R, 0),
1083 			PIC32_PINCTRL_FUNCTION(IC5, IC5R, 0),
1084 			PIC32_PINCTRL_FUNCTION(IC9, IC9R, 0),
1085 			PIC32_PINCTRL_FUNCTION(U1CTS, U1CTSR, 0),
1086 			PIC32_PINCTRL_FUNCTION(U2RX, U2RXR, 0),
1087 			PIC32_PINCTRL_FUNCTION(U5CTS, U5CTSR, 0),
1088 			PIC32_PINCTRL_FUNCTION(SS1IN, SS1INR, 0),
1089 			PIC32_PINCTRL_FUNCTION(SS3IN, SS3INR, 0),
1090 			PIC32_PINCTRL_FUNCTION(SS4IN, SS4INR, 0),
1091 			PIC32_PINCTRL_FUNCTION(SS5IN, SS5INR, 0),
1092 			PIC32_PINCTRL_FUNCTION(C2RX, C2RXR, 0),
1093 			PIC32_PINCTRL_FUNCTION(U3RTS, RPD9R, 1),
1094 			PIC32_PINCTRL_FUNCTION(U4TX, RPD9R, 2),
1095 			PIC32_PINCTRL_FUNCTION(U6TX, RPD9R, 4),
1096 			PIC32_PINCTRL_FUNCTION(SS1OUT, RPD9R, 5),
1097 			PIC32_PINCTRL_FUNCTION(SS3OUT, RPD9R, 7),
1098 			PIC32_PINCTRL_FUNCTION(SS4OUT, RPD9R, 8),
1099 			PIC32_PINCTRL_FUNCTION(SS5OUT, RPD9R, 9),
1100 			PIC32_PINCTRL_FUNCTION(SDO6, RPD9R, 10),
1101 			PIC32_PINCTRL_FUNCTION(OC5, RPD9R, 11),
1102 			PIC32_PINCTRL_FUNCTION(OC8, RPD9R, 12),
1103 			PIC32_PINCTRL_FUNCTION(C1OUT, RPD9R, 14),
1104 			PIC32_PINCTRL_FUNCTION(REFCLKO3, RPD9R, 15)),
1105 	PIC32_PINCTRL_GROUP(58, D10,
1106 			PIC32_PINCTRL_FUNCTION(U3TX, RPD10R, 1),
1107 			PIC32_PINCTRL_FUNCTION(U4RTS, RPD10R, 2),
1108 			PIC32_PINCTRL_FUNCTION(SDO1, RPD10R, 5),
1109 			PIC32_PINCTRL_FUNCTION(SDO2, RPD10R, 6),
1110 			PIC32_PINCTRL_FUNCTION(SDO3, RPD10R, 7),
1111 			PIC32_PINCTRL_FUNCTION(SDO5, RPD10R, 9),
1112 			PIC32_PINCTRL_FUNCTION(SS6OUT, RPD10R, 10),
1113 			PIC32_PINCTRL_FUNCTION(OC3, RPD10R, 11),
1114 			PIC32_PINCTRL_FUNCTION(OC6, RPD10R, 12),
1115 			PIC32_PINCTRL_FUNCTION(REFCLKO4, RPD10R, 13),
1116 			PIC32_PINCTRL_FUNCTION(C2OUT, RPD10R, 14),
1117 			PIC32_PINCTRL_FUNCTION(C1TX, RPD10R, 15)),
1118 	PIC32_PINCTRL_GROUP(59, D11,
1119 			PIC32_PINCTRL_FUNCTION(INT4, INT4R, 3),
1120 			PIC32_PINCTRL_FUNCTION(T5CK, T5CKR, 3),
1121 			PIC32_PINCTRL_FUNCTION(T7CK, T7CKR, 3),
1122 			PIC32_PINCTRL_FUNCTION(IC4, IC4R, 3),
1123 			PIC32_PINCTRL_FUNCTION(IC8, IC8R, 3),
1124 			PIC32_PINCTRL_FUNCTION(U3RX, U3RXR, 3),
1125 			PIC32_PINCTRL_FUNCTION(U4CTS, U4CTSR, 3),
1126 			PIC32_PINCTRL_FUNCTION(SDI2, SDI2R, 3),
1127 			PIC32_PINCTRL_FUNCTION(SDI4, SDI4R, 3),
1128 			PIC32_PINCTRL_FUNCTION(C1RX, C1RXR, 3),
1129 			PIC32_PINCTRL_FUNCTION(REFCLKI4, REFCLKI4R, 3),
1130 			PIC32_PINCTRL_FUNCTION(U1TX, RPD11R, 1),
1131 			PIC32_PINCTRL_FUNCTION(U2RTS, RPD11R, 2),
1132 			PIC32_PINCTRL_FUNCTION(U5TX, RPD11R, 3),
1133 			PIC32_PINCTRL_FUNCTION(U6RTS, RPD11R, 4),
1134 			PIC32_PINCTRL_FUNCTION(SDO1, RPD11R, 5),
1135 			PIC32_PINCTRL_FUNCTION(SDO2, RPD11R, 6),
1136 			PIC32_PINCTRL_FUNCTION(SDO3, RPD11R, 7),
1137 			PIC32_PINCTRL_FUNCTION(SDO4, RPD11R, 8),
1138 			PIC32_PINCTRL_FUNCTION(SDO5, RPD11R, 9),
1139 			PIC32_PINCTRL_FUNCTION(OC4, RPD11R, 11),
1140 			PIC32_PINCTRL_FUNCTION(OC7, RPD11R, 12),
1141 			PIC32_PINCTRL_FUNCTION(REFCLKO1, RPD11R, 15)),
1142 	PIC32_PINCTRL_GROUP(60, D12,
1143 			PIC32_PINCTRL_FUNCTION(INT2, INT2R, 10),
1144 			PIC32_PINCTRL_FUNCTION(T3CK, T3CKR, 10),
1145 			PIC32_PINCTRL_FUNCTION(T8CK, T8CKR, 10),
1146 			PIC32_PINCTRL_FUNCTION(IC2, IC2R, 10),
1147 			PIC32_PINCTRL_FUNCTION(IC5, IC5R, 10),
1148 			PIC32_PINCTRL_FUNCTION(IC9, IC9R, 10),
1149 			PIC32_PINCTRL_FUNCTION(U1CTS, U1CTSR, 10),
1150 			PIC32_PINCTRL_FUNCTION(U2RX, U2RXR, 10),
1151 			PIC32_PINCTRL_FUNCTION(U5CTS, U5CTSR, 10),
1152 			PIC32_PINCTRL_FUNCTION(SS1IN, SS1INR, 10),
1153 			PIC32_PINCTRL_FUNCTION(SS3IN, SS3INR, 10),
1154 			PIC32_PINCTRL_FUNCTION(SS4IN, SS4INR, 10),
1155 			PIC32_PINCTRL_FUNCTION(SS5IN, SS5INR, 10),
1156 			PIC32_PINCTRL_FUNCTION(C2RX, C2RXR, 10),
1157 			PIC32_PINCTRL_FUNCTION(U3RTS, RPD12R, 1),
1158 			PIC32_PINCTRL_FUNCTION(U4TX, RPD12R, 2),
1159 			PIC32_PINCTRL_FUNCTION(U6TX, RPD12R, 4),
1160 			PIC32_PINCTRL_FUNCTION(SS1OUT, RPD12R, 5),
1161 			PIC32_PINCTRL_FUNCTION(SS3OUT, RPD12R, 7),
1162 			PIC32_PINCTRL_FUNCTION(SS4OUT, RPD12R, 8),
1163 			PIC32_PINCTRL_FUNCTION(SS5OUT, RPD12R, 9),
1164 			PIC32_PINCTRL_FUNCTION(SDO6, RPD12R, 10),
1165 			PIC32_PINCTRL_FUNCTION(OC5, RPD12R, 11),
1166 			PIC32_PINCTRL_FUNCTION(OC8, RPD12R, 12),
1167 			PIC32_PINCTRL_FUNCTION(C1OUT, RPD12R, 14),
1168 			PIC32_PINCTRL_FUNCTION(REFCLKO3, RPD12R, 15)),
1169 	PIC32_PINCTRL_GROUP(62, D14,
1170 			PIC32_PINCTRL_FUNCTION(INT3, INT3R, 11),
1171 			PIC32_PINCTRL_FUNCTION(T2CK, T2CKR, 11),
1172 			PIC32_PINCTRL_FUNCTION(T6CK, T6CKR, 11),
1173 			PIC32_PINCTRL_FUNCTION(IC3, IC3R, 11),
1174 			PIC32_PINCTRL_FUNCTION(IC7, IC7R, 11),
1175 			PIC32_PINCTRL_FUNCTION(U1RX, U1RXR, 11),
1176 			PIC32_PINCTRL_FUNCTION(U2CTS, U2CTSR, 11),
1177 			PIC32_PINCTRL_FUNCTION(U5RX, U5RXR, 11),
1178 			PIC32_PINCTRL_FUNCTION(U6CTS, U6CTSR, 11),
1179 			PIC32_PINCTRL_FUNCTION(SDI1, SDI1R, 11),
1180 			PIC32_PINCTRL_FUNCTION(SDI3, SDI3R, 11),
1181 			PIC32_PINCTRL_FUNCTION(SDI5, SDI5R, 11),
1182 			PIC32_PINCTRL_FUNCTION(SS6IN, SS6INR, 11),
1183 			PIC32_PINCTRL_FUNCTION(REFCLKI1, REFCLKI1R, 11),
1184 			PIC32_PINCTRL_FUNCTION(U3TX, RPD14R, 1),
1185 			PIC32_PINCTRL_FUNCTION(U4RTS, RPD14R, 2),
1186 			PIC32_PINCTRL_FUNCTION(SDO1, RPD14R, 5),
1187 			PIC32_PINCTRL_FUNCTION(SDO2, RPD14R, 6),
1188 			PIC32_PINCTRL_FUNCTION(SDO3, RPD14R, 7),
1189 			PIC32_PINCTRL_FUNCTION(SDO5, RPD14R, 9),
1190 			PIC32_PINCTRL_FUNCTION(SS6OUT, RPD14R, 10),
1191 			PIC32_PINCTRL_FUNCTION(OC3, RPD14R, 11),
1192 			PIC32_PINCTRL_FUNCTION(OC6, RPD14R, 12),
1193 			PIC32_PINCTRL_FUNCTION(REFCLKO4, RPD14R, 13),
1194 			PIC32_PINCTRL_FUNCTION(C2OUT, RPD14R, 14),
1195 			PIC32_PINCTRL_FUNCTION(C1TX, RPD14R, 15)),
1196 	PIC32_PINCTRL_GROUP(63, D15,
1197 			PIC32_PINCTRL_FUNCTION(U1TX, RPD15R, 1),
1198 			PIC32_PINCTRL_FUNCTION(U2RTS, RPD15R, 2),
1199 			PIC32_PINCTRL_FUNCTION(U5TX, RPD15R, 3),
1200 			PIC32_PINCTRL_FUNCTION(U6RTS, RPD15R, 4),
1201 			PIC32_PINCTRL_FUNCTION(SDO1, RPD15R, 5),
1202 			PIC32_PINCTRL_FUNCTION(SDO2, RPD15R, 6),
1203 			PIC32_PINCTRL_FUNCTION(SDO3, RPD15R, 7),
1204 			PIC32_PINCTRL_FUNCTION(SDO4, RPD15R, 8),
1205 			PIC32_PINCTRL_FUNCTION(SDO5, RPD15R, 9),
1206 			PIC32_PINCTRL_FUNCTION(OC4, RPD15R, 11),
1207 			PIC32_PINCTRL_FUNCTION(OC7, RPD15R, 12),
1208 			PIC32_PINCTRL_FUNCTION(REFCLKO1, RPD15R, 15)),
1209 	PIC32_PINCTRL_GROUP(67, E3,
1210 			PIC32_PINCTRL_FUNCTION(INT2, INT2R, 6),
1211 			PIC32_PINCTRL_FUNCTION(T3CK, T3CKR, 6),
1212 			PIC32_PINCTRL_FUNCTION(T8CK, T8CKR, 6),
1213 			PIC32_PINCTRL_FUNCTION(IC2, IC2R, 6),
1214 			PIC32_PINCTRL_FUNCTION(IC5, IC5R, 6),
1215 			PIC32_PINCTRL_FUNCTION(IC9, IC9R, 6),
1216 			PIC32_PINCTRL_FUNCTION(U1CTS, U1CTSR, 6),
1217 			PIC32_PINCTRL_FUNCTION(U2RX, U2RXR, 6),
1218 			PIC32_PINCTRL_FUNCTION(U5CTS, U5CTSR, 6),
1219 			PIC32_PINCTRL_FUNCTION(SS1IN, SS1INR, 6),
1220 			PIC32_PINCTRL_FUNCTION(SS3IN, SS3INR, 6),
1221 			PIC32_PINCTRL_FUNCTION(SS4IN, SS4INR, 6),
1222 			PIC32_PINCTRL_FUNCTION(SS5IN, SS5INR, 6),
1223 			PIC32_PINCTRL_FUNCTION(C2RX, C2RXR, 6),
1224 			PIC32_PINCTRL_FUNCTION(U3RTS, RPE3R, 1),
1225 			PIC32_PINCTRL_FUNCTION(U4TX, RPE3R, 2),
1226 			PIC32_PINCTRL_FUNCTION(U6TX, RPE3R, 4),
1227 			PIC32_PINCTRL_FUNCTION(SS1OUT, RPE3R, 5),
1228 			PIC32_PINCTRL_FUNCTION(SS3OUT, RPE3R, 7),
1229 			PIC32_PINCTRL_FUNCTION(SS4OUT, RPE3R, 8),
1230 			PIC32_PINCTRL_FUNCTION(SS5OUT, RPE3R, 9),
1231 			PIC32_PINCTRL_FUNCTION(SDO6, RPE3R, 10),
1232 			PIC32_PINCTRL_FUNCTION(OC5, RPE3R, 11),
1233 			PIC32_PINCTRL_FUNCTION(OC8, RPE3R, 12),
1234 			PIC32_PINCTRL_FUNCTION(C1OUT, RPE3R, 14),
1235 			PIC32_PINCTRL_FUNCTION(REFCLKO3, RPE3R, 15)),
1236 	PIC32_PINCTRL_GROUP(69, E5,
1237 			PIC32_PINCTRL_FUNCTION(INT4, INT4R, 6),
1238 			PIC32_PINCTRL_FUNCTION(T5CK, T5CKR, 6),
1239 			PIC32_PINCTRL_FUNCTION(T7CK, T7CKR, 6),
1240 			PIC32_PINCTRL_FUNCTION(IC4, IC4R, 6),
1241 			PIC32_PINCTRL_FUNCTION(IC8, IC8R, 6),
1242 			PIC32_PINCTRL_FUNCTION(U3RX, U3RXR, 6),
1243 			PIC32_PINCTRL_FUNCTION(U4CTS, U4CTSR, 6),
1244 			PIC32_PINCTRL_FUNCTION(SDI2, SDI2R, 6),
1245 			PIC32_PINCTRL_FUNCTION(SDI4, SDI4R, 6),
1246 			PIC32_PINCTRL_FUNCTION(C1RX, C1RXR, 6),
1247 			PIC32_PINCTRL_FUNCTION(REFCLKI4, REFCLKI4R, 6),
1248 			PIC32_PINCTRL_FUNCTION(U1TX, RPE5R, 1),
1249 			PIC32_PINCTRL_FUNCTION(U2RTS, RPE5R, 2),
1250 			PIC32_PINCTRL_FUNCTION(U5TX, RPE5R, 3),
1251 			PIC32_PINCTRL_FUNCTION(U6RTS, RPE5R, 4),
1252 			PIC32_PINCTRL_FUNCTION(SDO1, RPE5R, 5),
1253 			PIC32_PINCTRL_FUNCTION(SDO2, RPE5R, 6),
1254 			PIC32_PINCTRL_FUNCTION(SDO3, RPE5R, 7),
1255 			PIC32_PINCTRL_FUNCTION(SDO4, RPE5R, 8),
1256 			PIC32_PINCTRL_FUNCTION(SDO5, RPE5R, 9),
1257 			PIC32_PINCTRL_FUNCTION(OC4, RPE5R, 11),
1258 			PIC32_PINCTRL_FUNCTION(OC7, RPE5R, 12),
1259 			PIC32_PINCTRL_FUNCTION(REFCLKO1, RPE5R, 15)),
1260 	PIC32_PINCTRL_GROUP(72, E8,
1261 			PIC32_PINCTRL_FUNCTION(INT1, INT1R, 13),
1262 			PIC32_PINCTRL_FUNCTION(T4CK, T4CKR, 13),
1263 			PIC32_PINCTRL_FUNCTION(T9CK, T9CKR, 13),
1264 			PIC32_PINCTRL_FUNCTION(IC1, IC1R, 13),
1265 			PIC32_PINCTRL_FUNCTION(IC6, IC6R, 13),
1266 			PIC32_PINCTRL_FUNCTION(U3CTS, U3CTSR, 13),
1267 			PIC32_PINCTRL_FUNCTION(U4RX, U4RXR, 13),
1268 			PIC32_PINCTRL_FUNCTION(U6RX, U6RXR, 13),
1269 			PIC32_PINCTRL_FUNCTION(SS2IN, SS2INR, 13),
1270 			PIC32_PINCTRL_FUNCTION(SDI6, SDI6R, 13),
1271 			PIC32_PINCTRL_FUNCTION(OCFA, OCFAR, 13),
1272 			PIC32_PINCTRL_FUNCTION(REFCLKI3, REFCLKI3R, 13),
1273 			PIC32_PINCTRL_FUNCTION(U1RTS, RPE8R, 1),
1274 			PIC32_PINCTRL_FUNCTION(U2TX, RPE8R, 2),
1275 			PIC32_PINCTRL_FUNCTION(U5RTS, RPE8R, 3),
1276 			PIC32_PINCTRL_FUNCTION(U6TX, RPE8R, 4),
1277 			PIC32_PINCTRL_FUNCTION(SS2OUT, RPE8R, 6),
1278 			PIC32_PINCTRL_FUNCTION(SDO4, RPE8R, 8),
1279 			PIC32_PINCTRL_FUNCTION(SDO6, RPE8R, 10),
1280 			PIC32_PINCTRL_FUNCTION(OC2, RPE8R, 11),
1281 			PIC32_PINCTRL_FUNCTION(OC1, RPE8R, 12),
1282 			PIC32_PINCTRL_FUNCTION(OC9, RPE8R, 13),
1283 			PIC32_PINCTRL_FUNCTION(C2TX, RPE8R, 15)),
1284 	PIC32_PINCTRL_GROUP(73, E9,
1285 			PIC32_PINCTRL_FUNCTION(INT2, INT2R, 13),
1286 			PIC32_PINCTRL_FUNCTION(T3CK, T3CKR, 13),
1287 			PIC32_PINCTRL_FUNCTION(T8CK, T8CKR, 13),
1288 			PIC32_PINCTRL_FUNCTION(IC2, IC2R, 13),
1289 			PIC32_PINCTRL_FUNCTION(IC5, IC5R, 13),
1290 			PIC32_PINCTRL_FUNCTION(IC9, IC9R, 13),
1291 			PIC32_PINCTRL_FUNCTION(U1CTS, U1CTSR, 13),
1292 			PIC32_PINCTRL_FUNCTION(U2RX, U2RXR, 13),
1293 			PIC32_PINCTRL_FUNCTION(U5CTS, U5CTSR, 13),
1294 			PIC32_PINCTRL_FUNCTION(SS1IN, SS1INR, 13),
1295 			PIC32_PINCTRL_FUNCTION(SS3IN, SS3INR, 13),
1296 			PIC32_PINCTRL_FUNCTION(SS4IN, SS4INR, 13),
1297 			PIC32_PINCTRL_FUNCTION(SS5IN, SS5INR, 13),
1298 			PIC32_PINCTRL_FUNCTION(C2RX, C2RXR, 13),
1299 			PIC32_PINCTRL_FUNCTION(U3RTS, RPE9R, 1),
1300 			PIC32_PINCTRL_FUNCTION(U4TX, RPE9R, 2),
1301 			PIC32_PINCTRL_FUNCTION(U6TX, RPE9R, 4),
1302 			PIC32_PINCTRL_FUNCTION(SS1OUT, RPE9R, 5),
1303 			PIC32_PINCTRL_FUNCTION(SS3OUT, RPE9R, 7),
1304 			PIC32_PINCTRL_FUNCTION(SS4OUT, RPE9R, 8),
1305 			PIC32_PINCTRL_FUNCTION(SS5OUT, RPE9R, 9),
1306 			PIC32_PINCTRL_FUNCTION(SDO6, RPE9R, 10),
1307 			PIC32_PINCTRL_FUNCTION(OC5, RPE9R, 11),
1308 			PIC32_PINCTRL_FUNCTION(OC8, RPE9R, 12),
1309 			PIC32_PINCTRL_FUNCTION(C1OUT, RPE9R, 14),
1310 			PIC32_PINCTRL_FUNCTION(REFCLKO3, RPE9R, 15)),
1311 	PIC32_PINCTRL_GROUP(80, F0,
1312 			PIC32_PINCTRL_FUNCTION(INT4, INT4R, 4),
1313 			PIC32_PINCTRL_FUNCTION(T5CK, T5CKR, 4),
1314 			PIC32_PINCTRL_FUNCTION(T7CK, T7CKR, 4),
1315 			PIC32_PINCTRL_FUNCTION(IC4, IC4R, 4),
1316 			PIC32_PINCTRL_FUNCTION(IC8, IC8R, 4),
1317 			PIC32_PINCTRL_FUNCTION(U3RX, U3RXR, 4),
1318 			PIC32_PINCTRL_FUNCTION(U4CTS, U4CTSR, 4),
1319 			PIC32_PINCTRL_FUNCTION(SDI2, SDI2R, 4),
1320 			PIC32_PINCTRL_FUNCTION(SDI4, SDI4R, 4),
1321 			PIC32_PINCTRL_FUNCTION(C1RX, C1RXR, 4),
1322 			PIC32_PINCTRL_FUNCTION(REFCLKI4, REFCLKI4R, 4),
1323 			PIC32_PINCTRL_FUNCTION(U1TX, RPF0R, 1),
1324 			PIC32_PINCTRL_FUNCTION(U2RTS, RPF0R, 2),
1325 			PIC32_PINCTRL_FUNCTION(U5TX, RPF0R, 3),
1326 			PIC32_PINCTRL_FUNCTION(U6RTS, RPF0R, 4),
1327 			PIC32_PINCTRL_FUNCTION(SDO1, RPF0R, 5),
1328 			PIC32_PINCTRL_FUNCTION(SDO2, RPF0R, 6),
1329 			PIC32_PINCTRL_FUNCTION(SDO3, RPF0R, 7),
1330 			PIC32_PINCTRL_FUNCTION(SDO4, RPF0R, 8),
1331 			PIC32_PINCTRL_FUNCTION(SDO5, RPF0R, 9),
1332 			PIC32_PINCTRL_FUNCTION(OC4, RPF0R, 11),
1333 			PIC32_PINCTRL_FUNCTION(OC7, RPF0R, 12),
1334 			PIC32_PINCTRL_FUNCTION(REFCLKO1, RPF0R, 15)),
1335 	PIC32_PINCTRL_GROUP(81, F1,
1336 			PIC32_PINCTRL_FUNCTION(INT3, INT3R, 4),
1337 			PIC32_PINCTRL_FUNCTION(T2CK, T2CKR, 4),
1338 			PIC32_PINCTRL_FUNCTION(T6CK, T6CKR, 4),
1339 			PIC32_PINCTRL_FUNCTION(IC3, IC3R, 4),
1340 			PIC32_PINCTRL_FUNCTION(IC7, IC7R, 4),
1341 			PIC32_PINCTRL_FUNCTION(U1RX, U1RXR, 4),
1342 			PIC32_PINCTRL_FUNCTION(U2CTS, U2CTSR, 4),
1343 			PIC32_PINCTRL_FUNCTION(U5RX, U5RXR, 4),
1344 			PIC32_PINCTRL_FUNCTION(U6CTS, U6CTSR, 4),
1345 			PIC32_PINCTRL_FUNCTION(SDI1, SDI1R, 4),
1346 			PIC32_PINCTRL_FUNCTION(SDI3, SDI3R, 4),
1347 			PIC32_PINCTRL_FUNCTION(SDI5, SDI5R, 4),
1348 			PIC32_PINCTRL_FUNCTION(SS6IN, SS6INR, 4),
1349 			PIC32_PINCTRL_FUNCTION(REFCLKI1, REFCLKI1R, 4),
1350 			PIC32_PINCTRL_FUNCTION(U3TX, RPF1R, 1),
1351 			PIC32_PINCTRL_FUNCTION(U4RTS, RPF1R, 2),
1352 			PIC32_PINCTRL_FUNCTION(SDO1, RPF1R, 5),
1353 			PIC32_PINCTRL_FUNCTION(SDO2, RPF1R, 6),
1354 			PIC32_PINCTRL_FUNCTION(SDO3, RPF1R, 7),
1355 			PIC32_PINCTRL_FUNCTION(SDO5, RPF1R, 9),
1356 			PIC32_PINCTRL_FUNCTION(SS6OUT, RPF1R, 10),
1357 			PIC32_PINCTRL_FUNCTION(OC3, RPF1R, 11),
1358 			PIC32_PINCTRL_FUNCTION(OC6, RPF1R, 12),
1359 			PIC32_PINCTRL_FUNCTION(REFCLKO4, RPF1R, 13),
1360 			PIC32_PINCTRL_FUNCTION(C2OUT, RPF1R, 14),
1361 			PIC32_PINCTRL_FUNCTION(C1TX, RPF1R, 15)),
1362 	PIC32_PINCTRL_GROUP(82, F2,
1363 			PIC32_PINCTRL_FUNCTION(INT1, INT1R, 11),
1364 			PIC32_PINCTRL_FUNCTION(T4CK, T4CKR, 11),
1365 			PIC32_PINCTRL_FUNCTION(T9CK, T9CKR, 11),
1366 			PIC32_PINCTRL_FUNCTION(IC1, IC1R, 11),
1367 			PIC32_PINCTRL_FUNCTION(IC6, IC6R, 11),
1368 			PIC32_PINCTRL_FUNCTION(U3CTS, U3CTSR, 11),
1369 			PIC32_PINCTRL_FUNCTION(U4RX, U4RXR, 11),
1370 			PIC32_PINCTRL_FUNCTION(U6RX, U6RXR, 11),
1371 			PIC32_PINCTRL_FUNCTION(SS2IN, SS2INR, 11),
1372 			PIC32_PINCTRL_FUNCTION(SDI6, SDI6R, 11),
1373 			PIC32_PINCTRL_FUNCTION(OCFA, OCFAR, 11),
1374 			PIC32_PINCTRL_FUNCTION(REFCLKI3, REFCLKI3R, 11),
1375 			PIC32_PINCTRL_FUNCTION(U1RTS, RPF2R, 1),
1376 			PIC32_PINCTRL_FUNCTION(U2TX, RPF2R, 2),
1377 			PIC32_PINCTRL_FUNCTION(U5RTS, RPF2R, 3),
1378 			PIC32_PINCTRL_FUNCTION(U6TX, RPF2R, 4),
1379 			PIC32_PINCTRL_FUNCTION(SS2OUT, RPF2R, 6),
1380 			PIC32_PINCTRL_FUNCTION(SDO4, RPF2R, 8),
1381 			PIC32_PINCTRL_FUNCTION(SDO6, RPF2R, 10),
1382 			PIC32_PINCTRL_FUNCTION(OC2, RPF2R, 11),
1383 			PIC32_PINCTRL_FUNCTION(OC1, RPF2R, 12),
1384 			PIC32_PINCTRL_FUNCTION(OC9, RPF2R, 13),
1385 			PIC32_PINCTRL_FUNCTION(C2TX, RPF2R, 15)),
1386 	PIC32_PINCTRL_GROUP(83, F3,
1387 			PIC32_PINCTRL_FUNCTION(INT1, INT1R, 8),
1388 			PIC32_PINCTRL_FUNCTION(T4CK, T4CKR, 8),
1389 			PIC32_PINCTRL_FUNCTION(T9CK, T9CKR, 8),
1390 			PIC32_PINCTRL_FUNCTION(IC1, IC1R, 8),
1391 			PIC32_PINCTRL_FUNCTION(IC6, IC6R, 8),
1392 			PIC32_PINCTRL_FUNCTION(U3CTS, U3CTSR, 8),
1393 			PIC32_PINCTRL_FUNCTION(U4RX, U4RXR, 8),
1394 			PIC32_PINCTRL_FUNCTION(U6RX, U6RXR, 8),
1395 			PIC32_PINCTRL_FUNCTION(SS2IN, SS2INR, 8),
1396 			PIC32_PINCTRL_FUNCTION(SDI6, SDI6R, 8),
1397 			PIC32_PINCTRL_FUNCTION(OCFA, OCFAR, 8),
1398 			PIC32_PINCTRL_FUNCTION(REFCLKI3, REFCLKI3R, 8),
1399 			PIC32_PINCTRL_FUNCTION(U1RTS, RPF3R, 1),
1400 			PIC32_PINCTRL_FUNCTION(U2TX, RPF3R, 2),
1401 			PIC32_PINCTRL_FUNCTION(U5RTS, RPF3R, 3),
1402 			PIC32_PINCTRL_FUNCTION(U6TX, RPF3R, 4),
1403 			PIC32_PINCTRL_FUNCTION(SS2OUT, RPF3R, 6),
1404 			PIC32_PINCTRL_FUNCTION(SDO4, RPF3R, 8),
1405 			PIC32_PINCTRL_FUNCTION(SDO6, RPF3R, 10),
1406 			PIC32_PINCTRL_FUNCTION(OC2, RPF3R, 11),
1407 			PIC32_PINCTRL_FUNCTION(OC1, RPF3R, 12),
1408 			PIC32_PINCTRL_FUNCTION(OC9, RPF3R, 13),
1409 			PIC32_PINCTRL_FUNCTION(C2TX, RPF3R, 15)),
1410 	PIC32_PINCTRL_GROUP(84, F4,
1411 			PIC32_PINCTRL_FUNCTION(INT3, INT3R, 2),
1412 			PIC32_PINCTRL_FUNCTION(T2CK, T2CKR, 2),
1413 			PIC32_PINCTRL_FUNCTION(T6CK, T6CKR, 2),
1414 			PIC32_PINCTRL_FUNCTION(IC3, IC3R, 2),
1415 			PIC32_PINCTRL_FUNCTION(IC7, IC7R, 2),
1416 			PIC32_PINCTRL_FUNCTION(U1RX, U1RXR, 2),
1417 			PIC32_PINCTRL_FUNCTION(U2CTS, U2CTSR, 2),
1418 			PIC32_PINCTRL_FUNCTION(U5RX, U5RXR, 2),
1419 			PIC32_PINCTRL_FUNCTION(U6CTS, U6CTSR, 2),
1420 			PIC32_PINCTRL_FUNCTION(SDI1, SDI1R, 2),
1421 			PIC32_PINCTRL_FUNCTION(SDI3, SDI3R, 2),
1422 			PIC32_PINCTRL_FUNCTION(SDI5, SDI5R, 2),
1423 			PIC32_PINCTRL_FUNCTION(SS6IN, SS6INR, 2),
1424 			PIC32_PINCTRL_FUNCTION(REFCLKI1, REFCLKI1R, 2),
1425 			PIC32_PINCTRL_FUNCTION(U3TX, RPF4R, 1),
1426 			PIC32_PINCTRL_FUNCTION(U4RTS, RPF4R, 2),
1427 			PIC32_PINCTRL_FUNCTION(SDO1, RPF4R, 5),
1428 			PIC32_PINCTRL_FUNCTION(SDO2, RPF4R, 6),
1429 			PIC32_PINCTRL_FUNCTION(SDO3, RPF4R, 7),
1430 			PIC32_PINCTRL_FUNCTION(SDO5, RPF4R, 9),
1431 			PIC32_PINCTRL_FUNCTION(SS6OUT, RPF4R, 10),
1432 			PIC32_PINCTRL_FUNCTION(OC3, RPF4R, 11),
1433 			PIC32_PINCTRL_FUNCTION(OC6, RPF4R, 12),
1434 			PIC32_PINCTRL_FUNCTION(REFCLKO4, RPF4R, 13),
1435 			PIC32_PINCTRL_FUNCTION(C2OUT, RPF4R, 14),
1436 			PIC32_PINCTRL_FUNCTION(C1TX, RPF4R, 15)),
1437 	PIC32_PINCTRL_GROUP(85, F5,
1438 			PIC32_PINCTRL_FUNCTION(INT4, INT4R, 2),
1439 			PIC32_PINCTRL_FUNCTION(T5CK, T5CKR, 2),
1440 			PIC32_PINCTRL_FUNCTION(T7CK, T7CKR, 2),
1441 			PIC32_PINCTRL_FUNCTION(IC4, IC4R, 2),
1442 			PIC32_PINCTRL_FUNCTION(IC8, IC8R, 2),
1443 			PIC32_PINCTRL_FUNCTION(U3RX, U3RXR, 2),
1444 			PIC32_PINCTRL_FUNCTION(U4CTS, U4CTSR, 2),
1445 			PIC32_PINCTRL_FUNCTION(SDI2, SDI2R, 2),
1446 			PIC32_PINCTRL_FUNCTION(SDI4, SDI4R, 2),
1447 			PIC32_PINCTRL_FUNCTION(C1RX, C1RXR, 2),
1448 			PIC32_PINCTRL_FUNCTION(REFCLKI4, REFCLKI4R, 2),
1449 			PIC32_PINCTRL_FUNCTION(U1TX, RPF5R, 1),
1450 			PIC32_PINCTRL_FUNCTION(U2RTS, RPF5R, 2),
1451 			PIC32_PINCTRL_FUNCTION(U5TX, RPF5R, 3),
1452 			PIC32_PINCTRL_FUNCTION(U6RTS, RPF5R, 4),
1453 			PIC32_PINCTRL_FUNCTION(SDO1, RPF5R, 5),
1454 			PIC32_PINCTRL_FUNCTION(SDO2, RPF5R, 6),
1455 			PIC32_PINCTRL_FUNCTION(SDO3, RPF5R, 7),
1456 			PIC32_PINCTRL_FUNCTION(SDO4, RPF5R, 8),
1457 			PIC32_PINCTRL_FUNCTION(SDO5, RPF5R, 9),
1458 			PIC32_PINCTRL_FUNCTION(OC4, RPF5R, 11),
1459 			PIC32_PINCTRL_FUNCTION(OC7, RPF5R, 12),
1460 			PIC32_PINCTRL_FUNCTION(REFCLKO1, RPF5R, 15)),
1461 	PIC32_PINCTRL_GROUP(88, F8,
1462 			PIC32_PINCTRL_FUNCTION(INT2, INT2R, 11),
1463 			PIC32_PINCTRL_FUNCTION(T3CK, T3CKR, 11),
1464 			PIC32_PINCTRL_FUNCTION(T8CK, T8CKR, 11),
1465 			PIC32_PINCTRL_FUNCTION(IC2, IC2R, 11),
1466 			PIC32_PINCTRL_FUNCTION(IC5, IC5R, 11),
1467 			PIC32_PINCTRL_FUNCTION(IC9, IC9R, 11),
1468 			PIC32_PINCTRL_FUNCTION(U1CTS, U1CTSR, 11),
1469 			PIC32_PINCTRL_FUNCTION(U2RX, U2RXR, 11),
1470 			PIC32_PINCTRL_FUNCTION(U5CTS, U5CTSR, 11),
1471 			PIC32_PINCTRL_FUNCTION(SS1IN, SS1INR, 11),
1472 			PIC32_PINCTRL_FUNCTION(SS3IN, SS3INR, 11),
1473 			PIC32_PINCTRL_FUNCTION(SS4IN, SS4INR, 11),
1474 			PIC32_PINCTRL_FUNCTION(SS5IN, SS5INR, 11),
1475 			PIC32_PINCTRL_FUNCTION(C2RX, C2RXR, 11),
1476 			PIC32_PINCTRL_FUNCTION(U3RTS, RPF8R, 1),
1477 			PIC32_PINCTRL_FUNCTION(U4TX, RPF8R, 2),
1478 			PIC32_PINCTRL_FUNCTION(U6TX, RPF8R, 4),
1479 			PIC32_PINCTRL_FUNCTION(SS1OUT, RPF8R, 5),
1480 			PIC32_PINCTRL_FUNCTION(SS3OUT, RPF8R, 7),
1481 			PIC32_PINCTRL_FUNCTION(SS4OUT, RPF8R, 8),
1482 			PIC32_PINCTRL_FUNCTION(SS5OUT, RPF8R, 9),
1483 			PIC32_PINCTRL_FUNCTION(SDO6, RPF8R, 10),
1484 			PIC32_PINCTRL_FUNCTION(OC5, RPF8R, 11),
1485 			PIC32_PINCTRL_FUNCTION(OC8, RPF8R, 12),
1486 			PIC32_PINCTRL_FUNCTION(C1OUT, RPF8R, 14),
1487 			PIC32_PINCTRL_FUNCTION(REFCLKO3, RPF8R, 15)),
1488 	PIC32_PINCTRL_GROUP(92, F12,
1489 			PIC32_PINCTRL_FUNCTION(INT2, INT2R, 9),
1490 			PIC32_PINCTRL_FUNCTION(T3CK, T3CKR, 9),
1491 			PIC32_PINCTRL_FUNCTION(T8CK, T8CKR, 9),
1492 			PIC32_PINCTRL_FUNCTION(IC2, IC2R, 9),
1493 			PIC32_PINCTRL_FUNCTION(IC5, IC5R, 9),
1494 			PIC32_PINCTRL_FUNCTION(IC9, IC9R, 9),
1495 			PIC32_PINCTRL_FUNCTION(U1CTS, U1CTSR, 9),
1496 			PIC32_PINCTRL_FUNCTION(U2RX, U2RXR, 9),
1497 			PIC32_PINCTRL_FUNCTION(U5CTS, U5CTSR, 9),
1498 			PIC32_PINCTRL_FUNCTION(SS1IN, SS1INR, 9),
1499 			PIC32_PINCTRL_FUNCTION(SS3IN, SS3INR, 9),
1500 			PIC32_PINCTRL_FUNCTION(SS4IN, SS4INR, 9),
1501 			PIC32_PINCTRL_FUNCTION(SS5IN, SS5INR, 9),
1502 			PIC32_PINCTRL_FUNCTION(C2RX, C2RXR, 9),
1503 			PIC32_PINCTRL_FUNCTION(U3RTS, RPF12R, 1),
1504 			PIC32_PINCTRL_FUNCTION(U4TX, RPF12R, 2),
1505 			PIC32_PINCTRL_FUNCTION(U6TX, RPF12R, 4),
1506 			PIC32_PINCTRL_FUNCTION(SS1OUT, RPF12R, 5),
1507 			PIC32_PINCTRL_FUNCTION(SS3OUT, RPF12R, 7),
1508 			PIC32_PINCTRL_FUNCTION(SS4OUT, RPF12R, 8),
1509 			PIC32_PINCTRL_FUNCTION(SS5OUT, RPF12R, 9),
1510 			PIC32_PINCTRL_FUNCTION(SDO6, RPF12R, 10),
1511 			PIC32_PINCTRL_FUNCTION(OC5, RPF12R, 11),
1512 			PIC32_PINCTRL_FUNCTION(OC8, RPF12R, 12),
1513 			PIC32_PINCTRL_FUNCTION(C1OUT, RPF12R, 14),
1514 			PIC32_PINCTRL_FUNCTION(REFCLKO3, RPF12R, 15)),
1515 	PIC32_PINCTRL_GROUP(93, F13,
1516 			PIC32_PINCTRL_FUNCTION(INT1, INT1R, 9),
1517 			PIC32_PINCTRL_FUNCTION(T4CK, T4CKR, 9),
1518 			PIC32_PINCTRL_FUNCTION(T9CK, T9CKR, 9),
1519 			PIC32_PINCTRL_FUNCTION(IC1, IC1R, 9),
1520 			PIC32_PINCTRL_FUNCTION(IC6, IC6R, 9),
1521 			PIC32_PINCTRL_FUNCTION(U3CTS, U3CTSR, 9),
1522 			PIC32_PINCTRL_FUNCTION(U4RX, U4RXR, 9),
1523 			PIC32_PINCTRL_FUNCTION(U6RX, U6RXR, 9),
1524 			PIC32_PINCTRL_FUNCTION(SS2IN, SS2INR, 9),
1525 			PIC32_PINCTRL_FUNCTION(SDI6, SDI6R, 9),
1526 			PIC32_PINCTRL_FUNCTION(OCFA, OCFAR, 9),
1527 			PIC32_PINCTRL_FUNCTION(REFCLKI3, REFCLKI3R, 9),
1528 			PIC32_PINCTRL_FUNCTION(U1RTS, RPF13R, 1),
1529 			PIC32_PINCTRL_FUNCTION(U2TX, RPF13R, 2),
1530 			PIC32_PINCTRL_FUNCTION(U5RTS, RPF13R, 3),
1531 			PIC32_PINCTRL_FUNCTION(U6TX, RPF13R, 4),
1532 			PIC32_PINCTRL_FUNCTION(SS2OUT, RPF13R, 6),
1533 			PIC32_PINCTRL_FUNCTION(SDO4, RPF13R, 8),
1534 			PIC32_PINCTRL_FUNCTION(SDO6, RPF13R, 10),
1535 			PIC32_PINCTRL_FUNCTION(OC2, RPF13R, 11),
1536 			PIC32_PINCTRL_FUNCTION(OC1, RPF13R, 12),
1537 			PIC32_PINCTRL_FUNCTION(OC9, RPF13R, 13),
1538 			PIC32_PINCTRL_FUNCTION(C2TX, RPF13R, 15)),
1539 	PIC32_PINCTRL_GROUP(96, G0,
1540 			PIC32_PINCTRL_FUNCTION(INT4, INT4R, 12),
1541 			PIC32_PINCTRL_FUNCTION(T5CK, T5CKR, 12),
1542 			PIC32_PINCTRL_FUNCTION(T7CK, T7CKR, 12),
1543 			PIC32_PINCTRL_FUNCTION(IC4, IC4R, 12),
1544 			PIC32_PINCTRL_FUNCTION(IC8, IC8R, 12),
1545 			PIC32_PINCTRL_FUNCTION(U3RX, U3RXR, 12),
1546 			PIC32_PINCTRL_FUNCTION(U4CTS, U4CTSR, 12),
1547 			PIC32_PINCTRL_FUNCTION(SDI2, SDI2R, 12),
1548 			PIC32_PINCTRL_FUNCTION(SDI4, SDI4R, 12),
1549 			PIC32_PINCTRL_FUNCTION(C1RX, C1RXR, 12),
1550 			PIC32_PINCTRL_FUNCTION(REFCLKI4, REFCLKI4R, 12),
1551 			PIC32_PINCTRL_FUNCTION(U1TX, RPG0R, 1),
1552 			PIC32_PINCTRL_FUNCTION(U2RTS, RPG0R, 2),
1553 			PIC32_PINCTRL_FUNCTION(U5TX, RPG0R, 3),
1554 			PIC32_PINCTRL_FUNCTION(U6RTS, RPG0R, 4),
1555 			PIC32_PINCTRL_FUNCTION(SDO1, RPG0R, 5),
1556 			PIC32_PINCTRL_FUNCTION(SDO2, RPG0R, 6),
1557 			PIC32_PINCTRL_FUNCTION(SDO3, RPG0R, 7),
1558 			PIC32_PINCTRL_FUNCTION(SDO4, RPG0R, 8),
1559 			PIC32_PINCTRL_FUNCTION(SDO5, RPG0R, 9),
1560 			PIC32_PINCTRL_FUNCTION(OC4, RPG0R, 11),
1561 			PIC32_PINCTRL_FUNCTION(OC7, RPG0R, 12),
1562 			PIC32_PINCTRL_FUNCTION(REFCLKO1, RPG0R, 15)),
1563 	PIC32_PINCTRL_GROUP(97, G1,
1564 			PIC32_PINCTRL_FUNCTION(INT3, INT3R, 12),
1565 			PIC32_PINCTRL_FUNCTION(T2CK, T2CKR, 12),
1566 			PIC32_PINCTRL_FUNCTION(T6CK, T6CKR, 12),
1567 			PIC32_PINCTRL_FUNCTION(IC3, IC3R, 12),
1568 			PIC32_PINCTRL_FUNCTION(IC7, IC7R, 12),
1569 			PIC32_PINCTRL_FUNCTION(U1RX, U1RXR, 12),
1570 			PIC32_PINCTRL_FUNCTION(U2CTS, U2CTSR, 12),
1571 			PIC32_PINCTRL_FUNCTION(U5RX, U5RXR, 12),
1572 			PIC32_PINCTRL_FUNCTION(U6CTS, U6CTSR, 12),
1573 			PIC32_PINCTRL_FUNCTION(SDI1, SDI1R, 12),
1574 			PIC32_PINCTRL_FUNCTION(SDI3, SDI3R, 12),
1575 			PIC32_PINCTRL_FUNCTION(SDI5, SDI5R, 12),
1576 			PIC32_PINCTRL_FUNCTION(SS6IN, SS6INR, 12),
1577 			PIC32_PINCTRL_FUNCTION(REFCLKI1, REFCLKI1R, 12),
1578 			PIC32_PINCTRL_FUNCTION(U3TX, RPG1R, 1),
1579 			PIC32_PINCTRL_FUNCTION(U4RTS, RPG1R, 2),
1580 			PIC32_PINCTRL_FUNCTION(SDO1, RPG1R, 5),
1581 			PIC32_PINCTRL_FUNCTION(SDO2, RPG1R, 6),
1582 			PIC32_PINCTRL_FUNCTION(SDO3, RPG1R, 7),
1583 			PIC32_PINCTRL_FUNCTION(SDO5, RPG1R, 9),
1584 			PIC32_PINCTRL_FUNCTION(SS6OUT, RPG1R, 10),
1585 			PIC32_PINCTRL_FUNCTION(OC3, RPG1R, 11),
1586 			PIC32_PINCTRL_FUNCTION(OC6, RPG1R, 12),
1587 			PIC32_PINCTRL_FUNCTION(REFCLKO4, RPG1R, 13),
1588 			PIC32_PINCTRL_FUNCTION(C2OUT, RPG1R, 14),
1589 			PIC32_PINCTRL_FUNCTION(C1TX, RPG1R, 15)),
1590 	PIC32_PINCTRL_GROUP(102, G6,
1591 			PIC32_PINCTRL_FUNCTION(INT2, INT2R, 1),
1592 			PIC32_PINCTRL_FUNCTION(T3CK, T3CKR, 1),
1593 			PIC32_PINCTRL_FUNCTION(T8CK, T8CKR, 1),
1594 			PIC32_PINCTRL_FUNCTION(IC2, IC2R, 1),
1595 			PIC32_PINCTRL_FUNCTION(IC5, IC5R, 1),
1596 			PIC32_PINCTRL_FUNCTION(IC9, IC9R, 1),
1597 			PIC32_PINCTRL_FUNCTION(U1CTS, U1CTSR, 1),
1598 			PIC32_PINCTRL_FUNCTION(U2RX, U2RXR, 1),
1599 			PIC32_PINCTRL_FUNCTION(U5CTS, U5CTSR, 1),
1600 			PIC32_PINCTRL_FUNCTION(SS1IN, SS1INR, 1),
1601 			PIC32_PINCTRL_FUNCTION(SS3IN, SS3INR, 1),
1602 			PIC32_PINCTRL_FUNCTION(SS4IN, SS4INR, 1),
1603 			PIC32_PINCTRL_FUNCTION(SS5IN, SS5INR, 1),
1604 			PIC32_PINCTRL_FUNCTION(C2RX, C2RXR, 1),
1605 			PIC32_PINCTRL_FUNCTION(U3RTS, RPG6R, 1),
1606 			PIC32_PINCTRL_FUNCTION(U4TX, RPG6R, 2),
1607 			PIC32_PINCTRL_FUNCTION(U6TX, RPG6R, 4),
1608 			PIC32_PINCTRL_FUNCTION(SS1OUT, RPG6R, 5),
1609 			PIC32_PINCTRL_FUNCTION(SS3OUT, RPG6R, 7),
1610 			PIC32_PINCTRL_FUNCTION(SS4OUT, RPG6R, 8),
1611 			PIC32_PINCTRL_FUNCTION(SS5OUT, RPG6R, 9),
1612 			PIC32_PINCTRL_FUNCTION(SDO6, RPG6R, 10),
1613 			PIC32_PINCTRL_FUNCTION(OC5, RPG6R, 11),
1614 			PIC32_PINCTRL_FUNCTION(OC8, RPG6R, 12),
1615 			PIC32_PINCTRL_FUNCTION(C1OUT, RPG6R, 14),
1616 			PIC32_PINCTRL_FUNCTION(REFCLKO3, RPG6R, 15)),
1617 	PIC32_PINCTRL_GROUP(103, G7,
1618 			PIC32_PINCTRL_FUNCTION(INT4, INT4R, 1),
1619 			PIC32_PINCTRL_FUNCTION(T5CK, T5CKR, 1),
1620 			PIC32_PINCTRL_FUNCTION(T7CK, T7CKR, 1),
1621 			PIC32_PINCTRL_FUNCTION(IC4, IC4R, 1),
1622 			PIC32_PINCTRL_FUNCTION(IC8, IC8R, 1),
1623 			PIC32_PINCTRL_FUNCTION(U3RX, U3RXR, 1),
1624 			PIC32_PINCTRL_FUNCTION(U4CTS, U4CTSR, 1),
1625 			PIC32_PINCTRL_FUNCTION(SDI2, SDI2R, 1),
1626 			PIC32_PINCTRL_FUNCTION(SDI4, SDI4R, 1),
1627 			PIC32_PINCTRL_FUNCTION(C1RX, C1RXR, 1),
1628 			PIC32_PINCTRL_FUNCTION(REFCLKI4, REFCLKI4R, 1),
1629 			PIC32_PINCTRL_FUNCTION(U1TX, RPG7R, 1),
1630 			PIC32_PINCTRL_FUNCTION(U2RTS, RPG7R, 2),
1631 			PIC32_PINCTRL_FUNCTION(U5TX, RPG7R, 3),
1632 			PIC32_PINCTRL_FUNCTION(U6RTS, RPG7R, 4),
1633 			PIC32_PINCTRL_FUNCTION(SDO1, RPG7R, 5),
1634 			PIC32_PINCTRL_FUNCTION(SDO2, RPG7R, 6),
1635 			PIC32_PINCTRL_FUNCTION(SDO3, RPG7R, 7),
1636 			PIC32_PINCTRL_FUNCTION(SDO4, RPG7R, 8),
1637 			PIC32_PINCTRL_FUNCTION(SDO5, RPG7R, 9),
1638 			PIC32_PINCTRL_FUNCTION(OC4, RPG7R, 11),
1639 			PIC32_PINCTRL_FUNCTION(OC7, RPG7R, 12),
1640 			PIC32_PINCTRL_FUNCTION(REFCLKO1, RPG7R, 15)),
1641 	PIC32_PINCTRL_GROUP(104, G8,
1642 			PIC32_PINCTRL_FUNCTION(INT3, INT3R, 1),
1643 			PIC32_PINCTRL_FUNCTION(T2CK, T2CKR, 1),
1644 			PIC32_PINCTRL_FUNCTION(T6CK, T6CKR, 1),
1645 			PIC32_PINCTRL_FUNCTION(IC3, IC3R, 1),
1646 			PIC32_PINCTRL_FUNCTION(IC7, IC7R, 1),
1647 			PIC32_PINCTRL_FUNCTION(U1RX, U1RXR, 1),
1648 			PIC32_PINCTRL_FUNCTION(U2CTS, U2CTSR, 1),
1649 			PIC32_PINCTRL_FUNCTION(U5RX, U5RXR, 1),
1650 			PIC32_PINCTRL_FUNCTION(U6CTS, U6CTSR, 1),
1651 			PIC32_PINCTRL_FUNCTION(SDI1, SDI1R, 1),
1652 			PIC32_PINCTRL_FUNCTION(SDI3, SDI3R, 1),
1653 			PIC32_PINCTRL_FUNCTION(SDI5, SDI5R, 1),
1654 			PIC32_PINCTRL_FUNCTION(SS6IN, SS6INR, 1),
1655 			PIC32_PINCTRL_FUNCTION(REFCLKI1, REFCLKI1R, 1),
1656 			PIC32_PINCTRL_FUNCTION(U3TX, RPG8R, 1),
1657 			PIC32_PINCTRL_FUNCTION(U4RTS, RPG8R, 2),
1658 			PIC32_PINCTRL_FUNCTION(SDO1, RPG8R, 5),
1659 			PIC32_PINCTRL_FUNCTION(SDO2, RPG8R, 6),
1660 			PIC32_PINCTRL_FUNCTION(SDO3, RPG8R, 7),
1661 			PIC32_PINCTRL_FUNCTION(SDO5, RPG8R, 9),
1662 			PIC32_PINCTRL_FUNCTION(SS6OUT, RPG8R, 10),
1663 			PIC32_PINCTRL_FUNCTION(OC3, RPG8R, 11),
1664 			PIC32_PINCTRL_FUNCTION(OC6, RPG8R, 12),
1665 			PIC32_PINCTRL_FUNCTION(REFCLKO4, RPG8R, 13),
1666 			PIC32_PINCTRL_FUNCTION(C2OUT, RPG8R, 14),
1667 			PIC32_PINCTRL_FUNCTION(C1TX, RPG8R, 15)),
1668 	PIC32_PINCTRL_GROUP(105, G9,
1669 			PIC32_PINCTRL_FUNCTION(INT1, INT1R, 1),
1670 			PIC32_PINCTRL_FUNCTION(T4CK, T4CKR, 1),
1671 			PIC32_PINCTRL_FUNCTION(T9CK, T9CKR, 1),
1672 			PIC32_PINCTRL_FUNCTION(IC1, IC1R, 1),
1673 			PIC32_PINCTRL_FUNCTION(IC6, IC6R, 1),
1674 			PIC32_PINCTRL_FUNCTION(U3CTS, U3CTSR, 1),
1675 			PIC32_PINCTRL_FUNCTION(U4RX, U4RXR, 1),
1676 			PIC32_PINCTRL_FUNCTION(U6RX, U6RXR, 1),
1677 			PIC32_PINCTRL_FUNCTION(SS2IN, SS2INR, 1),
1678 			PIC32_PINCTRL_FUNCTION(SDI6, SDI6R, 1),
1679 			PIC32_PINCTRL_FUNCTION(OCFA, OCFAR, 1),
1680 			PIC32_PINCTRL_FUNCTION(REFCLKI3, REFCLKI3R, 1),
1681 			PIC32_PINCTRL_FUNCTION(U1RTS, RPG9R, 1),
1682 			PIC32_PINCTRL_FUNCTION(U2TX, RPG9R, 2),
1683 			PIC32_PINCTRL_FUNCTION(U5RTS, RPG9R, 3),
1684 			PIC32_PINCTRL_FUNCTION(U6TX, RPG9R, 4),
1685 			PIC32_PINCTRL_FUNCTION(SS2OUT, RPG9R, 6),
1686 			PIC32_PINCTRL_FUNCTION(SDO4, RPG9R, 8),
1687 			PIC32_PINCTRL_FUNCTION(SDO6, RPG9R, 10),
1688 			PIC32_PINCTRL_FUNCTION(OC2, RPG9R, 11),
1689 			PIC32_PINCTRL_FUNCTION(OC1, RPG9R, 12),
1690 			PIC32_PINCTRL_FUNCTION(OC9, RPG9R, 13),
1691 			PIC32_PINCTRL_FUNCTION(C2TX, RPG9R, 15)),
1692 };
1693 
irqd_to_bank(struct irq_data * d)1694 static inline struct pic32_gpio_bank *irqd_to_bank(struct irq_data *d)
1695 {
1696 	return gpiochip_get_data(irq_data_get_irq_chip_data(d));
1697 }
1698 
pctl_to_bank(struct pic32_pinctrl * pctl,unsigned pin)1699 static inline struct pic32_gpio_bank *pctl_to_bank(struct pic32_pinctrl *pctl,
1700 						unsigned pin)
1701 {
1702 	return &pctl->gpio_banks[pin / PINS_PER_BANK];
1703 }
1704 
pic32_pinctrl_get_groups_count(struct pinctrl_dev * pctldev)1705 static int pic32_pinctrl_get_groups_count(struct pinctrl_dev *pctldev)
1706 {
1707 	struct pic32_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
1708 
1709 	return pctl->ngroups;
1710 }
1711 
pic32_pinctrl_get_group_name(struct pinctrl_dev * pctldev,unsigned group)1712 static const char *pic32_pinctrl_get_group_name(struct pinctrl_dev *pctldev,
1713 						    unsigned group)
1714 {
1715 	struct pic32_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
1716 
1717 	return pctl->groups[group].name;
1718 }
1719 
pic32_pinctrl_get_group_pins(struct pinctrl_dev * pctldev,unsigned group,const unsigned ** pins,unsigned * num_pins)1720 static int pic32_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
1721 					    unsigned group,
1722 					    const unsigned **pins,
1723 					    unsigned *num_pins)
1724 {
1725 	struct pic32_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
1726 
1727 	*pins = &pctl->groups[group].pin;
1728 	*num_pins = 1;
1729 
1730 	return 0;
1731 }
1732 
1733 static const struct pinctrl_ops pic32_pinctrl_ops = {
1734 	.get_groups_count = pic32_pinctrl_get_groups_count,
1735 	.get_group_name = pic32_pinctrl_get_group_name,
1736 	.get_group_pins = pic32_pinctrl_get_group_pins,
1737 	.dt_node_to_map = pinconf_generic_dt_node_to_map_pin,
1738 	.dt_free_map = pinctrl_utils_free_map,
1739 };
1740 
pic32_pinmux_get_functions_count(struct pinctrl_dev * pctldev)1741 static int pic32_pinmux_get_functions_count(struct pinctrl_dev *pctldev)
1742 {
1743 	struct pic32_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
1744 
1745 	return pctl->nfunctions;
1746 }
1747 
1748 static const char *
pic32_pinmux_get_function_name(struct pinctrl_dev * pctldev,unsigned func)1749 pic32_pinmux_get_function_name(struct pinctrl_dev *pctldev, unsigned func)
1750 {
1751 	struct pic32_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
1752 
1753 	return pctl->functions[func].name;
1754 }
1755 
pic32_pinmux_get_function_groups(struct pinctrl_dev * pctldev,unsigned func,const char * const ** groups,unsigned * const num_groups)1756 static int pic32_pinmux_get_function_groups(struct pinctrl_dev *pctldev,
1757 						unsigned func,
1758 						const char * const **groups,
1759 						unsigned * const num_groups)
1760 {
1761 	struct pic32_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
1762 
1763 	*groups = pctl->functions[func].groups;
1764 	*num_groups = pctl->functions[func].ngroups;
1765 
1766 	return 0;
1767 }
1768 
pic32_pinmux_enable(struct pinctrl_dev * pctldev,unsigned func,unsigned group)1769 static int pic32_pinmux_enable(struct pinctrl_dev *pctldev,
1770 				   unsigned func, unsigned group)
1771 {
1772 	struct pic32_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
1773 	const struct pic32_pin_group *pg = &pctl->groups[group];
1774 	const struct pic32_function *pf = &pctl->functions[func];
1775 	const char *fname = pf->name;
1776 	struct pic32_desc_function *functions = pg->functions;
1777 
1778 	while (functions->name) {
1779 		if (!strcmp(functions->name, fname)) {
1780 			dev_dbg(pctl->dev,
1781 				"setting function %s reg 0x%x = %d\n",
1782 				fname, functions->muxreg, functions->muxval);
1783 
1784 			writel(functions->muxval, pctl->reg_base + functions->muxreg);
1785 
1786 			return 0;
1787 		}
1788 
1789 		functions++;
1790 	}
1791 
1792 	dev_err(pctl->dev, "cannot mux pin %u to function %u\n", group, func);
1793 
1794 	return -EINVAL;
1795 }
1796 
pic32_gpio_request_enable(struct pinctrl_dev * pctldev,struct pinctrl_gpio_range * range,unsigned offset)1797 static int pic32_gpio_request_enable(struct pinctrl_dev *pctldev,
1798 				     struct pinctrl_gpio_range *range,
1799 				     unsigned offset)
1800 {
1801 	struct pic32_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
1802 	struct pic32_gpio_bank *bank = gpiochip_get_data(range->gc);
1803 	u32 mask = BIT(offset - bank->gpio_chip.base);
1804 
1805 	dev_dbg(pctl->dev, "requesting gpio %d in bank %d with mask 0x%x\n",
1806 		offset, bank->gpio_chip.base, mask);
1807 
1808 	writel(mask, bank->reg_base + PIC32_CLR(ANSEL_REG));
1809 
1810 	return 0;
1811 }
1812 
pic32_gpio_direction_input(struct gpio_chip * chip,unsigned offset)1813 static int pic32_gpio_direction_input(struct gpio_chip *chip,
1814 					  unsigned offset)
1815 {
1816 	struct pic32_gpio_bank *bank = gpiochip_get_data(chip);
1817 	u32 mask = BIT(offset);
1818 
1819 	writel(mask, bank->reg_base + PIC32_SET(TRIS_REG));
1820 
1821 	return 0;
1822 }
1823 
pic32_gpio_get(struct gpio_chip * chip,unsigned offset)1824 static int pic32_gpio_get(struct gpio_chip *chip, unsigned offset)
1825 {
1826 	struct pic32_gpio_bank *bank = gpiochip_get_data(chip);
1827 
1828 	return !!(readl(bank->reg_base + PORT_REG) & BIT(offset));
1829 }
1830 
pic32_gpio_set(struct gpio_chip * chip,unsigned offset,int value)1831 static void pic32_gpio_set(struct gpio_chip *chip, unsigned offset,
1832 			       int value)
1833 {
1834 	struct pic32_gpio_bank *bank = gpiochip_get_data(chip);
1835 	u32 mask = BIT(offset);
1836 
1837 	if (value)
1838 		writel(mask, bank->reg_base + PIC32_SET(PORT_REG));
1839 	else
1840 		writel(mask, bank->reg_base + PIC32_CLR(PORT_REG));
1841 }
1842 
pic32_gpio_direction_output(struct gpio_chip * chip,unsigned offset,int value)1843 static int pic32_gpio_direction_output(struct gpio_chip *chip,
1844 					   unsigned offset, int value)
1845 {
1846 	struct pic32_gpio_bank *bank = gpiochip_get_data(chip);
1847 	u32 mask = BIT(offset);
1848 
1849 	pic32_gpio_set(chip, offset, value);
1850 	writel(mask, bank->reg_base + PIC32_CLR(TRIS_REG));
1851 
1852 	return 0;
1853 }
1854 
pic32_gpio_set_direction(struct pinctrl_dev * pctldev,struct pinctrl_gpio_range * range,unsigned offset,bool input)1855 static int pic32_gpio_set_direction(struct pinctrl_dev *pctldev,
1856 					      struct pinctrl_gpio_range *range,
1857 					      unsigned offset, bool input)
1858 {
1859 	struct gpio_chip *chip = range->gc;
1860 
1861 	if (input)
1862 		pic32_gpio_direction_input(chip, offset);
1863 	else
1864 		pic32_gpio_direction_output(chip, offset, 0);
1865 
1866 	return 0;
1867 }
1868 
1869 static const struct pinmux_ops pic32_pinmux_ops = {
1870 	.get_functions_count = pic32_pinmux_get_functions_count,
1871 	.get_function_name = pic32_pinmux_get_function_name,
1872 	.get_function_groups = pic32_pinmux_get_function_groups,
1873 	.set_mux = pic32_pinmux_enable,
1874 	.gpio_request_enable = pic32_gpio_request_enable,
1875 	.gpio_set_direction = pic32_gpio_set_direction,
1876 };
1877 
pic32_pinconf_get(struct pinctrl_dev * pctldev,unsigned pin,unsigned long * config)1878 static int pic32_pinconf_get(struct pinctrl_dev *pctldev, unsigned pin,
1879 				 unsigned long *config)
1880 {
1881 	struct pic32_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
1882 	struct pic32_gpio_bank *bank = pctl_to_bank(pctl, pin);
1883 	unsigned param = pinconf_to_config_param(*config);
1884 	u32 mask = BIT(pin - bank->gpio_chip.base);
1885 	u32 arg;
1886 
1887 	switch (param) {
1888 	case PIN_CONFIG_BIAS_PULL_UP:
1889 		arg = !!(readl(bank->reg_base + CNPU_REG) & mask);
1890 		break;
1891 	case PIN_CONFIG_BIAS_PULL_DOWN:
1892 		arg = !!(readl(bank->reg_base + CNPD_REG) & mask);
1893 		break;
1894 	case PIN_CONFIG_MICROCHIP_DIGITAL:
1895 		arg = !(readl(bank->reg_base + ANSEL_REG) & mask);
1896 		break;
1897 	case PIN_CONFIG_MICROCHIP_ANALOG:
1898 		arg = !!(readl(bank->reg_base + ANSEL_REG) & mask);
1899 		break;
1900 	case PIN_CONFIG_DRIVE_OPEN_DRAIN:
1901 		arg = !!(readl(bank->reg_base + ODCU_REG) & mask);
1902 		break;
1903 	case PIN_CONFIG_INPUT_ENABLE:
1904 		arg = !!(readl(bank->reg_base + TRIS_REG) & mask);
1905 		break;
1906 	case PIN_CONFIG_OUTPUT:
1907 		arg = !(readl(bank->reg_base + TRIS_REG) & mask);
1908 		break;
1909 	default:
1910 		dev_err(pctl->dev, "Property %u not supported\n", param);
1911 		return -ENOTSUPP;
1912 	}
1913 
1914 	*config = pinconf_to_config_packed(param, arg);
1915 
1916 	return 0;
1917 }
1918 
pic32_pinconf_set(struct pinctrl_dev * pctldev,unsigned pin,unsigned long * configs,unsigned num_configs)1919 static int pic32_pinconf_set(struct pinctrl_dev *pctldev, unsigned pin,
1920 				 unsigned long *configs, unsigned num_configs)
1921 {
1922 	struct pic32_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev);
1923 	struct pic32_gpio_bank *bank = pctl_to_bank(pctl, pin);
1924 	unsigned param;
1925 	u32 arg;
1926 	unsigned int i;
1927 	u32 offset = pin - bank->gpio_chip.base;
1928 	u32 mask = BIT(offset);
1929 
1930 	dev_dbg(pctl->dev, "setting pin %d bank %d mask 0x%x\n",
1931 		pin, bank->gpio_chip.base, mask);
1932 
1933 	for (i = 0; i < num_configs; i++) {
1934 		param = pinconf_to_config_param(configs[i]);
1935 		arg = pinconf_to_config_argument(configs[i]);
1936 
1937 		switch (param) {
1938 		case PIN_CONFIG_BIAS_PULL_UP:
1939 			dev_dbg(pctl->dev, "   pullup\n");
1940 			writel(mask, bank->reg_base +PIC32_SET(CNPU_REG));
1941 			break;
1942 		case PIN_CONFIG_BIAS_PULL_DOWN:
1943 			dev_dbg(pctl->dev, "   pulldown\n");
1944 			writel(mask, bank->reg_base + PIC32_SET(CNPD_REG));
1945 			break;
1946 		case PIN_CONFIG_MICROCHIP_DIGITAL:
1947 			dev_dbg(pctl->dev, "   digital\n");
1948 			writel(mask, bank->reg_base + PIC32_CLR(ANSEL_REG));
1949 			break;
1950 		case PIN_CONFIG_MICROCHIP_ANALOG:
1951 			dev_dbg(pctl->dev, "   analog\n");
1952 			writel(mask, bank->reg_base + PIC32_SET(ANSEL_REG));
1953 			break;
1954 		case PIN_CONFIG_DRIVE_OPEN_DRAIN:
1955 			dev_dbg(pctl->dev, "   opendrain\n");
1956 			writel(mask, bank->reg_base + PIC32_SET(ODCU_REG));
1957 			break;
1958 		case PIN_CONFIG_INPUT_ENABLE:
1959 			pic32_gpio_direction_input(&bank->gpio_chip, offset);
1960 			break;
1961 		case PIN_CONFIG_OUTPUT:
1962 			pic32_gpio_direction_output(&bank->gpio_chip,
1963 						    offset, arg);
1964 			break;
1965 		default:
1966 			dev_err(pctl->dev, "Property %u not supported\n",
1967 				param);
1968 			return -ENOTSUPP;
1969 		}
1970 	}
1971 
1972 	return 0;
1973 }
1974 
1975 static const struct pinconf_ops pic32_pinconf_ops = {
1976 	.pin_config_get = pic32_pinconf_get,
1977 	.pin_config_set = pic32_pinconf_set,
1978 	.is_generic = true,
1979 };
1980 
1981 static struct pinctrl_desc pic32_pinctrl_desc = {
1982 	.name = "pic32-pinctrl",
1983 	.pctlops = &pic32_pinctrl_ops,
1984 	.pmxops = &pic32_pinmux_ops,
1985 	.confops = &pic32_pinconf_ops,
1986 	.owner = THIS_MODULE,
1987 };
1988 
pic32_gpio_get_direction(struct gpio_chip * chip,unsigned offset)1989 static int pic32_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
1990 {
1991 	struct pic32_gpio_bank *bank = gpiochip_get_data(chip);
1992 
1993 	if (readl(bank->reg_base + TRIS_REG) & BIT(offset))
1994 		return GPIO_LINE_DIRECTION_IN;
1995 
1996 	return GPIO_LINE_DIRECTION_OUT;
1997 }
1998 
pic32_gpio_irq_ack(struct irq_data * data)1999 static void pic32_gpio_irq_ack(struct irq_data *data)
2000 {
2001 	struct pic32_gpio_bank *bank = irqd_to_bank(data);
2002 
2003 	writel(0, bank->reg_base + CNF_REG);
2004 }
2005 
pic32_gpio_irq_mask(struct irq_data * data)2006 static void pic32_gpio_irq_mask(struct irq_data *data)
2007 {
2008 	struct pic32_gpio_bank *bank = irqd_to_bank(data);
2009 
2010 	writel(BIT(PIC32_CNCON_ON), bank->reg_base + PIC32_CLR(CNCON_REG));
2011 	gpiochip_disable_irq(&bank->gpio_chip, irqd_to_hwirq(data));
2012 }
2013 
pic32_gpio_irq_unmask(struct irq_data * data)2014 static void pic32_gpio_irq_unmask(struct irq_data *data)
2015 {
2016 	struct pic32_gpio_bank *bank = irqd_to_bank(data);
2017 
2018 	gpiochip_enable_irq(&bank->gpio_chip, irqd_to_hwirq(data));
2019 	writel(BIT(PIC32_CNCON_ON), bank->reg_base + PIC32_SET(CNCON_REG));
2020 }
2021 
pic32_gpio_irq_startup(struct irq_data * data)2022 static unsigned int pic32_gpio_irq_startup(struct irq_data *data)
2023 {
2024 	struct gpio_chip *chip = irq_data_get_irq_chip_data(data);
2025 
2026 	pic32_gpio_direction_input(chip, data->hwirq);
2027 	pic32_gpio_irq_unmask(data);
2028 
2029 	return 0;
2030 }
2031 
pic32_gpio_irq_set_type(struct irq_data * data,unsigned int type)2032 static int pic32_gpio_irq_set_type(struct irq_data *data, unsigned int type)
2033 {
2034 	struct pic32_gpio_bank *bank = irqd_to_bank(data);
2035 	u32 mask = irqd_to_hwirq(data);
2036 
2037 	switch (type & IRQ_TYPE_SENSE_MASK) {
2038 	case IRQ_TYPE_EDGE_RISING:
2039 		/* enable RISE */
2040 		writel(mask, bank->reg_base + PIC32_SET(CNEN_REG));
2041 		/* disable FALL */
2042 		writel(mask, bank->reg_base + PIC32_CLR(CNNE_REG));
2043 		/* enable EDGE */
2044 		writel(BIT(PIC32_CNCON_EDGE), bank->reg_base + PIC32_SET(CNCON_REG));
2045 		break;
2046 	case IRQ_TYPE_EDGE_FALLING:
2047 		/* disable RISE */
2048 		writel(mask, bank->reg_base + PIC32_CLR(CNEN_REG));
2049 		/* enable FALL */
2050 		writel(mask, bank->reg_base + PIC32_SET(CNNE_REG));
2051 		/* enable EDGE */
2052 		writel(BIT(PIC32_CNCON_EDGE), bank->reg_base + PIC32_SET(CNCON_REG));
2053 		break;
2054 	case IRQ_TYPE_EDGE_BOTH:
2055 		/* enable RISE */
2056 		writel(mask, bank->reg_base + PIC32_SET(CNEN_REG));
2057 		/* enable FALL */
2058 		writel(mask, bank->reg_base + PIC32_SET(CNNE_REG));
2059 		/* enable EDGE */
2060 		writel(BIT(PIC32_CNCON_EDGE), bank->reg_base + PIC32_SET(CNCON_REG));
2061 		break;
2062 	default:
2063 		return -EINVAL;
2064 	}
2065 
2066 	irq_set_handler_locked(data, handle_edge_irq);
2067 
2068 	return 0;
2069 }
2070 
pic32_gpio_get_pending(struct gpio_chip * gc,unsigned long status)2071 static u32 pic32_gpio_get_pending(struct gpio_chip *gc, unsigned long status)
2072 {
2073 	struct pic32_gpio_bank *bank = gpiochip_get_data(gc);
2074 	u32 pending = 0;
2075 	u32 cnen_rise, cnne_fall;
2076 	u32 pin;
2077 
2078 	cnen_rise = readl(bank->reg_base + CNEN_REG);
2079 	cnne_fall = readl(bank->reg_base + CNNE_REG);
2080 
2081 	for_each_set_bit(pin, &status, BITS_PER_LONG) {
2082 		u32 mask = BIT(pin);
2083 
2084 		if ((mask & cnen_rise) || (mask && cnne_fall))
2085 			pending |= mask;
2086 	}
2087 
2088 	return pending;
2089 }
2090 
pic32_gpio_irq_handler(struct irq_desc * desc)2091 static void pic32_gpio_irq_handler(struct irq_desc *desc)
2092 {
2093 	struct gpio_chip *gc = irq_desc_get_handler_data(desc);
2094 	struct pic32_gpio_bank *bank = gpiochip_get_data(gc);
2095 	struct irq_chip *chip = irq_desc_get_chip(desc);
2096 	unsigned long pending;
2097 	unsigned int pin;
2098 	u32 stat;
2099 
2100 	chained_irq_enter(chip, desc);
2101 
2102 	stat = readl(bank->reg_base + CNF_REG);
2103 	pending = pic32_gpio_get_pending(gc, stat);
2104 
2105 	for_each_set_bit(pin, &pending, BITS_PER_LONG)
2106 		generic_handle_domain_irq(gc->irq.domain, pin);
2107 
2108 	chained_irq_exit(chip, desc);
2109 }
2110 
2111 #define GPIO_BANK(_bank, _npins)					\
2112 	{								\
2113 		.gpio_chip = {						\
2114 			.label = "GPIO" #_bank,				\
2115 			.request = gpiochip_generic_request,		\
2116 			.free = gpiochip_generic_free,			\
2117 			.get_direction = pic32_gpio_get_direction,	\
2118 			.direction_input = pic32_gpio_direction_input,	\
2119 			.direction_output = pic32_gpio_direction_output, \
2120 			.get = pic32_gpio_get,				\
2121 			.set = pic32_gpio_set,				\
2122 			.ngpio = _npins,				\
2123 			.base = GPIO_BANK_START(_bank),			\
2124 			.owner = THIS_MODULE,				\
2125 			.can_sleep = 0,					\
2126 		},							\
2127 		.instance = (_bank),					\
2128 	}
2129 
2130 static struct pic32_gpio_bank pic32_gpio_banks[] = {
2131 	GPIO_BANK(0, PINS_PER_BANK),
2132 	GPIO_BANK(1, PINS_PER_BANK),
2133 	GPIO_BANK(2, PINS_PER_BANK),
2134 	GPIO_BANK(3, PINS_PER_BANK),
2135 	GPIO_BANK(4, PINS_PER_BANK),
2136 	GPIO_BANK(5, PINS_PER_BANK),
2137 	GPIO_BANK(6, PINS_PER_BANK),
2138 	GPIO_BANK(7, PINS_PER_BANK),
2139 	GPIO_BANK(8, PINS_PER_BANK),
2140 	GPIO_BANK(9, PINS_PER_BANK),
2141 };
2142 
pic32_gpio_irq_print_chip(struct irq_data * data,struct seq_file * p)2143 static void pic32_gpio_irq_print_chip(struct irq_data *data, struct seq_file *p)
2144 {
2145 	struct pic32_gpio_bank *bank = irqd_to_bank(data);
2146 
2147 	seq_printf(p, "GPIO%d", bank->instance);
2148 }
2149 
2150 static const struct irq_chip pic32_gpio_irq_chip = {
2151 	.irq_startup = pic32_gpio_irq_startup,
2152 	.irq_ack = pic32_gpio_irq_ack,
2153 	.irq_mask = pic32_gpio_irq_mask,
2154 	.irq_unmask = pic32_gpio_irq_unmask,
2155 	.irq_set_type = pic32_gpio_irq_set_type,
2156 	.irq_print_chip = pic32_gpio_irq_print_chip,
2157 	.flags = IRQCHIP_IMMUTABLE,
2158 	GPIOCHIP_IRQ_RESOURCE_HELPERS,
2159 };
2160 
pic32_pinctrl_probe(struct platform_device * pdev)2161 static int pic32_pinctrl_probe(struct platform_device *pdev)
2162 {
2163 	struct pic32_pinctrl *pctl;
2164 	int ret;
2165 
2166 	pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL);
2167 	if (!pctl)
2168 		return -ENOMEM;
2169 	pctl->dev = &pdev->dev;
2170 	dev_set_drvdata(&pdev->dev, pctl);
2171 
2172 	pctl->reg_base = devm_platform_ioremap_resource(pdev, 0);
2173 	if (IS_ERR(pctl->reg_base))
2174 		return PTR_ERR(pctl->reg_base);
2175 
2176 	pctl->clk = devm_clk_get(&pdev->dev, NULL);
2177 	if (IS_ERR(pctl->clk)) {
2178 		ret = PTR_ERR(pctl->clk);
2179 		dev_err(&pdev->dev, "clk get failed\n");
2180 		return ret;
2181 	}
2182 
2183 	ret = clk_prepare_enable(pctl->clk);
2184 	if (ret) {
2185 		dev_err(&pdev->dev, "clk enable failed\n");
2186 		return ret;
2187 	}
2188 
2189 	pctl->pins = pic32_pins;
2190 	pctl->npins = ARRAY_SIZE(pic32_pins);
2191 	pctl->functions = pic32_functions;
2192 	pctl->nfunctions = ARRAY_SIZE(pic32_functions);
2193 	pctl->groups = pic32_groups;
2194 	pctl->ngroups = ARRAY_SIZE(pic32_groups);
2195 	pctl->gpio_banks = pic32_gpio_banks;
2196 	pctl->nbanks = ARRAY_SIZE(pic32_gpio_banks);
2197 
2198 	pic32_pinctrl_desc.pins = pctl->pins;
2199 	pic32_pinctrl_desc.npins = pctl->npins;
2200 	pic32_pinctrl_desc.custom_params = pic32_mpp_bindings;
2201 	pic32_pinctrl_desc.num_custom_params = ARRAY_SIZE(pic32_mpp_bindings);
2202 
2203 	pctl->pctldev = devm_pinctrl_register(&pdev->dev, &pic32_pinctrl_desc,
2204 					      pctl);
2205 	if (IS_ERR(pctl->pctldev)) {
2206 		dev_err(&pdev->dev, "Failed to register pinctrl device\n");
2207 		return PTR_ERR(pctl->pctldev);
2208 	}
2209 
2210 	return 0;
2211 }
2212 
pic32_gpio_probe(struct platform_device * pdev)2213 static int pic32_gpio_probe(struct platform_device *pdev)
2214 {
2215 	struct device_node *np = pdev->dev.of_node;
2216 	struct pic32_gpio_bank *bank;
2217 	u32 id;
2218 	int irq, ret;
2219 	struct gpio_irq_chip *girq;
2220 
2221 	if (of_property_read_u32(np, "microchip,gpio-bank", &id)) {
2222 		dev_err(&pdev->dev, "microchip,gpio-bank property not found\n");
2223 		return -EINVAL;
2224 	}
2225 
2226 	if (id >= ARRAY_SIZE(pic32_gpio_banks)) {
2227 		dev_err(&pdev->dev, "invalid microchip,gpio-bank property\n");
2228 		return -EINVAL;
2229 	}
2230 
2231 	bank = &pic32_gpio_banks[id];
2232 
2233 	bank->reg_base = devm_platform_ioremap_resource(pdev, 0);
2234 	if (IS_ERR(bank->reg_base))
2235 		return PTR_ERR(bank->reg_base);
2236 
2237 	irq = platform_get_irq(pdev, 0);
2238 	if (irq < 0)
2239 		return irq;
2240 
2241 	bank->clk = devm_clk_get(&pdev->dev, NULL);
2242 	if (IS_ERR(bank->clk)) {
2243 		ret = PTR_ERR(bank->clk);
2244 		dev_err(&pdev->dev, "clk get failed\n");
2245 		return ret;
2246 	}
2247 
2248 	ret = clk_prepare_enable(bank->clk);
2249 	if (ret) {
2250 		dev_err(&pdev->dev, "clk enable failed\n");
2251 		return ret;
2252 	}
2253 
2254 	bank->gpio_chip.parent = &pdev->dev;
2255 
2256 	girq = &bank->gpio_chip.irq;
2257 	gpio_irq_chip_set_chip(girq, &pic32_gpio_irq_chip);
2258 	girq->parent_handler = pic32_gpio_irq_handler;
2259 	girq->num_parents = 1;
2260 	girq->parents = devm_kcalloc(&pdev->dev, 1, sizeof(*girq->parents),
2261 				     GFP_KERNEL);
2262 	if (!girq->parents)
2263 		return -ENOMEM;
2264 	girq->default_type = IRQ_TYPE_NONE;
2265 	girq->handler = handle_level_irq;
2266 	girq->parents[0] = irq;
2267 	ret = gpiochip_add_data(&bank->gpio_chip, bank);
2268 	if (ret < 0) {
2269 		dev_err(&pdev->dev, "Failed to add GPIO chip %u: %d\n",
2270 			id, ret);
2271 		return ret;
2272 	}
2273 	return 0;
2274 }
2275 
2276 static const struct of_device_id pic32_pinctrl_of_match[] = {
2277 	{ .compatible = "microchip,pic32mzda-pinctrl", },
2278 	{ },
2279 };
2280 
2281 static struct platform_driver pic32_pinctrl_driver = {
2282 	.driver = {
2283 		.name = "pic32-pinctrl",
2284 		.of_match_table = pic32_pinctrl_of_match,
2285 		.suppress_bind_attrs = true,
2286 	},
2287 	.probe = pic32_pinctrl_probe,
2288 };
2289 
2290 static const struct of_device_id pic32_gpio_of_match[] = {
2291 	{ .compatible = "microchip,pic32mzda-gpio", },
2292 	{ },
2293 };
2294 
2295 static struct platform_driver pic32_gpio_driver = {
2296 	.driver = {
2297 		.name = "pic32-gpio",
2298 		.of_match_table = pic32_gpio_of_match,
2299 		.suppress_bind_attrs = true,
2300 	},
2301 	.probe = pic32_gpio_probe,
2302 };
2303 
pic32_gpio_register(void)2304 static int __init pic32_gpio_register(void)
2305 {
2306 	return platform_driver_register(&pic32_gpio_driver);
2307 }
2308 arch_initcall(pic32_gpio_register);
2309 
pic32_pinctrl_register(void)2310 static int __init pic32_pinctrl_register(void)
2311 {
2312 	return platform_driver_register(&pic32_pinctrl_driver);
2313 }
2314 arch_initcall(pic32_pinctrl_register);
2315