[U-Boot] [PATCH] ns16550: allow UART address to be set dynamically

Stephen Warren swarren at wwwdotorg.org
Thu Dec 13 00:23:10 CET 2012


From: Stephen Warren <swarren at nvidia.com>

A single U-Boot binary may support multiple very similar boards. These
boards may use different UARTs for the main debug console. Hence, it is
impossible to #define CONFIG_SYS_NS16550_COM1 to some static UART
address, since the true value may only be determined at run-time, after
identifying the actual hardware. Provide an API for boards to call to
set the actual address of the UART, e.g. from spl_board_init() or
board_early_init_f().

Signed-off-by: Stephen Warren <swarren at nvidia.com>
---
Note: I have a Tegra patch that will depend on this functionality. I'd
like to see the patch applied through the Tegra tree if possible, or if
not, quickly pushed into u-boot/master or u-boot/next so Tom Warren can
base a Tegra branch on top of it easily without delay.

 drivers/serial/serial_ns16550.c |    5 +++++
 include/ns16550.h               |    1 +
 2 files changed, 6 insertions(+)

diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index fc01a3c..fc8253b 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -166,6 +166,11 @@ static int calc_divisor (NS16550_t port)
 		(MODE_X_DIV * gd->baudrate);
 }
 
+void NS16550_set_dynamic_address(int port, NS16550_t com_port)
+{
+	PORT = com_port;
+}
+
 void
 _serial_putc(const char c,const int port)
 {
diff --git a/include/ns16550.h b/include/ns16550.h
index 51cb5b4..6d7483f 100644
--- a/include/ns16550.h
+++ b/include/ns16550.h
@@ -171,6 +171,7 @@ typedef struct NS16550 *NS16550_t;
 /* useful defaults for LCR */
 #define UART_LCR_8N1	0x03
 
+void NS16550_set_dynamic_address(int port, NS16550_t com_port);
 void NS16550_init(NS16550_t com_port, int baud_divisor);
 void NS16550_putc(NS16550_t com_port, char c);
 char NS16550_getc(NS16550_t com_port);
-- 
1.7.10.4



More information about the U-Boot mailing list