From patchwork Tue Aug 30 08:43:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenyou Yang X-Patchwork-Id: 664058 X-Patchwork-Delegate: andreas.biessmann@googlemail.com 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 3sNhsj6bW2z9s4n for ; Tue, 30 Aug 2016 18:44:57 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 27942A759A; Tue, 30 Aug 2016 10:44:53 +0200 (CEST) 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 DEtSdOZoP9Uj; Tue, 30 Aug 2016 10:44:53 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 49164A7574; Tue, 30 Aug 2016 10:44:48 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6E56EA7534 for ; Tue, 30 Aug 2016 10:44:43 +0200 (CEST) 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 TXPj8yaa2VNx for ; Tue, 30 Aug 2016 10:44:43 +0200 (CEST) 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 ussmtp01.atmel.com (nasmtp01.atmel.com [192.199.1.245]) by theia.denx.de (Postfix) with ESMTPS id 614EF4BD3D for ; Tue, 30 Aug 2016 10:44:38 +0200 (CEST) Received: from apsmtp01.atmel.com (10.168.254.31) by DVREDG01.corp.atmel.com (10.42.103.30) with Microsoft SMTP Server (TLS) id 14.3.235.1; Tue, 30 Aug 2016 02:44:33 -0600 Received: from shaarm01.corp.atmel.com (10.168.254.13) by apsmtp01.atmel.com (10.168.254.31) with Microsoft SMTP Server id 14.3.235.1; Tue, 30 Aug 2016 16:52:50 +0800 From: Wenyou Yang To: U-Boot Mailing List Date: Tue, 30 Aug 2016 16:43:37 +0800 Message-ID: <1472546617-13425-3-git-send-email-wenyou.yang@atmel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1472546617-13425-1-git-send-email-wenyou.yang@atmel.com> References: <1472546617-13425-1-git-send-email-wenyou.yang@atmel.com> MIME-Version: 1.0 Cc: Stephen Warren Subject: [U-Boot] [PATCH v1 2/2] serial: atmel_usart: Support enable an early debug UART X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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 support to enable an early debug UART for debugging. Signed-off-by: Wenyou Yang Reviewed-by: Simon Glass --- drivers/serial/Kconfig | 7 +++++++ drivers/serial/atmel_usart.c | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index a6035dc..b8ecd80 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -98,6 +98,13 @@ config DEBUG_UART_AR933X driver will be available until the real driver model serial is running. +config DEBUG_UART_ATMEL + bool "Atmel USART" + help + Select this to enable a debug UART using the atmel usart driver. You + will need to provide parameters to make this work. The driver will + be available until the real driver-model serial is running. + config DEBUG_UART_NS16550 bool "ns16550" help diff --git a/drivers/serial/atmel_usart.c b/drivers/serial/atmel_usart.c index e450135..7674f97 100644 --- a/drivers/serial/atmel_usart.c +++ b/drivers/serial/atmel_usart.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -226,3 +227,24 @@ U_BOOT_DRIVER(serial_atmel) = { .priv_auto_alloc_size = sizeof(struct atmel_serial_priv), }; #endif + +#ifdef CONFIG_DEBUG_UART_ATMEL +static inline void _debug_uart_init(void) +{ + atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_DEBUG_UART_BASE; + + atmel_serial_setbrg_internal(usart, 0, CONFIG_BAUDRATE); +} + +static inline void _debug_uart_putc(int ch) +{ + atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_DEBUG_UART_BASE; + + while (!(readl(&usart->csr) & USART3_BIT(TXRDY))) + ; + + writel(ch, &usart->thr); +} + +DEBUG_UART_FUNCS +#endif