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