2 * Joshua Henderson <joshua.henderson@microchip.com>
3 * Copyright (C) 2015 Microchip Technology Inc. All rights reserved.
5 * This program is free software; you can distribute it and/or modify it
6 * under the terms of the GNU General Public License (Version 2) as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 #include "early_pin.h"
18 #define PPS_BASE 0x1f800000
20 /* Input PPS Registers */
69 #define REFCLKI1R 0x14E8
70 #define REFCLKI3R 0x14F0
71 #define REFCLKI4R 0x14F4
78 { IN_FUNC_INT3
, INT3R
},
79 { IN_FUNC_T2CK
, T2CKR
},
80 { IN_FUNC_T6CK
, T6CKR
},
81 { IN_FUNC_IC3
, IC3R
},
82 { IN_FUNC_IC7
, IC7R
},
83 { IN_FUNC_U1RX
, U1RXR
},
84 { IN_FUNC_U2CTS
, U2CTSR
},
85 { IN_FUNC_U5RX
, U5RXR
},
86 { IN_FUNC_U6CTS
, U6CTSR
},
87 { IN_FUNC_SDI1
, SDI1R
},
88 { IN_FUNC_SDI3
, SDI3R
},
89 { IN_FUNC_SDI5
, SDI5R
},
90 { IN_FUNC_SS6
, SS6R
},
91 { IN_FUNC_REFCLKI1
, REFCLKI1R
},
92 { IN_FUNC_INT4
, INT4R
},
93 { IN_FUNC_T5CK
, T5CKR
},
94 { IN_FUNC_T7CK
, T7CKR
},
95 { IN_FUNC_IC4
, IC4R
},
96 { IN_FUNC_IC8
, IC8R
},
97 { IN_FUNC_U3RX
, U3RXR
},
98 { IN_FUNC_U4CTS
, U4CTSR
},
99 { IN_FUNC_SDI2
, SDI2R
},
100 { IN_FUNC_SDI4
, SDI4R
},
101 { IN_FUNC_C1RX
, C1RXR
},
102 { IN_FUNC_REFCLKI4
, REFCLKI4R
},
103 { IN_FUNC_INT2
, INT2R
},
104 { IN_FUNC_T3CK
, T3CKR
},
105 { IN_FUNC_T8CK
, T8CKR
},
106 { IN_FUNC_IC2
, IC2R
},
107 { IN_FUNC_IC5
, IC5R
},
108 { IN_FUNC_IC9
, IC9R
},
109 { IN_FUNC_U1CTS
, U1CTSR
},
110 { IN_FUNC_U2RX
, U2RXR
},
111 { IN_FUNC_U5CTS
, U5CTSR
},
112 { IN_FUNC_SS1
, SS1R
},
113 { IN_FUNC_SS3
, SS3R
},
114 { IN_FUNC_SS4
, SS4R
},
115 { IN_FUNC_SS5
, SS5R
},
116 { IN_FUNC_C2RX
, C2RXR
},
117 { IN_FUNC_INT1
, INT1R
},
118 { IN_FUNC_T4CK
, T4CKR
},
119 { IN_FUNC_T9CK
, T9CKR
},
120 { IN_FUNC_IC1
, IC1R
},
121 { IN_FUNC_IC6
, IC6R
},
122 { IN_FUNC_U3CTS
, U3CTSR
},
123 { IN_FUNC_U4RX
, U4RXR
},
124 { IN_FUNC_U6RX
, U6RXR
},
125 { IN_FUNC_SS2
, SS2R
},
126 { IN_FUNC_SDI6
, SDI6R
},
127 { IN_FUNC_OCFA
, OCFAR
},
128 { IN_FUNC_REFCLKI3
, REFCLKI3R
},
131 void pic32_pps_input(int function
, int pin
)
133 void __iomem
*pps_base
= ioremap_nocache(PPS_BASE
, 0xF4);
136 for (i
= 0; i
< ARRAY_SIZE(input_pin_reg
); i
++) {
137 if (input_pin_reg
[i
].function
== function
) {
138 __raw_writel(pin
, pps_base
+ input_pin_reg
[i
].reg
);
146 /* Output PPS Registers */
147 #define RPA14R 0x1538
148 #define RPA15R 0x153C
158 #define RPB10R 0x1568
159 #define RPB14R 0x1578
160 #define RPB15R 0x157C
165 #define RPC13R 0x15B4
166 #define RPC14R 0x15B8
176 #define RPD10R 0x15E8
177 #define RPD11R 0x15EC
178 #define RPD12R 0x15F0
179 #define RPD14R 0x15F8
180 #define RPD15R 0x15FC
192 #define RPF12R 0x1670
193 #define RPF13R 0x1674
205 } output_pin_reg
[] = {
209 { OUT_RPD10
, RPD10R
},
212 { OUT_RPB10
, RPB10R
},
213 { OUT_RPC14
, RPC14R
},
216 { OUT_RPD14
, RPD14R
},
218 { OUT_RPA14
, RPA14R
},
223 { OUT_RPD11
, RPD11R
},
227 { OUT_RPC13
, RPC13R
},
230 { OUT_RPD15
, RPD15R
},
232 { OUT_RPA15
, RPA15R
},
237 { OUT_RPB15
, RPB15R
},
242 { OUT_RPF12
, RPF12R
},
243 { OUT_RPD12
, RPD12R
},
249 { OUT_RPB14
, RPB14R
},
255 { OUT_RPF13
, RPF13R
},
261 void pic32_pps_output(int function
, int pin
)
263 void __iomem
*pps_base
= ioremap_nocache(PPS_BASE
, 0x170);
266 for (i
= 0; i
< ARRAY_SIZE(output_pin_reg
); i
++) {
267 if (output_pin_reg
[i
].pin
== pin
) {
268 __raw_writel(function
,
269 pps_base
+ output_pin_reg
[i
].reg
);