
Hi Stephen,
On Wed, Dec 12, 2012 at 3:23 PM, Stephen Warren swarren@wwwdotorg.org wrote:
From: Stephen Warren swarren@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@nvidia.com
This seems reasonable in the interim while we are hard-coding things but needing more flexibility. How do you plan to configure the actual address - is it with the ODM data or FDT?
One question though - is it not possible to select the correct port number using environment (say) rather than changing the address of an existing port? After all, I think we can assume that all available ports are in the array. Or can we?
Regards, Simon
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