From: Axel Lin Date: Wed, 6 Mar 2019 14:02:55 +0000 (+0800) Subject: gpio: amd-fch: Set proper output level for direction_output X-Git-Tag: v5.15~6842^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f777cda3937007ef2818644bfa6d383c69d6bb28;p=platform%2Fkernel%2Flinux-starfive.git gpio: amd-fch: Set proper output level for direction_output Current amd_fch_gpio_direction_output implementation ignores the value argument, fix it so direction_output will set proper output level. Signed-off-by: Axel Lin Reviewed-by: Andy Shevchenko Reviewed-by: Enrico Weigelt Signed-off-by: Linus Walleij --- diff --git a/drivers/gpio/gpio-amd-fch.c b/drivers/gpio/gpio-amd-fch.c index 4c585d4..38c3f4a 100644 --- a/drivers/gpio/gpio-amd-fch.c +++ b/drivers/gpio/gpio-amd-fch.c @@ -65,9 +65,18 @@ static int amd_fch_gpio_direction_output(struct gpio_chip *gc, unsigned long flags; struct amd_fch_gpio_priv *priv = gpiochip_get_data(gc); void __iomem *ptr = amd_fch_gpio_addr(priv, gpio); + u32 val; spin_lock_irqsave(&priv->lock, flags); - writel_relaxed(readl_relaxed(ptr) | AMD_FCH_GPIO_FLAG_DIRECTION, ptr); + + val = readl_relaxed(ptr); + if (value) + val |= AMD_FCH_GPIO_FLAG_WRITE; + else + val &= ~AMD_FCH_GPIO_FLAG_WRITE; + + writel_relaxed(val | AMD_FCH_GPIO_FLAG_DIRECTION, ptr); + spin_unlock_irqrestore(&priv->lock, flags); return 0;