diff options
author | marius <marius@FreeBSD.org> | 2004-08-12 17:41:33 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2004-08-12 17:41:33 +0000 |
commit | f8c9f3a5e2940ba4fac814bea5bf4f4728dcd87b (patch) | |
tree | e750b2d26d6511903970a6a2a5d73da06845d58b /sys/sparc64/pci/ofw_pcibus.c | |
parent | 482740a238b6b7d0f1c649d1d3391e801547f668 (diff) | |
download | FreeBSD-src-f8c9f3a5e2940ba4fac814bea5bf4f4728dcd87b.zip FreeBSD-src-f8c9f3a5e2940ba4fac814bea5bf4f4728dcd87b.tar.gz |
- Introduce an ofw_bus kobj-interface for retrieving the OFW node and a
subset ("compatible", "device_type", "model" and "name") of the standard
properties in drivers for devices on Open Firmware supported busses. The
standard properties "reg", "interrupts" und "address" are not covered by
this interface because they are only of interest in the respective bridge
code. There's a remaining standard property "status" which is unclear how
to support properly but which also isn't used in FreeBSD at present.
This ofw_bus kobj-interface allows to replace the various (ebus_get_node(),
ofw_pci_get_node(), etc.) and partially inconsistent (central_get_type()
vs. sbus_get_device_type(), etc.) existing IVAR ones with a common one.
This in turn allows to simplify and remove code-duplication in drivers for
devices that can hang off of more than one OFW supported bus.
- Convert the sparc64 Central, EBus, FHC, PCI and SBus bus drivers and the
drivers for their children to use the ofw_bus kobj-interface. The IVAR-
interfaces of the Central, EBus and FHC are entirely replaced by this. The
PCI bus driver used its own kobj-interface and now also uses the ofw_bus
one. The IVARs special to the SBus, e.g. for retrieving the burst size,
remain.
Beware: this causes an ABI-breakage for modules of drivers which used the
IVAR-interfaces, i.e. esp(4), hme(4), isp(4) and uart(4), which need to be
recompiled.
The style-inconsistencies introduced in some of the bus drivers will be
fixed by tmm@ in a generic clean-up of the respective drivers later (he
requested to add the changes in the "new" style).
- Convert the powerpc MacIO bus driver and the drivers for its children to
use the ofw_bus kobj-interface. This invloves removing the IVARs related
to the "reg" property which were unused and a leftover from the NetBSD
origini of the code. There's no ABI-breakage caused by this because none
of these driver are currently built as modules.
There are other powerpc bus drivers which can be converted to the ofw_bus
kobj-interface, e.g. the PCI bus driver, which should be done together
with converting powerpc to use the OFW PCI code from sparc64.
- Make the SBus and FHC front-end of zs(4) and the sparc64 eeprom(4) take
advantage of the ofw_bus kobj-interface and simplify them a bit.
Reviewed by: grehan, tmm
Approved by: re (scottl)
Discussed with: tmm
Tested with: Sun AX1105, AXe, Ultra 2, Ultra 60; PPC cross-build on i386
Diffstat (limited to 'sys/sparc64/pci/ofw_pcibus.c')
-rw-r--r-- | sys/sparc64/pci/ofw_pcibus.c | 76 |
1 files changed, 67 insertions, 9 deletions
diff --git a/sys/sparc64/pci/ofw_pcibus.c b/sys/sparc64/pci/ofw_pcibus.c index 597b656..85369d1 100644 --- a/sys/sparc64/pci/ofw_pcibus.c +++ b/sys/sparc64/pci/ofw_pcibus.c @@ -30,6 +30,7 @@ */ #include "opt_ofw_pci.h" + #include <sys/param.h> #include <sys/bus.h> #include <sys/kernel.h> @@ -37,8 +38,9 @@ #include <sys/module.h> #include <sys/pciio.h> -#include <dev/ofw/openfirm.h> +#include <dev/ofw/ofw_bus.h> #include <dev/ofw/ofw_pci.h> +#include <dev/ofw/openfirm.h> #include <machine/bus.h> #include <machine/bus_common.h> @@ -62,7 +64,11 @@ static void ofw_pcibus_setup_device(device_t, u_int, u_int, u_int); static device_probe_t ofw_pcibus_probe; static device_attach_t ofw_pcibus_attach; static pci_assign_interrupt_t ofw_pcibus_assign_interrupt; -static ofw_pci_get_node_t ofw_pcibus_get_node; +static ofw_bus_get_compat_t ofw_pcibus_get_compat; +static ofw_bus_get_model_t ofw_pcibus_get_model; +static ofw_bus_get_name_t ofw_pcibus_get_name; +static ofw_bus_get_node_t ofw_pcibus_get_node; +static ofw_bus_get_type_t ofw_pcibus_get_type; static device_method_t ofw_pcibus_methods[] = { /* Device interface */ @@ -103,14 +109,22 @@ static device_method_t ofw_pcibus_methods[] = { DEVMETHOD(pci_set_powerstate, pci_set_powerstate_method), DEVMETHOD(pci_assign_interrupt, ofw_pcibus_assign_interrupt), - /* OFW PCI interface */ - DEVMETHOD(ofw_pci_get_node, ofw_pcibus_get_node), + /* ofw_bus interface */ + DEVMETHOD(ofw_bus_get_compat, ofw_pcibus_get_compat), + DEVMETHOD(ofw_bus_get_model, ofw_pcibus_get_model), + DEVMETHOD(ofw_bus_get_name, ofw_pcibus_get_name), + DEVMETHOD(ofw_bus_get_node, ofw_pcibus_get_node), + DEVMETHOD(ofw_bus_get_type, ofw_pcibus_get_type), { 0, 0 } }; struct ofw_pcibus_devinfo { struct pci_devinfo opd_dinfo; + char *opd_compat; + char *opd_model; + char *opd_name; + char *opd_type; phandle_t opd_node; }; @@ -132,7 +146,7 @@ static int ofw_pcibus_probe(device_t dev) { - if (ofw_pci_get_node(dev) == 0) + if (ofw_bus_get_node(dev) == 0) return (ENXIO); device_set_desc(dev, "OFW PCI bus"); @@ -205,7 +219,7 @@ ofw_pcibus_attach(device_t dev) if (bootverbose) device_printf(dev, "physical bus=%d\n", busno); - node = ofw_pci_get_node(dev); + node = ofw_bus_get_node(dev); for (child = OF_child(node); child != 0; child = OF_peer(child)) { if (OF_getprop(child, "reg", &pcir, sizeof(pcir)) == -1) panic("ofw_pci_attach: OF_getprop failed"); @@ -216,6 +230,14 @@ ofw_pcibus_attach(device_t dev) busno, slot, func, sizeof(*dinfo)); if (dinfo != NULL) { dinfo->opd_node = child; + OF_getprop_alloc(child, "compatible", 1, + (void **)&dinfo->opd_compat); + OF_getprop_alloc(child, "device_type", 1, + (void **)&dinfo->opd_type); + OF_getprop_alloc(child, "model", 1, + (void **)&dinfo->opd_model); + OF_getprop_alloc(child, "name", 1, + (void **)&dinfo->opd_name); pci_add_child(dev, (struct pci_devinfo *)dinfo); } } @@ -228,11 +250,10 @@ ofw_pcibus_assign_interrupt(device_t dev, device_t child) { struct ofw_pcibus_devinfo *dinfo = device_get_ivars(child); pcicfgregs *cfg = &dinfo->opd_dinfo.cfg; - phandle_t node = ofw_pci_get_node(child); ofw_pci_intr_t intr; int isz; - isz = OF_getprop(node, "interrupts", &intr, sizeof(intr)); + isz = OF_getprop(dinfo->opd_node, "interrupts", &intr, sizeof(intr)); if (isz != sizeof(intr)) { /* No property; our best guess is the intpin. */ intr = cfg->intpin; @@ -255,10 +276,47 @@ ofw_pcibus_assign_interrupt(device_t dev, device_t child) return (PCIB_ROUTE_INTERRUPT(device_get_parent(dev), child, intr)); } +static const char * +ofw_pcibus_get_compat(device_t bus, device_t dev) +{ + struct ofw_pcibus_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + return (dinfo->opd_compat); +} + +static const char * +ofw_pcibus_get_model(device_t bus, device_t dev) +{ + struct ofw_pcibus_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + return (dinfo->opd_model); +} + +static const char * +ofw_pcibus_get_name(device_t bus, device_t dev) +{ + struct ofw_pcibus_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + return (dinfo->opd_name); +} + static phandle_t ofw_pcibus_get_node(device_t bus, device_t dev) { - struct ofw_pcibus_devinfo *dinfo = device_get_ivars(dev); + struct ofw_pcibus_devinfo *dinfo; + dinfo = device_get_ivars(dev); return (dinfo->opd_node); } + +static const char * +ofw_pcibus_get_type(device_t bus, device_t dev) +{ + struct ofw_pcibus_devinfo *dinfo; + + dinfo = device_get_ivars(dev); + return (dinfo->opd_type); +} |