Commit c0c37402 authored by Axel Lin's avatar Axel Lin Committed by Albert ARIBAUD

gpio: spear_gpio: Fix gpio_set_value() implementation

In current gpio_set_value() implementation, it always sets the gpio control bit
no matter the value argument is 0 or 1. Thus the GPIOs never set to low.
This patch fixes this bug.

The address bus is used as a mask on read/write operations, so that independent
software drivers can set their GPIO bits without affecting any other pins in a
single write operation. Thus we don't need a read-modify-write to update the
register.
Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Acked-by: Stefan Roese's avatarStefan Roese <sr@denx.de>
Reviewed-by: default avatarVipin Kumar <vipin.kumar@st.com>
Reviewed-by: default avatarMichael Trimarchi <michael@amarulasolutions.com>
parent fcfddfd5
......@@ -36,7 +36,10 @@ int gpio_set_value(unsigned gpio, int value)
{
struct gpio_regs *regs = (struct gpio_regs *)CONFIG_GPIO_BASE;
writel(1 << gpio, &regs->gpiodata[DATA_REG_ADDR(gpio)]);
if (value)
writel(1 << gpio, &regs->gpiodata[DATA_REG_ADDR(gpio)]);
else
writel(0, &regs->gpiodata[DATA_REG_ADDR(gpio)]);
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment