From: patrick Date: Wed, 13 Jul 2016 20:42:44 +0000 (+0000) Subject: The "#address-cells" and "#size-cells" properties define the size X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5586125e6602058ecac077589fade48f0386bd34;p=openbsd The "#address-cells" and "#size-cells" properties define the size of the memory address and length information. The root node passes this information down to the children and it can be overwritten by other nodes inbetween. Pass these properties as part of the fdt attach args, so that we can grab that information quickly inside the drivers. ok kettenis@ --- diff --git a/sys/arch/arm/include/fdt.h b/sys/arch/arm/include/fdt.h index 67a3b9df6e1..cc7c6041229 100644 --- a/sys/arch/arm/include/fdt.h +++ b/sys/arch/arm/include/fdt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fdt.h,v 1.2 2016/06/09 12:32:42 kettenis Exp $ */ +/* $OpenBSD: fdt.h,v 1.3 2016/07/13 20:42:44 patrick Exp $ */ /* * Copyright (c) 2016 Patrick Wildt * @@ -30,6 +30,8 @@ struct fdt_attach_args { int fa_nreg; uint32_t *fa_intr; int fa_nintr; + int fa_acells; + int fa_scells; }; #endif /* __ARM_FDT_H__ */ diff --git a/sys/arch/arm/mainbus/mainbus.c b/sys/arch/arm/mainbus/mainbus.c index 5687b2a4ebf..ec867d6c2a1 100644 --- a/sys/arch/arm/mainbus/mainbus.c +++ b/sys/arch/arm/mainbus/mainbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mainbus.c,v 1.10 2016/05/29 11:03:34 jsg Exp $ */ +/* $OpenBSD: mainbus.c,v 1.11 2016/07/13 20:42:44 patrick Exp $ */ /* * Copyright (c) 2016 Patrick Wildt * @@ -36,6 +36,8 @@ struct mainbus_softc { struct device sc_dev; bus_space_tag_t sc_iot; bus_dma_tag_t sc_dmat; + int sc_acells; + int sc_scells; }; struct cfattach mainbus_ca = { @@ -96,6 +98,8 @@ mainbus_attach(struct device *parent, struct device *self, void *aux) sc->sc_iot = &armv7_bs_tag; #endif sc->sc_dmat = &mainbus_dma_tag; + sc->sc_acells = OF_getpropint(OF_peer(0), "#address-cells", 1); + sc->sc_scells = OF_getpropint(OF_peer(0), "#size-cells", 1); if ((len = OF_getprop(node, "model", buffer, sizeof(buffer))) > 0) { printf(": %s\n", buffer); @@ -145,6 +149,8 @@ mainbus_attach_node(struct device *self, int node) fa.fa_node = node; fa.fa_iot = sc->sc_iot; fa.fa_dmat = sc->sc_dmat; + fa.fa_acells = sc->sc_acells; + fa.fa_scells = sc->sc_scells; /* TODO: attach the device's clocks first? */ diff --git a/sys/arch/arm/simplebus/simplebus.c b/sys/arch/arm/simplebus/simplebus.c index d9869366c6d..65689d8a859 100644 --- a/sys/arch/arm/simplebus/simplebus.c +++ b/sys/arch/arm/simplebus/simplebus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: simplebus.c,v 1.5 2016/06/12 13:10:06 kettenis Exp $ */ +/* $OpenBSD: simplebus.c,v 1.6 2016/07/13 20:42:44 patrick Exp $ */ /* * Copyright (c) 2016 Patrick Wildt * @@ -35,6 +35,8 @@ struct simplebus_softc { int sc_node; bus_space_tag_t sc_iot; bus_dma_tag_t sc_dmat; + int sc_acells; + int sc_scells; }; struct cfattach simplebus_ca = { @@ -74,6 +76,10 @@ simplebus_attach(struct device *parent, struct device *self, void *aux) sc->sc_node = fa->fa_node; sc->sc_iot = fa->fa_iot; sc->sc_dmat = fa->fa_dmat; + sc->sc_acells = OF_getpropint(sc->sc_node, "#address-cells", + fa->fa_acells); + sc->sc_scells = OF_getpropint(sc->sc_node, "#size-cells", + fa->fa_scells); if (OF_getprop(sc->sc_node, "name", name, sizeof(name)) > 0) { name[sizeof(name) - 1] = 0; @@ -114,6 +120,8 @@ simplebus_attach_node(struct device *self, int node) fa.fa_node = node; fa.fa_iot = sc->sc_iot; fa.fa_dmat = sc->sc_dmat; + fa.fa_acells = sc->sc_acells; + fa.fa_scells = sc->sc_scells; len = OF_getproplen(node, "reg"); if (len > 0 && (len % sizeof(uint32_t)) == 0) {