-/* $OpenBSD: expower.c,v 1.7 2017/03/10 21:26:19 kettenis Exp $ */
+/* $OpenBSD: expower.c,v 1.8 2021/02/14 10:57:40 kettenis Exp $ */
/*
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
*
#include <dev/ofw/ofw_misc.h>
#include <dev/ofw/fdt.h>
+#include <arm/simplebus/simplebusvar.h>
+
#define HREAD4(sc, reg) \
(bus_space_read_4((sc)->sc_iot, (sc)->sc_ioh, (reg)))
#define HWRITE4(sc, reg, val) \
HWRITE4((sc), (reg), HREAD4((sc), (reg)) & ~(bits))
struct expower_softc {
- struct device sc_dev;
+ struct simplebus_softc sc_sbus;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
};
{
struct fdt_attach_args *faa = aux;
- return (OF_is_compatible(faa->fa_node, "samsung,exynos5250-pmu") ||
- OF_is_compatible(faa->fa_node, "samsung,exynos5420-pmu"));
+ if (OF_is_compatible(faa->fa_node, "samsung,exynos5250-pmu") ||
+ OF_is_compatible(faa->fa_node, "samsung,exynos5420-pmu"))
+ return 10; /* Must beat syscon(4). */
+
+ return 0;
}
void
struct expower_softc *sc = (struct expower_softc *)self;
struct fdt_attach_args *faa = aux;
- sc->sc_iot = faa->fa_iot;
+ 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))
- panic("%s: bus_space_map failed!", __func__);
-
- printf("\n");
+ faa->fa_reg[0].size, 0, &sc->sc_ioh)) {
+ printf(": can't map registers\n");
+ return;
+ }
regmap_register(faa->fa_node, sc->sc_iot, sc->sc_ioh,
faa->fa_reg[0].size);
+
+ simplebus_attach(parent, &sc->sc_sbus.sc_dev, faa);
}