diff mbox series

[v2] gpio: amd-fch: Set proper output level for direction_output

Message ID 20190306140255.9091-1-axel.lin@ingics.com
State New
Headers show
Series [v2] gpio: amd-fch: Set proper output level for direction_output | expand

Commit Message

Axel Lin March 6, 2019, 2:02 p.m. UTC
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 <axel.lin@ingics.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Enrico Weigelt <info@metux.net>
---
v2:
commit e226e3c33ab0 gpio: amd-fch: Fix type error found by sparse
make the original patch not able to be applied. Fix it.

 drivers/gpio/gpio-amd-fch.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Linus Walleij March 8, 2019, 12:16 p.m. UTC | #1
On Wed, Mar 6, 2019 at 3:03 PM Axel Lin <axel.lin@ingics.com> wrote:

> 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 <axel.lin@ingics.com>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Reviewed-by: Enrico Weigelt <info@metux.net>
> ---
> v2:

Patch applied!

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-amd-fch.c b/drivers/gpio/gpio-amd-fch.c
index 4c585d4e7e74..38c3f4a3d4aa 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;