diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2016-08-06 00:54:03 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2016-08-06 00:54:03 +0000 |
commit | d6344e6c757b16573f73b8003c7a87efdd0ef167 (patch) | |
tree | c65598f54cbe0c59e1f87db8768df9ea3d6ecdc2 /sys | |
parent | 632047e4e7060ac522311b7bb89cc39202cfbf68 (diff) |
Dynamically attach pluart(4) using the FDT.
ok kettenis@ patrick@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/armv7/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/arch/armv7/conf/RAMDISK | 4 | ||||
-rw-r--r-- | sys/arch/armv7/vexpress/files.vexpress | 4 | ||||
-rw-r--r-- | sys/arch/armv7/vexpress/pl011.c | 56 | ||||
-rw-r--r-- | sys/arch/armv7/vexpress/vexpress.c | 3 |
5 files changed, 22 insertions, 49 deletions
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 <patrick@blueri.se> @@ -38,10 +38,7 @@ #endif #include <machine/bus.h> -//#include <machine/clock.h> -#if NFDT > 0 #include <machine/fdt.h> -#endif #include <arm/armv7/armv7var.h> #include <armv7/vexpress/pl011reg.h> #include <armv7/vexpress/pl011var.h> @@ -49,6 +46,7 @@ #include <armv7/armv7/armv7_machdep.h> #include <dev/ofw/fdt.h> +#include <dev/ofw/openfirm.h> #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 <jsg@openbsd.org> @@ -40,7 +40,6 @@ struct cfdriver vexpress_cd = { struct board_dev vexpress_devs[] = { { "sysreg", 0 }, - { "pluart", 0 }, { NULL, 0 } }; |