From: pranavkumar@linaro.org (Pranavkumar Sawargaonkar)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] arm64: earlyprintk support for virtio-mmio console
Date: Fri, 26 Apr 2013 16:34:56 +0530 [thread overview]
Message-ID: <1366974299-17877-3-git-send-email-pranavkumar@linaro.org> (raw)
In-Reply-To: <1366974299-17877-1-git-send-email-pranavkumar@linaro.org>
This patch implements earlyprintk based on virtio console using early_wr config register.
Kernel args for using this will be: earlyprintk=virtio-console,<phys_address>
Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
---
arch/arm64/kernel/early_printk.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/arch/arm64/kernel/early_printk.c b/arch/arm64/kernel/early_printk.c
index ac974f4..52ac6b0 100644
--- a/arch/arm64/kernel/early_printk.c
+++ b/arch/arm64/kernel/early_printk.c
@@ -25,6 +25,9 @@
#include <linux/amba/serial.h>
#include <linux/serial_reg.h>
+#include <linux/virtio_ids.h>
+#include <linux/virtio_mmio.h>
+#include <linux/virtio_console.h>
static void __iomem *early_base;
static void (*printch)(char ch);
@@ -53,6 +56,37 @@ static void smh_printch(char ch)
}
/*
+ * VIRTIO MMIO console single character Tx.
+ */
+static void virtio_console_printch(char ch)
+{
+ u32 tmp;
+ static u32 init_done;
+ static u32 can_write;
+ struct virtio_console_config *p = early_base + VIRTIO_MMIO_CONFIG;
+
+ if (!init_done) {
+ tmp = readl_relaxed(early_base + VIRTIO_MMIO_DEVICE_ID);
+ if (tmp != VIRTIO_ID_CONSOLE) {
+ init_done = 1;
+ return;
+ }
+
+ tmp = readl_relaxed(early_base + VIRTIO_MMIO_HOST_FEATURES);
+ if (!(tmp & (1 << VIRTIO_CONSOLE_F_EARLY_WRITE))) {
+ init_done = 1;
+ return;
+ }
+
+ init_done = 1;
+ can_write = 1;
+ }
+
+ if (can_write)
+ writeb_relaxed(ch, &p->early_wr);
+}
+
+/*
* 8250/16550 (8-bit aligned registers) single character TX.
*/
static void uart8250_8bit_printch(char ch)
@@ -82,6 +116,7 @@ static const struct earlycon_match earlycon_match[] __initconst = {
{ .name = "smh", .printch = smh_printch, },
{ .name = "uart8250-8bit", .printch = uart8250_8bit_printch, },
{ .name = "uart8250-32bit", .printch = uart8250_32bit_printch, },
+ { .name = "virtio-console", .printch = virtio_console_printch, },
{}
};
--
1.7.9.5
next prev parent reply other threads:[~2013-04-26 11:04 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-26 11:04 [PATCH 0/2] Early printk support for virtio console devices Pranavkumar Sawargaonkar
2013-04-26 11:04 ` [PATCH 1/2] virtio: console: Add early writeonly register to config space Pranavkumar Sawargaonkar
2013-04-29 3:10 ` Rusty Russell
2013-04-26 11:04 ` Pranavkumar Sawargaonkar [this message]
2013-04-26 11:19 ` [PATCH 0/2] Early printk support for virtio console devices Alexander Graf
2013-04-26 11:33 ` Peter Maydell
2013-04-26 12:06 ` Anup Patel
2013-04-26 12:33 ` Arnd Bergmann
2013-04-26 12:59 ` Anup Patel
2013-04-26 15:03 ` Arnd Bergmann
2013-04-26 15:54 ` Marc Zyngier
2013-04-26 15:19 ` Peter Maydell
2013-04-29 3:09 ` Rusty Russell
2013-04-29 12:22 ` Alexander Graf
2013-04-29 12:48 ` Pranavkumar Sawargaonkar
2013-04-29 12:53 ` Alexander Graf
2013-05-01 2:07 ` Rusty Russell
2013-05-01 6:53 ` Anup Patel
2013-05-01 14:46 ` Will Deacon
2013-05-02 10:06 ` Peter Maydell
2013-05-06 5:11 ` Rusty Russell
2013-05-06 9:14 ` Peter Maydell
2013-05-07 4:46 ` Rusty Russell
2013-05-07 12:19 ` Peter Maydell
2013-05-07 15:52 ` Christopher Covington
2013-05-07 15:58 ` Peter Maydell
2013-05-08 14:17 ` Catalin Marinas
2013-05-09 10:39 ` Grant Likely
2013-05-06 9:40 ` Pranavkumar Sawargaonkar
2013-04-29 12:50 ` Peter Maydell
2013-04-29 12:53 ` Alexander Graf
2013-04-30 0:32 ` Rusty Russell
2013-05-01 0:26 ` Alexander Graf
2013-05-01 5:01 ` Anup Patel
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=1366974299-17877-3-git-send-email-pranavkumar@linaro.org \
--to=pranavkumar@linaro.org \
--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).