diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-10-09 11:14:23 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2016-10-09 11:14:23 +0000 |
commit | d2fec34135b93761a0a2758580a954b77099a20c (patch) | |
tree | c9359ec780a67efd6daf6d699e810083570ab5a1 /sys/arch/armv7 | |
parent | 29866764057d7c534130c34a0601fb2332e0485d (diff) |
Attach sxiccmu(4) using the fdt.
ok jsg@
Diffstat (limited to 'sys/arch/armv7')
-rw-r--r-- | sys/arch/armv7/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/arch/armv7/conf/RAMDISK | 4 | ||||
-rw-r--r-- | sys/arch/armv7/sunxi/files.sunxi | 4 | ||||
-rw-r--r-- | sys/arch/armv7/sunxi/sun4i.c | 8 | ||||
-rw-r--r-- | sys/arch/armv7/sunxi/sun7i.c | 8 | ||||
-rw-r--r-- | sys/arch/armv7/sunxi/sunxi.c | 5 | ||||
-rw-r--r-- | sys/arch/armv7/sunxi/sxiccmu.c | 56 |
7 files changed, 43 insertions, 46 deletions
diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC index fc6524801b4..2dbf06b8e91 100644 --- a/sys/arch/armv7/conf/GENERIC +++ b/sys/arch/armv7/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.64 2016/10/09 01:40:42 jsg Exp $ +# $OpenBSD: GENERIC,v 1.65 2016/10/09 11:14:22 kettenis Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -89,7 +89,7 @@ sunxi0 at mainbus? sxiintc* at fdt? # A1x interrupt controller sxipio* at fdt? early 1 # GPIO pins for leds & PHYs gpio* at sxipio? -sxiccmu* at sunxi? # Clock Control Module/Unit +sxiccmu* at fdt? early 1 # Clock Control Module/Unit sxitimer* at sunxi? sxidog* at fdt? # watchdog timer sxirtc* at fdt? # Real Time Clock diff --git a/sys/arch/armv7/conf/RAMDISK b/sys/arch/armv7/conf/RAMDISK index 48fbcfca452..5885873a71a 100644 --- a/sys/arch/armv7/conf/RAMDISK +++ b/sys/arch/armv7/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.59 2016/10/09 01:40:42 jsg Exp $ +# $OpenBSD: RAMDISK,v 1.60 2016/10/09 11:14:22 kettenis Exp $ machine armv7 arm @@ -87,7 +87,7 @@ sunxi0 at mainbus? sxiintc* at fdt? # A1x interrupt controller sxipio* at fdt? early 1 # GPIO pins for leds & PHYs gpio* at sxipio? -sxiccmu* at sunxi? # Clock Control Module/Unit +sxiccmu* at fdt? early 1 # Clock Control Module/Unit sxitimer* at sunxi? sxidog* at fdt? # watchdog timer sxirtc* at fdt? # Real Time Clock diff --git a/sys/arch/armv7/sunxi/files.sunxi b/sys/arch/armv7/sunxi/files.sunxi index 8615885337f..68f8e7bd056 100644 --- a/sys/arch/armv7/sunxi/files.sunxi +++ b/sys/arch/armv7/sunxi/files.sunxi @@ -1,4 +1,4 @@ -# $OpenBSD: files.sunxi,v 1.14 2016/10/08 09:50:14 kettenis Exp $ +# $OpenBSD: files.sunxi,v 1.15 2016/10/09 11:14:22 kettenis Exp $ define sunxi {} device sunxi: sunxi @@ -9,7 +9,7 @@ file arch/armv7/sunxi/sun4i.c file arch/armv7/sunxi/sun7i.c device sxiccmu -attach sxiccmu at sunxi +attach sxiccmu at fdt file arch/armv7/sunxi/sxiccmu.c sxiccmu device sxipio {}: gpiobus diff --git a/sys/arch/armv7/sunxi/sun4i.c b/sys/arch/armv7/sunxi/sun4i.c index b2b4b07b783..444f92f42fd 100644 --- a/sys/arch/armv7/sunxi/sun4i.c +++ b/sys/arch/armv7/sunxi/sun4i.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sun4i.c,v 1.5 2016/10/08 09:50:14 kettenis Exp $ */ +/* $OpenBSD: sun4i.c,v 1.6 2016/10/09 11:14:22 kettenis Exp $ */ /* * Copyright (c) 2011 Uwe Stuehler <uwe@openbsd.org> * @@ -25,12 +25,6 @@ struct armv7_dev sxia1x_devs[] = { - /* Clock Control Module/Unit */ - { .name = "sxiccmu", - .unit = 0, - .mem = { { CCMU_ADDR, CCMU_SIZE } }, - }, - /* Timers/Counters, resources mapped on first unit */ { .name = "sxitimer", .unit = 0, diff --git a/sys/arch/armv7/sunxi/sun7i.c b/sys/arch/armv7/sunxi/sun7i.c index e4209921391..13752da5cb4 100644 --- a/sys/arch/armv7/sunxi/sun7i.c +++ b/sys/arch/armv7/sunxi/sun7i.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sun7i.c,v 1.6 2016/10/08 09:50:14 kettenis Exp $ */ +/* $OpenBSD: sun7i.c,v 1.7 2016/10/09 11:14:22 kettenis Exp $ */ /* * Copyright (c) 2011 Uwe Stuehler <uwe@openbsd.org> @@ -26,12 +26,6 @@ struct armv7_dev sxia20_devs[] = { - /* Clock Control Module/Unit */ - { .name = "sxiccmu", - .unit = 0, - .mem = { { CCMU_ADDR, CCMU_SIZE } }, - }, - /* Terminator */ { .name = NULL, .unit = 0, diff --git a/sys/arch/armv7/sunxi/sunxi.c b/sys/arch/armv7/sunxi/sunxi.c index eaf3c5fec2d..8d921d5959b 100644 --- a/sys/arch/armv7/sunxi/sunxi.c +++ b/sys/arch/armv7/sunxi/sunxi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sunxi.c,v 1.19 2016/10/08 09:50:14 kettenis Exp $ */ +/* $OpenBSD: sunxi.c,v 1.20 2016/10/09 11:14:22 kettenis Exp $ */ /* * Copyright (c) 2005,2008 Dale Rahn <drahn@openbsd.com> * @@ -40,7 +40,6 @@ struct cfdriver sunxi_cd = { }; struct board_dev sun4i_devs[] = { - { "sxiccmu", 0 }, { "sxitimer", 0 }, { "sxitimer", 1 }, { "sxitimer", 2 }, @@ -48,7 +47,6 @@ struct board_dev sun4i_devs[] = { }; struct board_dev sun5i_devs[] = { - { "sxiccmu", 0 }, { "sxitimer", 0 }, { "sxitimer", 1 }, { "sxitimer", 2 }, @@ -56,7 +54,6 @@ struct board_dev sun5i_devs[] = { }; struct board_dev sun7i_devs[] = { - { "sxiccmu", 0 }, { NULL, 0 } }; diff --git a/sys/arch/armv7/sunxi/sxiccmu.c b/sys/arch/armv7/sunxi/sxiccmu.c index 5adf894d4e5..791189d39c9 100644 --- a/sys/arch/armv7/sunxi/sxiccmu.c +++ b/sys/arch/armv7/sunxi/sxiccmu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sxiccmu.c,v 1.20 2016/10/07 18:52:36 patrick Exp $ */ +/* $OpenBSD: sxiccmu.c,v 1.21 2016/10/09 11:14:22 kettenis Exp $ */ /* * Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org> * Copyright (c) 2013 Artturi Alm @@ -28,13 +28,14 @@ #include <arm/cpufunc.h> #include <machine/bus.h> +#include <machine/fdt.h> #include <machine/intr.h> -#include <armv7/armv7/armv7var.h> #include <armv7/sunxi/sunxireg.h> #include <dev/ofw/openfirm.h> #include <dev/ofw/ofw_clock.h> +#include <dev/ofw/fdt.h> #ifdef DEBUG_CCMU #define DPRINTF(x) do { printf x; } while (0) @@ -64,10 +65,11 @@ struct sxiccmu_softc { struct reset_device sc_rd; }; +int sxiccmu_match(struct device *, void *, void *); void sxiccmu_attach(struct device *, struct device *, void *); struct cfattach sxiccmu_ca = { - sizeof (struct sxiccmu_softc), NULL, sxiccmu_attach + sizeof (struct sxiccmu_softc), sxiccmu_match, sxiccmu_attach }; struct cfdriver sxiccmu_cd = { @@ -81,39 +83,49 @@ int sxiccmu_ccu_set_frequency(void *, uint32_t *, uint32_t); void sxiccmu_ccu_enable(void *, uint32_t *, int); void sxiccmu_ccu_reset(void *, uint32_t *, int); -void -sxiccmu_attach(struct device *parent, struct device *self, void *args) +int +sxiccmu_match(struct device *parent, void *match, void *aux) { - struct sxiccmu_softc *sc = (struct sxiccmu_softc *)self; - struct armv7_attach_args *aa = args; - int node; + struct fdt_attach_args *faa = aux; - sc->sc_iot = aa->aa_iot; + if (faa->fa_node == OF_finddevice("/clocks")) { + int node = OF_parent(faa->fa_node); - if (bus_space_map(sc->sc_iot, aa->aa_dev->mem[0].addr, - aa->aa_dev->mem[0].size, 0, &sc->sc_ioh)) - panic("sxiccmu_attach: bus_space_map failed!"); + return (OF_is_compatible(node, "allwinner,sun4i-a10") || + OF_is_compatible(node, "allwinner,sun5i-a10s") || + OF_is_compatible(node, "allwinner,sun5i-r8") || + OF_is_compatible(node, "allwinner,sun7i-a20") || + OF_is_compatible(node, "allwinner,sun8i-h3")); + } - node = OF_finddevice("/clocks"); - if (node == -1) - panic("%s: can't find clocks", __func__); + return OF_is_compatible(faa->fa_node, "allwinner,sun8i-h3-ccu"); +} - printf("\n"); +void +sxiccmu_attach(struct device *parent, struct device *self, void *aux) +{ + struct sxiccmu_softc *sc = (struct sxiccmu_softc *)self; + struct fdt_attach_args *faa = aux; + int node = faa->fa_node; - for (node = OF_child(node); node; node = OF_peer(node)) - sxiccmu_attach_clock(sc, node); + sc->sc_iot = faa->fa_iot; + if (faa->fa_nreg > 0 && 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__); - node = OF_finddevice("/soc/clock@01c20000"); - if (node == -1) - return; + printf("\n"); if (OF_is_compatible(node, "allwinner,sun8i-h3-ccu")) { + KASSERT(faa->fa_nreg > 0); sc->sc_gates = sun8i_h3_gates; sc->sc_ngates = nitems(sun8i_h3_gates); sc->sc_resets = sun8i_h3_resets; sc->sc_nresets = nitems(sun8i_h3_resets); + } else { + for (node = OF_child(node); node; node = OF_peer(node)) + sxiccmu_attach_clock(sc, node); } - + if (sc->sc_gates) { sc->sc_cd.cd_node = node; sc->sc_cd.cd_cookie = sc; |