diff --git a/boards/arm/npcx7m6fb_evb/npcx7m6fb_evb.dts b/boards/arm/npcx7m6fb_evb/npcx7m6fb_evb.dts index 15c5bf8dfbb..a9dc3fdec73 100644 --- a/boards/arm/npcx7m6fb_evb/npcx7m6fb_evb.dts +++ b/boards/arm/npcx7m6fb_evb/npcx7m6fb_evb.dts @@ -103,7 +103,8 @@ &tach1 { status = "okay"; - pinctrl-0 = <&alt3_ta1_sl1>; /* Use TA1_SL1 (PIN40) as input pin */ + pinctrl-0 = <&ta1_1_in_gp40>; + pinctrl-names = "default"; port = ; /* port-A is selected */ sample-clk = ; /* Use LFCLK as sampling clock */ pulses-per-round = <1>; /* number of pulses per round of encoder */ diff --git a/boards/arm/npcx9m6f_evb/npcx9m6f_evb.dts b/boards/arm/npcx9m6f_evb/npcx9m6f_evb.dts index c7d1badc218..643d9411ddc 100644 --- a/boards/arm/npcx9m6f_evb/npcx9m6f_evb.dts +++ b/boards/arm/npcx9m6f_evb/npcx9m6f_evb.dts @@ -116,7 +116,8 @@ &tach1 { status = "okay"; - pinctrl-0 = <&alt3_ta1_sl1>; /* Use TA1_SL1 (PIN40) as input pin */ + pinctrl-0 = <&ta1_1_in_gp40>; + pinctrl-names = "default"; port = ; /* port-A is selected */ sample-clk = ; /* Use LFCLK as sampling clock */ pulses-per-round = <1>; /* number of pulses per round of encoder */ diff --git a/drivers/sensor/nuvoton_tach_npcx/tach_nuvoton_npcx.c b/drivers/sensor/nuvoton_tach_npcx/tach_nuvoton_npcx.c index 46cdf72fe39..dddb0a98b0e 100644 --- a/drivers/sensor/nuvoton_tach_npcx/tach_nuvoton_npcx.c +++ b/drivers/sensor/nuvoton_tach_npcx/tach_nuvoton_npcx.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -55,15 +56,14 @@ struct tach_npcx_config { uintptr_t base; /* clock configuration */ struct npcx_clk_cfg clk_cfg; - /* pinmux configuration */ - const uint8_t alts_size; - const struct npcx_alt *alts_list; /* sampling clock frequency of tachometer */ uint32_t sample_clk; /* selected port of tachometer */ int port; /* number of pulses (holes) per round of tachometer's input (encoder) */ int pulses_per_round; + /* pinmux configuration */ + const struct pinctrl_dev_config *pcfg; }; /* Driver data */ @@ -332,7 +332,12 @@ static int tach_npcx_init(const struct device *dev) } /* Configure pin-mux for tachometer device */ - npcx_pinctrl_mux_configure(config->alts_list, config->alts_size, 1); + ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT); + if (ret < 0) { + LOG_ERR("Tacho pinctrl setup failed (%d)", ret); + return ret; + } + /* Configure tachometer and its operate freq. */ ret = tach_npcx_configure(dev); @@ -359,17 +364,15 @@ static const struct sensor_driver_api tach_npcx_driver_api = { }; #define NPCX_TACH_INIT(inst) \ - static const struct npcx_alt tach_alts##inst[] = \ - NPCX_DT_ALT_ITEMS_LIST(inst); \ + PINCTRL_DT_INST_DEFINE(inst); \ \ static const struct tach_npcx_config tach_cfg_##inst = { \ .base = DT_INST_REG_ADDR(inst), \ .clk_cfg = NPCX_DT_CLK_CFG_ITEM(inst), \ - .alts_size = ARRAY_SIZE(tach_alts##inst), \ - .alts_list = tach_alts##inst, \ .sample_clk = DT_INST_PROP(inst, sample_clk), \ .port = DT_INST_PROP(inst, port), \ .pulses_per_round = DT_INST_PROP(inst, pulses_per_round), \ + .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \ }; \ \ static struct tach_npcx_data tach_data_##inst; \ diff --git a/dts/bindings/tach/nuvoton,npcx-tach.yaml b/dts/bindings/tach/nuvoton,npcx-tach.yaml index 13c4bdb5dd9..ed4d352dcaa 100644 --- a/dts/bindings/tach/nuvoton,npcx-tach.yaml +++ b/dts/bindings/tach/nuvoton,npcx-tach.yaml @@ -5,7 +5,7 @@ description: Nuvoton, NPCX-Tachometer node compatible: "nuvoton,npcx-tach" -include: tach.yaml +include: [tach.yaml, pinctrl-device.yaml] properties: reg: @@ -13,9 +13,9 @@ properties: clocks: required: true pinctrl-0: - type: phandles - required: false - description: configurations of pinmux controllers in tachometers + required: true + pinctrl-names: + required: true sample-clk: type: int required: false