Skip to content

Commit 20c8f6b

Browse files
Chenhongrencfriedt
authored andcommitted
drivers: pinctrl: it8xxx2: add support for alternate function 5
This commit introduces alternate function 5 setting for it8xxx2 SoC. Signed-off-by: Ren Chen <[email protected]>
1 parent 61298e3 commit 20c8f6b

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

drivers/pinctrl/pinctrl_ite_it8xxx2.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
LOG_MODULE_REGISTER(pinctrl_ite_it8xxx2, LOG_LEVEL_ERR);
1616

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)
1720
#define GPIO_GROUP_MEMBERS 8
1821

1922
struct pinctrl_it8xxx2_gpio {
@@ -33,6 +36,14 @@ struct pinctrl_it8xxx2_gpio {
3336
uintptr_t func4_gcr[GPIO_GROUP_MEMBERS];
3437
/* function 4 enable mask */
3538
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+
3647
/* Input voltage selection */
3748
uintptr_t volt_sel[GPIO_GROUP_MEMBERS];
3849
/* Input voltage selection mask */
@@ -150,6 +161,9 @@ static int pinctrl_gpio_it8xxx2_configure_pins(const pinctrl_soc_pin_t *pins)
150161
volatile uint8_t *reg_gpcr = (uint8_t *)gpio->reg_gpcr + pin;
151162
volatile uint8_t *reg_func3_gcr = (uint8_t *)(gpio->func3_gcr[pin]);
152163
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 */
153167
volatile uint8_t *reg_func3_ext = (uint8_t *)(gpio->func3_ext[pin]);
154168

155169
/* Handle PIN configuration. */
@@ -213,9 +227,19 @@ static int pinctrl_gpio_it8xxx2_configure_pins(const pinctrl_soc_pin_t *pins)
213227
*/
214228
*reg_func4_gcr |= gpio->func4_en_mask[pin];
215229
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;
216237
case IT8XXX2_ALT_DEFAULT:
217238
*reg_func3_gcr &= ~gpio->func3_en_mask[pin];
218239
*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 */
219243
return 0;
220244
default:
221245
LOG_ERR("This function is not supported.");
@@ -392,7 +416,17 @@ static int pinctrl_it8xxx2_init(const struct device *dev)
392416
return 0;
393417
}
394418

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) \
396430
COND_CODE_1(DT_INST_PROP(inst, gpio_group), \
397431
(.gpio = { \
398432
.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)
405439
.func4_en_mask = DT_INST_PROP(inst, func4_en_mask), \
406440
.volt_sel = DT_INST_PROP(inst, volt_sel), \
407441
.volt_sel_mask = DT_INST_PROP(inst, volt_sel_mask), \
442+
DECLARE_GPIO_ALT_FUNC5(inst) \
408443
}), \
409444
(.ksi_kso = { \
410445
.reg_gctrl = (uint8_t *)DT_INST_REG_ADDR_BY_IDX(inst, 0), \

dts/bindings/pinctrl/ite,it8xxx2-pinctrl-func.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ properties:
2929
func4-en-mask:
3030
type: array
3131

32+
func5-gcr:
33+
type: array
34+
35+
func5-en-mask:
36+
type: array
37+
3238
volt-sel:
3339
type: array
3440

include/zephyr/dt-bindings/pinctrl/it8xxx2-pinctrl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#define IT8XXX2_ALT_FUNC_2 1U
1616
#define IT8XXX2_ALT_FUNC_3 2U
1717
#define IT8XXX2_ALT_FUNC_4 3U
18-
#define IT8XXX2_ALT_DEFAULT 4U
18+
#define IT8XXX2_ALT_FUNC_5 4U
19+
#define IT8XXX2_ALT_DEFAULT 5U
1920

2021
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_PINCTRL_IT8XXX2_PINCTRL_H_ */

0 commit comments

Comments
 (0)