summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Yung-Chieh Lo <yjlou@chromium.org>2013-12-26 11:38:01 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-01-03 23:04:23 +0000
commit3f00af41c41d35fec50090a48796db5c24d0a6d3 (patch)
treec9da15d14260d6d1ad2af575426debf014782f2d
parent5e50259c2252ac7b2f65e7cd75bf219f6c4293bf (diff)
downloadchrome-ec-3f00af41c41d35fec50090a48796db5c24d0a6d3.tar.gz
nyan: don't touch GPIO setting while init alternate functions.
Old code reset some GPIO configurations with af->flags = 0 while gpio_config_module(). This is bad because it could lead unexpected behavior on the bus. New code accepts GPIO_DEFAULT flag so that it doesn't touch the GPIO setting while configuring alternate functions. This should not effect other boards unless the GPIO_DEFAULT is set on that board. BUG=chrome-os-partner:24607 BRANCH=nyan TEST=run on nyan rev 3.12. No "SPI rx bad data" at boot. UART and i2c good. Change-Id: Id451cfae21e1d764452429dc5adfe1317ff5b140 Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/181135 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--board/nyan/board.c6
-rw-r--r--common/gpio.c8
2 files changed, 9 insertions, 5 deletions
diff --git a/board/nyan/board.c b/board/nyan/board.c
index bbaa1cc261..060b9a40e1 100644
--- a/board/nyan/board.c
+++ b/board/nyan/board.c
@@ -91,9 +91,9 @@ BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT);
/* Pins with alternate functions */
const struct gpio_alt_func gpio_alt_funcs[] = {
- {GPIO_A, 0x00f0, GPIO_ALT_SPI, MODULE_SPI},
- {GPIO_A, 0x0600, GPIO_ALT_USART, MODULE_UART},
- {GPIO_B, 0x00c0, GPIO_ALT_I2C, MODULE_I2C},
+ {GPIO_A, 0x00f0, GPIO_ALT_SPI, MODULE_SPI, GPIO_DEFAULT},
+ {GPIO_A, 0x0600, GPIO_ALT_USART, MODULE_UART, GPIO_DEFAULT},
+ {GPIO_B, 0x00c0, GPIO_ALT_I2C, MODULE_I2C, GPIO_DEFAULT},
};
const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs);
diff --git a/common/gpio.c b/common/gpio.c
index 43abdad0d4..13775ea449 100644
--- a/common/gpio.c
+++ b/common/gpio.c
@@ -73,11 +73,15 @@ void gpio_config_module(enum module_id id, int enable)
continue; /* Pins for some other module */
if (enable) {
- gpio_set_flags_by_mask(af->port, af->mask, af->flags);
+ if (!(af->flags & GPIO_DEFAULT))
+ gpio_set_flags_by_mask(af->port,
+ af->mask, af->flags);
gpio_set_alternate_function(af->port, af->mask,
af->func);
} else {
- gpio_set_flags_by_mask(af->port, af->mask, GPIO_INPUT);
+ if (!(af->flags & GPIO_DEFAULT))
+ gpio_set_flags_by_mask(af->port,
+ af->mask, GPIO_INPUT);
gpio_set_alternate_function(af->port, af->mask, -1);
}
}