summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRonald G. Minnich <rminnich@google.com>2013-06-18 13:02:23 -0700
committerStefan Reinauer <stefan.reinauer@coreboot.org>2013-07-10 22:35:15 +0200
commit32450568bc03d7b648d13755345cc647b97664f1 (patch)
treec24e165340413f6cd882f28c69a42686e097492e /src
parentc883fdc964207d3871e8609c67988c07d448a87d (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/cpu/samsung/exynos5250/gpio.c4
-rw-r--r--src/cpu/samsung/exynos5420/gpio.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/cpu/samsung/exynos5250/gpio.c b/src/cpu/samsung/exynos5250/gpio.c
index b8ebb0a4ed..2a93328a70 100644
--- a/src/cpu/samsung/exynos5250/gpio.c
+++ b/src/cpu/samsung/exynos5250/gpio.c
@@ -170,14 +170,14 @@ int gpio_direction_output(unsigned gpio, int value)
unsigned int val;
struct gpio_bank *bank = gpio_get_bank(gpio);
- gpio_cfg_pin(gpio, GPIO_OUTPUT);
-
val = readl(&bank->dat);
val &= ~DAT_MASK(GPIO_BIT(gpio));
if (value)
val |= DAT_SET(GPIO_BIT(gpio));
writel(val, &bank->dat);
+ gpio_cfg_pin(gpio, GPIO_OUTPUT);
+
return 0;
}
diff --git a/src/cpu/samsung/exynos5420/gpio.c b/src/cpu/samsung/exynos5420/gpio.c
index b8ebb0a4ed..2a93328a70 100644
--- a/src/cpu/samsung/exynos5420/gpio.c
+++ b/src/cpu/samsung/exynos5420/gpio.c
@@ -170,14 +170,14 @@ int gpio_direction_output(unsigned gpio, int value)
unsigned int val;
struct gpio_bank *bank = gpio_get_bank(gpio);
- gpio_cfg_pin(gpio, GPIO_OUTPUT);
-
val = readl(&bank->dat);
val &= ~DAT_MASK(GPIO_BIT(gpio));
if (value)
val |= DAT_SET(GPIO_BIT(gpio));
writel(val, &bank->dat);
+ gpio_cfg_pin(gpio, GPIO_OUTPUT);
+
return 0;
}