Skip to content

Commit d0e488e

Browse files
alvsunkartben
authored andcommitted
drivers: pinctrl: npcx: add pinctrl driver support for npck3
As title. Signed-off-by: Alvis Sun <[email protected]>
1 parent e1f258d commit d0e488e

File tree

5 files changed

+41
-2
lines changed

5 files changed

+41
-2
lines changed

drivers/pinctrl/Kconfig.npcx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@
33
# Copyright (c) 2022 Nuvoton Technology Corporation.
44
# SPDX-License-Identifier: Apache-2.0
55

6-
76
config PINCTRL_NPCX
87
bool "Nuvoton NPCX embedded controller (EC) pin controller driver"
98
default y
109
depends on DT_HAS_NUVOTON_NPCX_PINCTRL_ENABLED
1110
help
1211
This option enables the pin controller driver for NPCX family of
1312
processors.
13+
14+
config PINCTRL_NPCX_EX
15+
bool "Extended NPCX driver support"
16+
default y if DT_HAS_NUVOTON_NPCX_PINCTRL_NPCKN_ENABLED
17+
help
18+
This option enables the extended driver for NPCKN variant of processors.

drivers/pinctrl/pinctrl_npcx.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,24 @@ static void npcx_psl_input_detection_configure(const pinctrl_soc_pin_t *pin)
139139
}
140140

141141
/* Configure detection mode of PSL input pads */
142+
#if defined(CONFIG_PINCTRL_NPCX_EX)
143+
if (pin->flags.psl_in_mode == NPCX_PSL_IN_MODE_EDGE) {
144+
inst_glue->PSL_CTS3 |= BIT(psl_in->port);
145+
} else {
146+
inst_glue->PSL_CTS3 &= ~BIT(psl_in->port);
147+
}
148+
149+
/* Clear event bits */
150+
inst_glue->PSL_CTS |= BIT(psl_in->port);
151+
inst_glue->PSL_IN_POS |= BIT(psl_in->port);
152+
inst_glue->PSL_IN_NEG |= BIT(psl_in->port);
153+
#else
142154
if (pin->flags.psl_in_mode == NPCX_PSL_IN_MODE_EDGE) {
143155
inst_glue->PSL_CTS |= NPCX_PSL_CTS_MODE_BIT(psl_in->port);
144156
} else {
145157
inst_glue->PSL_CTS &= ~NPCX_PSL_CTS_MODE_BIT(psl_in->port);
146158
}
159+
#endif /* CONFIG_PINCTRL_NPCX_EX */
147160
}
148161

149162
static void npcx_device_control_configure(const pinctrl_soc_pin_t *pin)

dts/arm/nuvoton/npck/npck.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
* Then, the user can override the pin control options at the board level.
5757
*/
5858
pinctrl: pinctrl {
59-
compatible = "nuvoton,npcx-pinctrl";
59+
compatible = "nuvoton,npcx-pinctrl", "nuvoton,npcx-pinctrl-npckn";
6060
status = "okay";
6161
};
6262

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2025 Nuvoton Technology Corporation.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: |
5+
Nuvoton npcx pinctrl for npckn variant
6+
7+
compatible: "nuvoton,npcx-pinctrl-npckn"
8+
9+
include: nuvoton,npcx-pinctrl.yaml

soc/nuvoton/npcx/common/scfg.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ void npcx_pinctrl_i2c_port_sel(int controller, int port)
9898
{
9999
struct glue_reg *const inst_glue = HAL_GLUE_INST();
100100

101+
/* Set SMB_SEL bit to select port 1, otherwise select port 0 */
101102
if (port != 0) {
102103
inst_glue->SMB_SEL |= BIT(controller);
103104
} else {
@@ -138,10 +139,17 @@ int npcx_pinctrl_flash_write_protect_set(void)
138139
{
139140
struct scfg_reg *inst_scfg = HAL_SFCG_INST();
140141

142+
#if defined(CONFIG_PINCTRL_NPCX_EX)
143+
inst_scfg->DEV_CTL3 |= BIT(NPCX_DEV_CTL3_WP_IF);
144+
if (!IS_BIT_SET(inst_scfg->DEV_CTL3, NPCX_DEV_CTL3_WP_IF)) {
145+
return -EIO;
146+
}
147+
#else
141148
inst_scfg->DEV_CTL4 |= BIT(NPCX_DEV_CTL4_WP_IF);
142149
if (!IS_BIT_SET(inst_scfg->DEV_CTL4, NPCX_DEV_CTL4_WP_IF)) {
143150
return -EIO;
144151
}
152+
#endif
145153

146154
return 0;
147155
}
@@ -150,7 +158,11 @@ bool npcx_pinctrl_flash_write_protect_is_set(void)
150158
{
151159
struct scfg_reg *inst_scfg = HAL_SFCG_INST();
152160

161+
#if defined(CONFIG_PINCTRL_NPCX_EX)
162+
return IS_BIT_SET(inst_scfg->DEV_CTL3, NPCX_DEV_CTL3_WP_IF);
163+
#else
153164
return IS_BIT_SET(inst_scfg->DEV_CTL4, NPCX_DEV_CTL4_WP_IF);
165+
#endif
154166
}
155167

156168
void npcx_host_interface_sel(enum npcx_hif_type hif_type)

0 commit comments

Comments
 (0)