summaryrefslogtreecommitdiff
path: root/sys/arch/armv7
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2016-10-08 06:45:03 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2016-10-08 06:45:03 +0000
commitb88bea0abceb377a719cc0fd54e669f58e33a4f0 (patch)
treeb3ac041456047874b9aaff9dc26c9fa09a5fd312 /sys/arch/armv7
parent6a0ecc9101b5f78af877d5bd7b69de7b59d5b63e (diff)
Dynamically attach sysreg(4) using the FDT.
Diffstat (limited to 'sys/arch/armv7')
-rw-r--r--sys/arch/armv7/conf/GENERIC4
-rw-r--r--sys/arch/armv7/conf/RAMDISK4
-rw-r--r--sys/arch/armv7/vexpress/files.vexpress4
-rw-r--r--sys/arch/armv7/vexpress/sysreg.c28
-rw-r--r--sys/arch/armv7/vexpress/vexpress.c3
5 files changed, 28 insertions, 15 deletions
diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC
index d3eb7aa9c49..31fbac36a5a 100644
--- a/sys/arch/armv7/conf/GENERIC
+++ b/sys/arch/armv7/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.61 2016/10/07 19:10:46 patrick Exp $
+# $OpenBSD: GENERIC,v 1.62 2016/10/08 06:45:02 jsg Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -105,7 +105,7 @@ usb* at ehci? #flags 0x1
# ARM Versatile Express
vexpress0 at mainbus?
-sysreg* at vexpress?
+sysreg* at fdt?
pluart* at fdt?
plrtc* at fdt?
virtio* at fdt?
diff --git a/sys/arch/armv7/conf/RAMDISK b/sys/arch/armv7/conf/RAMDISK
index ff4b59f4daf..371d88727af 100644
--- a/sys/arch/armv7/conf/RAMDISK
+++ b/sys/arch/armv7/conf/RAMDISK
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISK,v 1.56 2016/10/07 19:10:46 patrick Exp $
+# $OpenBSD: RAMDISK,v 1.57 2016/10/08 06:45:02 jsg Exp $
machine armv7 arm
@@ -103,7 +103,7 @@ usb* at ehci? #flags 0x1
# ARM Versatile Express
vexpress0 at mainbus?
-sysreg* at vexpress?
+sysreg* at fdt?
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 c7ee6c384c4..776ba9d7c31 100644
--- a/sys/arch/armv7/vexpress/files.vexpress
+++ b/sys/arch/armv7/vexpress/files.vexpress
@@ -1,4 +1,4 @@
-# $OpenBSD: files.vexpress,v 1.7 2016/08/31 16:19:40 jsg Exp $
+# $OpenBSD: files.vexpress,v 1.8 2016/10/08 06:45:02 jsg Exp $
define vexpress {}
device vexpress: vexpress
@@ -12,5 +12,5 @@ attach virtio at fdt with virtio_mmio
file arch/armv7/vexpress/virtio_mmio.c virtio_mmio
device sysreg
-attach sysreg at vexpress
+attach sysreg at fdt
file arch/armv7/vexpress/sysreg.c sysreg
diff --git a/sys/arch/armv7/vexpress/sysreg.c b/sys/arch/armv7/vexpress/sysreg.c
index 4479ae0b550..6caad43b3d3 100644
--- a/sys/arch/armv7/vexpress/sysreg.c
+++ b/sys/arch/armv7/vexpress/sysreg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysreg.c,v 1.1 2015/06/08 06:33:16 jsg Exp $ */
+/* $OpenBSD: sysreg.c,v 1.2 2016/10/08 06:45:02 jsg Exp $ */
/*
* Copyright (c) 2015 Jonathan Gray <jsg@openbsd.org>
@@ -20,8 +20,13 @@
#include <sys/systm.h>
#include <sys/device.h>
#include <machine/bus.h>
+#include <machine/fdt.h>
+
#include <armv7/armv7/armv7var.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/fdt.h>
+
#define SYS_ID 0x00
#define SYS_PROCID0 0x84
#define SYS_PROCID1 0x88
@@ -47,27 +52,36 @@ struct sysreg_softc {
struct sysreg_softc *sysreg_sc;
+int sysreg_match(struct device *, void *, void *);
void sysreg_attach(struct device *, struct device *, void *);
void sysreg_reset(void);
struct cfattach sysreg_ca = {
- sizeof (struct sysreg_softc), NULL, sysreg_attach
+ sizeof (struct sysreg_softc), sysreg_match, sysreg_attach
};
struct cfdriver sysreg_cd = {
NULL, "sysreg", DV_DULL
};
+int
+sysreg_match(struct device *parent, void *match, void *aux)
+{
+ struct fdt_attach_args *faa = aux;
+
+ return OF_is_compatible(faa->fa_node, "arm,vexpress-sysreg");
+}
+
void
-sysreg_attach(struct device *parent, struct device *self, void *args)
+sysreg_attach(struct device *parent, struct device *self, void *aux)
{
- struct armv7_attach_args *aa = args;
+ struct fdt_attach_args *faa = aux;
struct sysreg_softc *sc = (struct sysreg_softc *)self;
uint32_t id;
- sc->sc_iot = aa->aa_iot;
- if (bus_space_map(sc->sc_iot, aa->aa_dev->mem[0].addr,
- aa->aa_dev->mem[0].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(": bus_space_map failed!");
sysreg_sc = sc;
diff --git a/sys/arch/armv7/vexpress/vexpress.c b/sys/arch/armv7/vexpress/vexpress.c
index 41f0a278f63..ef1841f2132 100644
--- a/sys/arch/armv7/vexpress/vexpress.c
+++ b/sys/arch/armv7/vexpress/vexpress.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vexpress.c,v 1.8 2016/08/06 00:54:02 jsg Exp $ */
+/* $OpenBSD: vexpress.c,v 1.9 2016/10/08 06:45:02 jsg Exp $ */
/*
* Copyright (c) 2015 Jonathan Gray <jsg@openbsd.org>
@@ -39,7 +39,6 @@ struct cfdriver vexpress_cd = {
};
struct board_dev vexpress_devs[] = {
- { "sysreg", 0 },
{ NULL, 0 }
};