From: jsg Date: Sat, 6 Aug 2016 00:54:02 +0000 (+0000) Subject: Dynamically attach pluart(4) using the FDT. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=784d018da212b6e834e089d08cdc8954ffa4d7f6;p=openbsd Dynamically attach pluart(4) using the FDT. ok kettenis@ patrick@ --- diff --git a/share/man/man4/man4.armv7/pluart.4 b/share/man/man4/man4.armv7/pluart.4 index d7aae70792f..f2158d98cb7 100644 --- a/share/man/man4/man4.armv7/pluart.4 +++ b/share/man/man4/man4.armv7/pluart.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: pluart.4,v 1.1 2015/06/14 13:53:49 jsg Exp $ +.\" $OpenBSD: pluart.4,v 1.2 2016/08/06 00:54:02 jsg Exp $ .\" .\" Copyright (c) 2015 Jonathan Gray .\" @@ -14,14 +14,14 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 14 2015 $ +.Dd $Mdocdate: August 6 2016 $ .Dt PLUART 4 armv7 .Os .Sh NAME .Nm pluart .Nd ARM PrimeCell PL011 UART .Sh SYNOPSIS -.Cd "pluart* at vexpress?" +.Cd "pluart* at fdt?" .Sh DESCRIPTION The .Nm diff --git a/share/man/man4/man4.armv7/vexpress.4 b/share/man/man4/man4.armv7/vexpress.4 index 5bfe8db7777..85ad6cc577c 100644 --- a/share/man/man4/man4.armv7/vexpress.4 +++ b/share/man/man4/man4.armv7/vexpress.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: vexpress.4,v 1.3 2016/08/06 00:40:54 jsg Exp $ +.\" $OpenBSD: vexpress.4,v 1.4 2016/08/06 00:54:02 jsg Exp $ .\" .\" Copyright (c) 2014 Sylvestre Gallon .\" @@ -33,8 +33,6 @@ ARM Versatile Express development boards. provides support for the following devices: .Pp .Bl -tag -width 12n -offset indent -compact -.It Xr pluart 4 -ARM PrimeCell PL011 UART .It Xr sysreg 4 ARM Motherboard Express microATX system registers .El diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC index b2178ef45f8..a2ef41e94cb 100644 --- a/sys/arch/armv7/conf/GENERIC +++ b/sys/arch/armv7/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.38 2016/08/06 00:40:54 jsg Exp $ +# $OpenBSD: GENERIC,v 1.39 2016/08/06 00:54:02 jsg Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -103,7 +103,7 @@ usb* at ehci? #flags 0x1 # ARM Versatile Express vexpress0 at mainbus? sysreg* at vexpress? -pluart* at vexpress? +pluart* at fdt? plrtc* at fdt? virtio* at fdt? diff --git a/sys/arch/armv7/conf/RAMDISK b/sys/arch/armv7/conf/RAMDISK index 3cfdf8bcb69..4c95f492564 100644 --- a/sys/arch/armv7/conf/RAMDISK +++ b/sys/arch/armv7/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.35 2016/08/06 00:40:54 jsg Exp $ +# $OpenBSD: RAMDISK,v 1.36 2016/08/06 00:54:02 jsg Exp $ machine armv7 arm @@ -102,7 +102,7 @@ usb* at ehci? #flags 0x1 # ARM Versatile Express vexpress0 at mainbus? sysreg* at vexpress? -pluart* at vexpress? +pluart* at fdt? plrtc* at fdt? virtio* at fdt? diff --git a/sys/arch/armv7/vexpress/files.vexpress b/sys/arch/armv7/vexpress/files.vexpress index cb6fe0b17c7..01b56ef36f4 100644 --- a/sys/arch/armv7/vexpress/files.vexpress +++ b/sys/arch/armv7/vexpress/files.vexpress @@ -1,4 +1,4 @@ -# $OpenBSD: files.vexpress,v 1.5 2016/08/06 00:40:54 jsg Exp $ +# $OpenBSD: files.vexpress,v 1.6 2016/08/06 00:54:02 jsg Exp $ define vexpress {} device vexpress: vexpress @@ -9,7 +9,7 @@ file arch/armv7/vexpress/vexpress_a9.c vexpress file arch/armv7/vexpress/vexpress_a15.c vexpress device pluart -attach pluart at vexpress +attach pluart at fdt file arch/armv7/vexpress/pl011.c pluart device plrtc diff --git a/sys/arch/armv7/vexpress/pl011.c b/sys/arch/armv7/vexpress/pl011.c index b4fa1b2e327..ce36fd180bb 100644 --- a/sys/arch/armv7/vexpress/pl011.c +++ b/sys/arch/armv7/vexpress/pl011.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pl011.c,v 1.4 2016/07/26 22:10:10 patrick Exp $ */ +/* $OpenBSD: pl011.c,v 1.5 2016/08/06 00:54:02 jsg Exp $ */ /* * Copyright (c) 2014 Patrick Wildt @@ -38,10 +38,7 @@ #endif #include -//#include -#if NFDT > 0 #include -#endif #include #include #include @@ -49,6 +46,7 @@ #include #include +#include #define DEVUNIT(x) (minor(x) & 0x7f) #define DEVCUA(x) (minor(x) & 0x80) @@ -154,58 +152,34 @@ pl011_init_cons(void) int pl011probe(struct device *parent, void *self, void *aux) { -#if NFDT > 0 - struct armv7_attach_args *aa = aux; - - if (fdt_node_compatible("arm,pl011", aa->aa_node)) - return 1; -#endif + struct fdt_attach_args *faa = aux; - return 0; + return OF_is_compatible(faa->fa_node, "arm,pl011"); } struct cdevsw pl011dev = cdev_tty_init(3/*XXX NUART */ ,pl011); /* 12: serial port */ void -pl011attach(struct device *parent, struct device *self, void *args) +pl011attach(struct device *parent, struct device *self, void *aux) { - struct armv7_attach_args *aa = args; + struct fdt_attach_args *faa = aux; struct pl011_softc *sc = (struct pl011_softc *) self; - struct armv7mem mem; - int irq; - -#if NFDT > 0 - if (aa->aa_node) { - struct fdt_reg reg; - - if (fdt_get_reg(aa->aa_node, 0, ®)) - panic("%s: could not extract memory data from FDT", - __func__); - mem.addr = reg.addr; - mem.size = reg.size; - - if (fdt_node_property_ints(aa->aa_node, "interrupts", - ints, 3) != 3) - panic("%s: could not extract interrupt data from FDT", - __func__); - irq = ints[1]; - } else -#endif - { - irq = aa->aa_dev->irq[0]; - mem.addr = aa->aa_dev->mem[0].addr; - mem.size = aa->aa_dev->mem[0].size; + + if (faa->fa_nreg < 1) { + printf(": no register data\n"); + return; } - sc->sc_irq = arm_intr_establish(irq, IPL_TTY, pl011_intr, + sc->sc_irq = arm_intr_establish_fdt(faa->fa_node, IPL_TTY, pl011_intr, sc, sc->sc_dev.dv_xname); - sc->sc_iot = aa->aa_iot; - if (bus_space_map(sc->sc_iot, mem.addr, mem.size, 0, &sc->sc_ioh)) + sc->sc_iot = faa->fa_iot; + if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, faa->fa_reg[0].size, + 0, &sc->sc_ioh)) panic("pl011attach: bus_space_map failed!"); - if (mem.addr == pl011consaddr) + if (faa->fa_reg[0].addr == pl011consaddr) printf(" console"); timeout_set(&sc->sc_diag_tmo, pl011_diag, sc); diff --git a/sys/arch/armv7/vexpress/vexpress.c b/sys/arch/armv7/vexpress/vexpress.c index 9425a222e11..41f0a278f63 100644 --- a/sys/arch/armv7/vexpress/vexpress.c +++ b/sys/arch/armv7/vexpress/vexpress.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vexpress.c,v 1.7 2016/08/06 00:40:54 jsg Exp $ */ +/* $OpenBSD: vexpress.c,v 1.8 2016/08/06 00:54:02 jsg Exp $ */ /* * Copyright (c) 2015 Jonathan Gray @@ -40,7 +40,6 @@ struct cfdriver vexpress_cd = { struct board_dev vexpress_devs[] = { { "sysreg", 0 }, - { "pluart", 0 }, { NULL, 0 } };