From 2a81ea7d5f1cf7b2e330479bf53d9eac87a65978 Mon Sep 17 00:00:00 2001 From: jsg Date: Sun, 21 Aug 2016 07:08:46 +0000 Subject: [PATCH] When detecting the console on attach test fa_node and stdout_node not fa_reg and pl011consaddr as the pl011consaddr addresss may have been translated. Set cn_dev at this point as well as in com(4) and imxuart(4) to handle cases where stdout is not serial0. --- sys/arch/armv7/vexpress/pl011.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sys/arch/armv7/vexpress/pl011.c b/sys/arch/armv7/vexpress/pl011.c index ce36fd180bb..acda4958648 100644 --- a/sys/arch/armv7/vexpress/pl011.c +++ b/sys/arch/armv7/vexpress/pl011.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pl011.c,v 1.5 2016/08/06 00:54:02 jsg Exp $ */ +/* $OpenBSD: pl011.c,v 1.6 2016/08/21 07:08:46 jsg Exp $ */ /* * Copyright (c) 2014 Patrick Wildt @@ -165,6 +165,7 @@ pl011attach(struct device *parent, struct device *self, void *aux) { struct fdt_attach_args *faa = aux; struct pl011_softc *sc = (struct pl011_softc *) self; + int maj; if (faa->fa_nreg < 1) { printf(": no register data\n"); @@ -179,8 +180,15 @@ pl011attach(struct device *parent, struct device *self, void *aux) 0, &sc->sc_ioh)) panic("pl011attach: bus_space_map failed!"); - if (faa->fa_reg[0].addr == pl011consaddr) - printf(" console"); + if (stdout_node == faa->fa_node) { + /* Locate the major number. */ + for (maj = 0; maj < nchrdev; maj++) + if (cdevsw[maj].d_open == pl011open) + break; + cn_tab->cn_dev = makedev(maj, sc->sc_dev.dv_unit); + + printf(": console"); + } timeout_set(&sc->sc_diag_tmo, pl011_diag, sc); timeout_set(&sc->sc_dtr_tmo, pl011_raisedtr, sc); -- 2.20.1