summaryrefslogtreecommitdiff
path: root/sys/arch/armv7
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2016-08-06 00:40:55 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2016-08-06 00:40:55 +0000
commit632047e4e7060ac522311b7bb89cc39202cfbf68 (patch)
tree89657b23faccbc4414d7cfe944ad85f9d277c333 /sys/arch/armv7
parent5744627905d53310fa8c891ba6518ce354107189 (diff)
Dynamically attach plrtc(4) using the FDT.
ok kettenis@ patrick@
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/pl031.c30
-rw-r--r--sys/arch/armv7/vexpress/vexpress.c3
5 files changed, 31 insertions, 14 deletions
diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC
index 455a4913651..b2178ef45f8 100644
--- a/sys/arch/armv7/conf/GENERIC
+++ b/sys/arch/armv7/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.37 2016/08/06 00:30:47 jsg Exp $
+# $OpenBSD: GENERIC,v 1.38 2016/08/06 00:40:54 jsg Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -104,7 +104,7 @@ usb* at ehci? #flags 0x1
vexpress0 at mainbus?
sysreg* at vexpress?
pluart* at vexpress?
-plrtc* at vexpress?
+plrtc* at fdt?
virtio* at fdt?
# Exynos
diff --git a/sys/arch/armv7/conf/RAMDISK b/sys/arch/armv7/conf/RAMDISK
index 6bbab8c8776..3cfdf8bcb69 100644
--- a/sys/arch/armv7/conf/RAMDISK
+++ b/sys/arch/armv7/conf/RAMDISK
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISK,v 1.34 2016/08/06 00:30:47 jsg Exp $
+# $OpenBSD: RAMDISK,v 1.35 2016/08/06 00:40:54 jsg Exp $
machine armv7 arm
@@ -103,7 +103,7 @@ usb* at ehci? #flags 0x1
vexpress0 at mainbus?
sysreg* at vexpress?
pluart* at vexpress?
-plrtc* at vexpress?
+plrtc* at fdt?
virtio* at fdt?
# Exynos
diff --git a/sys/arch/armv7/vexpress/files.vexpress b/sys/arch/armv7/vexpress/files.vexpress
index f78e779a3cb..cb6fe0b17c7 100644
--- a/sys/arch/armv7/vexpress/files.vexpress
+++ b/sys/arch/armv7/vexpress/files.vexpress
@@ -1,4 +1,4 @@
-# $OpenBSD: files.vexpress,v 1.4 2016/08/06 00:30:47 jsg Exp $
+# $OpenBSD: files.vexpress,v 1.5 2016/08/06 00:40:54 jsg Exp $
define vexpress {}
device vexpress: vexpress
@@ -13,7 +13,7 @@ attach pluart at vexpress
file arch/armv7/vexpress/pl011.c pluart
device plrtc
-attach plrtc at vexpress
+attach plrtc at fdt
file arch/armv7/vexpress/pl031.c plrtc
attach virtio at fdt with virtio_mmio
diff --git a/sys/arch/armv7/vexpress/pl031.c b/sys/arch/armv7/vexpress/pl031.c
index 40f8d70cd91..47af147213a 100644
--- a/sys/arch/armv7/vexpress/pl031.c
+++ b/sys/arch/armv7/vexpress/pl031.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pl031.c,v 1.1 2015/06/14 05:01:31 jsg Exp $ */
+/* $OpenBSD: pl031.c,v 1.2 2016/08/06 00:40:54 jsg Exp $ */
/*
* Copyright (c) 2015 Jonathan Gray <jsg@openbsd.org>
@@ -22,9 +22,13 @@
#include <sys/systm.h>
#include <machine/bus.h>
+#include <machine/fdt.h>
#include <armv7/armv7/armv7var.h>
#include <dev/clock_subr.h>
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/fdt.h>
+
#define RTCDR 0x00
#define RTCMR 0x04
#define RTCLR 0x08
@@ -44,13 +48,14 @@ struct plrtc_softc {
bus_space_handle_t sc_ioh;
};
+int plrtc_match(struct device *, void *, void *);
void plrtc_attach(struct device *, struct device *, void *);
int plrtc_gettime(struct todr_chip_handle *, struct timeval *);
int plrtc_settime(struct todr_chip_handle *, struct timeval *);
struct cfattach plrtc_ca = {
- sizeof(struct plrtc_softc), NULL , plrtc_attach
+ sizeof(struct plrtc_softc), plrtc_match, plrtc_attach
};
struct cfdriver plrtc_cd = {
@@ -81,16 +86,29 @@ plrtc_settime(todr_chip_handle_t handle, struct timeval *tv)
return (0);
}
+int
+plrtc_match(struct device *parent, void *match, void *aux)
+{
+ struct fdt_attach_args *faa = aux;
+
+ return (OF_is_compatible(faa->fa_node, "arm,pl031"));
+}
+
void
plrtc_attach(struct device *parent, struct device *self, void *aux)
{
- struct armv7_attach_args *aa = aux;
+ struct fdt_attach_args *faa = aux;
struct plrtc_softc *sc = (struct plrtc_softc *) self;
todr_chip_handle_t handle;
- 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)) {
+ if (faa->fa_nreg < 1) {
+ printf(": no register data\n");
+ return;
+ }
+
+ 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)) {
printf(": failed to map mem space\n");
return;
}
diff --git a/sys/arch/armv7/vexpress/vexpress.c b/sys/arch/armv7/vexpress/vexpress.c
index 21635a0b66f..9425a222e11 100644
--- a/sys/arch/armv7/vexpress/vexpress.c
+++ b/sys/arch/armv7/vexpress/vexpress.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vexpress.c,v 1.6 2016/08/06 00:30:47 jsg Exp $ */
+/* $OpenBSD: vexpress.c,v 1.7 2016/08/06 00:40:54 jsg Exp $ */
/*
* Copyright (c) 2015 Jonathan Gray <jsg@openbsd.org>
@@ -41,7 +41,6 @@ struct cfdriver vexpress_cd = {
struct board_dev vexpress_devs[] = {
{ "sysreg", 0 },
{ "pluart", 0 },
- { "plrtc", 0 },
{ NULL, 0 }
};