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