From patchwork Sat Apr 22 10:27:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lokesh Vutla X-Patchwork-Id: 753754 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3w984l01d0z9s78 for ; Sat, 22 Apr 2017 20:30:13 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="P7ZWcPZH"; dkim-atps=neutral Received: by lists.denx.de (Postfix, from userid 105) id 5AC08C21C65; Sat, 22 Apr 2017 10:30:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E9088C21BE6; Sat, 22 Apr 2017 10:29:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AD365C21BE6; Sat, 22 Apr 2017 10:29:57 +0000 (UTC) Received: from lelnx194.ext.ti.com (lelnx194.ext.ti.com [198.47.27.80]) by lists.denx.de (Postfix) with ESMTPS id EA66FC21BE5 for ; Sat, 22 Apr 2017 10:29:56 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id v3MATrG1005229; Sat, 22 Apr 2017 05:29:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1492856993; bh=9DqX8bYYjhOA3j8X4PoV63N9DI5zWYJj6gntDsUTPIs=; h=From:To:CC:Subject:Date; b=P7ZWcPZHl6Ay2AA/yq1eEgw0dfMxQk2VpcoisZCssYNRT528rExKVDeNaMJdIrx3J 1VfmhsZAOhvzHe2lADCBFEZV3MIKHpcdarZDxApZ83C5mahv0tlbpqd2O8WDAcqZcx q21pvoD5/qr38Bk8tkz7AsczbCD2hl2+YUg6vZys= Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v3MATrbB022581; Sat, 22 Apr 2017 05:29:53 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Sat, 22 Apr 2017 05:29:52 -0500 Received: from a0131933.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v3MAToFL015239; Sat, 22 Apr 2017 05:29:51 -0500 From: Lokesh Vutla To: Tom Rini , Simon Glass , Date: Sat, 22 Apr 2017 15:57:25 +0530 Message-ID: <20170422102725.1354-1-lokeshvutla@ti.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Cc: Tero Kristo Subject: [U-Boot] [RFC PATCH] serial: omap: Support debug UART X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add debug UART functions to permit omap specific ns16550 to provide an early debug UART. This is mostly in common with DEBUG_UART_NS16550 except for Mode definition register which is required for selecting UART mode(16x auto-baud or 13x mode). Signed-off-by: Lokesh Vutla Reviewed-by: Simon Glass Reviewed-by: Tom Rini --- - I understand it is duplication of code, but I guess the idea is not to use NS16550_init() as it has lot of ifdefs. Please advice if this can be improved. drivers/serial/Kconfig | 7 +++++++ drivers/serial/ns16550.c | 47 ++++++++++++++++++++++++++++++++++++----------- include/debug_uart.h | 11 +++++++++++ 3 files changed, 54 insertions(+), 11 deletions(-) diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index c0ec2ec2e4..5db9ec744e 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -238,6 +238,13 @@ config DEBUG_UART_UNIPHIER driver will be available until the real driver-model serial is running. +config DEBUG_UART_OMAP + bool "OMAP uart" + help + Select this to enable a debug UART using the omap ns16550 driver. + You will need to provide parameters to make this work. The driver + will be available until the real driver model serial is running. + endchoice config DEBUG_UART_BASE diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index 4f86780cb1..ca55df78b7 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c @@ -246,17 +246,6 @@ int NS16550_tstc(NS16550_t com_port) #include -#define serial_dout(reg, value) \ - serial_out_shift((char *)com_port + \ - ((char *)reg - (char *)com_port) * \ - (1 << CONFIG_DEBUG_UART_SHIFT), \ - CONFIG_DEBUG_UART_SHIFT, value) -#define serial_din(reg) \ - serial_in_shift((char *)com_port + \ - ((char *)reg - (char *)com_port) * \ - (1 << CONFIG_DEBUG_UART_SHIFT), \ - CONFIG_DEBUG_UART_SHIFT) - static inline void _debug_uart_init(void) { struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; @@ -293,6 +282,42 @@ DEBUG_UART_FUNCS #endif +#ifdef CONFIG_DEBUG_UART_OMAP + +#include + +static inline void _debug_uart_init(void) +{ + struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; + int baud_divisor; + + baud_divisor = ns16550_calc_divisor(com_port, CONFIG_DEBUG_UART_CLOCK, + CONFIG_BAUDRATE); + serial_dout(&com_port->ier, CONFIG_SYS_NS16550_IER); + serial_dout(&com_port->mdr1, 0x7); + serial_dout(&com_port->mcr, UART_MCRVAL); + serial_dout(&com_port->fcr, UART_FCR_DEFVAL); + + serial_dout(&com_port->lcr, UART_LCR_BKSE | UART_LCRVAL); + serial_dout(&com_port->dll, baud_divisor & 0xff); + serial_dout(&com_port->dlm, (baud_divisor >> 8) & 0xff); + serial_dout(&com_port->lcr, UART_LCRVAL); + serial_dout(&com_port->mdr1, 0x0); +} + +static inline void _debug_uart_putc(int ch) +{ + struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; + + while (!(serial_din(&com_port->lsr) & UART_LSR_THRE)) + ; + serial_dout(&com_port->thr, ch); +} + +DEBUG_UART_FUNCS + +#endif + #ifdef CONFIG_DM_SERIAL static int ns16550_serial_putc(struct udevice *dev, const char ch) { diff --git a/include/debug_uart.h b/include/debug_uart.h index 2980ae6200..6f0b0c5e15 100644 --- a/include/debug_uart.h +++ b/include/debug_uart.h @@ -111,6 +111,17 @@ void printhex8(uint value); #define _DEBUG_UART_ANNOUNCE #endif +#define serial_dout(reg, value) \ + serial_out_shift((char *)com_port + \ + ((char *)reg - (char *)com_port) * \ + (1 << CONFIG_DEBUG_UART_SHIFT), \ + CONFIG_DEBUG_UART_SHIFT, value) +#define serial_din(reg) \ + serial_in_shift((char *)com_port + \ + ((char *)reg - (char *)com_port) * \ + (1 << CONFIG_DEBUG_UART_SHIFT), \ + CONFIG_DEBUG_UART_SHIFT) + /* * Now define some functions - this should be inserted into the serial driver */