From patchwork Tue Apr 12 06:17:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Rigby X-Patchwork-Id: 965 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:47:48 -0000 Delivered-To: patches@linaro.org Received: by 10.68.59.138 with SMTP id z10cs144987pbq; Mon, 11 Apr 2011 23:18:24 -0700 (PDT) Received: by 10.231.171.205 with SMTP id i13mr6424329ibz.181.1302589103689; Mon, 11 Apr 2011 23:18:23 -0700 (PDT) Received: from mail-iy0-f178.google.com (mail-iy0-f178.google.com [209.85.210.178]) by mx.google.com with ESMTPS id f14si19188626ibb.72.2011.04.11.23.18.23 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 11 Apr 2011 23:18:23 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.178 is neither permitted nor denied by best guess record for domain of john.rigby@linaro.org) client-ip=209.85.210.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.178 is neither permitted nor denied by best guess record for domain of john.rigby@linaro.org) smtp.mail=john.rigby@linaro.org Received: by mail-iy0-f178.google.com with SMTP id 12so8030330iyi.37 for ; Mon, 11 Apr 2011 23:18:23 -0700 (PDT) Received: by 10.42.139.5 with SMTP id e5mr8068902icu.136.1302589103241; Mon, 11 Apr 2011 23:18:23 -0700 (PDT) Received: from localhost.localdomain (c-76-23-54-220.hsd1.ut.comcast.net [76.23.54.220]) by mx.google.com with ESMTPS id i20sm4716910iby.31.2011.04.11.23.18.21 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 11 Apr 2011 23:18:22 -0700 (PDT) From: John Rigby To: u-boot@lists.denx.de Cc: patches@linaro.org, Rabin Vincent , John Rigby Subject: [PATCHv3 1/4] Serial: p1011: new vendor init options Date: Tue, 12 Apr 2011 00:17:44 -0600 Message-Id: <1302589067-3688-2-git-send-email-john.rigby@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1301761196-26072-1-git-send-email-john.rigby@linaro.org> References: <1301761196-26072-1-git-send-email-john.rigby@linaro.org> From: Rabin Vincent Two new options: CONFIG_PL011_SERIAL_RLCR Some vendor versions of PL011 serial ports (e.g. ST-Ericsson U8500) have separate receive and transmit line control registers. Set this variable to initialize the extra register. CONFIG_PL011_SERIAL_FLUSH_ON_INIT On some platforms (e.g. U8500) U-Boot is loaded by a second stage boot loader that has already initialized the UART. Define this variable to flush the UART at init time. empty fifo on init Signed-off-by: Rabin Vincent Signed-off-by: John Rigby --- v3: Enable changes with new CONFIG_* options instead of platform. Document new CONFIG_* options in README. README | 12 ++++++++++++ drivers/serial/serial_pl01x.c | 17 +++++++++++++++-- drivers/serial/serial_pl01x.h | 4 ++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/README b/README index c128a6c..8ccac6e 100644 --- a/README +++ b/README @@ -468,6 +468,18 @@ The following options need to be configured: define this to a list of base addresses for each (supported) port. See e.g. include/configs/versatile.h + CONFIG_PL011_SERIAL_RLCR + + Some vendor versions of PL011 serial ports (e.g. ST-Ericsson U8500) + have separate receive and transmit line control registers. Set + this variable to initialize the extra register. + + CONFIG_PL011_SERIAL_FLUSH_ON_INIT + + On some platforms (e.g. U8500) U-Boot is loaded by a second stage + boot loader that has already initialized the UART. Define this + variable to flush the UART at init time. + - Console Interface: Depending on board, define exactly one serial port diff --git a/drivers/serial/serial_pl01x.c b/drivers/serial/serial_pl01x.c index 5dfcde8..164b0ac 100644 --- a/drivers/serial/serial_pl01x.c +++ b/drivers/serial/serial_pl01x.c @@ -111,6 +111,15 @@ int serial_init (void) unsigned int divider; unsigned int remainder; unsigned int fraction; + unsigned int lcr; + +#ifdef CONFIG_PL011_SERIAL_FLUSH_ON_INIT + /* Empty RX fifo if necessary */ + if (readl(®s->pl011_cr) & UART_PL011_CR_UARTEN) { + while (!(readl(®s->fr) & UART_PL01x_FR_RXFE)) + readl(®s->dr); + } +#endif /* First, disable everything */ writel(0, ®s->pl011_cr); @@ -131,9 +140,13 @@ int serial_init (void) writel(fraction, ®s->pl011_fbrd); /* Set the UART to be 8 bits, 1 stop bit, no parity, fifo enabled */ - writel(UART_PL011_LCRH_WLEN_8 | UART_PL011_LCRH_FEN, - ®s->pl011_lcrh); + lcr = UART_PL011_LCRH_WLEN_8 | UART_PL011_LCRH_FEN; + writel(lcr, ®s->pl011_lcrh); +#ifdef CONFIG_PL011_SERIAL_RLCR + /* program receive line control register */ + writel(lcr, ®s->pl011_rlcr); +#endif /* Finally, enable the UART */ writel(UART_PL011_CR_UARTEN | UART_PL011_CR_TXE | UART_PL011_CR_RXE, ®s->pl011_cr); diff --git a/drivers/serial/serial_pl01x.h b/drivers/serial/serial_pl01x.h index b670c24..96ee381 100644 --- a/drivers/serial/serial_pl01x.h +++ b/drivers/serial/serial_pl01x.h @@ -43,7 +43,11 @@ struct pl01x_regs { u32 pl010_lcrl; /* 0x10 Line control register, low byte */ u32 pl010_cr; /* 0x14 Control register */ u32 fr; /* 0x18 Flag register (Read only) */ +#ifdef CONFIG_PL011_SERIAL_RLCR + u32 pl011_rlcr; /* 0x1c Receive line control register */ +#else u32 reserved; +#endif u32 ilpr; /* 0x20 IrDA low-power counter register */ u32 pl011_ibrd; /* 0x24 Integer baud rate register */ u32 pl011_fbrd; /* 0x28 Fractional baud rate register */