summaryrefslogtreecommitdiffstats
path: root/sys/dev/fdt
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2014-10-26 04:01:57 +0000
committerian <ian@FreeBSD.org>2014-10-26 04:01:57 +0000
commit8526d66c636337d8a561fa54ed24f881c8ad347a (patch)
treed30aae75ed4f574bdf983f60ce365f26ac1f52c7 /sys/dev/fdt
parent14eb39a57df6f6895c77b2d794c3b6a68e73542f (diff)
downloadFreeBSD-src-8526d66c636337d8a561fa54ed24f881c8ad347a.zip
FreeBSD-src-8526d66c636337d8a561fa54ed24f881c8ad347a.tar.gz
MFC r272109, r272181:
Replace multiple nearly-identical copies of code to walk through an FDT node's interrupts=<...> property creating resource list entries with a single common implementation. This change makes ofw_bus_intr_to_rl() the one true copy of that code and removes the copies of it from other places. This also adds handling of the interrupts-extended property.
Diffstat (limited to 'sys/dev/fdt')
-rw-r--r--sys/dev/fdt/fdt_common.c40
-rw-r--r--sys/dev/fdt/fdt_common.h1
-rw-r--r--sys/dev/fdt/simplebus.c33
3 files changed, 2 insertions, 72 deletions
diff --git a/sys/dev/fdt/fdt_common.c b/sys/dev/fdt/fdt_common.c
index 77cf8ba..9d0c0f0 100644
--- a/sys/dev/fdt/fdt_common.c
+++ b/sys/dev/fdt/fdt_common.c
@@ -494,46 +494,6 @@ out:
}
int
-fdt_intr_to_rl(device_t dev, phandle_t node, struct resource_list *rl,
- struct fdt_sense_level *intr_sl)
-{
- phandle_t iparent;
- uint32_t *intr, icells;
- int nintr, i, k;
-
- nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr),
- (void **)&intr);
- if (nintr > 0) {
- if (OF_searchencprop(node, "interrupt-parent", &iparent,
- sizeof(iparent)) == -1) {
- device_printf(dev, "No interrupt-parent found, "
- "assuming direct parent\n");
- iparent = OF_parent(node);
- }
- if (OF_searchencprop(OF_node_from_xref(iparent),
- "#interrupt-cells", &icells, sizeof(icells)) == -1) {
- device_printf(dev, "Missing #interrupt-cells property, "
- "assuming <1>\n");
- icells = 1;
- }
- if (icells < 1 || icells > nintr) {
- device_printf(dev, "Invalid #interrupt-cells property "
- "value <%d>, assuming <1>\n", icells);
- icells = 1;
- }
- for (i = 0, k = 0; i < nintr; i += icells, k++) {
- intr[i] = ofw_bus_map_intr(dev, iparent, icells,
- &intr[i]);
- resource_list_add(rl, SYS_RES_IRQ, k, intr[i], intr[i],
- 1);
- }
- free(intr, M_OFWPROP);
- }
-
- return (0);
-}
-
-int
fdt_get_phyaddr(phandle_t node, device_t dev, int *phy_addr, void **phy_sc)
{
phandle_t phy_node;
diff --git a/sys/dev/fdt/fdt_common.h b/sys/dev/fdt/fdt_common.h
index d306f65..0a79ce0 100644
--- a/sys/dev/fdt/fdt_common.h
+++ b/sys/dev/fdt/fdt_common.h
@@ -88,7 +88,6 @@ int fdt_get_phyaddr(phandle_t, device_t, int *, void **);
int fdt_get_range(phandle_t, int, u_long *, u_long *);
int fdt_immr_addr(vm_offset_t);
int fdt_regsize(phandle_t, u_long *, u_long *);
-int fdt_intr_to_rl(device_t, phandle_t, struct resource_list *, struct fdt_sense_level *);
int fdt_is_compatible(phandle_t, const char *);
int fdt_is_compatible_strict(phandle_t, const char *);
int fdt_is_enabled(phandle_t);
diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c
index e21b913..4159783 100644
--- a/sys/dev/fdt/simplebus.c
+++ b/sys/dev/fdt/simplebus.c
@@ -247,11 +247,9 @@ simplebus_setup_dinfo(device_t dev, phandle_t node)
{
struct simplebus_softc *sc;
struct simplebus_devinfo *ndi;
- uint32_t *reg, *intr, icells;
+ uint32_t *reg;
uint64_t phys, size;
- phandle_t iparent;
int i, j, k;
- int nintr;
int nreg;
sc = device_get_softc(dev);
@@ -289,34 +287,7 @@ simplebus_setup_dinfo(device_t dev, phandle_t node)
}
free(reg, M_OFWPROP);
- nintr = OF_getencprop_alloc(node, "interrupts", sizeof(*intr),
- (void **)&intr);
- if (nintr > 0) {
- if (OF_searchencprop(node, "interrupt-parent", &iparent,
- sizeof(iparent)) == -1) {
- device_printf(dev, "No interrupt-parent found, "
- "assuming direct parent\n");
- iparent = OF_parent(node);
- }
- if (OF_searchencprop(OF_node_from_xref(iparent),
- "#interrupt-cells", &icells, sizeof(icells)) == -1) {
- device_printf(dev, "Missing #interrupt-cells property, "
- "assuming <1>\n");
- icells = 1;
- }
- if (icells < 1 || icells > nintr) {
- device_printf(dev, "Invalid #interrupt-cells property "
- "value <%d>, assuming <1>\n", icells);
- icells = 1;
- }
- for (i = 0, k = 0; i < nintr; i += icells, k++) {
- intr[i] = ofw_bus_map_intr(dev, iparent, icells,
- &intr[i]);
- resource_list_add(&ndi->rl, SYS_RES_IRQ, k, intr[i],
- intr[i], 1);
- }
- free(intr, M_OFWPROP);
- }
+ ofw_bus_intr_to_rl(dev, node, &ndi->rl);
return (ndi);
}
OpenPOWER on IntegriCloud