svn commit: r265959 - in stable/10/sys: conf dev/cfi dev/fdt dev/ofw powerpc/mambo powerpc/ofw powerpc/powermac powerpc/powerpc
Ian Lepore
ian at FreeBSD.org
Tue May 13 17:12:09 UTC 2014
Author: ian
Date: Tue May 13 17:12:07 2014
New Revision: 265959
URL: http://svnweb.freebsd.org/changeset/base/265959
Log:
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).
Added:
stable/10/sys/powerpc/ofw/openpic_ofw.c
- copied unchanged from r256898, head/sys/powerpc/ofw/openpic_ofw.c
Deleted:
stable/10/sys/powerpc/mambo/mambo_openpic.c
stable/10/sys/powerpc/powermac/openpic_macio.c
stable/10/sys/powerpc/powerpc/openpic_fdt.c
Modified:
stable/10/sys/conf/files.powerpc
stable/10/sys/dev/cfi/cfi_bus_nexus.c
stable/10/sys/dev/fdt/fdt_common.c
stable/10/sys/dev/fdt/fdt_pci.c
stable/10/sys/dev/fdt/fdt_powerpc.c
stable/10/sys/dev/fdt/fdtbus.c
stable/10/sys/dev/ofw/ofw_fdt.c
Modified: stable/10/sys/conf/files.powerpc
==============================================================================
--- stable/10/sys/conf/files.powerpc Tue May 13 17:09:50 2014 (r265958)
+++ stable/10/sys/conf/files.powerpc Tue May 13 17:12:07 2014 (r265959)
@@ -128,7 +128,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
@@ -147,6 +146,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
@@ -162,7 +162,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
@@ -200,7 +199,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: stable/10/sys/dev/cfi/cfi_bus_nexus.c
==============================================================================
--- stable/10/sys/dev/cfi/cfi_bus_nexus.c Tue May 13 17:09:50 2014 (r265958)
+++ stable/10/sys/dev/cfi/cfi_bus_nexus.c Tue May 13 17:12:07 2014 (r265959)
@@ -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}
Modified: stable/10/sys/dev/fdt/fdt_common.c
==============================================================================
--- stable/10/sys/dev/fdt/fdt_common.c Tue May 13 17:09:50 2014 (r265958)
+++ stable/10/sys/dev/fdt/fdt_common.c Tue May 13 17:12:07 2014 (r265959)
@@ -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: stable/10/sys/dev/fdt/fdt_pci.c
==============================================================================
--- stable/10/sys/dev/fdt/fdt_pci.c Tue May 13 17:09:50 2014 (r265958)
+++ stable/10/sys/dev/fdt/fdt_pci.c Tue May 13 17:12:07 2014 (r265959)
@@ -320,7 +320,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: stable/10/sys/dev/fdt/fdt_powerpc.c
==============================================================================
--- stable/10/sys/dev/fdt/fdt_powerpc.c Tue May 13 17:09:50 2014 (r265958)
+++ stable/10/sys/dev/fdt/fdt_powerpc.c Tue May 13 17:12:07 2014 (r265959)
@@ -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);
/*
Modified: stable/10/sys/dev/fdt/fdtbus.c
==============================================================================
--- stable/10/sys/dev/fdt/fdtbus.c Tue May 13 17:09:50 2014 (r265958)
+++ stable/10/sys/dev/fdt/fdtbus.c Tue May 13 17:12:07 2014 (r265959)
@@ -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;
Modified: stable/10/sys/dev/ofw/ofw_fdt.c
==============================================================================
--- stable/10/sys/dev/ofw/ofw_fdt.c Tue May 13 17:09:50 2014 (r265958)
+++ stable/10/sys/dev/ofw/ofw_fdt.c Tue May 13 17:12:07 2014 (r265959)
@@ -329,7 +329,7 @@ fdt_nextprop(int offset, char *buf, size
depth = -1;
} while (depth >= 0);
- return (-1);
+ return (0);
}
/*
Copied: stable/10/sys/powerpc/ofw/openpic_ofw.c (from r256898, head/sys/powerpc/ofw/openpic_ofw.c)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ stable/10/sys/powerpc/ofw/openpic_ofw.c Tue May 13 17:12:07 2014 (r265959, copy of r256898, head/sys/powerpc/ofw/openpic_ofw.c)
@@ -0,0 +1,129 @@
+/*-
+ * Copyright 2003 by Peter Grehan. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/module.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#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>
+#include <machine/intr_machdep.h>
+#include <machine/md_var.h>
+#include <machine/pio.h>
+#include <machine/resource.h>
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#include <sys/rman.h>
+
+#include <machine/openpicvar.h>
+
+#include "pic_if.h"
+
+/*
+ * OFW interface
+ */
+static int openpic_ofw_probe(device_t);
+static int openpic_ofw_attach(device_t);
+
+static device_method_t openpic_ofw_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, openpic_ofw_probe),
+ DEVMETHOD(device_attach, openpic_ofw_attach),
+
+ /* PIC interface */
+ DEVMETHOD(pic_bind, openpic_bind),
+ DEVMETHOD(pic_config, openpic_config),
+ DEVMETHOD(pic_dispatch, openpic_dispatch),
+ DEVMETHOD(pic_enable, openpic_enable),
+ DEVMETHOD(pic_eoi, openpic_eoi),
+ DEVMETHOD(pic_ipi, openpic_ipi),
+ DEVMETHOD(pic_mask, openpic_mask),
+ DEVMETHOD(pic_unmask, openpic_unmask),
+
+ DEVMETHOD_END
+};
+
+static driver_t openpic_ofw_driver = {
+ "openpic",
+ openpic_ofw_methods,
+ sizeof(struct openpic_softc),
+};
+
+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_ofw_probe(device_t dev)
+{
+ const char *type = ofw_bus_get_type(dev);
+
+ if (type == NULL)
+ return (ENXIO);
+
+ 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);
+
+ device_set_desc(dev, OPENPIC_DEVSTR);
+ return (0);
+}
+
+static int
+openpic_ofw_attach(device_t 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-stable
mailing list