aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorIan Lepore <ian@FreeBSD.org>2014-09-01 18:51:01 +0000
committerIan Lepore <ian@FreeBSD.org>2014-09-01 18:51:01 +0000
commit752ba930785ffdb0104f77e350ab2433dec877f6 (patch)
tree4154cc6d9c0d1aa962bd79ee696b5d2dba059f4e /sys/dev
parent974a10854c2fa3aba981ab0f81d801fb5456d6a9 (diff)
Notes
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/fdt/fdt_common.c4
-rw-r--r--sys/dev/fdt/simplebus.c2
-rw-r--r--sys/dev/gpio/ofw_gpiobus.c4
-rw-r--r--sys/dev/ofw/ofw_bus_subr.c2
-rw-r--r--sys/dev/ofw/ofw_fdt.c2
-rw-r--r--sys/dev/ofw/ofwbus.c2
-rw-r--r--sys/dev/ofw/openfirm.c16
-rw-r--r--sys/dev/ofw/openfirm.h3
-rw-r--r--sys/dev/tsec/if_tsec_fdt.c2
9 files changed, 26 insertions, 11 deletions
diff --git a/sys/dev/fdt/fdt_common.c b/sys/dev/fdt/fdt_common.c
index 2651a3a1a1cd..77cf8baeba33 100644
--- a/sys/dev/fdt/fdt_common.c
+++ b/sys/dev/fdt/fdt_common.c
@@ -510,7 +510,7 @@ fdt_intr_to_rl(device_t dev, phandle_t node, struct resource_list *rl,
"assuming direct parent\n");
iparent = OF_parent(node);
}
- if (OF_searchencprop(OF_xref_phandle(iparent),
+ if (OF_searchencprop(OF_node_from_xref(iparent),
"#interrupt-cells", &icells, sizeof(icells)) == -1) {
device_printf(dev, "Missing #interrupt-cells property, "
"assuming <1>\n");
@@ -545,7 +545,7 @@ fdt_get_phyaddr(phandle_t node, device_t dev, int *phy_addr, void **phy_sc)
sizeof(phy_handle)) <= 0)
return (ENXIO);
- phy_node = OF_xref_phandle(phy_handle);
+ phy_node = OF_node_from_xref(phy_handle);
if (OF_getprop(phy_node, "reg", (void *)&phy_reg,
sizeof(phy_reg)) <= 0)
diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c
index 1c8e54c6eb5d..e21b913d8634 100644
--- a/sys/dev/fdt/simplebus.c
+++ b/sys/dev/fdt/simplebus.c
@@ -298,7 +298,7 @@ simplebus_setup_dinfo(device_t dev, phandle_t node)
"assuming direct parent\n");
iparent = OF_parent(node);
}
- if (OF_searchencprop(OF_xref_phandle(iparent),
+ if (OF_searchencprop(OF_node_from_xref(iparent),
"#interrupt-cells", &icells, sizeof(icells)) == -1) {
device_printf(dev, "Missing #interrupt-cells property, "
"assuming <1>\n");
diff --git a/sys/dev/gpio/ofw_gpiobus.c b/sys/dev/gpio/ofw_gpiobus.c
index 6e182926695b..b7cf65a098f4 100644
--- a/sys/dev/gpio/ofw_gpiobus.c
+++ b/sys/dev/gpio/ofw_gpiobus.c
@@ -129,7 +129,7 @@ ofw_gpiobus_parse_gpios(struct gpiobus_softc *sc, struct gpiobus_ivar *dinfo,
i++;
continue;
}
- gpio = OF_xref_phandle(gpios[i]);
+ gpio = OF_node_from_xref(gpios[i]);
/* Verify if we're attaching to the correct GPIO controller. */
if (!OF_hasprop(gpio, "gpio-controller") ||
gpio != ofw_bus_get_node(sc->sc_dev)) {
@@ -168,7 +168,7 @@ ofw_gpiobus_parse_gpios(struct gpiobus_softc *sc, struct gpiobus_ivar *dinfo,
continue;
}
- gpio = OF_xref_phandle(gpios[i]);
+ gpio = OF_node_from_xref(gpios[i]);
/* Read gpio-cells property for this GPIO controller. */
if (OF_getencprop(gpio, "#gpio-cells", &cells,
sizeof(cells)) < 0) {
diff --git a/sys/dev/ofw/ofw_bus_subr.c b/sys/dev/ofw/ofw_bus_subr.c
index 64ac11f33d1a..7ddb5e6ab9d1 100644
--- a/sys/dev/ofw/ofw_bus_subr.c
+++ b/sys/dev/ofw/ofw_bus_subr.c
@@ -344,7 +344,7 @@ ofw_bus_search_intrmap(void *intr, int intrsz, void *regs, int physsz,
i = imapsz;
while (i > 0) {
bcopy(mptr + physsz + intrsz, &parent, sizeof(parent));
- if (OF_searchencprop(OF_xref_phandle(parent),
+ if (OF_searchencprop(OF_node_from_xref(parent),
"#interrupt-cells", &pintrsz, sizeof(pintrsz)) == -1)
pintrsz = 1; /* default */
pintrsz *= sizeof(pcell_t);
diff --git a/sys/dev/ofw/ofw_fdt.c b/sys/dev/ofw/ofw_fdt.c
index 617d2a3ba24d..2c9bf6ec96fc 100644
--- a/sys/dev/ofw/ofw_fdt.c
+++ b/sys/dev/ofw/ofw_fdt.c
@@ -208,7 +208,7 @@ ofw_fdt_instance_to_package(ofw_t ofw, ihandle_t instance)
{
/* Where real OF uses ihandles in the tree, FDT uses xref phandles */
- return (OF_xref_phandle(instance));
+ return (OF_node_from_xref(instance));
}
/* Get the length of a property of a package. */
diff --git a/sys/dev/ofw/ofwbus.c b/sys/dev/ofw/ofwbus.c
index 402fabcf6a88..11a6a645ab48 100644
--- a/sys/dev/ofw/ofwbus.c
+++ b/sys/dev/ofw/ofwbus.c
@@ -494,7 +494,7 @@ ofwbus_setup_dinfo(device_t dev, phandle_t node)
"assuming nexus on <%s>\n", nodename);
iparent = 0xffffffff;
}
- if (OF_searchencprop(OF_xref_phandle(iparent),
+ if (OF_searchencprop(OF_node_from_xref(iparent),
"#interrupt-cells", &icells, sizeof(icells)) == -1) {
device_printf(dev, "Missing #interrupt-cells property, "
"assuming <1> on <%s>\n", nodename);
diff --git a/sys/dev/ofw/openfirm.c b/sys/dev/ofw/openfirm.c
index 97e6cbf9f761..ea82159f51ef 100644
--- a/sys/dev/ofw/openfirm.c
+++ b/sys/dev/ofw/openfirm.c
@@ -463,7 +463,7 @@ OF_child_xref_phandle(phandle_t parent, phandle_t xref)
}
phandle_t
-OF_xref_phandle(phandle_t xref)
+OF_node_from_xref(phandle_t xref)
{
phandle_t node;
@@ -474,6 +474,20 @@ OF_xref_phandle(phandle_t xref)
return (node);
}
+phandle_t
+OF_xref_from_node(phandle_t node)
+{
+ phandle_t xref;
+
+ if (OF_getencprop(node, "phandle", &xref, sizeof(xref)) ==
+ -1 && OF_getencprop(node, "ibm,phandle", &xref,
+ sizeof(xref)) == -1 && OF_getencprop(node,
+ "linux,phandle", &xref, sizeof(xref)) == -1)
+ return (node);
+
+ return (xref);
+}
+
/* Call the method in the scope of a given instance. */
int
OF_call_method(const char *method, ihandle_t instance, int nargs, int nreturns,
diff --git a/sys/dev/ofw/openfirm.h b/sys/dev/ofw/openfirm.h
index 5ac08fe12897..5f96eeb6c586 100644
--- a/sys/dev/ofw/openfirm.h
+++ b/sys/dev/ofw/openfirm.h
@@ -130,7 +130,8 @@ ssize_t OF_package_to_path(phandle_t node, char *buf, size_t len);
* real phandle. If one can't be found (or running on OF implementations
* without this property), returns its input.
*/
-phandle_t OF_xref_phandle(phandle_t xref);
+phandle_t OF_node_from_xref(phandle_t xref);
+phandle_t OF_xref_from_node(phandle_t node);
/* Device I/O functions */
ihandle_t OF_open(const char *path);
diff --git a/sys/dev/tsec/if_tsec_fdt.c b/sys/dev/tsec/if_tsec_fdt.c
index 6ed8953f472c..ccc7c948767b 100644
--- a/sys/dev/tsec/if_tsec_fdt.c
+++ b/sys/dev/tsec/if_tsec_fdt.c
@@ -166,7 +166,7 @@ tsec_fdt_attach(device_t dev)
return (ENXIO);
}
- phy = OF_xref_phandle(phy);
+ phy = OF_node_from_xref(phy);
OF_decode_addr(OF_parent(phy), 0, &sc->phy_bst, &sc->phy_bsh);
OF_getencprop(phy, "reg", &sc->phyaddr, sizeof(sc->phyaddr));