summaryrefslogtreecommitdiffstats
path: root/sys/dev/fdt/syscon.c
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2018-03-17 18:04:15 +0000
committerkettenis <kettenis@openbsd.org>2018-03-17 18:04:15 +0000
commitc4620c40fbbabde16a0cd7797e2e58c4c0243d58 (patch)
tree70617a40067ab7e16e0380db3fe98e85875ecc8e /sys/dev/fdt/syscon.c
parentIn x509_cmp.c rev. 1.30 2018/03/17 14:57:23, jsing@ adjusted (diff)
downloadwireguard-openbsd-c4620c40fbbabde16a0cd7797e2e58c4c0243d58.tar.xz
wireguard-openbsd-c4620c40fbbabde16a0cd7797e2e58c4c0243d58.zip
If we are compatible with "simple-mfd", attempt to attach child nodes.
ok visa@
Diffstat (limited to 'sys/dev/fdt/syscon.c')
-rw-r--r--sys/dev/fdt/syscon.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/sys/dev/fdt/syscon.c b/sys/dev/fdt/syscon.c
index 91f5b82978b..fe6de250120 100644
--- a/sys/dev/fdt/syscon.c
+++ b/sys/dev/fdt/syscon.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscon.c,v 1.3 2017/10/09 11:47:53 kettenis Exp $ */
+/* $OpenBSD: syscon.c,v 1.4 2018/03/17 18:04:15 kettenis Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis
*
@@ -26,11 +26,17 @@
#include <dev/ofw/ofw_misc.h>
#include <dev/ofw/fdt.h>
+#ifdef __armv7__
+#include <arm/simplebus/simplebusvar.h>
+#else
+#include <arm64/dev/simplebusvar.h>
+#endif
+
extern void (*cpuresetfn)(void);
extern void (*powerdownfn)(void);
struct syscon_softc {
- struct device sc_dev;
+ struct simplebus_softc sc_sbus;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
uint32_t sc_regmap;
@@ -72,6 +78,9 @@ syscon_attach(struct device *parent, struct device *self, void *aux)
struct fdt_attach_args *faa = aux;
char name[32];
+ OF_getprop(faa->fa_node, "name", name, sizeof(name));
+ name[sizeof(name) - 1] = 0;
+
if (OF_is_compatible(faa->fa_node, "syscon")) {
if (faa->fa_nreg < 1) {
printf(": no registers\n");
@@ -88,19 +97,15 @@ syscon_attach(struct device *parent, struct device *self, void *aux)
regmap_register(faa->fa_node, sc->sc_iot, sc->sc_ioh,
faa->fa_reg[0].size);
-
- if (OF_getprop(faa->fa_node, "name", name, sizeof(name)) > 0) {
- name[sizeof(name) - 1] = 0;
- printf(": \"%s\"", name);
- }
-
- printf("\n");
}
+ if (OF_is_compatible(faa->fa_node, "simple-mfd"))
+ simplebus_attach(parent, &sc->sc_sbus.sc_dev, faa);
+ else
+ printf(": \"%s\"\n", name);
+
if (OF_is_compatible(faa->fa_node, "syscon-reboot") ||
OF_is_compatible(faa->fa_node, "syscon-poweroff")) {
- printf("\n");
-
sc->sc_regmap = OF_getpropint(faa->fa_node, "regmap", 0);
if (sc->sc_regmap == 0)
return;