Skip to content

Commit

Permalink
gpio: spear_gpio: Fix gpio_set_value() implementation
Browse files Browse the repository at this point in the history
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: Axel Lin <[email protected]>
Acked-by: Stefan Roese <[email protected]>
Reviewed-by: Vipin Kumar <[email protected]>
Reviewed-by: Michael Trimarchi <[email protected]>
  • Loading branch information
AxelLin authored and albert-aribaud-u-boot committed Jul 4, 2014
1 parent fcfddfd commit c0c3740
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/gpio/spear_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit c0c3740

Please sign in to comment.