summaryrefslogtreecommitdiff
path: root/chip/lm4/uart.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-08-02 14:28:43 -0700
committerChromeBot <chrome-bot@google.com>2013-08-07 12:43:35 -0700
commitf2b56fcb9fe078d5a29f1c3744e47e77240cd4e7 (patch)
tree4ff810332c543871da7febb2cc21597eee800b6d /chip/lm4/uart.c
parentce704b40005c1acdffabe58f47df42c1d7da33c2 (diff)
downloadchrome-ec-f2b56fcb9fe078d5a29f1c3744e47e77240cd4e7.tar.gz
Clean up configuring GPIO alternate functions
GPIO alternate functions used to be configured throughout the code, which made it hard to tell which ones you needed to configure yourself in board.c. It also sometimes (chip/lm4/i2c.c) led to GPIOs being configured as alternate functions even if they weren't used on a given board. With this change, every board has a table in board.c which lists ALL GPIOs which have alternate functions. This is now the only place where alternate functions are configured. Each module then calls gpio_init_module() to set up its GPIOs. This also fixes a bug where gpio_set_flags() ignored most of the flags passed to it (only direction and level were actually used). On stm32f, gpio_set_alternate() does not exist, and pins are configured via direct register writes from board.c. Rather than attempt to change that in the same CL, I've stubbed out gpio_set_alternate() for stm32f, and will fix the register writes in a follow-up CL. BUG=chrome-os-partner:21618 BRANCH=peppy (fixes I2C1 being initialized even though those pins are used for other things) TEST=boot link, falco, pit, spring Change-Id: I40f47025d8f767e0723c6b40c80413af9ba8deba Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/64400
Diffstat (limited to 'chip/lm4/uart.c')
-rw-r--r--chip/lm4/uart.c25
1 files changed, 1 insertions, 24 deletions
diff --git a/chip/lm4/uart.c b/chip/lm4/uart.c
index 15b83e5551..17443d9848 100644
--- a/chip/lm4/uart.c
+++ b/chip/lm4/uart.c
@@ -139,28 +139,6 @@ static void uart_host_interrupt(void)
/* Must be same prio as LPC interrupt handler so they don't preempt */
DECLARE_IRQ(CONFIG_UART_HOST_IRQ, uart_host_interrupt, 2);
-/**
- * Configure GPIOs for the UART module.
- */
-static void configure_gpio(void)
-{
- /* UART0 RX and TX are GPIO PA0:1 alternate function 1 */
- gpio_set_alternate_function(LM4_GPIO_A, 0x03, 1);
-
-#if (CONFIG_UART_HOST == 1) && defined(CONFIG_UART_HOST_GPIOS_PC4_5)
- /* UART1 RX and TX are GPIO PC4:5 alternate function 2 */
- gpio_set_alternate_function(LM4_GPIO_C, 0x30, 2);
-#elif (CONFIG_UART_HOST == 1) && defined(CONFIG_UART_HOST_GPIOS_PB0_1)
- /* UART1 RX and TX are GPIO PB0:1 alternate function 1 */
- gpio_set_alternate_function(LM4_GPIO_B, 0x03, 1);
-#elif (CONFIG_UART_HOST == 2) && defined(CONFIG_UART_HOST_GPIOS_PG4_5)
- /* UART2 RX and TX are GPIO PG4:5 alternate function 1 */
- gpio_set_alternate_function(LM4_GPIO_G, 0x30, 1);
-#else
-#error "Must put Host UART GPIOs somewhere"
-#endif
-}
-
static void uart_config(int port)
{
/* Disable the port */
@@ -201,8 +179,7 @@ void uart_init(void)
LM4_SYSTEM_RCGCUART |= (1 << CONFIG_UART_HOST) | 1;
scratch = LM4_SYSTEM_RCGCUART;
- /* Configure GPIOs */
- configure_gpio();
+ gpio_config_module(MODULE_UART, 1);
/* Configure UARTs (identically) */
uart_config(0);