From patchwork Wed Dec 12 23:23:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 205685 X-Patchwork-Delegate: wd@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 0B8572C008A for ; Thu, 13 Dec 2012 10:23:25 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 80AF54A1DF; Thu, 13 Dec 2012 00:23:23 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id a9yXarMAjjKS; Thu, 13 Dec 2012 00:23:23 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DDABF4A1D4; Thu, 13 Dec 2012 00:23:21 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9E2E24A1D4 for ; Thu, 13 Dec 2012 00:23:19 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rJNHNXH3ks1J for ; Thu, 13 Dec 2012 00:23:19 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from avon.wwwdotorg.org (avon.wwwdotorg.org [70.85.31.133]) by theia.denx.de (Postfix) with ESMTPS id 02EA84A1CD for ; Thu, 13 Dec 2012 00:23:17 +0100 (CET) Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id EA32662DF; Wed, 12 Dec 2012 16:25:55 -0700 (MST) Received: from swarren-lx1.nvidia.com (localhost [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id 2FBCFE40EB; Wed, 12 Dec 2012 16:23:14 -0700 (MST) From: Stephen Warren To: u-boot@lists.denx.de, Tom Rini Date: Wed, 12 Dec 2012 16:23:10 -0700 Message-Id: <1355354590-10023-1-git-send-email-swarren@wwwdotorg.org> X-Mailer: git-send-email 1.7.10.4 X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.96.5 at avon.wwwdotorg.org X-Virus-Status: Clean Cc: Stephen Warren , Tom Warren Subject: [U-Boot] [PATCH] ns16550: allow UART address to be set dynamically X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Stephen Warren 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 --- 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);