summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2016-07-13 20:42:45 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2016-07-13 20:42:45 +0000
commitee0dec28c54fc45794756ec26c580286bd4617aa (patch)
treea39ccd27aee1e2a60224b5d8724ad473a3c72e6d /sys/arch
parente20089837853de35ad72618b51600d663ea50b46 (diff)
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@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/arm/include/fdt.h4
-rw-r--r--sys/arch/arm/mainbus/mainbus.c8
-rw-r--r--sys/arch/arm/simplebus/simplebus.c10
3 files changed, 19 insertions, 3 deletions
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 <patrick@blueri.se>
*
@@ -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 <patrick@blueri.se>
*
@@ -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 <patrick@blueri.se>
*
@@ -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) {