From: jsg Date: Sat, 6 Aug 2016 00:40:54 +0000 (+0000) Subject: Dynamically attach plrtc(4) using the FDT. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d4dcc2ffc4be27ca2a82d1bdb89a09238ca16949;p=openbsd Dynamically attach plrtc(4) using the FDT. ok kettenis@ patrick@ --- diff --git a/share/man/man4/man4.armv7/plrtc.4 b/share/man/man4/man4.armv7/plrtc.4 index 1f8e00da327..cdda1f00f02 100644 --- a/share/man/man4/man4.armv7/plrtc.4 +++ b/share/man/man4/man4.armv7/plrtc.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: plrtc.4,v 1.1 2015/06/14 13:53:49 jsg Exp $ +.\" $OpenBSD: plrtc.4,v 1.2 2016/08/06 00:40:54 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 PLRTC 4 armv7 .Os .Sh NAME .Nm plrtc .Nd ARM PrimeCell PL031 Real-time clock .Sh SYNOPSIS -.Cd "plrtc* at vexpress?" +.Cd "plrtc* 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 5923975cb41..5bfe8db7777 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.2 2016/08/06 00:34:24 jsg Exp $ +.\" $OpenBSD: vexpress.4,v 1.3 2016/08/06 00:40:54 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 plrtc 4 -ARM PrimeCell PL031 Real-time clock .It Xr pluart 4 ARM PrimeCell PL011 UART .It Xr sysreg 4 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 @@ -22,9 +22,13 @@ #include #include +#include #include #include +#include +#include + #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 @@ -41,7 +41,6 @@ struct cfdriver vexpress_cd = { struct board_dev vexpress_devs[] = { { "sysreg", 0 }, { "pluart", 0 }, - { "plrtc", 0 }, { NULL, 0 } };