Patrick Georgi submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Marc Jones: Looks good to me, approved Jonathan Zhang: Looks good to me, but someone else must approve
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>
---
M src/console/Kconfig
M src/include/console/uart.h
2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/src/console/Kconfig b/src/console/Kconfig
index 283488c..548b701 100644
--- a/src/console/Kconfig
+++ b/src/console/Kconfig
@@ -58,6 +58,14 @@
comment "device-specific UART"
depends on HAVE_UART_SPECIAL

+config OVERRIDE_UART_FOR_CONSOLE
+ bool
+ help
+ Set to "y" when the platform overrides the index of uart port by providing
+ a get_uart_for_console routine.
+
+if !OVERRIDE_UART_FOR_CONSOLE
+
config UART_FOR_CONSOLE
int
prompt "Index for UART port to use for console" if !FIXED_UART_FOR_CONSOLE
@@ -87,6 +95,8 @@
comment "Serial port base address = 0x2e8"
depends on DRIVERS_UART_8250IO && UART_FOR_CONSOLE = 3

+endif
+
config UART_OVERRIDE_BAUDRATE
bool
help
diff --git a/src/include/console/uart.h b/src/include/console/uart.h
index 6126a89..2e23d43 100644
--- a/src/include/console/uart.h
+++ b/src/include/console/uart.h
@@ -20,6 +20,18 @@
}
#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 @@
#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) {}

To view, visit change 45405. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I2079bd1e5ffa209553383b6aafe3b8724849ba2a
Gerrit-Change-Number: 45405
Gerrit-PatchSet: 7
Gerrit-Owner: Bryant Ou <bryant.ou.q@gmail.com>
Gerrit-Reviewer: Jonathan Zhang <jonzhang@fb.com>
Gerrit-Reviewer: Marc Jones <marc@marcjonesconsulting.com>
Gerrit-Reviewer: Patrick Georgi <pgeorgi@google.com>
Gerrit-Reviewer: Patrick Rudolph <patrick.rudolph@9elements.com>
Gerrit-Reviewer: Philipp Deppenwiese <philipp.deppenwiese@9elements.com>
Gerrit-Reviewer: Ryback Hung <ryback.hung%quantatw.com@gtempaccount.com>
Gerrit-Reviewer: Tim Chu <Tim.Chu@quantatw.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Aaron Durbin <adurbin@chromium.org>
Gerrit-CC: Angel Pons <th3fanbus@gmail.com>
Gerrit-CC: Julius Werner <jwerner@chromium.org>
Gerrit-CC: Martin Roth <martinroth@google.com>
Gerrit-CC: Nico Huber <nico.h@gmx.de>
Gerrit-CC: Paul Menzel <paulepanter@users.sourceforge.net>
Gerrit-MessageType: merged