14
14
15
15
LOG_MODULE_REGISTER (pinctrl_ite_it8xxx2 , LOG_LEVEL_ERR );
16
16
17
+ #define PINCTRL_ALT_FUNC5_IS_DEFINED \
18
+ DT_ANY_COMPAT_HAS_PROP_STATUS_OKAY(DT_DRV_COMPAT, func5_gcr) && \
19
+ DT_ANY_COMPAT_HAS_PROP_STATUS_OKAY(DT_DRV_COMPAT, func5_en_mask)
17
20
#define GPIO_GROUP_MEMBERS 8
18
21
19
22
struct pinctrl_it8xxx2_gpio {
@@ -33,6 +36,14 @@ struct pinctrl_it8xxx2_gpio {
33
36
uintptr_t func4_gcr [GPIO_GROUP_MEMBERS ];
34
37
/* function 4 enable mask */
35
38
uint8_t func4_en_mask [GPIO_GROUP_MEMBERS ];
39
+
40
+ #if PINCTRL_ALT_FUNC5_IS_DEFINED
41
+ struct {
42
+ uintptr_t gcr [GPIO_GROUP_MEMBERS ];
43
+ uint8_t en_mask [GPIO_GROUP_MEMBERS ];
44
+ } func5 ;
45
+ #endif /* PINCTRL_ALT_FUNC5_IS_DEFINED */
46
+
36
47
/* Input voltage selection */
37
48
uintptr_t volt_sel [GPIO_GROUP_MEMBERS ];
38
49
/* Input voltage selection mask */
@@ -150,6 +161,9 @@ static int pinctrl_gpio_it8xxx2_configure_pins(const pinctrl_soc_pin_t *pins)
150
161
volatile uint8_t * reg_gpcr = (uint8_t * )gpio -> reg_gpcr + pin ;
151
162
volatile uint8_t * reg_func3_gcr = (uint8_t * )(gpio -> func3_gcr [pin ]);
152
163
volatile uint8_t * reg_func4_gcr = (uint8_t * )(gpio -> func4_gcr [pin ]);
164
+ #if PINCTRL_ALT_FUNC5_IS_DEFINED
165
+ volatile uint8_t * reg_func5_gcr = (uint8_t * )(gpio -> func5 .gcr [pin ]);
166
+ #endif /* PINCTRL_ALT_FUNC5_IS_DEFINED */
153
167
volatile uint8_t * reg_func3_ext = (uint8_t * )(gpio -> func3_ext [pin ]);
154
168
155
169
/* Handle PIN configuration. */
@@ -213,9 +227,19 @@ static int pinctrl_gpio_it8xxx2_configure_pins(const pinctrl_soc_pin_t *pins)
213
227
*/
214
228
* reg_func4_gcr |= gpio -> func4_en_mask [pin ];
215
229
break ;
230
+ case IT8XXX2_ALT_FUNC_5 :
231
+ #if PINCTRL_ALT_FUNC5_IS_DEFINED
232
+ if (reg_func5_gcr ) {
233
+ * reg_func5_gcr |= gpio -> func5 .en_mask [pin ];
234
+ }
235
+ #endif /* PINCTRL_ALT_FUNC5_IS_DEFINED */
236
+ break ;
216
237
case IT8XXX2_ALT_DEFAULT :
217
238
* reg_func3_gcr &= ~gpio -> func3_en_mask [pin ];
218
239
* reg_func4_gcr &= ~gpio -> func4_en_mask [pin ];
240
+ #if PINCTRL_ALT_FUNC5_IS_DEFINED
241
+ * reg_func5_gcr &= ~gpio -> func5 .en_mask [pin ];
242
+ #endif /* PINCTRL_ALT_FUNC5_IS_DEFINED */
219
243
return 0 ;
220
244
default :
221
245
LOG_ERR ("This function is not supported." );
@@ -392,7 +416,17 @@ static int pinctrl_it8xxx2_init(const struct device *dev)
392
416
return 0 ;
393
417
}
394
418
395
- #define INIT_UNION_CONFIG (inst ) \
419
+ #if PINCTRL_ALT_FUNC5_IS_DEFINED
420
+ #define DECLARE_GPIO_ALT_FUNC5 (inst ) \
421
+ .func5 = { \
422
+ .gcr = DT_INST_PROP_OR(inst, func5_gcr, {0}), \
423
+ .en_mask = DT_INST_PROP_OR(inst, func5_en_mask, {0}), \
424
+ },
425
+ #else
426
+ #define DECLARE_GPIO_ALT_FUNC5 (inst )
427
+ #endif /* PINCTRL_ALT_FUNC5_IS_DEFINED */
428
+
429
+ #define INIT_UNION_CONFIG (inst ) \
396
430
COND_CODE_1(DT_INST_PROP(inst, gpio_group), \
397
431
(.gpio = { \
398
432
.reg_gpcr = (uint8_t *)DT_INST_REG_ADDR_BY_IDX(inst, 0), \
@@ -405,6 +439,7 @@ static int pinctrl_it8xxx2_init(const struct device *dev)
405
439
.func4_en_mask = DT_INST_PROP(inst, func4_en_mask), \
406
440
.volt_sel = DT_INST_PROP(inst, volt_sel), \
407
441
.volt_sel_mask = DT_INST_PROP(inst, volt_sel_mask), \
442
+ DECLARE_GPIO_ALT_FUNC5(inst) \
408
443
}), \
409
444
(.ksi_kso = { \
410
445
.reg_gctrl = (uint8_t *)DT_INST_REG_ADDR_BY_IDX(inst, 0), \
0 commit comments