]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
pinctrl: npcm8xx: clear all gpio events
authorStanley Chu <yschu@nuvoton.com>
Wed, 4 Sep 2024 02:41:06 +0000 (10:41 +0800)
committerTom Rini <trini@konsulko.com>
Mon, 16 Sep 2024 22:43:35 +0000 (16:43 -0600)
Clear all gpio events to avoid unexpected interrupts
during kernel booting.

Signed-off-by: Stanley Chu <yschu@nuvoton.com>
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c

index ff49819b58da7022f4bcf8e10f67055800c386bf..67e564f85c38994c5f344b3fef6b06bd5c69518c 100644 (file)
@@ -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;
 }