From: eddie.huang@mediatek.com (Eddie Huang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] tty: serial: 8250_mtk: Add earlycon
Date: Thu, 18 Dec 2014 16:33:20 +0800 [thread overview]
Message-ID: <1418891601-53769-2-git-send-email-eddie.huang@mediatek.com> (raw)
In-Reply-To: <1418891601-53769-1-git-send-email-eddie.huang@mediatek.com>
Mediatek UART has highspeed register, but 8250_early.c doesn't
support this, so add earlycon in 8250_mtk.c
Signed-off-by: Eddie Huang <eddie.huang@mediatek.com>
---
drivers/tty/serial/8250/8250_mtk.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c
index de7aae5..65dd569 100644
--- a/drivers/tty/serial/8250/8250_mtk.c
+++ b/drivers/tty/serial/8250/8250_mtk.c
@@ -23,6 +23,7 @@
#include <linux/pm_runtime.h>
#include <linux/serial_8250.h>
#include <linux/serial_reg.h>
+#include <linux/console.h>
#include "8250.h"
@@ -289,6 +290,38 @@ static struct platform_driver mtk8250_platform_driver = {
};
module_platform_driver(mtk8250_platform_driver);
+#define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
+
+static void __init mtk8250_serial_putc(struct uart_port *port, int c)
+{
+ while ((readl(port->membase + (UART_LSR << 2)) & BOTH_EMPTY) !=
+ BOTH_EMPTY)
+ ;
+ writel(c, port->membase + (UART_TX << 2));
+}
+
+static void __init early_mtk8250_write(struct console *console,
+ const char *s, unsigned int count)
+{
+ struct earlycon_device *dev = console->data;
+
+ uart_console_write(&dev->port, s, count, mtk8250_serial_putc);
+}
+
+static int __init early_mtk8250_setup(struct earlycon_device *device,
+ const char *options)
+{
+ if (!device->port.membase)
+ return -ENODEV;
+
+ device->con->write = early_mtk8250_write;
+
+ return 0;
+}
+
+EARLYCON_DECLARE(mtk8250, early_mtk8250_setup);
+OF_EARLYCON_DECLARE(mtk8250, "mediatek,mt6577-uart", early_mtk8250_setup);
+
MODULE_AUTHOR("Matthias Brugger");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Mediatek 8250 serial port driver");
--
1.8.1.1.dirty
next prev parent reply other threads:[~2014-12-18 8:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-18 8:33 [PATCH 0/2] tty: serial: Add earlycon support to MT8173 SoC Eddie Huang
2014-12-18 8:33 ` Eddie Huang [this message]
2014-12-18 8:48 ` [PATCH 1/2] tty: serial: 8250_mtk: Add earlycon Matthias Brugger
2014-12-18 9:12 ` Arnd Bergmann
2014-12-26 21:24 ` Rob Herring
2014-12-29 4:24 ` Eddie Huang
2014-12-29 14:54 ` Rob Herring
2014-12-29 19:08 ` Arnd Bergmann
2014-12-18 8:33 ` [PATCH 2/2] arm64: dts: Add mediatek MT8173 earlycon support Eddie Huang
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=1418891601-53769-2-git-send-email-eddie.huang@mediatek.com \
--to=eddie.huang@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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).