2001-11-09 20:23:38 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1999, 2000 Matthew R. Green
|
|
|
|
* Copyright (c) 2001 Thomas Moestl <tmm@FreeBSD.org>
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* from: NetBSD: ebus.c,v 1.26 2001/09/10 16:27:53 eeh Exp
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* UltraSPARC 5 and beyond ebus support.
|
|
|
|
*
|
|
|
|
* note that this driver is not complete:
|
|
|
|
* - ebus2 dma code is completely unwritten
|
|
|
|
* - interrupt establish is written and appears to work
|
|
|
|
* - bus map code is written and appears to work
|
|
|
|
* XXX: This is PCI specific, however, there exist SBus-to-EBus bridges...
|
|
|
|
* XXX: The EBus was designed to allow easy adaption of ISA devices to it - a
|
|
|
|
* compatability layer for ISA devices might be nice, although probably not
|
|
|
|
* easily possible because of some cruft (like in[bwl]/out[bwl] and friends).
|
|
|
|
* Additionally, the existing ISA code is limited to one ISA bus, however,
|
|
|
|
* there are machines with both ISA and EBus.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/malloc.h>
|
2004-06-03 05:58:30 +00:00
|
|
|
#include <sys/module.h>
|
2001-11-09 20:23:38 +00:00
|
|
|
|
2004-04-28 13:06:46 +00:00
|
|
|
#include <machine/bus.h>
|
|
|
|
|
|
|
|
#include <sys/rman.h>
|
|
|
|
|
2003-08-23 00:11:16 +00:00
|
|
|
#include <dev/ofw/openfirm.h>
|
2002-03-24 02:11:06 +00:00
|
|
|
|
2001-11-09 20:23:38 +00:00
|
|
|
#include <machine/ofw_bus.h>
|
|
|
|
#include <machine/resource.h>
|
|
|
|
|
2003-08-22 07:39:05 +00:00
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
2001-11-09 20:23:38 +00:00
|
|
|
|
|
|
|
#include <sparc64/pci/ofw_pci.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The register, ranges and interrupt map properties are identical to the ISA
|
|
|
|
* ones.
|
|
|
|
*/
|
|
|
|
#include <sparc64/isa/ofw_isa.h>
|
|
|
|
#include <sparc64/ebus/ebusvar.h>
|
|
|
|
|
|
|
|
struct ebus_devinfo {
|
|
|
|
char *edi_name; /* PROM name */
|
|
|
|
char *edi_compat;
|
|
|
|
phandle_t edi_node; /* PROM node */
|
|
|
|
|
|
|
|
struct resource_list edi_rl;
|
|
|
|
};
|
|
|
|
|
2004-04-28 13:06:46 +00:00
|
|
|
struct ebus_rinfo {
|
|
|
|
int eri_rtype;
|
|
|
|
struct rman eri_rman;
|
|
|
|
struct resource *eri_res;
|
|
|
|
};
|
|
|
|
|
2001-11-09 20:23:38 +00:00
|
|
|
struct ebus_softc {
|
|
|
|
phandle_t sc_node;
|
|
|
|
|
|
|
|
struct isa_ranges *sc_range;
|
2004-04-28 13:06:46 +00:00
|
|
|
struct ebus_rinfo *sc_rinfo;
|
2001-11-09 20:23:38 +00:00
|
|
|
|
|
|
|
int sc_nrange;
|
|
|
|
int sc_nimap;
|
Add the new sparc64 OFW PCI framework, conditional on options OFW_NEWPCI
for now. It introduces a OFW PCI bus driver and a generic OFW PCI-PCI
bridge driver. By utilizing these, the PCI handling is much more elegant
now.
The advantages of the new approach are:
- Device enumeration should hopefully be more like on Solaris now,
so unit numbers should match what's printed on the box more
closely.
- Real interrupt routing is implemented now, so cardbus bridges
etc. have at least a chance to work.
- The quirk tables are gone and have been replaced by (hopefully
sufficient) heuristics.
- Much cleaner code.
There was also a report that previously bogus interrupt assignments
are fixed now, which can be attributed to the new heuristics.
A pitfall, and the reason why this is not the default yet, is that
it changes device enumeration, as mentioned above, which can make
it necessary to change the system configuration if more than one
unit of a device type is present (on a system with two hme cars,
for example, it is possible that hme0 becomes hme1 and vice versa
after enabling the option). Systems with multiple disk controllers
may need to be booted into single user (and require manual specification
of the root file system on boot) to adjust the fstab.
Nevertheless, I would like to encourage users to use this option,
so that it can be made the default soon.
In detail, the changes are:
- Introduce an OFW PCI bus driver; it inherits most methods from the
generic PCI bus driver, but uses the firmware for enumeration,
performs additional initialization for devices and firmware-specific
interrupt routing. It also implements an OFW-specific method to allow
child devices to get their firmware nodes.
- Introduce an OFW PCI-PCI bridge driver; again, it inherits most
of the generic PCI-PCI bridge driver; it has it's own method for
interrupt routing, as well as some sparc64-specific methods (one to
get the node again, and one to adjust the bridge bus range, since
we need to reenumerate all PCI buses).
- Convert the apb driver to the new way of handling things.
- Provide a common framework for OFW bridge drivers, used be the two
drivers above.
- Provide a small common framework for interrupt routing (for all
bridge types).
- Convert the psycho driver to the new framework; this gets rid of a
bunch of old kludges in pci_read_config(), and the whole
preinitialization (ofw_pci_init()).
- Convert the ISA MD part and the EBus driver to the new way
interrupts and nodes are handled.
- Introduce types for firmware interrupt properties.
- Rename the old sparcbus_if to ofw_pci_if by repo copy (it is only
required for PCI), and move it to a more correct location (new
support methodsx were also added, and an old one was deprecated).
- Fix a bunch of minor bugs, perform some cleanups.
In some cases, I introduced some minor code duplication to keep the
new code clean, in hopes that the old code will be unifdef'ed soon.
Reviewed in part by: imp
Tested by: jake, Marius Strobl <marius@alchemy.franken.de>,
Sergey Mokryshev <mokr@mokr.net>,
Chris Jackman <cjackNOSPAM@klatsch.org>
Info on u30 firmware provided by: kris
2003-07-01 14:52:47 +00:00
|
|
|
|
|
|
|
struct ofw_bus_iinfo sc_iinfo;
|
2001-11-09 20:23:38 +00:00
|
|
|
};
|
|
|
|
|
2004-04-28 13:06:46 +00:00
|
|
|
static device_probe_t ebus_probe;
|
|
|
|
static device_attach_t ebus_attach;
|
|
|
|
static bus_print_child_t ebus_print_child;
|
|
|
|
static bus_probe_nomatch_t ebus_probe_nomatch;
|
|
|
|
static bus_read_ivar_t ebus_read_ivar;
|
|
|
|
static bus_write_ivar_t ebus_write_ivar;
|
|
|
|
static bus_alloc_resource_t ebus_alloc_resource;
|
|
|
|
static bus_release_resource_t ebus_release_resource;
|
|
|
|
static bus_get_resource_list_t ebus_get_resource_list;
|
2001-11-09 20:23:38 +00:00
|
|
|
|
Fix interrupt assignment for non-builtin PCI devices on e450s.
This machine uses a non-standard scheme to specify the interrupts to
be assigned for devices in PCI slots; instead of giving the INO
or full interrupt number (which is done for the other devices in this
box), the firmware interrupt properties contain intpin numbers, which
have to be swizzled as usual on PCI-PCI bridges; however, the PCI host
bridge nodes have no interrupt map, so we need to guess the
correct INO by slot number of the device or the closest PCI-PCI
bridge leading to it, and the intpin.
To do this, this fix makes the following changes:
- Add a newbus method for sparc64 PCI host bridges to guess
the INO, and glue code in ofw_pci_orb_callback() to invoke it based
on a new quirk entry. The guessing is only done for interrupt numbers
too low to contain any IGN found on e450s.
- Create another new quirk entry was created to prevent mapping of EBus
interrupts at PCI level; the e450 has full INOs in the interrupt
properties of EBus devices, so trying to remap them could cause
problems.
- Set both quirk entries for e450s; remove the no-swizzle entry.
- Determine the psycho half (bus A or B) a driver instance manages
in psycho_attach()
- Implement the new guessing method for psycho, using the slot number,
psycho half and property value (intpin).
Thanks go to the testers, especially Brian Denehy, who tested many kernels
for me until I had found the right workaround.
Tested by: Brian Denehy <B.Denehy@90east.com>, jake, fenner,
Marius Strobl <marius@alchemy.franken.de>,
Marian Dobre <mari@onix.ro>
Approved by: re (scottl)
2003-05-30 20:48:05 +00:00
|
|
|
static struct ebus_devinfo *ebus_setup_dinfo(device_t, struct ebus_softc *,
|
2001-11-09 20:23:38 +00:00
|
|
|
phandle_t, char *);
|
|
|
|
static void ebus_destroy_dinfo(struct ebus_devinfo *);
|
|
|
|
static int ebus_print_res(struct ebus_devinfo *);
|
|
|
|
|
|
|
|
static device_method_t ebus_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, ebus_probe),
|
2004-04-28 13:06:46 +00:00
|
|
|
DEVMETHOD(device_attach, ebus_attach),
|
2001-11-09 20:23:38 +00:00
|
|
|
|
|
|
|
/* Bus interface */
|
|
|
|
DEVMETHOD(bus_print_child, ebus_print_child),
|
|
|
|
DEVMETHOD(bus_probe_nomatch, ebus_probe_nomatch),
|
|
|
|
DEVMETHOD(bus_read_ivar, ebus_read_ivar),
|
|
|
|
DEVMETHOD(bus_write_ivar, ebus_write_ivar),
|
|
|
|
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
|
|
|
|
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
|
|
|
|
DEVMETHOD(bus_alloc_resource, ebus_alloc_resource),
|
|
|
|
DEVMETHOD(bus_get_resource_list, ebus_get_resource_list),
|
|
|
|
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
|
|
|
|
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
|
2004-04-28 13:06:46 +00:00
|
|
|
DEVMETHOD(bus_release_resource, ebus_release_resource),
|
2001-11-09 20:23:38 +00:00
|
|
|
DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
|
|
|
|
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t ebus_driver = {
|
|
|
|
"ebus",
|
|
|
|
ebus_methods,
|
|
|
|
sizeof(struct ebus_softc),
|
|
|
|
};
|
|
|
|
|
|
|
|
static devclass_t ebus_devclass;
|
|
|
|
|
|
|
|
DRIVER_MODULE(ebus, pci, ebus_driver, ebus_devclass, 0, 0);
|
|
|
|
|
|
|
|
static int
|
|
|
|
ebus_probe(device_t dev)
|
|
|
|
{
|
|
|
|
char name[10];
|
|
|
|
phandle_t node;
|
|
|
|
|
2004-05-08 13:53:47 +00:00
|
|
|
if ((node = ofw_pci_get_node(dev)) == 0)
|
2001-11-09 20:23:38 +00:00
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
OF_getprop(node, "name", &name, sizeof(name));
|
|
|
|
if (pci_get_class(dev) != PCIC_BRIDGE ||
|
|
|
|
pci_get_vendor(dev) != 0x108e ||
|
|
|
|
strcmp(name, "ebus") != 0)
|
|
|
|
return (ENXIO);
|
|
|
|
|
|
|
|
if (pci_get_device(dev) == 0x1000)
|
|
|
|
device_set_desc(dev, "PCI-EBus2 bridge");
|
|
|
|
else if (pci_get_device(dev) == 0x1100)
|
|
|
|
device_set_desc(dev, "PCI-EBus3 bridge");
|
|
|
|
else
|
|
|
|
return (ENXIO);
|
2004-04-28 13:06:46 +00:00
|
|
|
return (0);
|
|
|
|
}
|
2001-11-09 20:23:38 +00:00
|
|
|
|
2004-04-28 13:06:46 +00:00
|
|
|
static int
|
|
|
|
ebus_attach(device_t dev)
|
|
|
|
{
|
|
|
|
struct ebus_softc *sc;
|
|
|
|
struct ebus_devinfo *edi;
|
|
|
|
struct ebus_rinfo *eri;
|
|
|
|
struct resource *res;
|
|
|
|
device_t cdev;
|
|
|
|
phandle_t node;
|
|
|
|
char *cname;
|
|
|
|
int i, rnum, rid;
|
2001-11-09 20:23:38 +00:00
|
|
|
|
|
|
|
sc = device_get_softc(dev);
|
2004-05-08 13:53:47 +00:00
|
|
|
sc->sc_node = node = ofw_pci_get_node(dev);
|
2001-11-09 20:23:38 +00:00
|
|
|
|
|
|
|
sc->sc_nrange = OF_getprop_alloc(node, "ranges",
|
|
|
|
sizeof(*sc->sc_range), (void **)&sc->sc_range);
|
2004-04-28 13:06:46 +00:00
|
|
|
if (sc->sc_nrange == -1) {
|
|
|
|
printf("ebus_attach: could not get ranges property\n");
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->sc_rinfo = malloc(sizeof(*sc->sc_rinfo) * sc->sc_nrange, M_DEVBUF,
|
|
|
|
M_WAITOK | M_ZERO);
|
|
|
|
|
|
|
|
/* For every range, there must be a matching resource. */
|
|
|
|
for (rnum = 0; rnum < sc->sc_nrange; rnum++) {
|
|
|
|
eri = &sc->sc_rinfo[rnum];
|
|
|
|
eri->eri_rtype = ofw_isa_range_restype(&sc->sc_range[rnum]);
|
|
|
|
rid = PCIR_BAR(rnum);
|
|
|
|
res = bus_alloc_resource_any(dev, eri->eri_rtype, &rid,
|
|
|
|
RF_ACTIVE);
|
|
|
|
if (res == NULL) {
|
|
|
|
printf("ebus_attach: failed to allocate range "
|
|
|
|
"resource!\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
eri->eri_res = res;
|
|
|
|
eri->eri_rman.rm_type = RMAN_ARRAY;
|
|
|
|
eri->eri_rman.rm_descr = "EBus range";
|
|
|
|
if (rman_init(&eri->eri_rman) != 0) {
|
|
|
|
printf("ebus_attach: failed to initialize rman!");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
if (rman_manage_region(&eri->eri_rman, rman_get_start(res),
|
|
|
|
rman_get_end(res)) != 0) {
|
|
|
|
printf("ebus_attach: failed to register region!");
|
|
|
|
rman_fini(&eri->eri_rman);
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
2001-11-09 20:23:38 +00:00
|
|
|
|
Add the new sparc64 OFW PCI framework, conditional on options OFW_NEWPCI
for now. It introduces a OFW PCI bus driver and a generic OFW PCI-PCI
bridge driver. By utilizing these, the PCI handling is much more elegant
now.
The advantages of the new approach are:
- Device enumeration should hopefully be more like on Solaris now,
so unit numbers should match what's printed on the box more
closely.
- Real interrupt routing is implemented now, so cardbus bridges
etc. have at least a chance to work.
- The quirk tables are gone and have been replaced by (hopefully
sufficient) heuristics.
- Much cleaner code.
There was also a report that previously bogus interrupt assignments
are fixed now, which can be attributed to the new heuristics.
A pitfall, and the reason why this is not the default yet, is that
it changes device enumeration, as mentioned above, which can make
it necessary to change the system configuration if more than one
unit of a device type is present (on a system with two hme cars,
for example, it is possible that hme0 becomes hme1 and vice versa
after enabling the option). Systems with multiple disk controllers
may need to be booted into single user (and require manual specification
of the root file system on boot) to adjust the fstab.
Nevertheless, I would like to encourage users to use this option,
so that it can be made the default soon.
In detail, the changes are:
- Introduce an OFW PCI bus driver; it inherits most methods from the
generic PCI bus driver, but uses the firmware for enumeration,
performs additional initialization for devices and firmware-specific
interrupt routing. It also implements an OFW-specific method to allow
child devices to get their firmware nodes.
- Introduce an OFW PCI-PCI bridge driver; again, it inherits most
of the generic PCI-PCI bridge driver; it has it's own method for
interrupt routing, as well as some sparc64-specific methods (one to
get the node again, and one to adjust the bridge bus range, since
we need to reenumerate all PCI buses).
- Convert the apb driver to the new way of handling things.
- Provide a common framework for OFW bridge drivers, used be the two
drivers above.
- Provide a small common framework for interrupt routing (for all
bridge types).
- Convert the psycho driver to the new framework; this gets rid of a
bunch of old kludges in pci_read_config(), and the whole
preinitialization (ofw_pci_init()).
- Convert the ISA MD part and the EBus driver to the new way
interrupts and nodes are handled.
- Introduce types for firmware interrupt properties.
- Rename the old sparcbus_if to ofw_pci_if by repo copy (it is only
required for PCI), and move it to a more correct location (new
support methodsx were also added, and an old one was deprecated).
- Fix a bunch of minor bugs, perform some cleanups.
In some cases, I introduced some minor code duplication to keep the
new code clean, in hopes that the old code will be unifdef'ed soon.
Reviewed in part by: imp
Tested by: jake, Marius Strobl <marius@alchemy.franken.de>,
Sergey Mokryshev <mokr@mokr.net>,
Chris Jackman <cjackNOSPAM@klatsch.org>
Info on u30 firmware provided by: kris
2003-07-01 14:52:47 +00:00
|
|
|
ofw_bus_setup_iinfo(node, &sc->sc_iinfo, sizeof(ofw_isa_intr_t));
|
|
|
|
|
2001-11-09 20:23:38 +00:00
|
|
|
/*
|
Add the new sparc64 OFW PCI framework, conditional on options OFW_NEWPCI
for now. It introduces a OFW PCI bus driver and a generic OFW PCI-PCI
bridge driver. By utilizing these, the PCI handling is much more elegant
now.
The advantages of the new approach are:
- Device enumeration should hopefully be more like on Solaris now,
so unit numbers should match what's printed on the box more
closely.
- Real interrupt routing is implemented now, so cardbus bridges
etc. have at least a chance to work.
- The quirk tables are gone and have been replaced by (hopefully
sufficient) heuristics.
- Much cleaner code.
There was also a report that previously bogus interrupt assignments
are fixed now, which can be attributed to the new heuristics.
A pitfall, and the reason why this is not the default yet, is that
it changes device enumeration, as mentioned above, which can make
it necessary to change the system configuration if more than one
unit of a device type is present (on a system with two hme cars,
for example, it is possible that hme0 becomes hme1 and vice versa
after enabling the option). Systems with multiple disk controllers
may need to be booted into single user (and require manual specification
of the root file system on boot) to adjust the fstab.
Nevertheless, I would like to encourage users to use this option,
so that it can be made the default soon.
In detail, the changes are:
- Introduce an OFW PCI bus driver; it inherits most methods from the
generic PCI bus driver, but uses the firmware for enumeration,
performs additional initialization for devices and firmware-specific
interrupt routing. It also implements an OFW-specific method to allow
child devices to get their firmware nodes.
- Introduce an OFW PCI-PCI bridge driver; again, it inherits most
of the generic PCI-PCI bridge driver; it has it's own method for
interrupt routing, as well as some sparc64-specific methods (one to
get the node again, and one to adjust the bridge bus range, since
we need to reenumerate all PCI buses).
- Convert the apb driver to the new way of handling things.
- Provide a common framework for OFW bridge drivers, used be the two
drivers above.
- Provide a small common framework for interrupt routing (for all
bridge types).
- Convert the psycho driver to the new framework; this gets rid of a
bunch of old kludges in pci_read_config(), and the whole
preinitialization (ofw_pci_init()).
- Convert the ISA MD part and the EBus driver to the new way
interrupts and nodes are handled.
- Introduce types for firmware interrupt properties.
- Rename the old sparcbus_if to ofw_pci_if by repo copy (it is only
required for PCI), and move it to a more correct location (new
support methodsx were also added, and an old one was deprecated).
- Fix a bunch of minor bugs, perform some cleanups.
In some cases, I introduced some minor code duplication to keep the
new code clean, in hopes that the old code will be unifdef'ed soon.
Reviewed in part by: imp
Tested by: jake, Marius Strobl <marius@alchemy.franken.de>,
Sergey Mokryshev <mokr@mokr.net>,
Chris Jackman <cjackNOSPAM@klatsch.org>
Info on u30 firmware provided by: kris
2003-07-01 14:52:47 +00:00
|
|
|
* Now attach our children.
|
2001-11-09 20:23:38 +00:00
|
|
|
*/
|
|
|
|
for (node = OF_child(node); node > 0; node = OF_peer(node)) {
|
|
|
|
if ((OF_getprop_alloc(node, "name", 1, (void **)&cname)) == -1)
|
|
|
|
continue;
|
|
|
|
|
Fix interrupt assignment for non-builtin PCI devices on e450s.
This machine uses a non-standard scheme to specify the interrupts to
be assigned for devices in PCI slots; instead of giving the INO
or full interrupt number (which is done for the other devices in this
box), the firmware interrupt properties contain intpin numbers, which
have to be swizzled as usual on PCI-PCI bridges; however, the PCI host
bridge nodes have no interrupt map, so we need to guess the
correct INO by slot number of the device or the closest PCI-PCI
bridge leading to it, and the intpin.
To do this, this fix makes the following changes:
- Add a newbus method for sparc64 PCI host bridges to guess
the INO, and glue code in ofw_pci_orb_callback() to invoke it based
on a new quirk entry. The guessing is only done for interrupt numbers
too low to contain any IGN found on e450s.
- Create another new quirk entry was created to prevent mapping of EBus
interrupts at PCI level; the e450 has full INOs in the interrupt
properties of EBus devices, so trying to remap them could cause
problems.
- Set both quirk entries for e450s; remove the no-swizzle entry.
- Determine the psycho half (bus A or B) a driver instance manages
in psycho_attach()
- Implement the new guessing method for psycho, using the slot number,
psycho half and property value (intpin).
Thanks go to the testers, especially Brian Denehy, who tested many kernels
for me until I had found the right workaround.
Tested by: Brian Denehy <B.Denehy@90east.com>, jake, fenner,
Marius Strobl <marius@alchemy.franken.de>,
Marian Dobre <mari@onix.ro>
Approved by: re (scottl)
2003-05-30 20:48:05 +00:00
|
|
|
if ((edi = ebus_setup_dinfo(dev, sc, node, cname)) == NULL) {
|
2001-11-09 20:23:38 +00:00
|
|
|
device_printf(dev, "<%s>: incomplete\n", cname);
|
|
|
|
free(cname, M_OFWPROP);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((cdev = device_add_child(dev, NULL, -1)) == NULL)
|
|
|
|
panic("ebus_attach: device_add_child failed");
|
|
|
|
device_set_ivars(cdev, edi);
|
|
|
|
}
|
2004-04-28 13:06:46 +00:00
|
|
|
return (bus_generic_attach(dev));
|
|
|
|
|
|
|
|
fail:
|
|
|
|
for (i = rnum; i >= 0; i--) {
|
|
|
|
eri = &sc->sc_rinfo[i];
|
|
|
|
if (i < rnum)
|
|
|
|
rman_fini(&eri->eri_rman);
|
|
|
|
if (eri->eri_res != 0) {
|
|
|
|
bus_release_resource(dev, eri->eri_rtype,
|
|
|
|
PCIR_BAR(rnum), eri->eri_res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(sc->sc_range, M_OFWPROP);
|
|
|
|
return (ENXIO);
|
2001-11-09 20:23:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ebus_print_child(device_t dev, device_t child)
|
|
|
|
{
|
|
|
|
struct ebus_devinfo *edi;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
edi = device_get_ivars(child);
|
|
|
|
retval = bus_print_child_header(dev, child);
|
|
|
|
retval += ebus_print_res(edi);
|
|
|
|
retval += bus_print_child_footer(dev, child);
|
|
|
|
return (retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ebus_probe_nomatch(device_t dev, device_t child)
|
|
|
|
{
|
|
|
|
struct ebus_devinfo *edi;
|
|
|
|
|
|
|
|
edi = device_get_ivars(child);
|
|
|
|
device_printf(dev, "<%s>", edi->edi_name);
|
|
|
|
ebus_print_res(edi);
|
|
|
|
printf(" (no driver attached)\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ebus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
|
|
|
|
{
|
|
|
|
struct ebus_devinfo *dinfo;
|
|
|
|
|
|
|
|
if ((dinfo = device_get_ivars(child)) == NULL)
|
|
|
|
return (ENOENT);
|
|
|
|
switch (which) {
|
|
|
|
case EBUS_IVAR_COMPAT:
|
|
|
|
*result = (uintptr_t)dinfo->edi_compat;
|
2002-02-13 15:35:22 +00:00
|
|
|
break;
|
2001-11-09 20:23:38 +00:00
|
|
|
case EBUS_IVAR_NAME:
|
|
|
|
*result = (uintptr_t)dinfo->edi_name;
|
|
|
|
break;
|
|
|
|
case EBUS_IVAR_NODE:
|
|
|
|
*result = dinfo->edi_node;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return (ENOENT);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ebus_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
|
|
|
|
{
|
|
|
|
struct ebus_devinfo *dinfo;
|
|
|
|
|
|
|
|
if ((dinfo = device_get_ivars(child)) == NULL)
|
|
|
|
return (ENOENT);
|
|
|
|
switch (which) {
|
|
|
|
case EBUS_IVAR_COMPAT:
|
|
|
|
case EBUS_IVAR_NAME:
|
|
|
|
case EBUS_IVAR_NODE:
|
|
|
|
return (EINVAL);
|
|
|
|
default:
|
|
|
|
return (ENOENT);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct resource *
|
|
|
|
ebus_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
|
|
|
u_long start, u_long end, u_long count, u_int flags)
|
|
|
|
{
|
|
|
|
struct ebus_softc *sc;
|
|
|
|
struct resource_list *rl;
|
2004-04-28 13:06:46 +00:00
|
|
|
struct resource_list_entry *rle = NULL;
|
|
|
|
struct resource *res;
|
|
|
|
struct ebus_rinfo *ri;
|
|
|
|
bus_space_tag_t bt;
|
|
|
|
bus_space_handle_t bh;
|
2001-11-09 20:23:38 +00:00
|
|
|
int passthrough = (device_get_parent(child) != bus);
|
|
|
|
int isdefault = (start == 0UL && end == ~0UL);
|
2004-04-28 13:06:46 +00:00
|
|
|
int ptype, ridx, rv;
|
2001-11-09 20:23:38 +00:00
|
|
|
|
|
|
|
sc = (struct ebus_softc *)device_get_softc(bus);
|
2004-04-28 13:06:46 +00:00
|
|
|
rl = BUS_GET_RESOURCE_LIST(bus, child);
|
2001-11-09 20:23:38 +00:00
|
|
|
/*
|
|
|
|
* Map ebus ranges to PCI ranges. This may include changing the
|
|
|
|
* allocation type.
|
|
|
|
*/
|
|
|
|
switch (type) {
|
|
|
|
case SYS_RES_IOPORT:
|
2004-04-28 13:06:46 +00:00
|
|
|
KASSERT(!(isdefault && passthrough),
|
|
|
|
("ebus_alloc_resource: passthrough of default alloc"));
|
|
|
|
if (!passthrough) {
|
|
|
|
rle = resource_list_find(rl, type, *rid);
|
|
|
|
if (rle == NULL)
|
|
|
|
return (NULL);
|
|
|
|
KASSERT(rle->res == NULL,
|
|
|
|
("ebus_alloc_resource: resource entry is busy"));
|
|
|
|
if (isdefault) {
|
|
|
|
start = rle->start;
|
|
|
|
count = ulmax(count, rle->count);
|
|
|
|
end = ulmax(rle->end, start + count - 1);
|
|
|
|
}
|
2001-11-09 20:23:38 +00:00
|
|
|
}
|
2004-04-28 13:06:46 +00:00
|
|
|
|
|
|
|
ptype = ofw_isa_range_map(sc->sc_range, sc->sc_nrange,
|
|
|
|
&start, &end, &ridx);
|
|
|
|
|
|
|
|
ri = &sc->sc_rinfo[ridx];
|
|
|
|
res = rman_reserve_resource(&ri->eri_rman, start, end, count,
|
|
|
|
flags, child);
|
|
|
|
if (res == NULL)
|
|
|
|
return (NULL);
|
|
|
|
bt = rman_get_bustag(ri->eri_res);
|
|
|
|
rman_set_bustag(res, bt);
|
|
|
|
rv = bus_space_subregion(bt, rman_get_bushandle(ri->eri_res),
|
|
|
|
rman_get_start(res) - rman_get_start(ri->eri_res), count,
|
|
|
|
&bh);
|
|
|
|
if (rv != 0) {
|
|
|
|
rman_release_resource(res);
|
|
|
|
return (NULL);
|
2001-11-09 20:23:38 +00:00
|
|
|
}
|
2004-04-28 13:06:46 +00:00
|
|
|
rman_set_bushandle(res, bh);
|
|
|
|
if (!passthrough)
|
|
|
|
rle->res = res;
|
|
|
|
return (res);
|
2001-11-09 20:23:38 +00:00
|
|
|
case SYS_RES_IRQ:
|
2004-04-28 13:06:46 +00:00
|
|
|
return (resource_list_alloc(rl, bus, child, type, rid, start,
|
|
|
|
end, count, flags));
|
2001-11-09 20:23:38 +00:00
|
|
|
default:
|
|
|
|
panic("ebus_alloc_resource: unsupported resource type %d",
|
|
|
|
type);
|
|
|
|
}
|
2004-04-28 13:06:46 +00:00
|
|
|
}
|
2002-02-13 15:35:22 +00:00
|
|
|
|
2004-04-28 13:06:46 +00:00
|
|
|
int
|
|
|
|
ebus_release_resource(device_t bus, device_t child, int type, int rid,
|
|
|
|
struct resource *res)
|
|
|
|
{
|
|
|
|
struct ebus_softc *sc;
|
|
|
|
struct resource_list *rl;
|
|
|
|
struct resource_list_entry *rle;
|
|
|
|
int passthrough = (device_get_parent(child) != bus);
|
|
|
|
int rv;
|
2001-11-09 20:23:38 +00:00
|
|
|
|
2004-04-28 13:06:46 +00:00
|
|
|
sc = (struct ebus_softc *)device_get_softc(bus);
|
|
|
|
rl = BUS_GET_RESOURCE_LIST(bus, child);
|
|
|
|
switch (type) {
|
|
|
|
case SYS_RES_IOPORT:
|
|
|
|
if ((rv = rman_release_resource(res)) != 0)
|
|
|
|
return (rv);
|
|
|
|
if (!passthrough) {
|
|
|
|
rle = resource_list_find(rl, type, rid);
|
|
|
|
KASSERT(rle != NULL, ("ebus_release_resource: "
|
|
|
|
"resource entry not found!"));
|
|
|
|
KASSERT(rle->res != NULL, ("ebus_alloc_resource: "
|
|
|
|
"resource entry is not busy"));
|
|
|
|
rle->res = NULL;
|
2001-11-09 20:23:38 +00:00
|
|
|
}
|
2004-04-28 13:06:46 +00:00
|
|
|
break;
|
|
|
|
case SYS_RES_IRQ:
|
|
|
|
return (resource_list_release(rl, bus, child, type, rid, res));
|
|
|
|
default:
|
|
|
|
panic("ebus_release_resource: unsupported resource type %d",
|
|
|
|
type);
|
2001-11-09 20:23:38 +00:00
|
|
|
}
|
2004-04-28 13:06:46 +00:00
|
|
|
return (0);
|
2001-11-09 20:23:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct resource_list *
|
|
|
|
ebus_get_resource_list(device_t dev, device_t child)
|
|
|
|
{
|
|
|
|
struct ebus_devinfo *edi;
|
|
|
|
|
|
|
|
edi = device_get_ivars(child);
|
|
|
|
return (&edi->edi_rl);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ebus_devinfo *
|
Fix interrupt assignment for non-builtin PCI devices on e450s.
This machine uses a non-standard scheme to specify the interrupts to
be assigned for devices in PCI slots; instead of giving the INO
or full interrupt number (which is done for the other devices in this
box), the firmware interrupt properties contain intpin numbers, which
have to be swizzled as usual on PCI-PCI bridges; however, the PCI host
bridge nodes have no interrupt map, so we need to guess the
correct INO by slot number of the device or the closest PCI-PCI
bridge leading to it, and the intpin.
To do this, this fix makes the following changes:
- Add a newbus method for sparc64 PCI host bridges to guess
the INO, and glue code in ofw_pci_orb_callback() to invoke it based
on a new quirk entry. The guessing is only done for interrupt numbers
too low to contain any IGN found on e450s.
- Create another new quirk entry was created to prevent mapping of EBus
interrupts at PCI level; the e450 has full INOs in the interrupt
properties of EBus devices, so trying to remap them could cause
problems.
- Set both quirk entries for e450s; remove the no-swizzle entry.
- Determine the psycho half (bus A or B) a driver instance manages
in psycho_attach()
- Implement the new guessing method for psycho, using the slot number,
psycho half and property value (intpin).
Thanks go to the testers, especially Brian Denehy, who tested many kernels
for me until I had found the right workaround.
Tested by: Brian Denehy <B.Denehy@90east.com>, jake, fenner,
Marius Strobl <marius@alchemy.franken.de>,
Marian Dobre <mari@onix.ro>
Approved by: re (scottl)
2003-05-30 20:48:05 +00:00
|
|
|
ebus_setup_dinfo(device_t dev, struct ebus_softc *sc, phandle_t node,
|
|
|
|
char *name)
|
2001-11-09 20:23:38 +00:00
|
|
|
{
|
|
|
|
struct ebus_devinfo *edi;
|
|
|
|
struct isa_regs *reg;
|
Add the new sparc64 OFW PCI framework, conditional on options OFW_NEWPCI
for now. It introduces a OFW PCI bus driver and a generic OFW PCI-PCI
bridge driver. By utilizing these, the PCI handling is much more elegant
now.
The advantages of the new approach are:
- Device enumeration should hopefully be more like on Solaris now,
so unit numbers should match what's printed on the box more
closely.
- Real interrupt routing is implemented now, so cardbus bridges
etc. have at least a chance to work.
- The quirk tables are gone and have been replaced by (hopefully
sufficient) heuristics.
- Much cleaner code.
There was also a report that previously bogus interrupt assignments
are fixed now, which can be attributed to the new heuristics.
A pitfall, and the reason why this is not the default yet, is that
it changes device enumeration, as mentioned above, which can make
it necessary to change the system configuration if more than one
unit of a device type is present (on a system with two hme cars,
for example, it is possible that hme0 becomes hme1 and vice versa
after enabling the option). Systems with multiple disk controllers
may need to be booted into single user (and require manual specification
of the root file system on boot) to adjust the fstab.
Nevertheless, I would like to encourage users to use this option,
so that it can be made the default soon.
In detail, the changes are:
- Introduce an OFW PCI bus driver; it inherits most methods from the
generic PCI bus driver, but uses the firmware for enumeration,
performs additional initialization for devices and firmware-specific
interrupt routing. It also implements an OFW-specific method to allow
child devices to get their firmware nodes.
- Introduce an OFW PCI-PCI bridge driver; again, it inherits most
of the generic PCI-PCI bridge driver; it has it's own method for
interrupt routing, as well as some sparc64-specific methods (one to
get the node again, and one to adjust the bridge bus range, since
we need to reenumerate all PCI buses).
- Convert the apb driver to the new way of handling things.
- Provide a common framework for OFW bridge drivers, used be the two
drivers above.
- Provide a small common framework for interrupt routing (for all
bridge types).
- Convert the psycho driver to the new framework; this gets rid of a
bunch of old kludges in pci_read_config(), and the whole
preinitialization (ofw_pci_init()).
- Convert the ISA MD part and the EBus driver to the new way
interrupts and nodes are handled.
- Introduce types for firmware interrupt properties.
- Rename the old sparcbus_if to ofw_pci_if by repo copy (it is only
required for PCI), and move it to a more correct location (new
support methodsx were also added, and an old one was deprecated).
- Fix a bunch of minor bugs, perform some cleanups.
In some cases, I introduced some minor code duplication to keep the
new code clean, in hopes that the old code will be unifdef'ed soon.
Reviewed in part by: imp
Tested by: jake, Marius Strobl <marius@alchemy.franken.de>,
Sergey Mokryshev <mokr@mokr.net>,
Chris Jackman <cjackNOSPAM@klatsch.org>
Info on u30 firmware provided by: kris
2003-07-01 14:52:47 +00:00
|
|
|
ofw_isa_intr_t *intrs;
|
|
|
|
ofw_pci_intr_t rintr;
|
2001-11-09 20:23:38 +00:00
|
|
|
u_int64_t start;
|
2002-03-24 02:11:06 +00:00
|
|
|
int nreg, nintr, i;
|
2001-11-09 20:23:38 +00:00
|
|
|
|
2003-02-19 05:47:46 +00:00
|
|
|
edi = malloc(sizeof(*edi), M_DEVBUF, M_ZERO | M_WAITOK);
|
2001-11-09 20:23:38 +00:00
|
|
|
if (edi == NULL)
|
|
|
|
return (NULL);
|
|
|
|
resource_list_init(&edi->edi_rl);
|
|
|
|
edi->edi_name = name;
|
|
|
|
edi->edi_node = node;
|
|
|
|
|
2004-03-27 22:39:47 +00:00
|
|
|
OF_getprop_alloc(node, "compatible", 1, (void **)&edi->edi_compat);
|
2001-11-09 20:23:38 +00:00
|
|
|
nreg = OF_getprop_alloc(node, "reg", sizeof(*reg), (void **)®);
|
|
|
|
if (nreg == -1) {
|
|
|
|
ebus_destroy_dinfo(edi);
|
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
for (i = 0; i < nreg; i++) {
|
|
|
|
start = ISA_REG_PHYS(reg + i);
|
|
|
|
/*
|
|
|
|
* XXX: use SYS_RES_IOPORT for compatability with ISA drivers -
|
|
|
|
* probably, SYS_RES_MEMORY would be more apporpriate, although
|
|
|
|
* that does not really matter.
|
|
|
|
*/
|
|
|
|
resource_list_add(&edi->edi_rl, SYS_RES_IOPORT, i,
|
2002-02-13 15:35:22 +00:00
|
|
|
start, start + reg[i].size - 1, reg[i].size);
|
2001-11-09 20:23:38 +00:00
|
|
|
}
|
Add the new sparc64 OFW PCI framework, conditional on options OFW_NEWPCI
for now. It introduces a OFW PCI bus driver and a generic OFW PCI-PCI
bridge driver. By utilizing these, the PCI handling is much more elegant
now.
The advantages of the new approach are:
- Device enumeration should hopefully be more like on Solaris now,
so unit numbers should match what's printed on the box more
closely.
- Real interrupt routing is implemented now, so cardbus bridges
etc. have at least a chance to work.
- The quirk tables are gone and have been replaced by (hopefully
sufficient) heuristics.
- Much cleaner code.
There was also a report that previously bogus interrupt assignments
are fixed now, which can be attributed to the new heuristics.
A pitfall, and the reason why this is not the default yet, is that
it changes device enumeration, as mentioned above, which can make
it necessary to change the system configuration if more than one
unit of a device type is present (on a system with two hme cars,
for example, it is possible that hme0 becomes hme1 and vice versa
after enabling the option). Systems with multiple disk controllers
may need to be booted into single user (and require manual specification
of the root file system on boot) to adjust the fstab.
Nevertheless, I would like to encourage users to use this option,
so that it can be made the default soon.
In detail, the changes are:
- Introduce an OFW PCI bus driver; it inherits most methods from the
generic PCI bus driver, but uses the firmware for enumeration,
performs additional initialization for devices and firmware-specific
interrupt routing. It also implements an OFW-specific method to allow
child devices to get their firmware nodes.
- Introduce an OFW PCI-PCI bridge driver; again, it inherits most
of the generic PCI-PCI bridge driver; it has it's own method for
interrupt routing, as well as some sparc64-specific methods (one to
get the node again, and one to adjust the bridge bus range, since
we need to reenumerate all PCI buses).
- Convert the apb driver to the new way of handling things.
- Provide a common framework for OFW bridge drivers, used be the two
drivers above.
- Provide a small common framework for interrupt routing (for all
bridge types).
- Convert the psycho driver to the new framework; this gets rid of a
bunch of old kludges in pci_read_config(), and the whole
preinitialization (ofw_pci_init()).
- Convert the ISA MD part and the EBus driver to the new way
interrupts and nodes are handled.
- Introduce types for firmware interrupt properties.
- Rename the old sparcbus_if to ofw_pci_if by repo copy (it is only
required for PCI), and move it to a more correct location (new
support methodsx were also added, and an old one was deprecated).
- Fix a bunch of minor bugs, perform some cleanups.
In some cases, I introduced some minor code duplication to keep the
new code clean, in hopes that the old code will be unifdef'ed soon.
Reviewed in part by: imp
Tested by: jake, Marius Strobl <marius@alchemy.franken.de>,
Sergey Mokryshev <mokr@mokr.net>,
Chris Jackman <cjackNOSPAM@klatsch.org>
Info on u30 firmware provided by: kris
2003-07-01 14:52:47 +00:00
|
|
|
free(reg, M_OFWPROP);
|
2001-11-09 20:23:38 +00:00
|
|
|
|
|
|
|
nintr = OF_getprop_alloc(node, "interrupts", sizeof(*intrs),
|
|
|
|
(void **)&intrs);
|
|
|
|
for (i = 0; i < nintr; i++) {
|
Add the new sparc64 OFW PCI framework, conditional on options OFW_NEWPCI
for now. It introduces a OFW PCI bus driver and a generic OFW PCI-PCI
bridge driver. By utilizing these, the PCI handling is much more elegant
now.
The advantages of the new approach are:
- Device enumeration should hopefully be more like on Solaris now,
so unit numbers should match what's printed on the box more
closely.
- Real interrupt routing is implemented now, so cardbus bridges
etc. have at least a chance to work.
- The quirk tables are gone and have been replaced by (hopefully
sufficient) heuristics.
- Much cleaner code.
There was also a report that previously bogus interrupt assignments
are fixed now, which can be attributed to the new heuristics.
A pitfall, and the reason why this is not the default yet, is that
it changes device enumeration, as mentioned above, which can make
it necessary to change the system configuration if more than one
unit of a device type is present (on a system with two hme cars,
for example, it is possible that hme0 becomes hme1 and vice versa
after enabling the option). Systems with multiple disk controllers
may need to be booted into single user (and require manual specification
of the root file system on boot) to adjust the fstab.
Nevertheless, I would like to encourage users to use this option,
so that it can be made the default soon.
In detail, the changes are:
- Introduce an OFW PCI bus driver; it inherits most methods from the
generic PCI bus driver, but uses the firmware for enumeration,
performs additional initialization for devices and firmware-specific
interrupt routing. It also implements an OFW-specific method to allow
child devices to get their firmware nodes.
- Introduce an OFW PCI-PCI bridge driver; again, it inherits most
of the generic PCI-PCI bridge driver; it has it's own method for
interrupt routing, as well as some sparc64-specific methods (one to
get the node again, and one to adjust the bridge bus range, since
we need to reenumerate all PCI buses).
- Convert the apb driver to the new way of handling things.
- Provide a common framework for OFW bridge drivers, used be the two
drivers above.
- Provide a small common framework for interrupt routing (for all
bridge types).
- Convert the psycho driver to the new framework; this gets rid of a
bunch of old kludges in pci_read_config(), and the whole
preinitialization (ofw_pci_init()).
- Convert the ISA MD part and the EBus driver to the new way
interrupts and nodes are handled.
- Introduce types for firmware interrupt properties.
- Rename the old sparcbus_if to ofw_pci_if by repo copy (it is only
required for PCI), and move it to a more correct location (new
support methodsx were also added, and an old one was deprecated).
- Fix a bunch of minor bugs, perform some cleanups.
In some cases, I introduced some minor code duplication to keep the
new code clean, in hopes that the old code will be unifdef'ed soon.
Reviewed in part by: imp
Tested by: jake, Marius Strobl <marius@alchemy.franken.de>,
Sergey Mokryshev <mokr@mokr.net>,
Chris Jackman <cjackNOSPAM@klatsch.org>
Info on u30 firmware provided by: kris
2003-07-01 14:52:47 +00:00
|
|
|
rintr = ofw_isa_route_intr(dev, node, &sc->sc_iinfo, intrs[i]);
|
2004-05-08 13:53:47 +00:00
|
|
|
if (rintr == PCI_INVALID_IRQ)
|
2001-11-09 20:23:38 +00:00
|
|
|
panic("ebus_setup_dinfo: could not map ebus "
|
|
|
|
"interrupt %d", intrs[i]);
|
|
|
|
resource_list_add(&edi->edi_rl, SYS_RES_IRQ, i,
|
Add the new sparc64 OFW PCI framework, conditional on options OFW_NEWPCI
for now. It introduces a OFW PCI bus driver and a generic OFW PCI-PCI
bridge driver. By utilizing these, the PCI handling is much more elegant
now.
The advantages of the new approach are:
- Device enumeration should hopefully be more like on Solaris now,
so unit numbers should match what's printed on the box more
closely.
- Real interrupt routing is implemented now, so cardbus bridges
etc. have at least a chance to work.
- The quirk tables are gone and have been replaced by (hopefully
sufficient) heuristics.
- Much cleaner code.
There was also a report that previously bogus interrupt assignments
are fixed now, which can be attributed to the new heuristics.
A pitfall, and the reason why this is not the default yet, is that
it changes device enumeration, as mentioned above, which can make
it necessary to change the system configuration if more than one
unit of a device type is present (on a system with two hme cars,
for example, it is possible that hme0 becomes hme1 and vice versa
after enabling the option). Systems with multiple disk controllers
may need to be booted into single user (and require manual specification
of the root file system on boot) to adjust the fstab.
Nevertheless, I would like to encourage users to use this option,
so that it can be made the default soon.
In detail, the changes are:
- Introduce an OFW PCI bus driver; it inherits most methods from the
generic PCI bus driver, but uses the firmware for enumeration,
performs additional initialization for devices and firmware-specific
interrupt routing. It also implements an OFW-specific method to allow
child devices to get their firmware nodes.
- Introduce an OFW PCI-PCI bridge driver; again, it inherits most
of the generic PCI-PCI bridge driver; it has it's own method for
interrupt routing, as well as some sparc64-specific methods (one to
get the node again, and one to adjust the bridge bus range, since
we need to reenumerate all PCI buses).
- Convert the apb driver to the new way of handling things.
- Provide a common framework for OFW bridge drivers, used be the two
drivers above.
- Provide a small common framework for interrupt routing (for all
bridge types).
- Convert the psycho driver to the new framework; this gets rid of a
bunch of old kludges in pci_read_config(), and the whole
preinitialization (ofw_pci_init()).
- Convert the ISA MD part and the EBus driver to the new way
interrupts and nodes are handled.
- Introduce types for firmware interrupt properties.
- Rename the old sparcbus_if to ofw_pci_if by repo copy (it is only
required for PCI), and move it to a more correct location (new
support methodsx were also added, and an old one was deprecated).
- Fix a bunch of minor bugs, perform some cleanups.
In some cases, I introduced some minor code duplication to keep the
new code clean, in hopes that the old code will be unifdef'ed soon.
Reviewed in part by: imp
Tested by: jake, Marius Strobl <marius@alchemy.franken.de>,
Sergey Mokryshev <mokr@mokr.net>,
Chris Jackman <cjackNOSPAM@klatsch.org>
Info on u30 firmware provided by: kris
2003-07-01 14:52:47 +00:00
|
|
|
rintr, rintr, 1);
|
2001-11-09 20:23:38 +00:00
|
|
|
}
|
Add the new sparc64 OFW PCI framework, conditional on options OFW_NEWPCI
for now. It introduces a OFW PCI bus driver and a generic OFW PCI-PCI
bridge driver. By utilizing these, the PCI handling is much more elegant
now.
The advantages of the new approach are:
- Device enumeration should hopefully be more like on Solaris now,
so unit numbers should match what's printed on the box more
closely.
- Real interrupt routing is implemented now, so cardbus bridges
etc. have at least a chance to work.
- The quirk tables are gone and have been replaced by (hopefully
sufficient) heuristics.
- Much cleaner code.
There was also a report that previously bogus interrupt assignments
are fixed now, which can be attributed to the new heuristics.
A pitfall, and the reason why this is not the default yet, is that
it changes device enumeration, as mentioned above, which can make
it necessary to change the system configuration if more than one
unit of a device type is present (on a system with two hme cars,
for example, it is possible that hme0 becomes hme1 and vice versa
after enabling the option). Systems with multiple disk controllers
may need to be booted into single user (and require manual specification
of the root file system on boot) to adjust the fstab.
Nevertheless, I would like to encourage users to use this option,
so that it can be made the default soon.
In detail, the changes are:
- Introduce an OFW PCI bus driver; it inherits most methods from the
generic PCI bus driver, but uses the firmware for enumeration,
performs additional initialization for devices and firmware-specific
interrupt routing. It also implements an OFW-specific method to allow
child devices to get their firmware nodes.
- Introduce an OFW PCI-PCI bridge driver; again, it inherits most
of the generic PCI-PCI bridge driver; it has it's own method for
interrupt routing, as well as some sparc64-specific methods (one to
get the node again, and one to adjust the bridge bus range, since
we need to reenumerate all PCI buses).
- Convert the apb driver to the new way of handling things.
- Provide a common framework for OFW bridge drivers, used be the two
drivers above.
- Provide a small common framework for interrupt routing (for all
bridge types).
- Convert the psycho driver to the new framework; this gets rid of a
bunch of old kludges in pci_read_config(), and the whole
preinitialization (ofw_pci_init()).
- Convert the ISA MD part and the EBus driver to the new way
interrupts and nodes are handled.
- Introduce types for firmware interrupt properties.
- Rename the old sparcbus_if to ofw_pci_if by repo copy (it is only
required for PCI), and move it to a more correct location (new
support methodsx were also added, and an old one was deprecated).
- Fix a bunch of minor bugs, perform some cleanups.
In some cases, I introduced some minor code duplication to keep the
new code clean, in hopes that the old code will be unifdef'ed soon.
Reviewed in part by: imp
Tested by: jake, Marius Strobl <marius@alchemy.franken.de>,
Sergey Mokryshev <mokr@mokr.net>,
Chris Jackman <cjackNOSPAM@klatsch.org>
Info on u30 firmware provided by: kris
2003-07-01 14:52:47 +00:00
|
|
|
free(intrs, M_OFWPROP);
|
2001-11-09 20:23:38 +00:00
|
|
|
|
|
|
|
return (edi);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-02-13 15:35:22 +00:00
|
|
|
* NOTE: This does not free the name member (it is needed afterwards in some
|
2001-11-09 20:23:38 +00:00
|
|
|
* cases).
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
ebus_destroy_dinfo(struct ebus_devinfo *edi)
|
|
|
|
{
|
|
|
|
|
|
|
|
resource_list_free(&edi->edi_rl);
|
|
|
|
free(edi, M_DEVBUF);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ebus_print_res(struct ebus_devinfo *edi)
|
|
|
|
{
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
retval = 0;
|
|
|
|
retval += resource_list_print_type(&edi->edi_rl, "addr", SYS_RES_IOPORT,
|
|
|
|
"%#lx");
|
|
|
|
retval += resource_list_print_type(&edi->edi_rl, "irq", SYS_RES_IRQ,
|
|
|
|
"%ld");
|
|
|
|
return (retval);
|
|
|
|
}
|