svn commit: r256898 - in head/sys: conf dev/fdt powerpc/mambo powerpc/ofw powerpc/powermac powerpc/powerpc
Nathan Whitehorn
nwhitehorn at FreeBSD.org
Tue Oct 22 14:07:59 UTC 2013
Author: nwhitehorn
Date: Tue Oct 22 14:07:57 2013
New Revision: 256898
URL: http://svnweb.freebsd.org/changeset/base/256898
Log:
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.
Added:
head/sys/powerpc/ofw/openpic_ofw.c
- copied, changed from r256886, head/sys/powerpc/powermac/openpic_macio.c
Deleted:
head/sys/powerpc/mambo/mambo_openpic.c
head/sys/powerpc/powermac/openpic_macio.c
head/sys/powerpc/powerpc/openpic_fdt.c
Modified:
head/sys/conf/files.powerpc
head/sys/dev/fdt/fdt_common.c
head/sys/dev/fdt/fdt_pci.c
head/sys/dev/fdt/fdt_powerpc.c
Modified: head/sys/conf/files.powerpc
==============================================================================
--- head/sys/conf/files.powerpc Tue Oct 22 14:00:46 2013 (r256897)
+++ head/sys/conf/files.powerpc Tue Oct 22 14:07:57 2013 (r256898)
@@ -124,7 +124,6 @@ powerpc/mambo/mambocall.S optional mambo
powerpc/mambo/mambo.c optional mambo
powerpc/mambo/mambo_console.c optional mambo
powerpc/mambo/mambo_disk.c optional mambo
-powerpc/mambo/mambo_openpic.c optional mambo
powerpc/mpc85xx/atpic.c optional mpc85xx isa
powerpc/mpc85xx/ds1553_bus_fdt.c optional ds1553 fdt
powerpc/mpc85xx/ds1553_core.c optional ds1553
@@ -143,6 +142,7 @@ powerpc/ofw/ofw_syscons.c optional sc ai
powerpc/ofw/ofwcall32.S optional aim powerpc
powerpc/ofw/ofwcall64.S optional aim powerpc64
powerpc/ofw/ofwmagic.S optional aim
+powerpc/ofw/openpic_ofw.c optional aim | fdt
powerpc/ofw/rtas.c optional aim
powerpc/powermac/ata_kauai.c optional powermac ata | powermac atamacio
powerpc/powermac/ata_macio.c optional powermac ata | powermac atamacio
@@ -158,7 +158,6 @@ powerpc/powermac/kiic.c optional powerm
powerpc/powermac/macgpio.c optional powermac pci
powerpc/powermac/macio.c optional powermac pci
powerpc/powermac/nvbl.c optional powermac nvbl
-powerpc/powermac/openpic_macio.c optional powermac pci
powerpc/powermac/platform_powermac.c optional powermac
powerpc/powermac/powermac_thermal.c optional powermac
powerpc/powermac/pswitch.c optional powermac pswitch
@@ -196,7 +195,6 @@ powerpc/powerpc/mmu_if.m standard
powerpc/powerpc/mp_machdep.c optional smp
powerpc/powerpc/nexus.c standard
powerpc/powerpc/openpic.c standard
-powerpc/powerpc/openpic_fdt.c optional fdt
powerpc/powerpc/pic_if.m standard
powerpc/powerpc/pmap_dispatch.c standard
powerpc/powerpc/platform.c standard
Modified: head/sys/dev/fdt/fdt_common.c
==============================================================================
--- head/sys/dev/fdt/fdt_common.c Tue Oct 22 14:00:46 2013 (r256897)
+++ head/sys/dev/fdt/fdt_common.c Tue Oct 22 14:07:57 2013 (r256898)
@@ -478,21 +478,31 @@ fdt_intr_decode(phandle_t intr_parent, p
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 re
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 re
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 re
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 re
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
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)
Modified: head/sys/dev/fdt/fdt_pci.c
==============================================================================
--- head/sys/dev/fdt/fdt_pci.c Tue Oct 22 14:00:46 2013 (r256897)
+++ head/sys/dev/fdt/fdt_pci.c Tue Oct 22 14:07:57 2013 (r256898)
@@ -317,7 +317,7 @@ fdt_pci_route_intr(int bus, int slot, in
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);
Modified: head/sys/dev/fdt/fdt_powerpc.c
==============================================================================
--- head/sys/dev/fdt/fdt_powerpc.c Tue Oct 22 14:00:46 2013 (r256897)
+++ head/sys/dev/fdt/fdt_powerpc.c Tue Oct 22 14:07:57 2013 (r256898)
@@ -123,7 +123,8 @@ fdt_pic_decode_openpic(phandle_t node, p
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);
/*
Copied and modified: head/sys/powerpc/ofw/openpic_ofw.c (from r256886, head/sys/powerpc/powermac/openpic_macio.c)
==============================================================================
--- head/sys/powerpc/powermac/openpic_macio.c Tue Oct 22 11:56:46 2013 (r256886, copy source)
+++ head/sys/powerpc/ofw/openpic_ofw.c Tue Oct 22 14:07:57 2013 (r256898)
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
@@ -55,15 +56,15 @@ __FBSDID("$FreeBSD$");
#include "pic_if.h"
/*
- * MacIO interface
+ * OFW interface
*/
-static int openpic_macio_probe(device_t);
-static int openpic_macio_attach(device_t);
+static int openpic_ofw_probe(device_t);
+static int openpic_ofw_attach(device_t);
-static device_method_t openpic_macio_methods[] = {
+static device_method_t openpic_ofw_methods[] = {
/* Device interface */
- DEVMETHOD(device_probe, openpic_macio_probe),
- DEVMETHOD(device_attach, openpic_macio_attach),
+ DEVMETHOD(device_probe, openpic_ofw_probe),
+ DEVMETHOD(device_attach, openpic_ofw_attach),
/* PIC interface */
DEVMETHOD(pic_bind, openpic_bind),
@@ -75,26 +76,35 @@ static device_method_t openpic_macio_me
DEVMETHOD(pic_mask, openpic_mask),
DEVMETHOD(pic_unmask, openpic_unmask),
- { 0, 0 },
+ DEVMETHOD_END
};
-static driver_t openpic_macio_driver = {
+static driver_t openpic_ofw_driver = {
"openpic",
- openpic_macio_methods,
+ openpic_ofw_methods,
sizeof(struct openpic_softc),
};
-DRIVER_MODULE(openpic, macio, openpic_macio_driver, openpic_devclass, 0, 0);
+DRIVER_MODULE(openpic, nexus, openpic_ofw_driver, openpic_devclass, 0, 0);
+DRIVER_MODULE(openpic, simplebus, openpic_ofw_driver, openpic_devclass, 0, 0);
+DRIVER_MODULE(openpic, macio, openpic_ofw_driver, openpic_devclass, 0, 0);
static int
-openpic_macio_probe(device_t dev)
+openpic_ofw_probe(device_t dev)
{
const char *type = ofw_bus_get_type(dev);
- if (strcmp(type, "open-pic") != 0)
+ if (type == NULL)
return (ENXIO);
- /* On some U4 systems, there is a phantom MPIC in the mac-io cell */
+ if (!ofw_bus_is_compatible(dev, "chrp,open-pic") &&
+ strcmp(type, "open-pic") != 0)
+ return (ENXIO);
+
+ /*
+ * On some U4 systems, there is a phantom MPIC in the mac-io cell.
+ * The uninorth driver will pick up the real PIC, so ignore it here.
+ */
if (OF_finddevice("/u4") != (phandle_t)-1)
return (ENXIO);
@@ -103,8 +113,17 @@ openpic_macio_probe(device_t dev)
}
static int
-openpic_macio_attach(device_t dev)
+openpic_ofw_attach(device_t dev)
{
-
- return (openpic_common_attach(dev, ofw_bus_get_node(dev)));
+ phandle_t xref, node;
+
+ node = ofw_bus_get_node(dev);
+
+ if (OF_getprop(node, "phandle", &xref, sizeof(xref)) == -1 &&
+ OF_getprop(node, "ibm,phandle", &xref, sizeof(xref)) == -1 &&
+ OF_getprop(node, "linux,phandle", &xref, sizeof(xref)) == -1)
+ xref = node;
+
+ return (openpic_common_attach(dev, xref));
}
+
More information about the svn-src-all
mailing list