From 26d60b8958abf85b37e87e9ae7b9ba9fb9875a41 Mon Sep 17 00:00:00 2001 From: "Ronald G. Minnich" Date: Tue, 18 Jun 2013 13:02:23 -0700 Subject: [PATCH] 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. BUG=chrome-os-partner:19420 TEST=Build and boot on pit. BRANCH=None Change-Id: Ie40786139b0b496e22a80dc3dd712b6adff03d1e Signed-off-by: Ronald G. Minnich Reviewed-on: https://gerrit.chromium.org/gerrit/59087 Reviewed-by: David Hendricks Commit-Queue: Ronald G. Minnich Tested-by: Ronald G. Minnich --- src/cpu/samsung/exynos5250/gpio.c | 4 ++-- src/cpu/samsung/exynos5420/gpio.c | 4 ++-- 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; }