diff options
author | tmm <tmm@FreeBSD.org> | 2002-11-07 16:07:46 +0000 |
---|---|---|
committer | tmm <tmm@FreeBSD.org> | 2002-11-07 16:07:46 +0000 |
commit | e5e9ae1dc2eb709f9dbb1b4db59d2d12626d5325 (patch) | |
tree | 0eeb7240934c2f9099476c579c331e3af2df0c50 /sys/sparc64/pci | |
parent | 92eb830a35122db8e11af254e93833c48efdd107 (diff) | |
download | FreeBSD-src-e5e9ae1dc2eb709f9dbb1b4db59d2d12626d5325.zip FreeBSD-src-e5e9ae1dc2eb709f9dbb1b4db59d2d12626d5325.tar.gz |
Add two new workaround for firmware anomalies:
1. At least some Netra t1 models have PCI buses with no associated
interrupt map, but obviously expect the PCI swizzle to be done with
the interrupt number from the higher level as intpin. In this case,
the mapping also needs to continue at parent bus nodes.
To handle that, add a quirk table based on the "name" property of
the root node to avoid breaking other boxen. This property is now
retrieved and printed at boot.
2. On SPARCengine Ultra AX machines, interrupt numbers are not mapped
at all, and full interrupt numbers (not just INOs) are given in
the interrupt properties. This is more or less cosmetical; the
PCI interrupt numbers would be wrong, but the psycho resource
allocation method would pass the right numbers on anyway.
Tested by: mux (1), Maxim Mazurok <maxim@km.ua> (2)
Diffstat (limited to 'sys/sparc64/pci')
-rw-r--r-- | sys/sparc64/pci/ofw_pci.c | 72 | ||||
-rw-r--r-- | sys/sparc64/pci/ofw_pci.h | 7 | ||||
-rw-r--r-- | sys/sparc64/pci/psycho.c | 2 |
3 files changed, 70 insertions, 11 deletions
diff --git a/sys/sparc64/pci/ofw_pci.c b/sys/sparc64/pci/ofw_pci.c index d36e730..6d7754b 100644 --- a/sys/sparc64/pci/ofw_pci.c +++ b/sys/sparc64/pci/ofw_pci.c @@ -47,6 +47,7 @@ #include <sparc64/pci/ofw_pci.h> #include <machine/ofw_bus.h> +#include <machine/ver.h> #include "pcib_if.h" @@ -54,16 +55,63 @@ u_int8_t pci_bus_cnt; phandle_t *pci_bus_map; int pci_bus_map_sz; +#define OPQ_NEED_SWIZZLE 1 +static struct ofw_pci_quirk { + char *opq_model; + int opq_quirks; +} ofw_pci_quirks[] = { + { "SUNW,UltraSPARC-IIi-cEngine", OPQ_NEED_SWIZZLE } +}; +#define OPQ_NENT (sizeof(ofw_pci_quirks) / sizeof(ofw_pci_quirks[0])) + +static int pci_quirks; + +#define OFW_PCI_PCIBUS "pci" #define PCI_BUS_MAP_INC 10 +int +ofw_pci_orb_callback(phandle_t node, u_int8_t *pintptr, int pintsz, + u_int8_t *pregptr, int pregsz, u_int8_t **rintr, int *terminate) +{ + struct ofw_pci_register preg; + u_int32_t pintr, intr; + char type[32]; + + if ((pci_quirks & OPQ_NEED_SWIZZLE) != 0 && + pintsz == sizeof(u_int32_t) && pregsz >= sizeof(preg) && + OF_getprop(node, "device_type", type, sizeof(type)) != -1 && + strcmp(type, OFW_PCI_PCIBUS) == 0) { + /* + * Handle a quirk found on some Netra t1 models: there exist + * PCI bridges without interrupt maps, where we apparently must + * do the PCI swizzle and continue to map on at the parent. + */ + bcopy(pintptr, &pintr, sizeof(pintr)); + bcopy(pregptr, &preg, sizeof(preg)); + intr = (OFW_PCI_PHYS_HI_DEVICE(preg.phys_hi) + pintr) % 4; + *rintr = malloc(sizeof(intr), M_OFWPROP, M_WAITOK); + bcopy(&intr, *rintr, sizeof(intr)); + *terminate = 0; + return (sizeof(intr)); + } + return (-1); +} + u_int32_t -ofw_pci_route_intr(phandle_t node) +ofw_pci_route_intr(phandle_t node, u_int32_t ign) { u_int32_t rv; - rv = ofw_bus_route_intr(node, ORIP_NOINT); + rv = ofw_bus_route_intr(node, ORIP_NOINT, ofw_pci_orb_callback); if (rv == ORIR_NOTFOUND) return (255); + /* + * Some machines (notably the SPARCengine Ultra AX) have no mappings + * at all, but use complete interrupt vector number including the IGN. + * Catch this case and remove the IGN. + */ + if (rv > ign) + rv -= ign; return (rv); } @@ -112,7 +160,6 @@ ofw_pci_binit(device_t busdev, struct ofw_pci_bdesc *obd) PCIR_SUBBUS_1, obd->obd_subbus, 1); } -#define OFW_PCI_PCIBUS "pci" /* * Walk the PCI bus hierarchy, starting with the root PCI bus and descending * through bridges, and initialize the interrupt line and latency timer @@ -120,15 +167,24 @@ ofw_pci_binit(device_t busdev, struct ofw_pci_bdesc *obd) * as well as the the bus numbers and ranges of the bridges. */ void -ofw_pci_init(device_t dev, phandle_t bushdl, struct ofw_pci_bdesc *obd) +ofw_pci_init(device_t dev, phandle_t bushdl, u_int32_t ign, + struct ofw_pci_bdesc *obd) { struct ofw_pci_register pcir; struct ofw_pci_bdesc subobd, *tobd; phandle_t node; char type[32]; - int intr, freemap; + int i, intr, freemap; u_int slot, busno, func, sub, lat; + /* Initialize the quirk list. */ + for (i = 0; i < OPQ_NENT; i++) { + if (strcmp(sparc64_model, ofw_pci_quirks[i].opq_model) == 0) { + pci_quirks = ofw_pci_quirks[i].opq_quirks; + break; + } + } + if ((node = OF_child(bushdl)) == 0) return; freemap = 0; @@ -141,7 +197,7 @@ ofw_pci_init(device_t dev, phandle_t bushdl, struct ofw_pci_bdesc *obd) else type[sizeof(type) - 1] = '\0'; if (OF_getprop(node, "reg", &pcir, sizeof(pcir)) == -1) - panic("ofw_pci_route_intr: OF_getprop failed"); + panic("ofw_pci_init: OF_getprop failed"); slot = OFW_PCI_PHYS_HI_DEVICE(pcir.phys_hi); func = OFW_PCI_PHYS_HI_FUNCTION(pcir.phys_hi); if (strcmp(type, OFW_PCI_PCIBUS) == 0) { @@ -173,7 +229,7 @@ ofw_pci_init(device_t dev, phandle_t bushdl, struct ofw_pci_bdesc *obd) device_printf(dev, "%s: descending to " "subordinate PCI bus\n", __func__); #endif /* OFW_PCI_DEBUG */ - ofw_pci_init(dev, node, &subobd); + ofw_pci_init(dev, node, ign, &subobd); } else { /* * Initialize the latency timer register for @@ -199,7 +255,7 @@ ofw_pci_init(device_t dev, phandle_t bushdl, struct ofw_pci_bdesc *obd) } /* Initialize the intline registers. */ - if ((intr = ofw_pci_route_intr(node)) != 255) { + if ((intr = ofw_pci_route_intr(node, ign)) != 255) { #ifdef OFW_PCI_DEBUG device_printf(dev, "%s: mapping intr for " "%d/%d/%d to %d (preset was %d)\n", diff --git a/sys/sparc64/pci/ofw_pci.h b/sys/sparc64/pci/ofw_pci.h index 68cf1ec..45bbb43 100644 --- a/sys/sparc64/pci/ofw_pci.h +++ b/sys/sparc64/pci/ofw_pci.h @@ -34,6 +34,8 @@ #ifndef _SPARC64_PCI_OFW_PCI_H_ #define _SPARC64_PCI_OFW_PCI_H_ +#include <machine/ofw_bus.h> + /* PCI range child spaces. XXX: are these MI? */ #define PCI_CS_CONFIG 0x00 #define PCI_CS_IO 0x01 @@ -69,10 +71,11 @@ struct ofw_pci_bdesc { struct ofw_pci_bdesc *obd_super; }; -u_int32_t ofw_pci_route_intr(phandle_t); +u_int32_t ofw_pci_route_intr(phandle_t, u_int32_t); +obr_callback_t ofw_pci_orb_callback; u_int8_t ofw_pci_alloc_busno(phandle_t); ofw_pci_binit_t ofw_pci_binit; -void ofw_pci_init(device_t, phandle_t, struct ofw_pci_bdesc *); +void ofw_pci_init(device_t, phandle_t, u_int32_t, struct ofw_pci_bdesc *); phandle_t ofw_pci_find_node(int, int, int); phandle_t ofw_pci_node(device_t); diff --git a/sys/sparc64/pci/psycho.c b/sys/sparc64/pci/psycho.c index edf9f11..51fb78f 100644 --- a/sys/sparc64/pci/psycho.c +++ b/sys/sparc64/pci/psycho.c @@ -630,7 +630,7 @@ psycho_attach(device_t dev) * the firmware uses the same model as this driver if it does. * Additionally, set up the bus numbers and ranges. */ - ofw_pci_init(dev, sc->sc_node, &obd); + ofw_pci_init(dev, sc->sc_node, sc->sc_ign, &obd); device_add_child(dev, "pci", device_get_unit(dev)); return (bus_generic_attach(dev)); |