From patchwork Sat Sep 29 00:31:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 187973 X-Patchwork-Delegate: marek.vasut@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 CB1DF2C00D3 for ; Sat, 29 Sep 2012 10:42:04 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2358928238; Sat, 29 Sep 2012 02:41:35 +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 D8RIAcnIFeKl; Sat, 29 Sep 2012 02:41:34 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 735162824F; Sat, 29 Sep 2012 02:36:21 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 544ED28113 for ; Sat, 29 Sep 2012 02:32:19 +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 Y7DEfBYPUZDF for ; Sat, 29 Sep 2012 02:32:19 +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-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by theia.denx.de (Postfix) with ESMTPS id BA5DE28147 for ; Sat, 29 Sep 2012 02:31:52 +0200 (CEST) Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 3XT9gD35j7z3hhxN; Sat, 29 Sep 2012 02:31:52 +0200 (CEST) X-Auth-Info: WDjlDznhNtMOamRCcO/hTQXvbQMgkTfJwWeQNG+j1cw= Received: from mashiro.lan (unknown [195.140.253.167]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA id 3XT9gD1mpJzbbmY; Sat, 29 Sep 2012 02:31:52 +0200 (CEST) From: Marek Vasut To: u-boot@lists.denx.de Date: Sat, 29 Sep 2012 02:31:17 +0200 Message-Id: <1348878687-14194-61-git-send-email-marex@denx.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1348878687-14194-1-git-send-email-marex@denx.de> References: <1347837696-3192-1-git-send-email-marex@denx.de> <1348878687-14194-1-git-send-email-marex@denx.de> Cc: Marek Vasut , Tom Rini Subject: [U-Boot] [PATCH 60/70] serial: arm: Implement CONFIG_SERIAL_MULTI into sa1100 serial driver 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 Implement support for CONFIG_SERIAL_MULTI into sa1100 serial driver. This driver was so far only usable directly, but this patch also adds support for the multi method. This allows using more than one serial driver alongside the sa1100 driver. Also, add a weak implementation of default_serial_console() returning this driver. Signed-off-by: Marek Vasut Cc: Marek Vasut Cc: Tom Rini --- common/serial.c | 2 ++ drivers/serial/serial_sa1100.c | 68 +++++++++++++++++++++++++++++++++++----- 2 files changed, 63 insertions(+), 7 deletions(-) diff --git a/common/serial.c b/common/serial.c index 1953aaf..3dae01b 100644 --- a/common/serial.c +++ b/common/serial.c @@ -90,6 +90,7 @@ serial_initfunc(mxc_serial_initialize); serial_initfunc(netarm_serial_initialize); serial_initfunc(pl01x_serial_initialize); serial_initfunc(s3c44b0_serial_initialize); +serial_initfunc(sa1100_serial_initialize); void serial_register(struct serial_device *dev) { @@ -158,6 +159,7 @@ void serial_initialize(void) netarm_serial_initialize(); pl01x_serial_initialize(); s3c44b0_serial_initialize(); + sa1100_serial_initialize(); serial_assign(default_serial_console()->name); } diff --git a/drivers/serial/serial_sa1100.c b/drivers/serial/serial_sa1100.c index 5d18875..86e682d 100644 --- a/drivers/serial/serial_sa1100.c +++ b/drivers/serial/serial_sa1100.c @@ -30,10 +30,12 @@ #include #include +#include +#include DECLARE_GLOBAL_DATA_PTR; -void serial_setbrg (void) +static void sa1100_serial_setbrg(void) { unsigned int reg = 0; @@ -89,7 +91,7 @@ void serial_setbrg (void) * are always 8 data bits, no parity, 1 stop bit, no start bits. * */ -int serial_init (void) +static int sa1100_serial_init(void) { serial_setbrg (); @@ -100,7 +102,7 @@ int serial_init (void) /* * Output a single byte to the serial port. */ -void serial_putc (const char c) +static void sa1100_serial_putc(const char c) { #ifdef CONFIG_SERIAL1 /* wait for room in the tx FIFO on SERIAL1 */ @@ -124,7 +126,7 @@ void serial_putc (const char c) * otherwise. When the function is succesfull, the character read is * written into its argument c. */ -int serial_tstc (void) +static int sa1100_serial_tstc(void) { #ifdef CONFIG_SERIAL1 return Ser1UTSR1 & UTSR1_RNE; @@ -138,7 +140,7 @@ int serial_tstc (void) * otherwise. When the function is succesfull, the character read is * written into its argument c. */ -int serial_getc (void) +static int sa1100_serial_getc(void) { #ifdef CONFIG_SERIAL1 while (!(Ser1UTSR1 & UTSR1_RNE)); @@ -151,10 +153,62 @@ int serial_getc (void) #endif } -void -serial_puts (const char *s) +static void sa1100_serial_puts(const char *s) { while (*s) { serial_putc (*s++); } } + +#ifdef CONFIG_SERIAL_MULTI +static struct serial_device sa1100_serial_drv = { + .name = "sa1100_serial", + .start = sa1100_serial_init, + .stop = NULL, + .setbrg = sa1100_serial_setbrg, + .putc = sa1100_serial_putc, + .puts = sa1100_serial_puts, + .getc = sa1100_serial_getc, + .tstc = sa1100_serial_tstc, +}; + +void sa1100_serial_initialize(void) +{ + serial_register(&sa1100_serial_drv); +} + +__weak struct serial_device *default_serial_console(void) +{ + return &sa1100_serial_drv; +} +#else +int serial_init(void) +{ + return sa1100_serial_init(); +} + +void serial_setbrg(void) +{ + sa1100_serial_setbrg(); +} + +void serial_putc(const char c) +{ + sa1100_serial_putc(c); +} + +void serial_puts(const char *s) +{ + sa1100_serial_puts(s); +} + +int serial_getc(void) +{ + return sa1100_serial_getc(); +} + +int serial_tstc(void) +{ + return sa1100_serial_tstc(); +} +#endif