]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
pinctrl: nuvoton: set output state before enabling the output
authorJim Liu <jim.t90615@gmail.com>
Tue, 9 May 2023 07:07:34 +0000 (15:07 +0800)
committerTom Rini <trini@konsulko.com>
Thu, 1 Jun 2023 16:32:03 +0000 (12:32 -0400)
The default output state may be different to request,
change the configuration sequence to avoid glitch.

Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
drivers/gpio/npcm_gpio.c
drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c

index 8afd57fa8e5364d0822d6306594aeaf043e3c0c5..98e5dc79c1ccd9fdc67859e4278471f7bdf6fd4e 100644 (file)
@@ -37,14 +37,14 @@ static int npcm_gpio_direction_output(struct udevice *dev, unsigned int offset,
 {
        struct npcm_gpio_priv *priv = dev_get_priv(dev);
 
-       clrbits_le32(priv->base + GPIO_IEM, BIT(offset));
-       writel(BIT(offset), priv->base + GPIO_OES);
-
        if (value)
                setbits_le32(priv->base + GPIO_DOUT, BIT(offset));
        else
                clrbits_le32(priv->base + GPIO_DOUT, BIT(offset));
 
+       clrbits_le32(priv->base + GPIO_IEM, BIT(offset));
+       writel(BIT(offset), priv->base + GPIO_OES);
+
        return 0;
 }
 
index 1ad8bfbd8808153bc6c8bbeae38e19b0ddcd5167..92513822e70c6e829522781d9a451f20501256ee 100644 (file)
@@ -1552,12 +1552,12 @@ static int npcm7xx_pinconf_set(struct udevice *dev, unsigned int pin,
                setbits_le32(base + NPCM7XX_GP_N_OES, BIT(gpio));
        case PIN_CONFIG_OUTPUT:
                dev_dbg(dev, "set pin %d output %d\n", pin, arg);
-               clrbits_le32(base + NPCM7XX_GP_N_IEM, BIT(gpio));
-               setbits_le32(base + NPCM7XX_GP_N_OES, BIT(gpio));
                if (arg)
                        setbits_le32(base + NPCM7XX_GP_N_DOUT, BIT(gpio));
                else
                        clrbits_le32(base + NPCM7XX_GP_N_DOUT, BIT(gpio));
+               clrbits_le32(base + NPCM7XX_GP_N_IEM, BIT(gpio));
+               setbits_le32(base + NPCM7XX_GP_N_OES, BIT(gpio));
                break;
        case PIN_CONFIG_DRIVE_PUSH_PULL:
                dev_dbg(dev, "set pin %d push pull\n", pin);
index 0ec47e9577e475922c349b7c131d17fb5a0efbc9..f18be08518e670350a9da065c29083ddf4767061 100644 (file)
@@ -900,12 +900,12 @@ static int npcm8xx_pinconf_set(struct udevice *dev, unsigned int selector,
                setbits_le32(base + GPIO_OES, BIT(gpio));
        case PIN_CONFIG_OUTPUT:
                dev_dbg(dev, "set pin %d output %d\n", pin, arg);
-               clrbits_le32(base + GPIO_IEM, BIT(gpio));
-               setbits_le32(base + GPIO_OES, BIT(gpio));
                if (arg)
                        setbits_le32(base + GPIO_DOUT, BIT(gpio));
                else
                        clrbits_le32(base + GPIO_DOUT, BIT(gpio));
+               clrbits_le32(base + GPIO_IEM, BIT(gpio));
+               setbits_le32(base + GPIO_OES, BIT(gpio));
                break;
        case PIN_CONFIG_DRIVE_PUSH_PULL:
                dev_dbg(dev, "set pin %d push pull\n", pin);