diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2016-05-02 08:15:56 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2016-05-02 08:15:56 +0000 |
commit | e745dff34c8b0de52da4f946c480d9cae831323c (patch) | |
tree | 72221689fe098a9caa64a9147f2ae28c7042d034 /sys/arch | |
parent | 3c702be99add97af0c6607ca0e072c99ebf6ef01 (diff) |
Rework mainbus and implement simplebus to be able to span a tree-like
topology based on device tree information. Introduce a common attach
args structure to be used for all fdt-capable bus devices.
ok jsg@ kettenis@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/arm/conf/files.arm | 15 | ||||
-rw-r--r-- | sys/arch/arm/cortex/cortex.c | 4 | ||||
-rw-r--r-- | sys/arch/arm/cortex/files.cortex | 4 | ||||
-rw-r--r-- | sys/arch/arm/include/fdt.h | 31 | ||||
-rw-r--r-- | sys/arch/arm/mainbus/cpu_mainbus.c | 4 | ||||
-rw-r--r-- | sys/arch/arm/mainbus/mainbus.c | 194 | ||||
-rw-r--r-- | sys/arch/arm/mainbus/mainbus.h | 66 | ||||
-rw-r--r-- | sys/arch/arm/simplebus/simplebus.c | 118 | ||||
-rw-r--r-- | sys/arch/arm/xscale/files.pxa2x0 | 4 | ||||
-rw-r--r-- | sys/arch/armish/conf/files.armish | 6 | ||||
-rw-r--r-- | sys/arch/armish/dev/i80321_mainbus.c | 4 | ||||
-rw-r--r-- | sys/arch/armish/dev/obio.c | 4 | ||||
-rw-r--r-- | sys/arch/armv7/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/arch/armv7/conf/RAMDISK | 3 | ||||
-rw-r--r-- | sys/arch/armv7/conf/files.armv7 | 5 | ||||
-rw-r--r-- | sys/arch/armv7/exynos/files.exynos | 4 | ||||
-rw-r--r-- | sys/arch/armv7/imx/files.imx | 4 | ||||
-rw-r--r-- | sys/arch/armv7/include/fdt.h | 3 | ||||
-rw-r--r-- | sys/arch/armv7/omap/files.omap | 4 | ||||
-rw-r--r-- | sys/arch/armv7/sunxi/files.sunxi | 4 | ||||
-rw-r--r-- | sys/arch/armv7/vexpress/files.vexpress | 4 |
21 files changed, 338 insertions, 150 deletions
diff --git a/sys/arch/arm/conf/files.arm b/sys/arch/arm/conf/files.arm index cb11960f922..d4cdcc3a811 100644 --- a/sys/arch/arm/conf/files.arm +++ b/sys/arch/arm/conf/files.arm @@ -1,4 +1,4 @@ -# $OpenBSD: files.arm,v 1.35 2016/03/22 23:28:02 patrick Exp $ +# $OpenBSD: files.arm,v 1.36 2016/05/02 08:15:55 patrick Exp $ # $NetBSD: files.arm,v 1.76 2003/11/05 12:53:15 scw Exp $ # generic networking files @@ -16,15 +16,24 @@ file arch/arm/arm/disassem.c ddb file arch/arm/arm/fiq.c fiq file arch/arm/arm/fiq_subr.S fiq +define fdt {} + # mainbus files -device mainbus {} +device mainbus: fdt attach mainbus at root file arch/arm/mainbus/mainbus.c mainbus +device simplebus: fdt +attach simplebus at fdt +file arch/arm/simplebus/simplebus.c simplebus + +# FDT support +file dev/ofw/fdt.c + include "arch/arm/cortex/files.cortex" device cpu {} -attach cpu at mainbus with cpu_mainbus +attach cpu at fdt with cpu_mainbus file arch/arm/mainbus/cpu_mainbus.c cpu_mainbus diff --git a/sys/arch/arm/cortex/cortex.c b/sys/arch/arm/cortex/cortex.c index 913feb7963c..d2d6aa508b6 100644 --- a/sys/arch/arm/cortex/cortex.c +++ b/sys/arch/arm/cortex/cortex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cortex.c,v 1.4 2016/04/08 12:08:54 patrick Exp $ */ +/* $OpenBSD: cortex.c,v 1.5 2016/05/02 08:15:55 patrick Exp $ */ /* $NetBSD: mainbus.c,v 1.3 2001/06/13 17:52:43 nathanw Exp $ */ /* @@ -97,7 +97,7 @@ struct cfdriver cortex_cd = { int cortexmatch(struct device *parent, void *cfdata, void *aux) { - struct mainbus_attach_args *ma = aux; + union mainbus_attach_args *ma = aux; struct cfdata *cf = (struct cfdata *)cfdata; int cputype = cpufunc_id(); diff --git a/sys/arch/arm/cortex/files.cortex b/sys/arch/arm/cortex/files.cortex index c0f4359fc2a..cb4200a091d 100644 --- a/sys/arch/arm/cortex/files.cortex +++ b/sys/arch/arm/cortex/files.cortex @@ -1,8 +1,8 @@ -# $OpenBSD: files.cortex,v 1.3 2013/09/09 14:31:54 patrick Exp $ +# $OpenBSD: files.cortex,v 1.4 2016/05/02 08:15:55 patrick Exp $ # ARM core device cortex {} -attach cortex at mainbus +attach cortex at fdt file arch/arm/cortex/cortex.c cortex device ampintc diff --git a/sys/arch/arm/include/fdt.h b/sys/arch/arm/include/fdt.h new file mode 100644 index 00000000000..e7ba52faaae --- /dev/null +++ b/sys/arch/arm/include/fdt.h @@ -0,0 +1,31 @@ +/* $OpenBSD: fdt.h,v 1.1 2016/05/02 08:15:55 patrick Exp $ */ +/* + * Copyright (c) 2016 Patrick Wildt <patrick@blueri.se> + * + * 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. + */ + +#ifndef __ARM_FDT_H__ +#define __ARM_FDT_H__ + +#define _ARM32_BUS_DMA_PRIVATE +#include <machine/bus.h> + +struct fdt_attach_args { + const char *fa_name; + int fa_node; + bus_space_tag_t fa_iot; + bus_dma_tag_t fa_dmat; +}; + +#endif /* __ARM_FDT_H__ */ diff --git a/sys/arch/arm/mainbus/cpu_mainbus.c b/sys/arch/arm/mainbus/cpu_mainbus.c index 63de2094b39..e6726605d70 100644 --- a/sys/arch/arm/mainbus/cpu_mainbus.c +++ b/sys/arch/arm/mainbus/cpu_mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu_mainbus.c,v 1.1 2004/02/01 05:09:49 drahn Exp $ */ +/* $OpenBSD: cpu_mainbus.c,v 1.2 2016/05/02 08:15:55 patrick Exp $ */ /* $NetBSD: cpu_mainbus.c,v 1.3 2002/01/05 22:41:48 chris Exp $ */ /* @@ -72,7 +72,7 @@ static void cpu_mainbus_attach (struct device *, struct device *, void *); static int cpu_mainbus_match(struct device *parent, void *vcf, void *aux) { - struct mainbus_attach_args *ma = aux; + union mainbus_attach_args *ma = aux; struct cfdata *cf = (struct cfdata *)vcf; return (strcmp(cf->cf_driver->cd_name, ma->ma_name) == 0); diff --git a/sys/arch/arm/mainbus/mainbus.c b/sys/arch/arm/mainbus/mainbus.c index 6ad3e8ff755..c42e0dcbdf6 100644 --- a/sys/arch/arm/mainbus/mainbus.c +++ b/sys/arch/arm/mainbus/mainbus.c @@ -1,45 +1,18 @@ -/* $OpenBSD: mainbus.c,v 1.7 2013/05/30 16:15:01 deraadt Exp $ */ -/* $NetBSD: mainbus.c,v 1.3 2001/06/13 17:52:43 nathanw Exp $ */ - +/* $OpenBSD: mainbus.c,v 1.8 2016/05/02 08:15:55 patrick Exp $ */ /* - * Copyright (c) 1994,1995 Mark Brinicombe. - * Copyright (c) 1994 Brini. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Brini. - * 4. The name of the company nor the name of the author may be used to - * endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * RiscBSD kernel project + * Copyright (c) 2016 Patrick Wildt <patrick@blueri.se> * - * mainbus.c + * 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. * - * mainbus configuration - * - * Created : 15/12/94 + * 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> @@ -47,78 +20,155 @@ #include <sys/kernel.h> #include <sys/device.h> +#include <dev/ofw/openfirm.h> + #include <arm/mainbus/mainbus.h> -/* Prototypes for functions provided */ +int mainbus_match(struct device *, void *, void *); +void mainbus_attach(struct device *, struct device *, void *); -int mainbusmatch(struct device *, void *, void *); -void mainbusattach(struct device *, struct device *, void *); -int mainbusprint(void *aux, const char *mainbus); -int mainbussearch(struct device *, void *, void *); +void mainbus_attach_node(struct device *, int); -/* attach and device structures for the device */ +int mainbus_legacy_search(struct device *, void *, void *); +void mainbus_legacy_found(struct device *, char *); + +struct mainbus_softc { + struct device sc_dev; + bus_space_tag_t sc_iot; + bus_dma_tag_t sc_dmat; +}; struct cfattach mainbus_ca = { - sizeof(struct device), mainbusmatch, mainbusattach + sizeof(struct mainbus_softc), mainbus_match, mainbus_attach, NULL, + config_activate_children }; struct cfdriver mainbus_cd = { NULL, "mainbus", DV_DULL }; +struct arm32_bus_dma_tag mainbus_dma_tag = { + 0, + 0, + NULL, + _bus_dmamap_create, + _bus_dmamap_destroy, + _bus_dmamap_load, + _bus_dmamap_load_mbuf, + _bus_dmamap_load_uio, + _bus_dmamap_load_raw, + _bus_dmamap_unload, + _bus_dmamap_sync, + _bus_dmamem_alloc, + _bus_dmamem_free, + _bus_dmamem_map, + _bus_dmamem_unmap, + _bus_dmamem_mmap, +}; + /* - * int mainbusmatch(struct device *parent, struct cfdata *cf, void *aux) + * Mainbus takes care of FDT and non-FDT machines, so we + * always attach. */ - int -mainbusmatch(struct device *parent, void *cf, void *aux) +mainbus_match(struct device *parent, void *cfdata, void *aux) { return (1); } +void +mainbus_attach(struct device *parent, struct device *self, void *aux) +{ + struct mainbus_softc *sc = (struct mainbus_softc *)self; + char buffer[128]; + int node; + + if ((node = OF_peer(0)) == 0) { + printf(": no device tree\n"); + config_search(mainbus_legacy_search, self, aux); + return; + } + +#ifdef CPU_ARMv7 + extern struct bus_space armv7_bs_tag; + sc->sc_iot = &armv7_bs_tag; +#endif + sc->sc_dmat = &mainbus_dma_tag; + + if (OF_getprop(node, "model", buffer, sizeof(buffer))) + printf(": %s\n", buffer); + else + printf(": unknown model\n"); + + /* Attach CPU first. */ + mainbus_legacy_found(self, "cpu"); + + /* TODO: Scan for interrupt controllers and attach them first? */ + + /* Scan the whole tree. */ + for (node = OF_child(node); + node != 0; + node = OF_peer(node)) + { + mainbus_attach_node(self, node); + } +} + /* - * void mainbusattach(struct device *parent, struct device *self, void *aux) - * - * probe and attach all children + * Look for a driver that wants to be attached to this node. */ - void -mainbusattach(struct device *parent, struct device *self, void *aux) +mainbus_attach_node(struct device *self, int node) { - printf("\n"); + struct mainbus_softc *sc = (struct mainbus_softc *)self; + struct fdt_attach_args fa; + char buffer[128]; + + if (!OF_getprop(node, "compatible", buffer, sizeof(buffer))) + return; + + if (OF_getprop(node, "status", buffer, sizeof(buffer))) + if (!strcmp(buffer, "disabled")) + return; - config_search(mainbussearch, self, aux); + memset(&fa, 0, sizeof(fa)); + fa.fa_name = ""; + fa.fa_node = node; + fa.fa_iot = sc->sc_iot; + fa.fa_dmat = sc->sc_dmat; + + /* TODO: attach the device's clocks first? */ + + config_found(self, &fa, NULL); } +/* + * Legacy support for SoCs that do not use FDT. + */ int -mainbussearch(struct device *parent, void *vcf, void *aux) +mainbus_legacy_search(struct device *parent, void *match, void *aux) { - struct mainbus_attach_args ma; - struct cfdata *cf = vcf; + union mainbus_attach_args ma; + struct cfdata *cf = match; + memset(&ma, 0, sizeof(ma)); ma.ma_name = cf->cf_driver->cd_name; /* allow for devices to be disabled in UKC */ if ((*cf->cf_attach->ca_match)(parent, cf, &ma) == 0) return 0; - config_attach(parent, cf, &ma, mainbusprint); + config_attach(parent, cf, &ma, NULL); return 1; } -/* - * int mainbusprint(void *aux, const char *mainbus) - * - * print routine used during config of children - */ - -int -mainbusprint(void *aux, const char *mainbus) +void +mainbus_legacy_found(struct device *self, char *name) { - struct mainbus_attach_args *ma = aux; + union mainbus_attach_args ma; - if (mainbus != NULL) - printf("%s at %s", ma->ma_name, mainbus); + memset(&ma, 0, sizeof(ma)); + ma.ma_name = name; - return (UNCONF); + config_found(self, &ma, NULL); } diff --git a/sys/arch/arm/mainbus/mainbus.h b/sys/arch/arm/mainbus/mainbus.h index 3e1799628de..42a4076de34 100644 --- a/sys/arch/arm/mainbus/mainbus.h +++ b/sys/arch/arm/mainbus/mainbus.h @@ -1,51 +1,29 @@ -/* $OpenBSD: mainbus.h,v 1.2 2011/09/22 17:45:59 miod Exp $ */ -/* $NetBSD: mainbus.h,v 1.1 2001/02/24 19:38:02 reinoud Exp $ */ - +/* $OpenBSD: mainbus.h,v 1.3 2016/05/02 08:15:55 patrick Exp $ */ /* - * Copyright (c) 1994,1995 Mark Brinicombe. - * Copyright (c) 1994 Brini. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Brini. - * 4. The name of the company nor the name of the author may be used to - * endorse or promote products derived from this software without specific - * prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * RiscBSD kernel project - * - * mainbus.h + * Copyright (c) 2016 Patrick Wildt <patrick@blueri.se> * - * mainbus configuration + * 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. * - * Created : 15/12/94 + * 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. */ -/* - * mainbus driver attach arguments - */ +#ifndef __MAINBUS_H__ +#define __MAINBUS_H__ -struct mainbus_attach_args { - const char *ma_name; +#include <arm/fdt.h> + +/* Passed as third arg to attach functions. */ +union mainbus_attach_args { + const char *ma_name; + struct fdt_attach_args ma_faa; }; + +#endif /* __MAINBUS_H__ */ diff --git a/sys/arch/arm/simplebus/simplebus.c b/sys/arch/arm/simplebus/simplebus.c new file mode 100644 index 00000000000..d87044b2e02 --- /dev/null +++ b/sys/arch/arm/simplebus/simplebus.c @@ -0,0 +1,118 @@ +/* $OpenBSD: simplebus.c,v 1.1 2016/05/02 08:15:55 patrick Exp $ */ +/* + * Copyright (c) 2016 Patrick Wildt <patrick@blueri.se> + * + * 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/kernel.h> +#include <sys/device.h> + +#include <dev/ofw/openfirm.h> + +#include <arm/fdt.h> + +int simplebus_match(struct device *, void *, void *); +void simplebus_attach(struct device *, struct device *, void *); + +void simplebus_attach_node(struct device *, int); + +struct simplebus_softc { + struct device sc_dev; + int sc_node; + bus_space_tag_t sc_iot; + bus_dma_tag_t sc_dmat; +}; + +struct cfattach simplebus_ca = { + sizeof(struct simplebus_softc), simplebus_match, simplebus_attach, NULL, + config_activate_children +}; + +struct cfdriver simplebus_cd = { + NULL, "simplebus", DV_DULL +}; + +/* + * Simplebus is a generic bus with no special casings. + */ +int +simplebus_match(struct device *parent, void *cfdata, void *aux) +{ + struct fdt_attach_args *fa = (struct fdt_attach_args *)aux; + char buffer[128]; + + if (fa->fa_node == 0) + return (0); + + if (!OF_getprop(fa->fa_node, "compatible", buffer, + sizeof(buffer))) + return (0); + + if (strcmp(buffer, "simple-bus")) + return (0); + + return (1); +} + +void +simplebus_attach(struct device *parent, struct device *self, void *aux) +{ + struct simplebus_softc *sc = (struct simplebus_softc *)self; + struct fdt_attach_args *fa = (struct fdt_attach_args *)aux; + int node; + + sc->sc_node = fa->fa_node; + sc->sc_iot = fa->fa_iot; + sc->sc_dmat = fa->fa_dmat; + + printf("\n"); + + /* Scan the whole tree. */ + for (node = OF_child(sc->sc_node); + node != 0; + node = OF_peer(node)) + { + simplebus_attach_node(self, node); + } +} + +/* + * Look for a driver that wants to be attached to this node. + */ +void +simplebus_attach_node(struct device *self, int node) +{ + struct simplebus_softc *sc = (struct simplebus_softc *)self; + struct fdt_attach_args fa; + char buffer[128]; + + if (!OF_getprop(node, "compatible", buffer, sizeof(buffer))) + return; + + if (OF_getprop(node, "status", buffer, sizeof(buffer))) + if (!strcmp(buffer, "disabled")) + return; + + memset(&fa, 0, sizeof(fa)); + fa.fa_name = ""; + fa.fa_node = node; + fa.fa_iot = sc->sc_iot; + fa.fa_dmat = sc->sc_dmat; + + /* TODO: attach the device's clocks first? */ + + config_found(self, &fa, NULL); +} diff --git a/sys/arch/arm/xscale/files.pxa2x0 b/sys/arch/arm/xscale/files.pxa2x0 index b73d7b71935..102d2df4119 100644 --- a/sys/arch/arm/xscale/files.pxa2x0 +++ b/sys/arch/arm/xscale/files.pxa2x0 @@ -1,4 +1,4 @@ -# $OpenBSD: files.pxa2x0,v 1.24 2014/10/18 12:21:56 miod Exp $ +# $OpenBSD: files.pxa2x0,v 1.25 2016/05/02 08:15:55 patrick Exp $ # $NetBSD: files.pxa2x0,v 1.6 2004/05/01 19:09:14 thorpej Exp $ # # Configuration info for Intel PXA2[51]0 CPU support @@ -9,7 +9,7 @@ file arch/arm/arm/softintr.c # Use the generic ARM soft interrupt code. # PXA2[51]0's integrated peripherals bus. define pxaip {[addr=-1], [size=0], [intr=-1], [index=-1]} device pxaip -attach pxaip at mainbus +attach pxaip at fdt file arch/arm/xscale/pxa2x0.c file arch/arm/arm/irq_dispatch.S file arch/arm/xscale/pxa2x0_space.c diff --git a/sys/arch/armish/conf/files.armish b/sys/arch/armish/conf/files.armish index 9bb866adbf8..62a038a5bee 100644 --- a/sys/arch/armish/conf/files.armish +++ b/sys/arch/armish/conf/files.armish @@ -1,4 +1,4 @@ -# $OpenBSD: files.armish,v 1.19 2016/01/15 13:20:06 tobiasu Exp $ +# $OpenBSD: files.armish,v 1.20 2016/05/02 08:15:55 patrick Exp $ maxpartitions 16 maxusers 2 8 64 @@ -32,14 +32,14 @@ include "dev/i2c/files.i2c" # ARM i80321 files include "arch/arm/xscale/files.i80321" -attach iopxs at mainbus with iopxs_mainbus +attach iopxs at fdt with iopxs_mainbus file arch/armish/dev/i80321_mainbus.c iopxs_mainbus file arch/armish/dev/pci_addr_fixup.c iopxs file arch/armish/dev/iq80321_pci.c iopxs # IQ80310 on-board devices (including CPLD) device obio {addr, [size = -1], [width = -1], [xint = -1]}: bus_space_generic -attach obio at mainbus +attach obio at fdt file arch/armish/dev/obio.c obio file arch/armish/dev/obio_space.c obio diff --git a/sys/arch/armish/dev/i80321_mainbus.c b/sys/arch/armish/dev/i80321_mainbus.c index ce711aac6fd..1004e79c96c 100644 --- a/sys/arch/armish/dev/i80321_mainbus.c +++ b/sys/arch/armish/dev/i80321_mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i80321_mainbus.c,v 1.10 2006/09/15 23:36:11 drahn Exp $ */ +/* $OpenBSD: i80321_mainbus.c,v 1.11 2016/05/02 08:15:55 patrick Exp $ */ /* $NetBSD: i80321_mainbus.c,v 1.16 2005/12/15 01:44:00 briggs Exp $ */ /* @@ -91,7 +91,7 @@ int i80321_mainbus_found; int i80321_mainbus_match(struct device *parent, void *match, void *aux) { - struct mainbus_attach_args *ma = aux; + union mainbus_attach_args *ma = aux; struct cfdata *cf = match; if (i80321_mainbus_found) diff --git a/sys/arch/armish/dev/obio.c b/sys/arch/armish/dev/obio.c index 0704ba7532e..c5186aaab93 100644 --- a/sys/arch/armish/dev/obio.c +++ b/sys/arch/armish/dev/obio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: obio.c,v 1.3 2006/06/01 17:06:16 drahn Exp $ */ +/* $OpenBSD: obio.c,v 1.4 2016/05/02 08:15:55 patrick Exp $ */ /* $NetBSD: obio.c,v 1.14 2005/12/11 12:17:09 christos Exp $ */ /* @@ -73,7 +73,7 @@ int obio_found; int obio_match(struct device *parent, void *match, void *aux) { - struct mainbus_attach_args *ma = aux; + union mainbus_attach_args *ma = aux; struct cfdata *cf = match; if (obio_found) diff --git a/sys/arch/armv7/conf/GENERIC b/sys/arch/armv7/conf/GENERIC index ccb34cea778..953984dffe9 100644 --- a/sys/arch/armv7/conf/GENERIC +++ b/sys/arch/armv7/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.8 2016/04/24 17:30:31 matthieu Exp $ +# $OpenBSD: GENERIC,v 1.9 2016/05/02 08:15:55 patrick Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -28,6 +28,7 @@ config bsd swap generic # The main bus device mainbus0 at root +simplebus* at fdt? cpu0 at mainbus? # Cortex-A9 diff --git a/sys/arch/armv7/conf/RAMDISK b/sys/arch/armv7/conf/RAMDISK index 8c0c22ba574..cda7119663b 100644 --- a/sys/arch/armv7/conf/RAMDISK +++ b/sys/arch/armv7/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.7 2015/09/13 14:43:42 deraadt Exp $ +# $OpenBSD: RAMDISK,v 1.8 2016/05/02 08:15:55 patrick Exp $ machine armv7 arm @@ -27,6 +27,7 @@ config bsd root on rd0a swap on rd0b # The main bus device mainbus0 at root +simplebus* at fdt? cpu0 at mainbus? # Cortex-A9 diff --git a/sys/arch/armv7/conf/files.armv7 b/sys/arch/armv7/conf/files.armv7 index 7a9dc6a811e..847fbcbf013 100644 --- a/sys/arch/armv7/conf/files.armv7 +++ b/sys/arch/armv7/conf/files.armv7 @@ -1,4 +1,4 @@ -# $OpenBSD: files.armv7,v 1.16 2016/04/24 00:57:23 patrick Exp $ +# $OpenBSD: files.armv7,v 1.17 2016/05/02 08:15:55 patrick Exp $ maxpartitions 16 maxusers 2 8 64 @@ -8,9 +8,6 @@ major {sd = 24} major {cd = 26} major {rd = 18} -define fdt {} -file dev/ofw/fdt.c - file arch/arm/arm/conf.c #interrupt API layer diff --git a/sys/arch/armv7/exynos/files.exynos b/sys/arch/armv7/exynos/files.exynos index 89c419322f3..ca121ce8b7c 100644 --- a/sys/arch/armv7/exynos/files.exynos +++ b/sys/arch/armv7/exynos/files.exynos @@ -1,8 +1,8 @@ -# $OpenBSD: files.exynos,v 1.3 2016/04/24 00:57:23 patrick Exp $ +# $OpenBSD: files.exynos,v 1.4 2016/05/02 08:15:55 patrick Exp $ define exynos {} device exynos: exynos -attach exynos at mainbus +attach exynos at fdt file arch/armv7/exynos/exynos_machdep.c exynos needs-flag file arch/armv7/exynos/exynos.c exynos file arch/armv7/exynos/exynos4.c exynos diff --git a/sys/arch/armv7/imx/files.imx b/sys/arch/armv7/imx/files.imx index 3e7ec3351f6..0294af62ad6 100644 --- a/sys/arch/armv7/imx/files.imx +++ b/sys/arch/armv7/imx/files.imx @@ -1,8 +1,8 @@ -# $OpenBSD: files.imx,v 1.3 2015/05/15 15:35:43 jsg Exp $ +# $OpenBSD: files.imx,v 1.4 2016/05/02 08:15:55 patrick Exp $ define imx {} device imx: imx -attach imx at mainbus +attach imx at fdt file arch/armv7/imx/imx_machdep.c imx needs-flag file arch/armv7/imx/imx.c imx file arch/armv7/imx/imx6.c diff --git a/sys/arch/armv7/include/fdt.h b/sys/arch/armv7/include/fdt.h new file mode 100644 index 00000000000..5ba05d2d1b2 --- /dev/null +++ b/sys/arch/armv7/include/fdt.h @@ -0,0 +1,3 @@ +/* $OpenBSD: fdt.h,v 1.1 2016/05/02 08:15:55 patrick Exp $ */ + +#include <arm/fdt.h> diff --git a/sys/arch/armv7/omap/files.omap b/sys/arch/armv7/omap/files.omap index 8fd446f32de..a50b93e6509 100644 --- a/sys/arch/armv7/omap/files.omap +++ b/sys/arch/armv7/omap/files.omap @@ -1,8 +1,8 @@ -# $OpenBSD: files.omap,v 1.7 2015/05/15 15:35:43 jsg Exp $ +# $OpenBSD: files.omap,v 1.8 2016/05/02 08:15:55 patrick Exp $ define omap {} device omap: omap -attach omap at mainbus +attach omap at fdt file arch/armv7/omap/omap_machdep.c omap needs-flag file arch/armv7/omap/omap.c omap file arch/armv7/omap/omap3.c diff --git a/sys/arch/armv7/sunxi/files.sunxi b/sys/arch/armv7/sunxi/files.sunxi index 80c4ba4a9b4..521b2d7da2b 100644 --- a/sys/arch/armv7/sunxi/files.sunxi +++ b/sys/arch/armv7/sunxi/files.sunxi @@ -1,8 +1,8 @@ -# $OpenBSD: files.sunxi,v 1.3 2015/05/15 15:35:43 jsg Exp $ +# $OpenBSD: files.sunxi,v 1.4 2016/05/02 08:15:55 patrick Exp $ define sunxi {} device sunxi: sunxi -attach sunxi at mainbus +attach sunxi at fdt file arch/armv7/sunxi/sunxi_machdep.c sunxi needs-flag file arch/armv7/sunxi/sunxi.c sunxi file arch/armv7/sunxi/sun4i.c diff --git a/sys/arch/armv7/vexpress/files.vexpress b/sys/arch/armv7/vexpress/files.vexpress index dd7db10932d..a06d39415fc 100644 --- a/sys/arch/armv7/vexpress/files.vexpress +++ b/sys/arch/armv7/vexpress/files.vexpress @@ -1,8 +1,8 @@ -# $OpenBSD: files.vexpress,v 1.2 2015/06/14 05:01:31 jsg Exp $ +# $OpenBSD: files.vexpress,v 1.3 2016/05/02 08:15:55 patrick Exp $ define vexpress {} device vexpress: vexpress -attach vexpress at mainbus +attach vexpress at fdt file arch/armv7/vexpress/vexpress_machdep.c vexpress needs-flag file arch/armv7/vexpress/vexpress.c vexpress file arch/armv7/vexpress/vexpress_a9.c vexpress |