@@ -35,6 +35,14 @@ static const uintptr_t reg_base[] = {
35
35
#error Unsupported SoC Series
36
36
#endif
37
37
38
+ #ifdef CONFIG_PINCTRL_RCAR_VOLTAGE_CONTROL
39
+ /* POC Control Register can control IO voltage level that is supplied to the pin */
40
+ struct pfc_pocctrl_reg {
41
+ uint32_t offset ;
42
+ const uint16_t pins [32 ];
43
+ };
44
+ #endif /* CONFIG_PINCTRL_RCAR_VOLTAGE_CONTROL */
45
+
38
46
/*
39
47
* Each drive step is either encoded in 2 or 3 bits.
40
48
* So based on a 24 mA maximum value each step is either
@@ -189,6 +197,110 @@ int pfc_rcar_set_bias(uintptr_t pfc_base, uint16_t pin, uint16_t flags)
189
197
return 0 ;
190
198
}
191
199
200
+ #ifdef CONFIG_PINCTRL_RCAR_VOLTAGE_CONTROL
201
+
202
+ const struct pfc_pocctrl_reg pfc_r8a77951_r8a77961_volt_regs [] = {
203
+ {
204
+ .offset = 0x0380 ,
205
+ .pins = {
206
+ [0 ] = RCAR_GP_PIN (3 , 0 ), /* SD0_CLK */
207
+ [1 ] = RCAR_GP_PIN (3 , 1 ), /* SD0_CMD */
208
+ [2 ] = RCAR_GP_PIN (3 , 2 ), /* SD0_DAT0 */
209
+ [3 ] = RCAR_GP_PIN (3 , 3 ), /* SD0_DAT1 */
210
+ [4 ] = RCAR_GP_PIN (3 , 4 ), /* SD0_DAT2 */
211
+ [5 ] = RCAR_GP_PIN (3 , 5 ), /* SD0_DAT3 */
212
+ [6 ] = RCAR_GP_PIN (3 , 6 ), /* SD1_CLK */
213
+ [7 ] = RCAR_GP_PIN (3 , 7 ), /* SD1_CMD */
214
+ [8 ] = RCAR_GP_PIN (3 , 8 ), /* SD1_DAT0 */
215
+ [9 ] = RCAR_GP_PIN (3 , 9 ), /* SD1_DAT1 */
216
+ [10 ] = RCAR_GP_PIN (3 , 10 ), /* SD1_DAT2 */
217
+ [11 ] = RCAR_GP_PIN (3 , 11 ), /* SD1_DAT3 */
218
+ [12 ] = RCAR_GP_PIN (4 , 0 ), /* SD2_CLK */
219
+ [13 ] = RCAR_GP_PIN (4 , 1 ), /* SD2_CMD */
220
+ [14 ] = RCAR_GP_PIN (4 , 2 ), /* SD2_DAT0 */
221
+ [15 ] = RCAR_GP_PIN (4 , 3 ), /* SD2_DAT1 */
222
+ [16 ] = RCAR_GP_PIN (4 , 4 ), /* SD2_DAT2 */
223
+ [17 ] = RCAR_GP_PIN (4 , 5 ), /* SD2_DAT3 */
224
+ [18 ] = RCAR_GP_PIN (4 , 6 ), /* SD2_DS */
225
+ [19 ] = RCAR_GP_PIN (4 , 7 ), /* SD3_CLK */
226
+ [20 ] = RCAR_GP_PIN (4 , 8 ), /* SD3_CMD */
227
+ [21 ] = RCAR_GP_PIN (4 , 9 ), /* SD3_DAT0 */
228
+ [22 ] = RCAR_GP_PIN (4 , 10 ), /* SD3_DAT1 */
229
+ [23 ] = RCAR_GP_PIN (4 , 11 ), /* SD3_DAT2 */
230
+ [24 ] = RCAR_GP_PIN (4 , 12 ), /* SD3_DAT3 */
231
+ [25 ] = RCAR_GP_PIN (4 , 13 ), /* SD3_DAT4 */
232
+ [26 ] = RCAR_GP_PIN (4 , 14 ), /* SD3_DAT5 */
233
+ [27 ] = RCAR_GP_PIN (4 , 15 ), /* SD3_DAT6 */
234
+ [28 ] = RCAR_GP_PIN (4 , 16 ), /* SD3_DAT7 */
235
+ [29 ] = RCAR_GP_PIN (4 , 17 ), /* SD3_DS */
236
+ [30 ] = -1 ,
237
+ [31 ] = -1 ,
238
+ }
239
+ },
240
+ { /* sentinel */ },
241
+ };
242
+
243
+ static const struct pfc_pocctrl_reg * pfc_rcar_get_io_voltage_regs (void )
244
+ {
245
+ return pfc_r8a77951_r8a77961_volt_regs ;
246
+ }
247
+
248
+ static const struct pfc_pocctrl_reg * pfc_rcar_get_pocctrl_reg (uint16_t pin , uint8_t * bit )
249
+ {
250
+ const struct pfc_pocctrl_reg * voltage_regs = pfc_rcar_get_io_voltage_regs ();
251
+
252
+ BUILD_ASSERT (ARRAY_SIZE (voltage_regs -> pins ) < UINT8_MAX );
253
+
254
+ /* Loop around all the registers to find the bit for a given pin */
255
+ while (voltage_regs && voltage_regs -> offset ) {
256
+ uint8_t i ;
257
+
258
+ for (i = 0U ; i < ARRAY_SIZE (voltage_regs -> pins ); i ++ ) {
259
+ if (voltage_regs -> pins [i ] == pin ) {
260
+ * bit = i ;
261
+ return voltage_regs ;
262
+ }
263
+ }
264
+ voltage_regs ++ ;
265
+ }
266
+
267
+ return NULL ;
268
+ }
269
+
270
+ static void pfc_rcar_set_voltage (uintptr_t pfc_base , uint16_t pin , uint16_t voltage )
271
+ {
272
+ uint32_t val ;
273
+ uint8_t bit ;
274
+ const struct pfc_pocctrl_reg * voltage_reg ;
275
+
276
+ voltage_reg = pfc_rcar_get_pocctrl_reg (pin , & bit );
277
+ if (!voltage_reg ) {
278
+ return ;
279
+ }
280
+
281
+ val = sys_read32 (pfc_base + voltage_reg -> offset );
282
+
283
+ switch (voltage ) {
284
+ case PIN_VOLTAGE_1P8V :
285
+ if (!(val & BIT (bit ))) {
286
+ return ;
287
+ }
288
+ val &= ~BIT (bit );
289
+ break ;
290
+ case PIN_VOLTAGE_3P3V :
291
+ if (val & BIT (bit )) {
292
+ return ;
293
+ }
294
+ val |= BIT (bit );
295
+ break ;
296
+ default :
297
+ break ;
298
+ }
299
+
300
+ pfc_rcar_write (pfc_base , voltage_reg -> offset , val );
301
+ }
302
+ #endif /* CONFIG_PINCTRL_RCAR_VOLTAGE_CONTROL */
303
+
192
304
int pinctrl_configure_pin (const pinctrl_soc_pin_t * pin )
193
305
{
194
306
int ret = 0 ;
@@ -214,6 +326,12 @@ int pinctrl_configure_pin(const pinctrl_soc_pin_t *pin)
214
326
return - EINVAL ;
215
327
}
216
328
329
+ #ifdef CONFIG_PINCTRL_RCAR_VOLTAGE_CONTROL
330
+ if (pin -> voltage != PIN_VOLTAGE_NONE ) {
331
+ pfc_rcar_set_voltage (pfc_base , pin -> pin , pin -> voltage );
332
+ }
333
+ #endif
334
+
217
335
/* Select function for pin */
218
336
if ((pin -> flags & RCAR_PIN_FLAGS_FUNC_SET ) != 0U ) {
219
337
pfc_rcar_set_ipsr (pfc_base , & pin -> func );
0 commit comments