ARM: when setting a GPIO to put, set the value, then the direction

We saw a problem on x86 last year in which setting direction, then value,
glitched the output and caused problems. Change this code to set the output,
then the direction.

Change-Id: I3e1e17ffe82ae270eea539530368a58c6cfe0ebe
Signed-off-by: Ronald G. Minnich <rminnich@google.com>
Signed-off-by: Gabe Black <gabeblack@chromium.org>
Reviewed-on: http://review.coreboot.org/3679
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Ronald G. Minnich 2013-06-18 13:02:23 -07:00 committed by Stefan Reinauer
parent c883fdc964
commit 32450568bc
2 changed files with 4 additions and 4 deletions

View File

@ -170,14 +170,14 @@ int gpio_direction_output(unsigned gpio, int value)
unsigned int val; unsigned int val;
struct gpio_bank *bank = gpio_get_bank(gpio); struct gpio_bank *bank = gpio_get_bank(gpio);
gpio_cfg_pin(gpio, GPIO_OUTPUT);
val = readl(&bank->dat); val = readl(&bank->dat);
val &= ~DAT_MASK(GPIO_BIT(gpio)); val &= ~DAT_MASK(GPIO_BIT(gpio));
if (value) if (value)
val |= DAT_SET(GPIO_BIT(gpio)); val |= DAT_SET(GPIO_BIT(gpio));
writel(val, &bank->dat); writel(val, &bank->dat);
gpio_cfg_pin(gpio, GPIO_OUTPUT);
return 0; return 0;
} }

View File

@ -170,14 +170,14 @@ int gpio_direction_output(unsigned gpio, int value)
unsigned int val; unsigned int val;
struct gpio_bank *bank = gpio_get_bank(gpio); struct gpio_bank *bank = gpio_get_bank(gpio);
gpio_cfg_pin(gpio, GPIO_OUTPUT);
val = readl(&bank->dat); val = readl(&bank->dat);
val &= ~DAT_MASK(GPIO_BIT(gpio)); val &= ~DAT_MASK(GPIO_BIT(gpio));
if (value) if (value)
val |= DAT_SET(GPIO_BIT(gpio)); val |= DAT_SET(GPIO_BIT(gpio));
writel(val, &bank->dat); writel(val, &bank->dat);
gpio_cfg_pin(gpio, GPIO_OUTPUT);
return 0; return 0;
} }