summaryrefslogtreecommitdiffstats
path: root/sys/sparc64/pci
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2004-08-12 17:41:33 +0000
committermarius <marius@FreeBSD.org>2004-08-12 17:41:33 +0000
commitf8c9f3a5e2940ba4fac814bea5bf4f4728dcd87b (patch)
treee750b2d26d6511903970a6a2a5d73da06845d58b /sys/sparc64/pci
parent482740a238b6b7d0f1c649d1d3391e801547f668 (diff)
downloadFreeBSD-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')
-rw-r--r--sys/sparc64/pci/apb.c5
-rw-r--r--sys/sparc64/pci/ofw_pci.h7
-rw-r--r--sys/sparc64/pci/ofw_pci_if.m17
-rw-r--r--sys/sparc64/pci/ofw_pcib.c7
-rw-r--r--sys/sparc64/pci/ofw_pcib_subr.c7
-rw-r--r--sys/sparc64/pci/ofw_pcib_subr.h2
-rw-r--r--sys/sparc64/pci/ofw_pcibus.c76
-rw-r--r--sys/sparc64/pci/psycho.c11
8 files changed, 88 insertions, 44 deletions
diff --git a/sys/sparc64/pci/apb.c b/sys/sparc64/pci/apb.c
index be43974..4fc8fd2 100644
--- a/sys/sparc64/pci/apb.c
+++ b/sys/sparc64/pci/apb.c
@@ -48,6 +48,7 @@
#include <sys/module.h>
#include <sys/bus.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
@@ -101,8 +102,10 @@ static device_method_t apb_methods[] = {
DEVMETHOD(pcib_write_config, pcib_write_config),
DEVMETHOD(pcib_route_interrupt, ofw_pcib_gen_route_interrupt),
+ /* ofw_bus interface */
+ DEVMETHOD(ofw_bus_get_node, ofw_pcib_gen_get_node),
+
/* ofw_pci interface */
- DEVMETHOD(ofw_pci_get_node, ofw_pcib_gen_get_node),
DEVMETHOD(ofw_pci_adjust_busrange, ofw_pcib_gen_adjust_busrange),
{ 0, 0 }
diff --git a/sys/sparc64/pci/ofw_pci.h b/sys/sparc64/pci/ofw_pci.h
index d1b6623..d5fdf12 100644
--- a/sys/sparc64/pci/ofw_pci.h
+++ b/sys/sparc64/pci/ofw_pci.h
@@ -48,11 +48,4 @@ typedef u_int32_t ofw_pci_intr_t;
u_int8_t ofw_pci_alloc_busno(phandle_t);
-static __inline phandle_t
-ofw_pci_get_node(device_t dev)
-{
-
- return (OFW_PCI_GET_NODE(device_get_parent(dev), dev));
-}
-
#endif /* ! _SPARC64_PCI_OFW_PCI_H_ */
diff --git a/sys/sparc64/pci/ofw_pci_if.m b/sys/sparc64/pci/ofw_pci_if.m
index adbb8cf..ef203b6 100644
--- a/sys/sparc64/pci/ofw_pci_if.m
+++ b/sys/sparc64/pci/ofw_pci_if.m
@@ -35,7 +35,6 @@ INTERFACE ofw_pci;
CODE {
static ofw_pci_intr_pending_t ofw_pci_default_intr_pending;
static ofw_pci_get_bus_handle_t ofw_pci_default_get_bus_handle;
- static ofw_pci_get_node_t ofw_pci_default_get_node;
static ofw_pci_adjust_busrange_t ofw_pci_default_adjust_busrange;
static int
@@ -54,13 +53,6 @@ CODE {
childhdl, tag));
}
- static phandle_t
- ofw_pci_default_get_node(device_t bus, device_t dev)
- {
-
- return (0);
- }
-
static void
ofw_pci_default_adjust_busrange(device_t dev, u_int busno)
{
@@ -85,15 +77,6 @@ METHOD bus_space_handle_t get_bus_handle {
bus_space_tag_t *tag;
} DEFAULT ofw_pci_default_get_bus_handle;
-# Get the firmware node for the device dev on the bus. The default method will
-# return 0, which signals that there is no such node.
-# This could be an ivar, but isn't to avoid numbering conflicts with standard
-# pci/pcib ones.
-METHOD phandle_t get_node {
- device_t bus;
- device_t dev;
-} DEFAULT ofw_pci_default_get_node;
-
# Make sure that all PCI bridges up in the hierarchy contain this bus in their
# subordinate bus range. This is required because we reenumerate all PCI
# buses.
diff --git a/sys/sparc64/pci/ofw_pcib.c b/sys/sparc64/pci/ofw_pcib.c
index 66ef81f..bf2f1d7 100644
--- a/sys/sparc64/pci/ofw_pcib.c
+++ b/sys/sparc64/pci/ofw_pcib.c
@@ -40,6 +40,7 @@
#include <sys/bus.h>
#include <sys/module.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
@@ -82,8 +83,10 @@ static device_method_t ofw_pcib_methods[] = {
DEVMETHOD(pcib_write_config, pcib_write_config),
DEVMETHOD(pcib_route_interrupt, ofw_pcib_gen_route_interrupt),
+ /* ofw_bus interface */
+ DEVMETHOD(ofw_bus_get_node, ofw_pcib_gen_get_node),
+
/* ofw_pci interface */
- DEVMETHOD(ofw_pci_get_node, ofw_pcib_gen_get_node),
DEVMETHOD(ofw_pci_adjust_busrange, ofw_pcib_gen_adjust_busrange),
{ 0, 0 }
@@ -102,7 +105,7 @@ ofw_pcib_probe(device_t dev)
{
if ((pci_get_class(dev) == PCIC_BRIDGE) &&
(pci_get_subclass(dev) == PCIS_BRIDGE_PCI) &&
- ofw_pci_get_node(dev) != 0) {
+ ofw_bus_get_node(dev) != 0) {
device_set_desc(dev, "OFW PCI-PCI bridge");
return (0);
}
diff --git a/sys/sparc64/pci/ofw_pcib_subr.c b/sys/sparc64/pci/ofw_pcib_subr.c
index daf7e0b..b297d34 100644
--- a/sys/sparc64/pci/ofw_pcib_subr.c
+++ b/sys/sparc64/pci/ofw_pcib_subr.c
@@ -31,8 +31,9 @@
#include <sys/systm.h>
#include <sys/bus.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/ofw_bus.h>
@@ -53,7 +54,7 @@ ofw_pcib_gen_setup(device_t bridge)
u_int secbus;
sc->ops_pcib_sc.dev = bridge;
- sc->ops_node = ofw_pci_get_node(bridge);
+ sc->ops_node = ofw_bus_get_node(bridge);
KASSERT(sc->ops_node != 0,
("ofw_pcib_gen_setup: no ofw pci parent bus!"));
@@ -81,7 +82,7 @@ ofw_pcib_gen_route_interrupt(device_t bridge, device_t dev, int intpin)
struct ofw_bus_iinfo *ii = &sc->ops_iinfo;
struct ofw_pci_register reg;
device_t pbridge = device_get_parent(device_get_parent(bridge));
- phandle_t node = ofw_pci_get_node(dev);
+ phandle_t node = ofw_bus_get_node(dev);
ofw_pci_intr_t pintr, mintr;
u_int8_t maskbuf[sizeof(reg) + sizeof(pintr)];
diff --git a/sys/sparc64/pci/ofw_pcib_subr.h b/sys/sparc64/pci/ofw_pcib_subr.h
index f925cbe..8c17e2c 100644
--- a/sys/sparc64/pci/ofw_pcib_subr.h
+++ b/sys/sparc64/pci/ofw_pcib_subr.h
@@ -41,7 +41,7 @@ struct ofw_pcib_gen_softc {
void ofw_pcib_gen_setup(device_t);
pcib_route_interrupt_t ofw_pcib_gen_route_interrupt;
-ofw_pci_get_node_t ofw_pcib_gen_get_node;
+ofw_bus_get_node_t ofw_pcib_gen_get_node;
ofw_pci_adjust_busrange_t ofw_pcib_gen_adjust_busrange;
#endif /* !_SPARC64_PCI_OFW_PCI_SUBR_H */
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);
+}
diff --git a/sys/sparc64/pci/psycho.c b/sys/sparc64/pci/psycho.c
index aa002cc..6b42f01 100644
--- a/sys/sparc64/pci/psycho.c
+++ b/sys/sparc64/pci/psycho.c
@@ -48,8 +48,9 @@
#include <sys/malloc.h>
#include <sys/pcpu.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_private.h>
@@ -113,7 +114,7 @@ static pcib_write_config_t psycho_write_config;
static pcib_route_interrupt_t psycho_route_interrupt;
static ofw_pci_intr_pending_t psycho_intr_pending;
static ofw_pci_get_bus_handle_t psycho_get_bus_handle;
-static ofw_pci_get_node_t psycho_get_node;
+static ofw_bus_get_node_t psycho_get_node;
static ofw_pci_adjust_busrange_t psycho_adjust_busrange;
static device_method_t psycho_methods[] = {
@@ -137,10 +138,12 @@ static device_method_t psycho_methods[] = {
DEVMETHOD(pcib_write_config, psycho_write_config),
DEVMETHOD(pcib_route_interrupt, psycho_route_interrupt),
+ /* ofw_bus interface */
+ DEVMETHOD(ofw_bus_get_node, psycho_get_node),
+
/* ofw_pci interface */
DEVMETHOD(ofw_pci_intr_pending, psycho_intr_pending),
DEVMETHOD(ofw_pci_get_bus_handle, psycho_get_bus_handle),
- DEVMETHOD(ofw_pci_get_node, psycho_get_node),
DEVMETHOD(ofw_pci_adjust_busrange, psycho_adjust_busrange),
{ 0, 0 }
@@ -840,7 +843,7 @@ psycho_route_interrupt(device_t bridge, device_t dev, int pin)
struct psycho_softc *sc = device_get_softc(bridge);
struct ofw_pci_register reg;
bus_addr_t intrmap;
- phandle_t node = ofw_pci_get_node(dev);
+ phandle_t node = ofw_bus_get_node(dev);
ofw_pci_intr_t pintr, mintr;
u_int8_t maskbuf[sizeof(reg) + sizeof(pintr)];
OpenPOWER on IntegriCloud