shithub: n900

Download patch

ref: 951b9aa55bdcc5a930dc0648aaf233e76b093086
parent: 5d67920090391e724e120796c49867b5d9a16e10
author: mia soweli <inbox@tachibana-labs.org>
date: Wed Sep 13 10:53:20 EDT 2023

uart: enable console when console= is set, probe in case uart is missing.

on the n900, the uart will be powered off unless the system is in r&d mode
and the uart is enabled. otherwise reads and writes will fault.

it should not be enabled by default, and it should be probed in case it is off.

--- a/sys/src/9/omap/uartomap.c
+++ b/sys/src/9/omap/uartomap.c
@@ -280,7 +280,27 @@
 void
 uartinit(void)
 {
-	consuart = &omapuart[2];
+	Uart *u;
+	Ctlr *c;
+	char *p, *pe;
+	ulong n;
+
+	p = getconf("console");
+	if(p == nil)
+		return;
+
+	n = strtoul(p, &pe, 0);
+	if(pe == p || n > nelem(omapuart))
+		return;
+
+	u = &omapuart[n];
+	c = omapuart[n].regs;
+	if(!probeaddr((uintptr)c->io))
+		return;
+
+	(*u->phys->enable)(u, 0);
+
+	consuart = u;
 	consuart->console = 1;
 	uartputs(kmesg.buf, kmesg.n);
 }