From: Zhichang Yuan <yuanzhichang@hisilicon.com>
To: <linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <linuxarm@huawei.com>
Cc: <arnd@arndb.de>, <gregkh@linuxfoundation.org>,
<will.deacon@arm.com>, <devicetree@vger.kernel.org>,
<linux-pci@vger.kernel.org>, <linux-serial@vger.kernel.org>,
<minyard@acm.org>, <benh@kernel.crashing.org>,
<lorenzo.pieralisi@arm.com>, <liviu.dudau@arm.com>,
<zourongrong@gmail.com>, <john.garry@huawei.com>,
<gabriele.paoloni@huawei.com>, <zhichang.yuan02@gmail.com>,
<kantyzc@163.com>, <xuwei5@hisilicon.com>,
"zhichang.yuan" <yuanzhichang@hisilicon.com>
Subject: [PATCH V3 4/4] ARM64 LPC: support earlycon for UART connected to LPC
Date: Wed, 14 Sep 2016 20:15:54 +0800 [thread overview]
Message-ID: <1473855354-150093-5-git-send-email-yuanzhichang@hisilicon.com> (raw)
In-Reply-To: <1473855354-150093-1-git-send-email-yuanzhichang@hisilicon.com>
From: "zhichang.yuan" <yuanzhichang@hisilicon.com>
This patch support the earlycon for UART connected to LPC on Hip06.
This patch is depended on the LPC driver.
Signed-off-by: zhichang.yuan <yuanzhichang@hisilicon.com>
---
drivers/bus/hisi_lpc.c | 113 +++++++++++++++++++++++++++++++++++
drivers/tty/serial/8250/8250_early.c | 26 +++++++-
2 files changed, 137 insertions(+), 2 deletions(-)
diff --git a/drivers/bus/hisi_lpc.c b/drivers/bus/hisi_lpc.c
index 9b364d0..2269828 100644
--- a/drivers/bus/hisi_lpc.c
+++ b/drivers/bus/hisi_lpc.c
@@ -360,6 +360,119 @@ void hisilpc_comm_outb(void *devobj, unsigned long ptaddr,
/**
+ * hisilpc_early_in - read/input operation specific for hisi LPC earlycon.
+ * @devobj: pointer to device relevant information of the caller.
+ * @inbuf: the buffer where the read back data is populated.
+ *
+ * for earlycon, dlen and count should be one.
+ *
+ * Return the data read from earlycon on success, error ID on fail.
+ *
+ */
+static unsigned int __init hisilpc_early_in(struct uart_port *port, int offset)
+{
+ unsigned int backval = 0;
+ unsigned int ret = 0;
+ struct lpc_cycle_para para;
+ struct hisilpc_dev lpcdev;
+
+ if (!port->mapbase || !port->iobase || !port->membase)
+ return -EINVAL;
+
+ para.opflags = FG_EARLYCON_LPC;
+ para.csize = 1;
+ lpcdev.membase = port->membase;
+
+ ret = hisilpc_target_in(&lpcdev, ¶,
+ port->iobase + (offset << port->regshift),
+ (unsigned char *)&backval, 1);
+ return (ret) ? : backval;
+}
+
+/**
+ * hisilpc_early_out - write/output operation specific for hisi LPC earlycon.
+ * @port: pointer to uart_port of eralycon
+ *
+ * for earlycon, dlen and count should be one.
+ *
+ */
+static void __init hisilpc_early_out(struct uart_port *port, int offset,
+ int value)
+{
+ struct lpc_cycle_para para;
+ struct hisilpc_dev lpcdev;
+
+ if (!port->mapbase || !port->iobase || !port->membase)
+ return;
+
+ para.opflags = FG_EARLYCON_LPC;
+ para.csize = 1;
+ lpcdev.membase = port->membase;
+
+ (void)hisilpc_target_out(&lpcdev, ¶,
+ port->iobase + (offset << port->regshift),
+ (unsigned char *)&value, 1);
+}
+
+
+/**
+ * early_hisilpc8250_setup - initilize the lpc earlycon
+ * @device: pointer to the elarycon device
+ * @options: a option string from earlycon kernel-parameter
+ *
+ * Returns 0 on success, non-zero on fail.
+ *
+ */
+static int __init early_hisilpc8250_setup(struct earlycon_device *device,
+ const char *options)
+{
+ char *p;
+ int ret;
+
+ if (!device->port.membase)
+ return -ENODEV;
+
+ if (device->port.iotype != UPIO_MEM)
+ return -EINVAL;
+
+ if (device->options) {
+ p = strchr(device->options, ',');
+ if (p && (p + 1) != '\0') {
+ ret = kstrtoul(++p, 0,
+ (unsigned long *)&device->port.iobase);
+ if (ret || device->port.iobase == 0)
+ return ret ?: -EFAULT;
+ } else
+ device->port.iobase = 0x2f8;
+ } else {
+ device->port.iobase = 0x2f8;
+ device->baud = 0;
+ }
+
+ device->port.serial_in = hisilpc_early_in;
+ device->port.serial_out = hisilpc_early_out;
+ /* must convert iotype to UPIO_PORT for Hip06 indirect-io */
+ device->port.iotype = UPIO_PORT;
+
+ /* disable interrupts from LPC */
+ writel(LPC_IRQ_CLEAR, device->port.membase + LPC_REG_IRQ_ST);
+ /* ensure the LPC is available */
+ while (!(readl(device->port.membase + LPC_REG_OP_STATUS) &
+ LPC_STATUS_IDLE))
+ cpu_relax();
+
+ return early_serial8250_setup(device, options);
+}
+
+
+
+EARLYCON_DECLARE(hisilpcuart, early_hisilpc8250_setup);
+OF_EARLYCON_DECLARE(hisilpcuart, "hisilicon,lpc-uart",
+ early_hisilpc8250_setup);
+
+
+
+/**
* hisilpc_ischild_ipmi - check whether the designated device is ipmi
* @dev: the device to be checked.
* @data: the value used to match the acpi device in checking.
diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 85a12f0..3b5d0a8 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -37,7 +37,7 @@
#include <asm/io.h>
#include <asm/serial.h>
-static unsigned int __init serial8250_early_in(struct uart_port *port, int offset)
+static unsigned int __init serial8250_early_in_raw(struct uart_port *port, int offset)
{
offset <<= port->regshift;
@@ -57,7 +57,7 @@ static unsigned int __init serial8250_early_in(struct uart_port *port, int offse
}
}
-static void __init serial8250_early_out(struct uart_port *port, int offset, int value)
+static void __init serial8250_early_out_raw(struct uart_port *port, int offset, int value)
{
offset <<= port->regshift;
@@ -80,6 +80,28 @@ static void __init serial8250_early_out(struct uart_port *port, int offset, int
}
}
+static inline void __init serial8250_early_out(struct uart_port *port,
+ int offset, int value)
+{
+ if (port->serial_out)
+ port->serial_out(port, offset, value);
+ else {
+ port->serial_out = serial8250_early_out_raw;
+ serial8250_early_out_raw(port, offset, value);
+ }
+}
+
+static inline unsigned int __init serial8250_early_in(struct uart_port *port,
+ int offset)
+{
+ if (port->serial_in)
+ return port->serial_in(port, offset);
+
+ port->serial_in = serial8250_early_in_raw;
+ return serial8250_early_in_raw(port, offset);
+}
+
+
#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
static void __init serial_putc(struct uart_port *port, int c)
--
1.9.1
prev parent reply other threads:[~2016-09-14 12:03 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-14 12:15 [PATCH V3 0/4] ARM64 LPC: legacy ISA I/O support Zhichang Yuan
2016-09-14 12:15 ` [PATCH V3 1/4] ARM64 LPC: Indirect ISA port IO introduced Zhichang Yuan
2016-09-14 12:24 ` Arnd Bergmann
2016-09-14 14:16 ` zhichang.yuan
2016-09-14 14:23 ` Arnd Bergmann
2016-09-18 3:38 ` zhichang
2016-09-21 9:26 ` zhichang
2016-09-14 12:15 ` [PATCH V3 2/4] ARM64 LPC: LPC driver implementation on Hip06 Zhichang Yuan
2016-09-14 12:33 ` Arnd Bergmann
2016-09-14 14:50 ` zhichang.yuan
2016-09-14 21:32 ` Arnd Bergmann
2016-09-15 8:02 ` Gabriele Paoloni
2016-09-15 8:22 ` Arnd Bergmann
2016-09-15 12:05 ` Gabriele Paoloni
2016-09-15 12:24 ` Arnd Bergmann
2016-09-15 14:28 ` Gabriele Paoloni
2016-09-21 10:09 ` zhichang
2016-09-21 16:20 ` Gabriele Paoloni
2016-09-21 20:18 ` Arnd Bergmann
2016-09-22 11:55 ` Gabriele Paoloni
2016-09-22 12:14 ` Arnd Bergmann
2016-09-22 14:47 ` Gabriele Paoloni
2016-09-22 14:59 ` Arnd Bergmann
2016-09-22 15:20 ` Gabriele Paoloni
2016-09-22 15:46 ` zhichang.yuan
2016-09-22 16:27 ` zhichang.yuan
2016-09-23 9:51 ` Arnd Bergmann
2016-09-23 10:23 ` Gabriele Paoloni
2016-09-23 13:42 ` Arnd Bergmann
2016-09-23 14:59 ` Gabriele Paoloni
2016-09-23 15:55 ` Arnd Bergmann
2016-09-24 8:14 ` zhichang
2016-09-24 21:00 ` Arnd Bergmann
2016-09-26 13:21 ` Gabriele Paoloni
2016-09-24 8:00 ` zhichang
2016-10-02 22:03 ` Jon Masters
2016-10-04 12:02 ` John Garry
2016-10-06 0:18 ` Benjamin Herrenschmidt
2016-10-06 13:31 ` John Garry
2016-09-14 14:09 ` kbuild test robot
2016-09-14 12:15 ` [PATCH V3 3/4] ARM64 LPC: support serial based on low-pin-count Zhichang Yuan
2016-09-14 12:25 ` Arnd Bergmann
2016-09-14 15:04 ` zhichang.yuan
2016-09-14 21:33 ` Arnd Bergmann
[not found] ` <815bebc1-96c9-2131-930d-bccdd4bf1c55@gmail.com>
2016-09-21 19:29 ` Arnd Bergmann
2016-09-14 12:15 ` Zhichang Yuan [this message]
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=1473855354-150093-5-git-send-email-yuanzhichang@hisilicon.com \
--to=yuanzhichang@hisilicon.com \
--cc=arnd@arndb.de \
--cc=benh@kernel.crashing.org \
--cc=devicetree@vger.kernel.org \
--cc=gabriele.paoloni@huawei.com \
--cc=gregkh@linuxfoundation.org \
--cc=john.garry@huawei.com \
--cc=kantyzc@163.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=liviu.dudau@arm.com \
--cc=lorenzo.pieralisi@arm.com \
--cc=minyard@acm.org \
--cc=will.deacon@arm.com \
--cc=xuwei5@hisilicon.com \
--cc=zhichang.yuan02@gmail.com \
--cc=zourongrong@gmail.com \
/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).