summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2017-04-30 14:00:07 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2017-04-30 14:00:07 +0000
commit2a6016a45dcf021a577e8b6a7bdf238ab3536290 (patch)
treed5a6ac9627cd2f8eedf4989afcffff70062d0b29
parent29d7e3e57cc1af0c3fc3e07dba11181efc32179b (diff)
Add rkgrf(4), a driver that makes the "generic register file" of the Rockchip
RK3399 available to other drivers through the regmap interface.
-rw-r--r--sys/arch/arm64/conf/GENERIC5
-rw-r--r--sys/arch/arm64/conf/RAMDISK5
-rw-r--r--sys/arch/arm64/conf/files.arm643
-rw-r--r--sys/dev/fdt/files.fdt6
-rw-r--r--sys/dev/fdt/rkgrf.c79
5 files changed, 94 insertions, 4 deletions
diff --git a/sys/arch/arm64/conf/GENERIC b/sys/arch/arm64/conf/GENERIC
index 1bd4c2bbcf5..6d2ace33cc9 100644
--- a/sys/arch/arm64/conf/GENERIC
+++ b/sys/arch/arm64/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.24 2017/04/29 17:24:41 kettenis Exp $
+# $OpenBSD: GENERIC,v 1.25 2017/04/30 14:00:06 kettenis Exp $
#
# GENERIC machine description file
#
@@ -78,6 +78,9 @@ bcmdog* at fdt?
dwctwo* at fdt?
usb* at dwctwo?
+# Rockchip SoCs
+rkgrf* at fdt? early 1
+
# Sunxi SoCs
sxipio* at fdt? early 1 # GPIO pins for leds & PHYs
gpio* at sxipio?
diff --git a/sys/arch/arm64/conf/RAMDISK b/sys/arch/arm64/conf/RAMDISK
index 46abe2ff5db..465970b7ec7 100644
--- a/sys/arch/arm64/conf/RAMDISK
+++ b/sys/arch/arm64/conf/RAMDISK
@@ -1,4 +1,4 @@
-# $OpenBSD: RAMDISK,v 1.21 2017/04/29 17:24:41 kettenis Exp $
+# $OpenBSD: RAMDISK,v 1.22 2017/04/30 14:00:06 kettenis Exp $
#
# GENERIC machine description file
#
@@ -85,6 +85,9 @@ bcmdog* at fdt?
dwctwo* at fdt?
usb* at dwctwo?
+# Rockchip SoCs
+rkgrf* at fdt? early 1
+
# Sunxi SoCs
sxipio* at fdt? early 1 # GPIO pins for leds & PHYs
gpio* at sxipio?
diff --git a/sys/arch/arm64/conf/files.arm64 b/sys/arch/arm64/conf/files.arm64
index 95a107a8a43..8dae608f001 100644
--- a/sys/arch/arm64/conf/files.arm64
+++ b/sys/arch/arm64/conf/files.arm64
@@ -1,4 +1,4 @@
-# $OpenBSD: files.arm64,v 1.13 2017/04/29 17:24:41 kettenis Exp $
+# $OpenBSD: files.arm64,v 1.14 2017/04/30 14:00:06 kettenis Exp $
maxpartitions 16
maxusers 2 8 64
@@ -61,6 +61,7 @@ file arch/arm64/dev/simplebus.c simplebus
file dev/ofw/fdt.c
file dev/ofw/ofw_clock.c
file dev/ofw/ofw_gpio.c
+file dev/ofw/ofw_misc.c
file dev/ofw/ofw_pinctrl.c
file dev/ofw/ofw_regulator.c
diff --git a/sys/dev/fdt/files.fdt b/sys/dev/fdt/files.fdt
index c5ffce01553..b1f8db12441 100644
--- a/sys/dev/fdt/files.fdt
+++ b/sys/dev/fdt/files.fdt
@@ -1,4 +1,4 @@
-# $OpenBSD: files.fdt,v 1.10 2017/04/29 20:49:09 kettenis Exp $
+# $OpenBSD: files.fdt,v 1.11 2017/04/30 14:00:06 kettenis Exp $
#
# Config file and device description for machine-independent FDT code.
# Included by ports that need it.
@@ -57,3 +57,7 @@ file dev/fdt/xhci_fdt.c xhci_fdt
device syscon
attach syscon at fdt
file dev/fdt/syscon.c syscon
+
+device rkgrf
+attach rkgrf at fdt
+file dev/fdt/rkgrf.c rkgrf
diff --git a/sys/dev/fdt/rkgrf.c b/sys/dev/fdt/rkgrf.c
new file mode 100644
index 00000000000..184b666fc2f
--- /dev/null
+++ b/sys/dev/fdt/rkgrf.c
@@ -0,0 +1,79 @@
+/* $OpenBSD: rkgrf.c,v 1.1 2017/04/30 14:00:06 kettenis Exp $ */
+/*
+ * Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <machine/intr.h>
+#include <machine/bus.h>
+#include <machine/fdt.h>
+
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_misc.h>
+#include <dev/ofw/fdt.h>
+
+struct rkgrf_softc {
+ struct device sc_dev;
+ bus_space_tag_t sc_iot;
+ bus_space_handle_t sc_ioh;
+};
+
+int rkgrf_match(struct device *, void *, void *);
+void rkgrf_attach(struct device *, struct device *, void *);
+
+struct cfattach rkgrf_ca = {
+ sizeof (struct rkgrf_softc), rkgrf_match, rkgrf_attach
+};
+
+struct cfdriver rkgrf_cd = {
+ NULL, "rkgrf", DV_DULL
+};
+
+int
+rkgrf_match(struct device *parent, void *match, void *aux)
+{
+ struct fdt_attach_args *faa = aux;
+
+ return (OF_is_compatible(faa->fa_node, "rockchip,rk3399-grf") ||
+ OF_is_compatible(faa->fa_node, "rockchip,rk3399-pmugrf"));
+}
+
+void
+rkgrf_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct rkgrf_softc *sc = (struct rkgrf_softc *)self;
+ struct fdt_attach_args *faa = aux;
+
+ if (faa->fa_nreg < 1) {
+ printf(": no registers\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(": can't map registers\n");
+ return;
+ }
+
+ printf("\n");
+
+ regmap_register(faa->fa_node, sc->sc_iot, sc->sc_ioh,
+ faa->fa_reg[0].size);
+}