From f9b49e8782efb7628984e1f3c3abc1ef7a58b84b Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Wed, 14 Jan 2015 20:41:30 -0800 Subject: [PATCH] Add delay before reading GPIOs in gpio_base2_value() This adds a 10us delay in between (re-)configuring and reading GPIOs in gpio_base2_value() to give the values stored some time to update. As far as I know this hasn't bitten us since the function was added, but adding a short delay here seems like the right thing to do. BUG=none BRANCH=none TEST=built and booted on Brain Change-Id: I869cf375680435ad87729f93d29a623bdf09dfbc Signed-off-by: Patrick Georgi Original-Commit-Id: 2484900fc9ceba87220a293de8ef20c3b9b20cfd Original-Signed-off-by: David Hendricks Original-Change-Id: I79616a09d8d2ce4e416ffc94e35798dd25a6250d Original-Reviewed-on: https://chromium-review.googlesource.com/240854 Original-Reviewed-by: Julius Werner Reviewed-on: http://review.coreboot.org/9725 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- src/lib/gpio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/gpio.c b/src/lib/gpio.c index 0875538bae..633eabb4f5 100644 --- a/src/lib/gpio.c +++ b/src/lib/gpio.c @@ -26,10 +26,14 @@ int gpio_base2_value(gpio_t gpio[], int num_gpio) { int i, result = 0; - for (i = 0; i < num_gpio; i++) { + for (i = 0; i < num_gpio; i++) gpio_input(gpio[i]); + + /* Wait until signals become stable */ + udelay(10); + + for (i = 0; i < num_gpio; i++) result |= gpio_get(gpio[i]) << i; - } return result; }