From patchwork Mon May 13 04:20:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sonic Zhang X-Patchwork-Id: 243263 X-Patchwork-Delegate: sonic.adi@gmail.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 060F02C00A4 for ; Mon, 13 May 2013 14:25:03 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 62A3A4A029; Mon, 13 May 2013 06:24:48 +0200 (CEST) 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 NXsZ0Lsy-vIP; Mon, 13 May 2013 06:24:48 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 782884A037; Mon, 13 May 2013 06:24:33 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CF7714A028 for ; Mon, 13 May 2013 06:24:30 +0200 (CEST) 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 FnQ074PV4IdH for ; Mon, 13 May 2013 06:24:26 +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 am1outboundpool.messaging.microsoft.com (am1ehsobe005.messaging.microsoft.com [213.199.154.208]) by theia.denx.de (Postfix) with ESMTPS id 3FD1D4A029 for ; Mon, 13 May 2013 06:23:27 +0200 (CEST) Received: from mail86-am1-R.bigfish.com (10.3.201.228) by AM1EHSOBE018.bigfish.com (10.3.207.140) with Microsoft SMTP Server id 14.1.225.23; Mon, 13 May 2013 04:23:25 +0000 Received: from mail86-am1 (localhost [127.0.0.1]) by mail86-am1-R.bigfish.com (Postfix) with ESMTP id E16D440331; Mon, 13 May 2013 04:23:25 +0000 (UTC) X-Forefront-Antispam-Report: CIP:137.71.25.55; KIP:(null); UIP:(null); IPV:NLI; H:nwd2mta1.analog.com; RD:nwd2mail10.analog.com; EFVD:NLI X-SpamScore: 17 X-BigFish: VS17(z1039mzzz1f42h1ee6h1ce5h1fdah1202h1fd0h1e76h1d1ah1cabh1d2ah1fc6hzz8275bhz2ei87h2a8h668h839hd24he5bh1288h12a5h12a9h12bdh12e5h1354h137ah139eh13b6h13eah1441h1504h1537h15a8h162dh1631h1758h17eeh1898h18e1h1946h19b5h1b0ah1d0ch1d2eh1d3fhff4m1355m129fi1155h) Received-SPF: neutral (mail86-am1: 137.71.25.55 is neither permitted nor denied by domain of gmail.com) client-ip=137.71.25.55; envelope-from=sonic.adi@gmail.com; helo=nwd2mta1.analog.com ; 1.analog.com ; X-FB-DOMAIN-IP-MATCH: fail Received: from mail86-am1 (localhost.localdomain [127.0.0.1]) by mail86-am1 (MessageSwitch) id 1368419003386197_3520; Mon, 13 May 2013 04:23:23 +0000 (UTC) Received: from AM1EHSMHS010.bigfish.com (unknown [10.3.201.240]) by mail86-am1.bigfish.com (Postfix) with ESMTP id 5BD8E48004A; Mon, 13 May 2013 04:23:23 +0000 (UTC) Received: from nwd2mta1.analog.com (137.71.25.55) by AM1EHSMHS010.bigfish.com (10.3.207.110) with Microsoft SMTP Server (TLS) id 14.1.225.23; Mon, 13 May 2013 04:23:23 +0000 Received: from NWD2HUBCAS6.ad.analog.com (nwd2hubcas6.ad.analog.com [10.64.72.159]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id r4D4MfQh018892 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Sun, 12 May 2013 21:22:41 -0700 Received: from zeus.spd.analog.com (10.64.82.11) by NWD2HUBCAS6.ad.analog.com (10.64.72.159) with Microsoft SMTP Server id 14.3.123.3; Mon, 13 May 2013 00:22:10 -0400 Received: from linux.site ([10.99.22.20]) by zeus.spd.analog.com (8.14.6/8.14.6) with ESMTP id r4D4M99G011126; Mon, 13 May 2013 00:22:09 -0400 Received: from localhost.localdomain (unknown [10.99.22.72]) by linux.site (Postfix) with ESMTP id 5BBBE4264510; Sun, 12 May 2013 14:55:43 -0600 (MDT) From: Sonic Zhang To: Date: Mon, 13 May 2013 12:20:15 +0800 Message-ID: <1368418817-27670-1-git-send-email-sonic.adi@gmail.com> X-Mailer: git-send-email 1.7.0.4 MIME-Version: 1.0 Cc: u-boot-devel@blackfin.uclinux.org, Sonic Zhang Subject: [U-Boot] [PATCH v1 1/3] blackfin: Enable early print via the generic serial API. 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: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Sonic Zhang Remove blackfin specific implementation of the generic serial API when early print macro is defined. In BFIN_BOOT_BYPASS mode, don't call generic serial_puts, because early print in bypass mode is running before code binary is relocated to the link address. Signed-off-by: Sonic Zhang --- arch/blackfin/cpu/serial.c | 71 ++++++++++++------------------------ arch/blackfin/cpu/serial.h | 10 +++--- include/configs/bfin_adi_common.h | 3 -- 3 files changed, 29 insertions(+), 55 deletions(-) diff --git a/arch/blackfin/cpu/serial.c b/arch/blackfin/cpu/serial.c index 36d2a5c..89290d6 100644 --- a/arch/blackfin/cpu/serial.c +++ b/arch/blackfin/cpu/serial.c @@ -197,13 +197,16 @@ static void uart_loop(uint32_t uart_base, int state) static inline void __serial_set_baud(uint32_t uart_base, uint32_t baud) { +#ifdef CONFIG_DEBUG_EARLY_SERIAL + serial_early_set_baud(uart_base, baud); +#else uint16_t divisor = (get_uart_clk() + (baud * 8)) / (baud * 16) - ANOMALY_05000230; /* Program the divisor to get the baud rate we want */ serial_set_divisor(uart_base, divisor); +#endif } -#ifdef CONFIG_SYS_BFIN_UART static void uart_puts(uint32_t uart_base, const char *s) { @@ -313,65 +316,39 @@ void bfin_serial_initialize(void) #endif } -#else - -/* Symbol for our assembly to call. */ -void serial_set_baud(uint32_t baud) -{ - serial_early_set_baud(UART_BASE, baud); -} - -/* Symbol for common u-boot code to call. - * Setup the baudrate (brg: baudrate generator). - */ -void serial_setbrg(void) +#ifdef CONFIG_DEBUG_EARLY_SERIAL +inline void uart_early_putc(uint32_t uart_base, const char c) { - serial_set_baud(gd->baudrate); -} - -/* Symbol for our assembly to call. */ -void serial_initialize(void) -{ - serial_early_init(UART_BASE); -} - -/* Symbol for common u-boot code to call. */ -int serial_init(void) -{ - serial_initialize(); - serial_setbrg(); - uart_lsr_clear(UART_BASE); - return 0; -} + /* send a \r for compatibility */ + if (c == '\n') + uart_early_putc(uart_base, '\r'); -int serial_tstc(void) -{ - return uart_tstc(UART_BASE); -} + /* wait for the hardware fifo to clear up */ + while (!(_lsr_read(pUART) & THRE)) + continue; -int serial_getc(void) -{ - return uart_getc(UART_BASE); + /* queue the character for transmission */ + bfin_write(&pUART->thr, c); + SSYNC(); } -void serial_putc(const char c) +void uart_early_puts(const char *s) { - uart_putc(UART_BASE, c); + while (*s) + uart_early_putc(UART_BASE, *s++); } -void serial_puts(const char *s) +/* Symbol for our assembly to call. */ +void _serial_early_set_baud(uint32_t baud) { - while (*s) - serial_putc(*s++); + serial_early_set_baud(UART_BASE, baud); } -LOOP( -void serial_loop(int state) +/* Symbol for our assembly to call. */ +void _serial_early_init(void) { - uart_loop(UART_BASE, state); + serial_early_init(UART_BASE); } -) - #endif #endif diff --git a/arch/blackfin/cpu/serial.h b/arch/blackfin/cpu/serial.h index d67fd81..87a337d 100644 --- a/arch/blackfin/cpu/serial.h +++ b/arch/blackfin/cpu/serial.h @@ -78,16 +78,16 @@ static inline void serial_early_puts(const char *s) #else .macro serial_early_init -#if defined(CONFIG_DEBUG_EARLY_SERIAL) && defined(BFIN_BOOT_BYPASS) - call _serial_initialize; +#if defined(CONFIG_DEBUG_EARLY_SERIAL) && !defined(CONFIG_UART_MEM) + call __serial_early_init; #endif .endm .macro serial_early_set_baud -#if defined(CONFIG_DEBUG_EARLY_SERIAL) && defined(BFIN_BOOT_BYPASS) +#if defined(CONFIG_DEBUG_EARLY_SERIAL) && !defined(CONFIG_UART_MEM) R0.L = LO(CONFIG_BAUDRATE); R0.H = HI(CONFIG_BAUDRATE); - call _serial_set_baud; + call __serial_early_set_baud; #endif .endm @@ -121,7 +121,7 @@ static inline void serial_early_puts(const char *s) R0.L = 7b; \ R0.H = 7b; \ update_serial_early_string_addr \ - call _serial_puts; + call _uart_early_puts; #else # define serial_early_puts(str) #endif diff --git a/include/configs/bfin_adi_common.h b/include/configs/bfin_adi_common.h index d3ae3a7..c986ba3 100644 --- a/include/configs/bfin_adi_common.h +++ b/include/configs/bfin_adi_common.h @@ -111,9 +111,6 @@ #ifndef CONFIG_BAUDRATE # define CONFIG_BAUDRATE 57600 #endif -#ifndef CONFIG_DEBUG_EARLY_SERIAL -# define CONFIG_SYS_BFIN_UART -#endif /* * Debug Settings