From: Anup Patel <anup@brainfault.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.com>, Palmer Dabbelt <palmer@sifive.com>,
Albert Ou <aou@eecs.berkeley.edu>
Cc: Rob Herring <robh@kernel.org>, Anup Patel <anup@brainfault.org>,
linux-kernel@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
Atish Patra <atish.patra@wdc.com>,
linux-serial@vger.kernel.org, linux-riscv@lists.infradead.org
Subject: [PATCH 1/3] tty/serial: Add RISC-V SBI earlycon support
Date: Tue, 4 Dec 2018 19:25:05 +0530 [thread overview]
Message-ID: <20181204135507.3706-2-anup@brainfault.org> (raw)
In-Reply-To: <20181204135507.3706-1-anup@brainfault.org>
In RISC-V, the M-mode runtime firmware provide SBI calls for
debug prints. This patch adds earlycon support using RISC-V
SBI console calls. To enable it, just pass "earlycon=sbi" in
kernel parameters.
Signed-off-by: Anup Patel <anup@brainfault.org>
---
drivers/tty/serial/Kconfig | 12 +++++++++++
drivers/tty/serial/Makefile | 1 +
drivers/tty/serial/earlycon-riscv-sbi.c | 28 +++++++++++++++++++++++++
3 files changed, 41 insertions(+)
create mode 100644 drivers/tty/serial/earlycon-riscv-sbi.c
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 32886c304641..287bb41ac814 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -85,6 +85,18 @@ config SERIAL_EARLYCON_ARM_SEMIHOST
with "earlycon=smh" on the kernel command line. The console is
enabled when early_param is processed.
+config SERIAL_EARLYCON_RISCV_SBI
+ bool "Early console using RISC-V SBI"
+ depends on RISCV
+ select SERIAL_CORE
+ select SERIAL_CORE_CONSOLE
+ select SERIAL_EARLYCON
+ help
+ Support for early debug console using RISC-V SBI. This enables
+ the console before standard serial driver is probed. This is enabled
+ with "earlycon=sbi" on the kernel command line. The console is
+ enabled when early_param is processed.
+
config SERIAL_SB1250_DUART
tristate "BCM1xxx on-chip DUART serial support"
depends on SIBYTE_SB1xxx_SOC=y
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index daac675612df..3ce26ce08616 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_SERIAL_CORE) += serial_core.o
obj-$(CONFIG_SERIAL_EARLYCON) += earlycon.o
obj-$(CONFIG_SERIAL_EARLYCON_ARM_SEMIHOST) += earlycon-arm-semihost.o
+obj-$(CONFIG_SERIAL_EARLYCON_RISCV_SBI) += earlycon-riscv-sbi.o
# These Sparc drivers have to appear before others such as 8250
# which share ttySx minor node space. Otherwise console device
diff --git a/drivers/tty/serial/earlycon-riscv-sbi.c b/drivers/tty/serial/earlycon-riscv-sbi.c
new file mode 100644
index 000000000000..e1a551aae336
--- /dev/null
+++ b/drivers/tty/serial/earlycon-riscv-sbi.c
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * RISC-V SBI based earlycon
+ *
+ * Copyright (C) 2018 Anup Patel <anup@brainfault.org>
+ */
+#include <linux/kernel.h>
+#include <linux/console.h>
+#include <linux/init.h>
+#include <linux/serial_core.h>
+#include <asm/sbi.h>
+
+static void sbi_console_write(struct console *con,
+ const char *s, unsigned int n)
+{
+ int i;
+
+ for (i = 0; i < n; ++i)
+ sbi_console_putchar(s[i]);
+}
+
+static int __init early_sbi_setup(struct earlycon_device *device,
+ const char *opt)
+{
+ device->con->write = sbi_console_write;
+ return 0;
+}
+EARLYCON_DECLARE(sbi, early_sbi_setup);
--
2.17.1
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2018-12-04 14:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-04 13:55 [PATCH 0/3] RISC-V SBI earlycon Anup Patel
2018-12-04 13:55 ` Anup Patel [this message]
2018-12-05 9:58 ` [PATCH 1/3] tty/serial: Add RISC-V SBI earlycon support Greg Kroah-Hartman
2018-12-07 18:45 ` Palmer Dabbelt
2018-12-07 18:30 ` Palmer Dabbelt
2019-01-10 14:07 ` [PATCH] tty/serial: emit CR before NL in RISC-V SBL console Andreas Schwab
2019-01-10 15:16 ` Anup Patel
2019-01-10 15:26 ` Andreas Schwab
2019-01-10 16:17 ` Anup Patel
2019-01-10 17:11 ` [PATCH] tty/serial: use uart_console_write in the RISC-V SBL early console Andreas Schwab
2019-01-11 11:13 ` Anup Patel
2019-01-23 23:58 ` Palmer Dabbelt
2019-01-15 13:59 ` Christoph Hellwig
2019-01-10 20:54 ` [PATCH] tty/serial: emit CR before NL in RISC-V SBL console Palmer Dabbelt
2018-12-04 13:55 ` [PATCH 2/3] RISC-V: defconfig: Enable RISC-V SBI earlycon support Anup Patel
2018-12-07 18:30 ` Palmer Dabbelt
2018-12-04 13:55 ` [PATCH 3/3] RISC-V: Remove EARLY_PRINTK support Anup Patel
2018-12-07 18:30 ` Palmer Dabbelt
2018-12-07 18:30 ` [PATCH 0/3] RISC-V SBI earlycon Palmer Dabbelt
2019-03-25 16:23 ` Andreas Schwab
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=20181204135507.3706-2-anup@brainfault.org \
--to=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=atish.patra@wdc.com \
--cc=gregkh@linuxfoundation.org \
--cc=hch@infradead.org \
--cc=jslaby@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-serial@vger.kernel.org \
--cc=palmer@sifive.com \
--cc=robh@kernel.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).