From patchwork Tue Jun 29 16:58:47 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Cavagnolo X-Patchwork-Id: 71794 X-Patchwork-Delegate: promsoft@gmail.com Return-Path: X-Original-To: wd@gemini.denx.de Delivered-To: wd@gemini.denx.de Received: from diddl.denx.de (diddl.denx.de [10.0.0.6]) by gemini.denx.de (Postfix) with ESMTP id 7EE3E14EBFA for ; Tue, 29 Jun 2010 19:01:25 +0200 (CEST) Received: from diddl.denx.de (localhost.localdomain [127.0.0.1]) by diddl.denx.de (Postfix) with ESMTP id 688E030E5E2D for ; Tue, 29 Jun 2010 19:01:25 +0200 (CEST) Received: from pop.mnet-online.de by diddl.denx.de with POP3 (fetchmail-6.3.17) for (single-drop); Tue, 29 Jun 2010 19:01:25 +0200 (CEST) Received: from murder ([192.168.8.180]) by backend2 (Cyrus v2.2.12) with LMTPA; Tue, 29 Jun 2010 18:59:14 +0200 X-Sieve: CMU Sieve 2.2 Received: from mail.m-online.net (localhost [127.0.0.1]) by frontend1.mail.m-online.net (Cyrus v2.2.12) with LMTPA; Tue, 29 Jun 2010 18:59:14 +0200 Received: from scanner-2.m-online.net (scanner-2.mail.m-online.net [192.168.8.166]) by mail.m-online.net (Postfix) with ESMTP id 7C5271C0025E; Tue, 29 Jun 2010 18:59:14 +0200 (CEST) Received: from mxin-2.m-online.net ([192.168.1.21]) by scanner-2.m-online.net (scanner-2.m-online.net [192.168.8.166]) (amavisd-new, port 10026) with ESMTP id 04672-04; Tue, 29 Jun 2010 18:59:13 +0200 (CEST) Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by mxin-2.m-online.net (Postfix) with ESMTP id EB3C2468D63; Tue, 29 Jun 2010 18:59:12 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D94102808B; Tue, 29 Jun 2010 18:59:06 +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 tt8NUFHWJixS; Tue, 29 Jun 2010 18:59:06 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D5D8F2808D; Tue, 29 Jun 2010 18:59:01 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1A9D528089 for ; Tue, 29 Jun 2010 18:58:59 +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 duhnN0TlAeDm for ; Tue, 29 Jun 2010 18:58:57 +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 mail-pv0-f172.google.com (mail-pv0-f172.google.com [74.125.83.172]) by theia.denx.de (Postfix) with ESMTP id 0991428083 for ; Tue, 29 Jun 2010 18:58:53 +0200 (CEST) Received: by pvd12 with SMTP id 12so1377351pvd.3 for ; Tue, 29 Jun 2010 09:58:52 -0700 (PDT) Received: by 10.142.250.1 with SMTP id x1mr8375885wfh.109.1277830732561; Tue, 29 Jun 2010 09:58:52 -0700 (PDT) Received: from localhost.localdomain (adsl-99-114-136-65.dsl.pltn13.sbcglobal.net [99.114.136.65]) by mx.google.com with ESMTPS id k17sm5077264rvh.15.2010.06.29.09.58.51 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 29 Jun 2010 09:58:52 -0700 (PDT) From: Brian Cavagnolo To: andrea.scian@dave-tech.it Date: Tue, 29 Jun 2010 09:58:47 -0700 Message-Id: <1277830727-1794-1-git-send-email-brian@cozybit.com> X-Mailer: git-send-email 1.6.0.4 In-Reply-To: References: Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH] bug fix and cleanup for s3c44b0 serial driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 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 X-Virus-Scanned: by amavisd-new at m-online.net Specifically, don't dereference the URXH0 register twice; calculate the BRD based on the formula in the databook instead of using a messy switch statement; and migrate the BRD calculation to the hardware hardware header because it's board specific. Signed-off-by: Brian Cavagnolo --- arch/arm/include/asm/arch-s3c44b0/hardware.h | 3 +- drivers/serial/serial_s3c44b0.c | 65 +------------------------- 2 files changed, 4 insertions(+), 64 deletions(-) diff --git a/arch/arm/include/asm/arch-s3c44b0/hardware.h b/arch/arm/include/asm/arch-s3c44b0/hardware.h index 146e265..38ff32c 100644 --- a/arch/arm/include/asm/arch-s3c44b0/hardware.h +++ b/arch/arm/include/asm/arch-s3c44b0/hardware.h @@ -11,7 +11,8 @@ #define REGL(addr) (*(volatile unsigned int *)(REGBASE+addr)) #define REGW(addr) (*(volatile unsigned short *)(REGBASE+addr)) #define REGB(addr) (*(volatile unsigned char *)(REGBASE+addr)) - +#define BRD(bps) (DIV_ROUND(CONFIG_S3C44B0_CLOCK_SPEED * 1000000, \ + (bps)*16) - 1) /*****************************/ /* CPU Wrapper Registers */ diff --git a/drivers/serial/serial_s3c44b0.c b/drivers/serial/serial_s3c44b0.c index 95d0266..e6c535c 100644 --- a/drivers/serial/serial_s3c44b0.c +++ b/drivers/serial/serial_s3c44b0.c @@ -48,7 +48,7 @@ static int serial_flush_input(void) /* keep on reading as long as the receiver is not empty */ while(UTRSTAT0&0x01) { - tmp = REGB(URXH0); + tmp = URXH0; } return 0; @@ -70,68 +70,7 @@ static int serial_flush_output(void) void serial_setbrg (void) { - u32 divisor = 0; - - /* get correct divisor */ - switch(gd->baudrate) { - - case 1200: -#if CONFIG_S3C44B0_CLOCK_SPEED==66 - divisor = 3124; -#elif CONFIG_S3C44B0_CLOCK_SPEED==75 - divisor = 3905; -#else -# error CONFIG_S3C44B0_CLOCK_SPEED undefined -#endif - break; - - case 9600: -#if CONFIG_S3C44B0_CLOCK_SPEED==66 - divisor = 390; -#elif CONFIG_S3C44B0_CLOCK_SPEED==75 - divisor = 487; -#else -# error CONFIG_S3C44B0_CLOCK_SPEED undefined -#endif - break; - - case 19200: -#if CONFIG_S3C44B0_CLOCK_SPEED==66 - divisor = 194; -#elif CONFIG_S3C44B0_CLOCK_SPEED==75 - divisor = 243; -#else -# error CONFIG_S3C44B0_CLOCK_SPEED undefined -#endif - break; - - case 38400: -#if CONFIG_S3C44B0_CLOCK_SPEED==66 - divisor = 97; -#elif CONFIG_S3C44B0_CLOCK_SPEED==75 - divisor = 121; -#else -# error CONFIG_S3C44B0_CLOCK_SPEED undefined -#endif /* break; */ - - case 57600: -#if CONFIG_S3C44B0_CLOCK_SPEED==66 - divisor = 64; -#elif CONFIG_S3C44B0_CLOCK_SPEED==75 - divisor = 80; -#else -# error CONFIG_S3C44B0_CLOCK_SPEED undefined -#endif /* break; */ - - case 115200: -#if CONFIG_S3C44B0_CLOCK_SPEED==66 - divisor = 32; -#elif CONFIG_S3C44B0_CLOCK_SPEED==75 - divisor = 40; -#else -# error CONFIG_S3C44B0_CLOCK_SPEED undefined -#endif /* break; */ - } + u32 divisor = BRD(gd->baudrate); serial_flush_output(); serial_flush_input();