From: Nishanth Menon <nm@ti.com>
To: Jiri Slaby <jslaby@suse.com>
Cc: Timur Tabi <timur@codeaurora.org>,
Christopher Covington <cov@codeaurora.org>,
<linux-kernel@vger.kernel.org>, <linuxppc-dev@lists.ozlabs.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
<linux-arm-kernel@lists.infradead.org>,
Nishanth Menon <nm@ti.com>
Subject: [PATCH] tty: hvc_dcc: Add basic early_con support
Date: Mon, 19 Dec 2016 18:23:36 -0600 [thread overview]
Message-ID: <20161220002336.28733-1-nm@ti.com> (raw)
In some cases, earlycon can help catch errors with kernel boot prior to
standard console is available.
Example bootargs: console=hvc0 earlycon=hvcdcc
Signed-off-by: Nishanth Menon <nm@ti.com>
---
Based on: v4.9 tag
Also applies on: next-20161219
Tested on Simulation environment (which did not have serial console option)
drivers/tty/hvc/hvc_dcc.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/drivers/tty/hvc/hvc_dcc.c b/drivers/tty/hvc/hvc_dcc.c
index 82f240fb98f0..1ec06e550656 100644
--- a/drivers/tty/hvc/hvc_dcc.c
+++ b/drivers/tty/hvc/hvc_dcc.c
@@ -10,7 +10,9 @@
* GNU General Public License for more details.
*/
+#include <linux/console.h>
#include <linux/init.h>
+#include <linux/serial_core.h>
#include <asm/dcc.h>
#include <asm/processor.h>
@@ -94,3 +96,45 @@ static int __init hvc_dcc_init(void)
return PTR_ERR_OR_ZERO(p);
}
device_initcall(hvc_dcc_init);
+
+static int hvc_dcc_earlyputc(int c)
+{
+ unsigned long count = 0xFFFFFFFF;
+ static bool dead_dcc_earlycon;
+
+ if (dead_dcc_earlycon)
+ return -EBUSY;
+
+ while (count--) {
+ if (!(__dcc_getstatus() & DCC_STATUS_TX))
+ break;
+ }
+ if (!count) {
+ dead_dcc_earlycon = true;
+ return -EBUSY;
+ }
+ __dcc_putchar(c);
+ return 0;
+}
+
+static void hvc_dcc_earlywrite(struct console *con, const char *s,
+ unsigned int n)
+{
+ int r;
+
+ while (n--) {
+ r = hvc_dcc_earlyputc(*s);
+ if (r)
+ break;
+ s++;
+ }
+}
+
+static int
+__init early_hvc_dcc_setup(struct earlycon_device *device, const char *opt)
+{
+ device->con->write = hvc_dcc_earlywrite;
+ return 0;
+}
+
+EARLYCON_DECLARE(hvcdcc, early_hvc_dcc_setup);
--
2.11.0.65.geff96d7
reply other threads:[~2016-12-20 3:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20161220002336.28733-1-nm@ti.com \
--to=nm@ti.com \
--cc=cov@codeaurora.org \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=timur@codeaurora.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).