diff options
author | Randall Spangler <rspangler@chromium.org> | 2013-07-23 18:13:15 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-07-24 16:31:14 -0700 |
commit | e6f0c272a02d03a15f826b8c7282d0084c125b6b (patch) | |
tree | 35e57a253ef0dbd1692c06f57a3cdf9ed092d476 | |
parent | b13a2aed146c7e54c21fe5d84f0a3ff1989a612b (diff) | |
download | chrome-ec-e6f0c272a02d03a15f826b8c7282d0084c125b6b.tar.gz |
Clean up and document UART config options
No functional changes, just renaming config options.
BUG=chrome-os-partner:18343
BRANCH=none
TEST=build all platforms
Change-Id: I91584cb1f8990dd0f980abd32c04465a66243e71
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/63244
-rw-r--r-- | board/bds/board.h | 5 | ||||
-rw-r--r-- | board/bolt/board.h | 5 | ||||
-rw-r--r-- | board/daisy/board.h | 3 | ||||
-rw-r--r-- | board/falco/board.h | 5 | ||||
-rw-r--r-- | board/link/board.h | 5 | ||||
-rw-r--r-- | board/mccroskey/board.h | 3 | ||||
-rw-r--r-- | board/peppy/board.h | 5 | ||||
-rw-r--r-- | board/pit/board.h | 3 | ||||
-rw-r--r-- | board/puppy/board.h | 3 | ||||
-rw-r--r-- | board/slippy/board.h | 5 | ||||
-rw-r--r-- | board/snow/board.h | 3 | ||||
-rw-r--r-- | board/spring/board.h | 4 | ||||
-rw-r--r-- | board/wolf/board.h | 5 | ||||
-rw-r--r-- | chip/lm4/config_chip.h | 1 | ||||
-rw-r--r-- | chip/lm4/uart.c | 43 | ||||
-rw-r--r-- | chip/stm32/config-stm32l15x.h | 1 | ||||
-rw-r--r-- | chip/stm32/config_chip.h | 5 | ||||
-rw-r--r-- | chip/stm32/uart.c | 7 | ||||
-rw-r--r-- | common/console.c | 2 | ||||
-rw-r--r-- | common/uart_buffering.c | 17 | ||||
-rw-r--r-- | include/config.h | 43 | ||||
-rw-r--r-- | include/console.h | 3 |
22 files changed, 80 insertions, 96 deletions
diff --git a/board/bds/board.h b/board/bds/board.h index 98b0945515..ed25fac20c 100644 --- a/board/bds/board.h +++ b/board/bds/board.h @@ -37,9 +37,8 @@ enum adc_channel #define I2C_PORTS_USED 1 /* GPIOs for second UART port */ -#define CONFIG_HOST_UART 1 -#define CONFIG_HOST_UART_IRQ LM4_IRQ_UART1 -#define CONFIG_HOST_UART1_GPIOS_PB0_1 +#define CONFIG_UART_HOST 1 +#define CONFIG_UART_HOST_GPIOS_PB0_1 /* GPIO signal list */ enum gpio_signal { diff --git a/board/bolt/board.h b/board/bolt/board.h index 7d0b451611..0d9d6782bc 100644 --- a/board/bolt/board.h +++ b/board/bolt/board.h @@ -79,9 +79,8 @@ #define USB_PORT_COUNT 2 /* GPIOs for second UART port */ -#define CONFIG_HOST_UART 2 -#define CONFIG_HOST_UART_IRQ LM4_IRQ_UART2 -#define CONFIG_HOST_UART2_GPIOS_PG4_5 +#define CONFIG_UART_HOST 2 +#define CONFIG_UART_HOST_GPIOS_PG4_5 /* GPIO signal definitions. */ enum gpio_signal { diff --git a/board/daisy/board.h b/board/daisy/board.h index cbadd0464e..a0fb0bd168 100644 --- a/board/daisy/board.h +++ b/board/daisy/board.h @@ -11,9 +11,6 @@ /* 16 MHz SYSCLK clock frequency */ #define CPU_CLOCK 16000000 -/* Use USART1 as console serial port */ -#define CONFIG_CONSOLE_UART 1 - /* Optional features */ #define CONFIG_BATTERY_SMART #define CONFIG_BOARD_POST_GPIO_INIT diff --git a/board/falco/board.h b/board/falco/board.h index de500dd0d2..2b8874a91f 100644 --- a/board/falco/board.h +++ b/board/falco/board.h @@ -60,9 +60,8 @@ #define USB_PORT_COUNT 2 /* GPIOs for second UART port */ -#define CONFIG_HOST_UART 2 -#define CONFIG_HOST_UART_IRQ LM4_IRQ_UART2 -#define CONFIG_HOST_UART2_GPIOS_PG4_5 +#define CONFIG_UART_HOST 2 +#define CONFIG_UART_HOST_GPIOS_PG4_5 /* GPIO signal definitions. */ enum gpio_signal { diff --git a/board/link/board.h b/board/link/board.h index 82b68c56f8..30c8389213 100644 --- a/board/link/board.h +++ b/board/link/board.h @@ -84,9 +84,8 @@ enum adc_channel #define USB_CHARGE_PORT_COUNT 2 /* GPIOs for second UART port */ -#define CONFIG_HOST_UART 1 -#define CONFIG_HOST_UART_IRQ LM4_IRQ_UART1 -#define CONFIG_HOST_UART1_GPIOS_PC4_5 +#define CONFIG_UART_HOST 1 +#define CONFIG_UART_HOST_GPIOS_PC4_5 /* GPIO signal definitions. */ enum gpio_signal { diff --git a/board/mccroskey/board.h b/board/mccroskey/board.h index e5fa6c79e3..bc3578ae97 100644 --- a/board/mccroskey/board.h +++ b/board/mccroskey/board.h @@ -11,9 +11,6 @@ /* 48 MHz SYSCLK clock frequency */ #define CPU_CLOCK 48000000 -/* Use USART1 as console serial port */ -#define CONFIG_CONSOLE_UART 1 - /* Debug features */ #define CONFIG_I2C_DEBUG /* FIXME(dhendrix): remove this eventually */ #undef CONFIG_TASK_PROFILING diff --git a/board/peppy/board.h b/board/peppy/board.h index ac46d2a948..cf5ad95563 100644 --- a/board/peppy/board.h +++ b/board/peppy/board.h @@ -60,9 +60,8 @@ #define USB_PORT_COUNT 2 /* GPIOs for second UART port */ -#define CONFIG_HOST_UART 2 -#define CONFIG_HOST_UART_IRQ LM4_IRQ_UART2 -#define CONFIG_HOST_UART2_GPIOS_PG4_5 +#define CONFIG_UART_HOST 2 +#define CONFIG_UART_HOST_GPIOS_PG4_5 /* GPIO signal definitions. */ enum gpio_signal { diff --git a/board/pit/board.h b/board/pit/board.h index 036184c5ea..1c510b2565 100644 --- a/board/pit/board.h +++ b/board/pit/board.h @@ -8,9 +8,6 @@ #ifndef __BOARD_H #define __BOARD_H -/* Use USART1 as console serial port */ -#define CONFIG_CONSOLE_UART 1 - /* Optional features */ #define CONFIG_BATTERY_BQ20Z453 #define CONFIG_BATTERY_SMART diff --git a/board/puppy/board.h b/board/puppy/board.h index 39789080e4..9a1be1d9ac 100644 --- a/board/puppy/board.h +++ b/board/puppy/board.h @@ -8,9 +8,6 @@ #ifndef __BOARD_H #define __BOARD_H -/* Use USART1 as console serial port */ -#define CONFIG_CONSOLE_UART 1 - /* Optional features */ #define CONFIG_BATTERY_BQ20Z453 #define CONFIG_BATTERY_SMART diff --git a/board/slippy/board.h b/board/slippy/board.h index cbe72b5d32..3d7e7753bd 100644 --- a/board/slippy/board.h +++ b/board/slippy/board.h @@ -61,9 +61,8 @@ #define USB_PORT_COUNT 2 /* GPIOs for second UART port */ -#define CONFIG_HOST_UART 2 -#define CONFIG_HOST_UART_IRQ LM4_IRQ_UART2 -#define CONFIG_HOST_UART2_GPIOS_PG4_5 +#define CONFIG_UART_HOST 2 +#define CONFIG_UART_HOST_GPIOS_PG4_5 /* GPIO signal definitions. */ enum gpio_signal { diff --git a/board/snow/board.h b/board/snow/board.h index 32906b9ad6..5a5b3be161 100644 --- a/board/snow/board.h +++ b/board/snow/board.h @@ -11,9 +11,6 @@ /* 16 MHz SYSCLK clock frequency */ #define CPU_CLOCK 16000000 -/* Use USART1 as console serial port */ -#define CONFIG_CONSOLE_UART 1 - /* Debug features */ #undef CONFIG_TASK_PROFILING diff --git a/board/spring/board.h b/board/spring/board.h index 893ddc1b07..c74275ea07 100644 --- a/board/spring/board.h +++ b/board/spring/board.h @@ -11,9 +11,6 @@ /* 16 MHz SYSCLK clock frequency */ #define CPU_CLOCK 16000000 -/* Use USART1 as console serial port */ -#define CONFIG_CONSOLE_UART 1 -#define CONFIG_CONSOLE_RESTRICTED_INPUT /* Debug features */ #undef CONFIG_TASK_PROFILING @@ -27,6 +24,7 @@ #define CONFIG_CHIPSET_GAIA #endif #define CONFIG_CMD_PMU +#define CONFIG_CONSOLE_RESTRICTED_INPUT #define CONFIG_EXTPOWER_USB #define CONFIG_HOST_COMMAND_STATUS #define CONFIG_I2C diff --git a/board/wolf/board.h b/board/wolf/board.h index 7cbbd9c003..7ee3554b5b 100644 --- a/board/wolf/board.h +++ b/board/wolf/board.h @@ -53,9 +53,8 @@ #define USB_PORT_COUNT 2 /* GPIOs for second UART port */ -#define CONFIG_HOST_UART 2 -#define CONFIG_HOST_UART_IRQ LM4_IRQ_UART2 -#define CONFIG_HOST_UART2_GPIOS_PG4_5 +#define CONFIG_UART_HOST 2 +#define CONFIG_UART_HOST_GPIOS_PG4_5 /* GPIO signal definitions. */ enum gpio_signal { diff --git a/chip/lm4/config_chip.h b/chip/lm4/config_chip.h index c2ddbbb702..6dd030a5d1 100644 --- a/chip/lm4/config_chip.h +++ b/chip/lm4/config_chip.h @@ -13,6 +13,7 @@ #define CONFIG_IRQ_COUNT 132 /* Use a bigger console output buffer */ +#undef CONFIG_UART_TX_BUF_SIZE #define CONFIG_UART_TX_BUF_SIZE 8192 /* Interval between HOOK_TICK notifications */ diff --git a/chip/lm4/uart.c b/chip/lm4/uart.c index 1e7df2f0a3..15b83e5551 100644 --- a/chip/lm4/uart.c +++ b/chip/lm4/uart.c @@ -14,8 +14,7 @@ #include "uart.h" #include "util.h" -/* Baud rate for UARTs */ -#define BAUD_RATE 115200 +#define CONFIG_UART_HOST_IRQ CONCAT2(LM4_IRQ_UART, CONFIG_UART_HOST) static int init_done; @@ -114,17 +113,17 @@ DECLARE_IRQ(LM4_IRQ_UART0, uart_ec_interrupt, 1); static void uart_host_interrupt(void) { /* Clear transmit and receive interrupt status */ - LM4_UART_ICR(CONFIG_HOST_UART) = 0x70; + LM4_UART_ICR(CONFIG_UART_HOST) = 0x70; #ifdef CONFIG_LPC /* * If we have space in our FIFO and a character is pending in LPC, * handle that character. */ - if (!(LM4_UART_FR(CONFIG_HOST_UART) & 0x20) && lpc_comx_has_char()) { + if (!(LM4_UART_FR(CONFIG_UART_HOST) & 0x20) && lpc_comx_has_char()) { /* Copy the next byte then disable transmit interrupt */ - LM4_UART_DR(CONFIG_HOST_UART) = lpc_comx_get_char(); - LM4_UART_IM(CONFIG_HOST_UART) &= ~0x20; + LM4_UART_DR(CONFIG_UART_HOST) = lpc_comx_get_char(); + LM4_UART_IM(CONFIG_UART_HOST) &= ~0x20; } /* @@ -133,12 +132,12 @@ static void uart_host_interrupt(void) * because LPC is much faster than UART, and we don't have flow control * on the UART receive-side either. */ - if (!(LM4_UART_FR(CONFIG_HOST_UART) & 0x10)) - lpc_comx_put_char(LM4_UART_DR(CONFIG_HOST_UART)); + if (!(LM4_UART_FR(CONFIG_UART_HOST) & 0x10)) + lpc_comx_put_char(LM4_UART_DR(CONFIG_UART_HOST)); #endif } /* Must be same prio as LPC interrupt handler so they don't preempt */ -DECLARE_IRQ(CONFIG_HOST_UART_IRQ, uart_host_interrupt, 2); +DECLARE_IRQ(CONFIG_UART_HOST_IRQ, uart_host_interrupt, 2); /** * Configure GPIOs for the UART module. @@ -148,13 +147,13 @@ 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 defined(CONFIG_HOST_UART1_GPIOS_PC4_5) +#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 defined(CONFIG_HOST_UART1_GPIOS_PB0_1) +#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 defined(CONFIG_HOST_UART2_GPIOS_PG4_5) +#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 @@ -169,10 +168,10 @@ static void uart_config(int port) /* Use the internal oscillator */ LM4_UART_CC(port) = 0x1; /* Set the baud rate divisor */ - LM4_UART_IBRD(port) = (INTERNAL_CLOCK / 16) / BAUD_RATE; + LM4_UART_IBRD(port) = (INTERNAL_CLOCK / 16) / CONFIG_UART_BAUD_RATE; LM4_UART_FBRD(port) = - (((INTERNAL_CLOCK / 16) % BAUD_RATE) * 64 - + BAUD_RATE / 2) / BAUD_RATE; + (((INTERNAL_CLOCK / 16) % CONFIG_UART_BAUD_RATE) * 64 + + CONFIG_UART_BAUD_RATE / 2) / CONFIG_UART_BAUD_RATE; /* * 8-N-1, FIFO enabled. Must be done after setting * the divisor for the new divisor to take effect. @@ -199,7 +198,7 @@ void uart_init(void) volatile uint32_t scratch __attribute__((unused)); /* Enable UART0 and Host UART and delay a few clocks */ - LM4_SYSTEM_RCGCUART |= (1 << CONFIG_HOST_UART) | 1; + LM4_SYSTEM_RCGCUART |= (1 << CONFIG_UART_HOST) | 1; scratch = LM4_SYSTEM_RCGCUART; /* Configure GPIOs */ @@ -207,7 +206,7 @@ void uart_init(void) /* Configure UARTs (identically) */ uart_config(0); - uart_config(CONFIG_HOST_UART); + uart_config(CONFIG_UART_HOST); /* * Enable interrupts for UART0 only. Host UART will have to wait @@ -224,18 +223,18 @@ void uart_init(void) void uart_comx_enable(void) { - uart_clear_rx_fifo(CONFIG_HOST_UART); - task_enable_irq(CONFIG_HOST_UART_IRQ); + uart_clear_rx_fifo(CONFIG_UART_HOST); + task_enable_irq(CONFIG_UART_HOST_IRQ); } int uart_comx_putc_ok(void) { - if (LM4_UART_FR(CONFIG_HOST_UART) & 0x20) { + if (LM4_UART_FR(CONFIG_UART_HOST) & 0x20) { /* * FIFO is full, so enable transmit interrupt to let us know * when it empties. */ - LM4_UART_IM(CONFIG_HOST_UART) |= 0x20; + LM4_UART_IM(CONFIG_UART_HOST) |= 0x20; return 0; } else { return 1; @@ -244,7 +243,7 @@ int uart_comx_putc_ok(void) void uart_comx_putc(int c) { - LM4_UART_DR(CONFIG_HOST_UART) = c; + LM4_UART_DR(CONFIG_UART_HOST) = c; } /*****************************************************************************/ diff --git a/chip/stm32/config-stm32l15x.h b/chip/stm32/config-stm32l15x.h index ad3e95e099..eef90576d4 100644 --- a/chip/stm32/config-stm32l15x.h +++ b/chip/stm32/config-stm32l15x.h @@ -47,6 +47,7 @@ #define CONFIG_IRQ_COUNT 45 /* Lots of RAM, so use bigger UART buffer */ +#undef CONFIG_UART_TX_BUF_SIZE #define CONFIG_UART_TX_BUF_SIZE 2048 /* Flash erases to 0, not 1 */ diff --git a/chip/stm32/config_chip.h b/chip/stm32/config_chip.h index c34a683f7c..a06d590e31 100644 --- a/chip/stm32/config_chip.h +++ b/chip/stm32/config_chip.h @@ -6,7 +6,10 @@ #ifndef __CROS_EC_CONFIG_CHIP_H #define __CROS_EC_CONFIG_CHIP_H -/* use variant specific configuration for flash / UART / IRQ */ +/* Default to UART 1 for EC console */ +#define CONFIG_UART_CONSOLE 1 + +/* Use variant specific configuration for flash / UART / IRQ */ #if defined(CHIP_VARIANT_stm32l15x) #include "config-stm32l15x.h" #elif defined(CHIP_VARIANT_stm32f100) diff --git a/chip/stm32/uart.c b/chip/stm32/uart.c index cade7542f8..77b5d93623 100644 --- a/chip/stm32/uart.c +++ b/chip/stm32/uart.c @@ -13,13 +13,8 @@ #include "uart.h" #include "util.h" -/* Baud rate for UARTs */ -#ifndef CONFIG_UART_BAUD_RATE -#define CONFIG_UART_BAUD_RATE 115200 -#endif - /* Console USART index */ -#define UARTN CONFIG_CONSOLE_UART +#define UARTN CONFIG_UART_CONSOLE static int init_done; /* Initialization done? */ static int should_stop; /* Last TX control action */ diff --git a/common/console.c b/common/console.c index 077bd28b13..dd12613f9a 100644 --- a/common/console.c +++ b/common/console.c @@ -17,7 +17,7 @@ #define PROMPT "> " /* Current console command line */ -static char input_buf[CONSOLE_INPUT_LINE_SIZE]; +static char input_buf[CONFIG_CONSOLE_INPUT_LINE_SIZE]; /** * Split a line of input into words. diff --git a/common/uart_buffering.c b/common/uart_buffering.c index 277ae90a16..42d9d4e487 100644 --- a/common/uart_buffering.c +++ b/common/uart_buffering.c @@ -16,19 +16,6 @@ #include "uart.h" #include "util.h" -/* - * Transmit and receive buffer sizes must be power of 2 for the macros below - * to work properly. - */ -#ifndef CONFIG_UART_TX_BUF_SIZE -#define CONFIG_UART_TX_BUF_SIZE 512 -#endif - -#ifndef CONFIG_UART_RX_BUF_SIZE -/* Must be larger than CONSOLE_INPUT_LINE_SIZE to copy and paste scripts */ -#define CONFIG_UART_RX_BUF_SIZE 128 -#endif - #define HISTORY_SIZE 8 /* Macros to advance in the circular buffers */ @@ -52,7 +39,7 @@ static volatile int tx_buf_tail; static volatile char rx_buf[CONFIG_UART_RX_BUF_SIZE]; static volatile int rx_buf_head; static volatile int rx_buf_tail; -static volatile char rx_cur_buf[CONSOLE_INPUT_LINE_SIZE]; +static volatile char rx_cur_buf[CONFIG_CONSOLE_INPUT_LINE_SIZE]; static volatile int rx_cur_buf_tail; static volatile int rx_cur_buf_head; static volatile int rx_cur_buf_ptr; @@ -232,7 +219,7 @@ static void insert_char(char c) int ptr; /* On overflow, discard input */ - if (rx_cur_buf_head == CONSOLE_INPUT_LINE_SIZE && c != '\n') + if (rx_cur_buf_head == CONFIG_CONSOLE_INPUT_LINE_SIZE && c != '\n') return; /* Move buffer ptr to the end if 'c' is new line */ diff --git a/include/config.h b/include/config.h index ee667e4cd3..e6a2166add 100644 --- a/include/config.h +++ b/include/config.h @@ -129,8 +129,10 @@ */ #define CONFIG_CONSOLE_CMDHELP +/* Max length of a single line of input */ +#define CONFIG_CONSOLE_INPUT_LINE_SIZE 80 + #undef CONFIG_CONSOLE_RESTRICTED_INPUT -#undef CONFIG_CONSOLE_UART /*****************************************************************************/ /* @@ -222,11 +224,6 @@ #undef CONFIG_HOSTCMD #undef CONFIG_HOST_COMMAND_STATUS #undef CONFIG_HOST_EMU -#undef CONFIG_HOST_UART -#undef CONFIG_HOST_UART1_GPIOS_PB0_1 -#undef CONFIG_HOST_UART1_GPIOS_PC4_5 -#undef CONFIG_HOST_UART2_GPIOS_PG4_5 -#undef CONFIG_HOST_UART_IRQ #undef CONFIG_I2C #undef CONFIG_I2C_ARBITRATION @@ -362,9 +359,37 @@ #undef CONFIG_TEMP_SENSOR_G781 #undef CONFIG_TEMP_SENSOR_TMP006 -#undef CONFIG_UART_BAUD_RATE -#undef CONFIG_UART_RX_BUF_SIZE -#undef CONFIG_UART_TX_BUF_SIZE +/*****************************************************************************/ +/* UART config */ + +/* Baud rate for UARTs */ +#define CONFIG_UART_BAUD_RATE 115200 + +/* UART index (number) for EC console */ +#undef CONFIG_UART_CONSOLE + +/* UART index (number) for host UART, if present */ +#undef CONFIG_UART_HOST + +/* GPIOs used by host UART. Choose at most one. */ +#undef CONFIG_UART_HOST_GPIOS_PB0_1 +#undef CONFIG_UART_HOST_GPIOS_PC4_5 +#undef CONFIG_UART_HOST_GPIOS_PG4_5 + +/* + * UART transmit buffer size in bytes. Must be a power of 2 for macros in + * common/uart_buffering.c to work properly. + */ +#define CONFIG_UART_TX_BUF_SIZE 512 + +/* + * UART receive buffer size in bytes. Must be a power of 2 for macros in + * common/uart_buffering.c to work properly. Must be larger than + * CONFIG_CONSOLE_INPUT_LINE_SIZE to copy and paste scripts. + */ +#define CONFIG_UART_RX_BUF_SIZE 128 + +/*****************************************************************************/ #undef CONFIG_USB_PORT_POWER_DUMB #undef CONFIG_USB_PORT_POWER_SMART diff --git a/include/console.h b/include/console.h index 90e46bd8cf..827517eee8 100644 --- a/include/console.h +++ b/include/console.h @@ -58,9 +58,6 @@ enum console_channel { /* Mask to use to enable all channels */ #define CC_ALL 0xffffffffUL -/* Max length of a single line of input */ -#define CONSOLE_INPUT_LINE_SIZE 80 - /** * Put a string to the console channel. * |