mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vladimir Murzin <vladimir.murzin@arm.com>
To: arnd@arndb.de, linux@arm.linux.org.uk,
	gregkh@linuxfoundation.org, daniel.lezcano@linaro.org,
	tglx@linutronix.de, u.kleine-koenig@pengutronix.de,
	afaerber@suse.de, mcoquelin.stm32@gmail.com
Cc: Mark.Rutland@arm.com, Pawel.Moll@arm.com,
	ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
	jslaby@suse.cz, robh+dt@kernel.org, devicetree@vger.kernel.org,
	linux-serial@vger.kernel.org, linux-api@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH 05/10] serial: mps2-uart: add support for early console
Date: Wed, 25 Nov 2015 10:33:36 +0000	[thread overview]
Message-ID: <1448447621-17900-6-git-send-email-vladimir.murzin@arm.com> (raw)
In-Reply-To: <1448447621-17900-1-git-send-email-vladimir.murzin@arm.com>

This adds support early console for MPS2 UART which can be enabled via
earlycon=mps2,0x40004000

Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
---
 drivers/tty/serial/Kconfig     |    1 +
 drivers/tty/serial/mps2-uart.c |   30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index b47f8fc..bb8c66b 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1477,6 +1477,7 @@ config SERIAL_MPS2_UART_CONSOLE
 	bool "MPS2 UART console support"
 	depends on SERIAL_MPS2_UART
 	select SERIAL_CORE_CONSOLE
+	select SERIAL_EARLYCON
 
 config SERIAL_MPS2_UART
 	tristate "MPS2 UART port"
diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c
index 00e882e..c2f530e 100644
--- a/drivers/tty/serial/mps2-uart.c
+++ b/drivers/tty/serial/mps2-uart.c
@@ -445,6 +445,36 @@ static struct console mps2_uart_console = {
 
 #define MPS2_SERIAL_CONSOLE (&mps2_uart_console)
 
+static void mps2_early_putchar(struct uart_port *port, int ch)
+{
+
+	while (readb(port->membase + UARTn_STATE) & UARTn_STATE_TX_FULL)
+		cpu_relax();
+
+	writeb((unsigned char)ch, port->membase + UARTn_DATA);
+}
+
+
+static void mps2_early_write(struct console *con, const char *s, unsigned n)
+{
+	struct earlycon_device *dev = con->data;
+
+	uart_console_write(&dev->port, s, n, mps2_early_putchar);
+}
+
+static int __init mps2_early_console_setup(struct earlycon_device *device,
+					   const char *opt)
+{
+	if (!device->port.membase)
+		return -ENODEV;
+
+	device->con->write = mps2_early_write;
+
+	return 0;
+}
+EARLYCON_DECLARE(mps2, mps2_early_console_setup);
+OF_EARLYCON_DECLARE(mps2, "arm,mps2-uart", mps2_early_console_setup);
+
 #else
 #define MPS2_SERIAL_CONSOLE NULL
 #endif
-- 
1.7.9.5


  parent reply	other threads:[~2015-11-25 10:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-25 10:33 [RFC PATCH 00/10] Support for Cortex-M Prototyping System Vladimir Murzin
2015-11-25 10:33 ` [RFC PATCH 01/10] dt-bindings: document the MPS2 timer bindings Vladimir Murzin
2015-11-25 20:04   ` Rob Herring
2015-11-25 10:33 ` [RFC PATCH 02/10] clockevents/drivers: add MPS2 Timer driver Vladimir Murzin
2015-11-25 13:40   ` Daniel Lezcano
2015-11-25 14:51     ` Vladimir Murzin
2015-11-25 15:10       ` Daniel Lezcano
2015-11-25 15:21         ` Vladimir Murzin
2015-11-25 10:33 ` [RFC PATCH 03/10] dt-bindings: document the MPS2 UART bindings Vladimir Murzin
2015-11-25 20:07   ` Rob Herring
2015-12-01 11:35     ` Vladimir Murzin
2015-11-25 10:33 ` [RFC PATCH 04/10] serial: mps2-uart: add MPS2 UART driver Vladimir Murzin
2015-11-25 10:33 ` Vladimir Murzin [this message]
2015-11-25 10:33 ` [RFC PATCH 06/10] ARM: mps2: introduce MPS2 platform Vladimir Murzin
2015-11-25 10:33 ` [RFC PATCH 07/10] ARM: mps2: add low-level debug support Vladimir Murzin
2015-11-25 10:33 ` [RFC PATCH 08/10] ARM: configs: add MPS2 defconfig Vladimir Murzin
2015-11-25 10:33 ` [RFC PATCH 09/10] ARM: dts: introduce MPS2 AN385/AN386 Vladimir Murzin
2015-11-25 10:33 ` [RFC PATCH 10/10] ARM: dts: introduce MPS2 AN399/AN400 Vladimir Murzin
2015-11-25 11:22 ` [RFC PATCH 00/10] Support for Cortex-M Prototyping System Arnd Bergmann
2015-11-25 14:39   ` Vladimir Murzin

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=1448447621-17900-6-git-send-email-vladimir.murzin@arm.com \
    --to=vladimir.murzin@arm.com \
    --cc=Mark.Rutland@arm.com \
    --cc=Pawel.Moll@arm.com \
    --cc=afaerber@suse.de \
    --cc=arnd@arndb.de \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=jslaby@suse.cz \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=u.kleine-koenig@pengutronix.de \
    /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

all inboxes | Powered by JetHome®