[PATCH v1 3/3] pinctrl: npcm8xx: clear all gpio events

Jim Liu jim.t90615 at gmail.com
Wed Sep 4 04:41:06 CEST 2024


From: Stanley Chu <yschu at nuvoton.com>

Clear all gpio events to avoid unexpected interrupts
during kernel booting.

Signed-off-by: Stanley Chu <yschu at nuvoton.com>
---
 drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c b/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c
index ff49819b58..67e564f85c 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c
@@ -48,6 +48,7 @@
 #define GPIO_OES	0x70 /* Output Enable Set */
 #define GPIO_OEC	0x74 /* Output Enable Clear */
 
+#define NPCM8XX_NUM_GPIO_BANK	8
 #define NPCM8XX_GPIO_PER_BANK	32
 #define GPIOX_OFFSET	16
 
@@ -967,6 +968,18 @@ static int npcm8xx_pinconf_set(struct udevice *dev, unsigned int selector,
 }
 #endif
 
+static void npcm8xx_pinctrl_clear_events(struct npcm8xx_pinctrl_priv *priv)
+{
+	void __iomem *base;
+	int i;
+
+	for (i = 0; i < NPCM8XX_NUM_GPIO_BANK; i++) {
+		base = priv->gpio_base + (0x1000 * i);
+		clrbits_le32(base + GPIO_EVEN, 0xFFFFFFFF);
+		setbits_le32(base + GPIO_EVST, 0xFFFFFFFF);
+	}
+}
+
 static struct pinctrl_ops npcm8xx_pinctrl_ops = {
 	.set_state	= pinctrl_generic_set_state,
 	.get_pins_count = npcm8xx_get_pins_count,
@@ -1001,6 +1014,11 @@ static int npcm8xx_pinctrl_probe(struct udevice *dev)
 	if (IS_ERR(priv->rst_regmap))
 		return -EINVAL;
 
+	/*
+	 * Clear all previous gpio events, otherwise it may produce
+	 * unexpected interrupts during kernel booting.
+	 */
+	npcm8xx_pinctrl_clear_events(priv);
 	return 0;
 }
 
-- 
2.34.1



More information about the U-Boot mailing list