diff options
author | ian <ian@FreeBSD.org> | 2014-05-13 17:12:07 +0000 |
---|---|---|
committer | ian <ian@FreeBSD.org> | 2014-05-13 17:12:07 +0000 |
commit | 42a63a26cfe02dc91a47c8dba60ca2aae1fa1e2a (patch) | |
tree | 96994974626d0b161a11247118a5976f448b97df /sys/dev | |
parent | 3d20d204d8598105e6dd4fb0d595e33d2461a02b (diff) | |
download | FreeBSD-src-42a63a26cfe02dc91a47c8dba60ca2aae1fa1e2a.zip FreeBSD-src-42a63a26cfe02dc91a47c8dba60ca2aae1fa1e2a.tar.gz |
MFC r256870, r256898, r256899, r256900 (by nwhitehorn):
Standards-conformance and code deduplication:
- Use bus reference phandles in place of FDT offsets as IRQ domain keys
- Unify the identical macio/fdt/mambo OpenPIC drivers into one
- Be more forgiving (following ePAPR) about what we need from the device
tree to identify an OpenPIC
- Correctly map all IRQs into an interrupt domain
- Set IRQ_*_CONFORM for interrupts on an unknown PIC type instead of
failing attachment for that device.
Allow lots of interrupts (useful on multi-domain platforms) and do not
set device_quiet() on all devices attached under nexus(4).
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/cfi/cfi_bus_nexus.c | 15 | ||||
-rw-r--r-- | sys/dev/fdt/fdt_common.c | 30 | ||||
-rw-r--r-- | sys/dev/fdt/fdt_pci.c | 2 | ||||
-rw-r--r-- | sys/dev/fdt/fdt_powerpc.c | 3 | ||||
-rw-r--r-- | sys/dev/fdt/fdtbus.c | 6 | ||||
-rw-r--r-- | sys/dev/ofw/ofw_fdt.c | 2 |
6 files changed, 37 insertions, 21 deletions
diff --git a/sys/dev/cfi/cfi_bus_nexus.c b/sys/dev/cfi/cfi_bus_nexus.c index 4e1fa4e..a87ee14 100644 --- a/sys/dev/cfi/cfi_bus_nexus.c +++ b/sys/dev/cfi/cfi_bus_nexus.c @@ -50,14 +50,25 @@ __FBSDID("$FreeBSD$"); static int cfi_nexus_probe(device_t dev) { + return (BUS_PROBE_NOWILDCARD); +} + +static int +cfi_nexus_attach(device_t dev) +{ + int error; + + error = cfi_probe(dev); + if (error != 0) + return (error); - return cfi_probe(dev); + return cfi_attach(dev); } static device_method_t cfi_nexus_methods[] = { /* device interface */ DEVMETHOD(device_probe, cfi_nexus_probe), - DEVMETHOD(device_attach, cfi_attach), + DEVMETHOD(device_attach, cfi_nexus_attach), DEVMETHOD(device_detach, cfi_detach), {0, 0} diff --git a/sys/dev/fdt/fdt_common.c b/sys/dev/fdt/fdt_common.c index dad4297..740ccb5 100644 --- a/sys/dev/fdt/fdt_common.c +++ b/sys/dev/fdt/fdt_common.c @@ -478,21 +478,31 @@ fdt_intr_decode(phandle_t intr_parent, pcell_t *intr, int *interrupt, int *trig, int *pol) { fdt_pic_decode_t intr_decode; + phandle_t intr_offset; int i, rv; + intr_offset = OF_xref_phandle(intr_parent); + for (i = 0; fdt_pic_table[i] != NULL; i++) { /* XXX check if pic_handle has interrupt-controller prop? */ intr_decode = fdt_pic_table[i]; - rv = intr_decode(intr_parent, intr, interrupt, trig, pol); + rv = intr_decode(intr_offset, intr, interrupt, trig, pol); - if (rv == 0) + if (rv == 0) { /* This was recognized as our PIC and decoded. */ + *interrupt = FDT_MAP_IRQ(intr_parent, *interrupt); return (0); + } } - return (ENXIO); + /* Not in table, so guess */ + *interrupt = FDT_MAP_IRQ(intr_parent, fdt32_to_cpu(*intr)); + *trig = INTR_TRIGGER_CONFORM; + *pol = INTR_POLARITY_CONFORM; + + return (0); } int @@ -500,7 +510,7 @@ fdt_intr_to_rl(phandle_t node, struct resource_list *rl, struct fdt_sense_level *intr_sl) { phandle_t intr_par; - ihandle_t iph; + phandle_t iph; pcell_t *intr; pcell_t intr_cells; int interrupt, trig, pol; @@ -517,8 +527,7 @@ fdt_intr_to_rl(phandle_t node, struct resource_list *rl, debugf("no intr-parent phandle\n"); intr_par = OF_parent(node); } else { - iph = fdt32_to_cpu(iph); - intr_par = OF_instance_to_package(iph); + intr_par = OF_xref_phandle(iph); } if (OF_getprop(intr_par, "#interrupt-cells", &intr_cells, @@ -540,7 +549,7 @@ fdt_intr_to_rl(phandle_t node, struct resource_list *rl, interrupt = -1; trig = pol = 0; - if (fdt_intr_decode(intr_par, &intr[i * intr_cells], + if (fdt_intr_decode(iph, &intr[i * intr_cells], &interrupt, &trig, &pol) != 0) { rv = ENXIO; goto out; @@ -557,7 +566,7 @@ fdt_intr_to_rl(phandle_t node, struct resource_list *rl, intr_sl[i].trig = trig; intr_sl[i].pol = pol; - irq = FDT_MAP_IRQ(intr_par, interrupt); + irq = FDT_MAP_IRQ(iph, interrupt); resource_list_add(rl, SYS_RES_IRQ, i, irq, irq, 1); } @@ -570,7 +579,6 @@ int fdt_get_phyaddr(phandle_t node, device_t dev, int *phy_addr, void **phy_sc) { phandle_t phy_node; - ihandle_t phy_ihandle; pcell_t phy_handle, phy_reg; uint32_t i; device_t parent, child; @@ -579,9 +587,7 @@ fdt_get_phyaddr(phandle_t node, device_t dev, int *phy_addr, void **phy_sc) sizeof(phy_handle)) <= 0) return (ENXIO); - phy_ihandle = (ihandle_t)phy_handle; - phy_ihandle = fdt32_to_cpu(phy_ihandle); - phy_node = OF_instance_to_package(phy_ihandle); + phy_node = OF_xref_phandle(phy_handle); if (OF_getprop(phy_node, "reg", (void *)&phy_reg, sizeof(phy_reg)) <= 0) diff --git a/sys/dev/fdt/fdt_pci.c b/sys/dev/fdt/fdt_pci.c index a4cf9d1..bcfe300 100644 --- a/sys/dev/fdt/fdt_pci.c +++ b/sys/dev/fdt/fdt_pci.c @@ -320,7 +320,7 @@ fdt_pci_route_intr(int bus, int slot, int func, int pin, trig, pol); #if defined(__powerpc__) - powerpc_config_intr(FDT_MAP_IRQ(intr_par, *interrupt), trig, + powerpc_config_intr(FDT_MAP_IRQ(iph, *interrupt), trig, pol); #endif return (0); diff --git a/sys/dev/fdt/fdt_powerpc.c b/sys/dev/fdt/fdt_powerpc.c index ac81c08..d3e9d4e 100644 --- a/sys/dev/fdt/fdt_powerpc.c +++ b/sys/dev/fdt/fdt_powerpc.c @@ -123,7 +123,8 @@ fdt_pic_decode_openpic(phandle_t node, pcell_t *intr, int *interrupt, int *trig, int *pol) { - if (!fdt_is_compatible(node, "chrp,open-pic")) + if (!fdt_is_compatible(node, "chrp,open-pic") && + !fdt_is_type(node, "open-pic")) return (ENXIO); /* diff --git a/sys/dev/fdt/fdtbus.c b/sys/dev/fdt/fdtbus.c index 5390dd0..f113b8e 100644 --- a/sys/dev/fdt/fdtbus.c +++ b/sys/dev/fdt/fdtbus.c @@ -158,9 +158,7 @@ fdtbus_probe(device_t dev) debugf("%s(dev=%p); pass=%u\n", __func__, dev, bus_current_pass); - device_set_desc(dev, "FDT main bus"); - if (!bootverbose) - device_quiet(dev); + device_set_desc(dev, "Flattened Device Tree"); return (BUS_PROBE_NOWILDCARD); } @@ -182,7 +180,7 @@ fdtbus_attach(device_t dev) * IRQ rman. */ start = 0; - end = FDT_INTR_MAX - 1; + end = ~0; sc->sc_irq.rm_start = start; sc->sc_irq.rm_end = end; sc->sc_irq.rm_type = RMAN_ARRAY; diff --git a/sys/dev/ofw/ofw_fdt.c b/sys/dev/ofw/ofw_fdt.c index 7b3b0e9..4191e7e 100644 --- a/sys/dev/ofw/ofw_fdt.c +++ b/sys/dev/ofw/ofw_fdt.c @@ -329,7 +329,7 @@ fdt_nextprop(int offset, char *buf, size_t size) depth = -1; } while (depth >= 0); - return (-1); + return (0); } /* |