linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Timur Tabi <timur@codeaurora.org>
To: linux-serial@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, Andrew.Jackson@arm.com,
	andre.przywara@arm.com, jun.nie@linaro.or,
	peter@hurleysoftware.com,
	Linus Walleij <linus.walleij@linaro.org>,
	Greg Kroah-Hartman <greg@kroah.com>,
	jslaby@suse.com, rmk+kernel@arm.linux.org.uk
Subject: [PATCH] tty: amba-pl011: add options to earlycon for 32-bit reg access
Date: Thu,  5 Nov 2015 18:37:47 -0600	[thread overview]
Message-ID: <1446770267-26749-1-git-send-email-timur@codeaurora.org> (raw)

Add the "sbsa32" command-line option to earlycon to specify that the
pl011 registers should be accessed with 32-bit accessors only.  This is
SBSA platforms

Similarly, also add the "zte" option for the ZTE UART.  It's functionally
similar to the standard PL011, but some registers are at different
offsets.

Normal console uses the "access_32b" field of the vendor data structure
to determine whether the registers needs 32-bit accessors.  Early console
is used before the vendor data is available, so we need a different
mechanism to choose the accessor.

Example:

	earlycon=pl011,0x3ced1000,sbsa32

Signed-off-by: Timur Tabi <timur@codeaurora.org>
---

This patch applies on top of Russell's 12-part amba-pl011.c patchset.

 drivers/tty/serial/amba-pl011.c | 46 +++++++++++++++++++++++++++++++++++++----
 1 file changed, 42 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 373b152..58eda89 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2301,10 +2301,10 @@ static struct console amba_console = {
 
 static void pl011_putc(struct uart_port *port, int c)
 {
-	while (readl(port->membase + REG_FR) & UART01x_FR_TXFF)
+	while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
 		;
-	writeb(c, port->membase + REG_DR);
-	while (readl(port->membase + REG_FR) & UART01x_FR_BUSY)
+	writeb(c, port->membase + UART01x_DR);
+	while (readl(port->membase + UART01x_FR) & UART01x_FR_BUSY)
 		;
 }
 
@@ -2315,13 +2315,51 @@ static void pl011_early_write(struct console *con, const char *s, unsigned n)
 	uart_console_write(&dev->port, s, n, pl011_putc);
 }
 
+static void pl011_putc_sbsa32(struct uart_port *port, int c)
+{
+	while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
+		cpu_relax();
+	writel(c, port->membase + UART01x_DR);
+	while (readl(port->membase + UART01x_FR) & UART01x_FR_BUSY)
+		cpu_relax();
+}
+
+static void pl011_early_write_sbsa32(struct console *con, const char *s, unsigned n)
+{
+	struct earlycon_device *dev = con->data;
+
+	uart_console_write(&dev->port, s, n, pl011_putc_sbsa32);
+}
+
+static void pl011_putc_zte(struct uart_port *port, int c)
+{
+	while (readl(port->membase + ZX_UART011_FR) & UART01x_FR_TXFF)
+		cpu_relax();
+	writel(c, port->membase + ZX_UART011_DR);
+	while (readl(port->membase + ZX_UART011_FR) & UART01x_FR_BUSY)
+		cpu_relax();
+}
+
+static void pl011_early_write_zte(struct console *con, const char *s, unsigned n)
+{
+	struct earlycon_device *dev = con->data;
+
+	uart_console_write(&dev->port, s, n, pl011_putc_zte);
+}
+
 static int __init pl011_early_console_setup(struct earlycon_device *device,
 					    const char *opt)
 {
 	if (!device->port.membase)
 		return -ENODEV;
 
-	device->con->write = pl011_early_write;
+	if (strcmp(device->options, "sbsa32") == 0)
+		device->con->write = pl011_early_write_sbsa32;
+	else if (strcmp(device->options, "zte") == 0)
+		device->con->write = pl011_early_write_zte;
+	else
+		device->con->write = pl011_early_write;
+
 	return 0;
 }
 EARLYCON_DECLARE(pl011, pl011_early_console_setup);
-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

             reply	other threads:[~2015-11-06  0:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-06  0:37 Timur Tabi [this message]
2015-11-06  1:52 ` [PATCH] tty: amba-pl011: add options to earlycon for 32-bit reg access Peter Hurley
2015-11-06  2:00   ` Timur Tabi
2015-11-06  2:44     ` Peter Hurley
2015-11-06 18:59       ` Timur Tabi
2015-11-07 22:36         ` Peter Hurley
2015-11-07 23:02           ` Russell King - ARM Linux
2015-11-07 23:31           ` Timur Tabi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1446770267-26749-1-git-send-email-timur@codeaurora.org \
    --to=timur@codeaurora.org \
    --cc=Andrew.Jackson@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=greg@kroah.com \
    --cc=jslaby@suse.com \
    --cc=jun.nie@linaro.or \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=peter@hurleysoftware.com \
    --cc=rmk+kernel@arm.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).