aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorBryant Ou <Bryant.Ou.Q@gmail.com>2020-09-14 23:41:41 -0700
committerPatrick Georgi <pgeorgi@google.com>2020-11-09 07:46:10 +0000
commit0ee920bf6439d5f404a77971a5f7e3fa04339924 (patch)
tree9c970f7a3ed09d8db32b82b90befa6842c215b9b /src/include
parent12985c1dd78b4a641ea7bd1ff34f1d7d4361d309 (diff)
console: Override uart base address
Add a new CONFIG_OVERRIDE_UART_FOR_CONSOLE token to override the index of uart port, platform use a get_uart_for_console routine to decide what index value should be used for console. Signed-off-by: Bryant Ou <Bryant.Ou.Q@gmail.com> Change-Id: I2079bd1e5ffa209553383b6aafe3b8724849ba2a Reviewed-on: https://review.coreboot.org/c/coreboot/+/45405 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Marc Jones <marc@marcjonesconsulting.com> Reviewed-by: Jonathan Zhang <jonzhang@fb.com>
Diffstat (limited to 'src/include')
-rw-r--r--src/include/console/uart.h18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/include/console/uart.h b/src/include/console/uart.h
index 6126a89d57..2e23d43a4e 100644
--- a/src/include/console/uart.h
+++ b/src/include/console/uart.h
@@ -20,6 +20,18 @@ static inline unsigned int get_uart_baudrate(void)
}
#endif
+#if CONFIG(OVERRIDE_UART_FOR_CONSOLE)
+/* Return the index of uart port, define this in your platform
+ * when need to use variables to override the index.
+ */
+unsigned int get_uart_for_console(void);
+#else
+static inline unsigned int get_uart_for_console(void)
+{
+ return CONFIG_UART_FOR_CONSOLE;
+}
+#endif
+
/* Returns the divisor value for a given baudrate.
* The formula to satisfy is:
* refclk / divisor = baudrate * oversample
@@ -56,15 +68,15 @@ void oxford_remap(unsigned int new_base);
#if __CONSOLE_SERIAL_ENABLE__
static inline void __uart_init(void)
{
- uart_init(CONFIG_UART_FOR_CONSOLE);
+ uart_init(get_uart_for_console());
}
static inline void __uart_tx_byte(u8 data)
{
- uart_tx_byte(CONFIG_UART_FOR_CONSOLE, data);
+ uart_tx_byte(get_uart_for_console(), data);
}
static inline void __uart_tx_flush(void)
{
- uart_tx_flush(CONFIG_UART_FOR_CONSOLE);
+ uart_tx_flush(get_uart_for_console());
}
#else
static inline void __uart_init(void) {}