summaryrefslogtreecommitdiffstats
path: root/sys/sparc64/sbus
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/sbus
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/sbus')
-rw-r--r--sys/sparc64/sbus/sbus.c92
-rw-r--r--sys/sparc64/sbus/sbusvar.h8
2 files changed, 67 insertions, 33 deletions
diff --git a/sys/sparc64/sbus/sbus.c b/sys/sparc64/sbus/sbus.c
index 89c7ac9..4ae43d1 100644
--- a/sys/sparc64/sbus/sbus.c
+++ b/sys/sparc64/sbus/sbus.c
@@ -112,6 +112,7 @@
#include <sys/pcpu.h>
#include <sys/reboot.h>
+#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/openfirm.h>
#include <machine/bus.h>
@@ -132,7 +133,6 @@
#include <sparc64/sbus/sbusreg.h>
#include <sparc64/sbus/sbusvar.h>
-
#ifdef DEBUG
#define SDB_DVMA 0x1
#define SDB_INTR 0x2
@@ -144,11 +144,12 @@ int sbus_debug = 0;
struct sbus_devinfo {
int sdi_burstsz;
- char *sdi_compat;
+ char *sdi_compat; /* PROM compatible */
+ char *sdi_model; /* PROM model */
char *sdi_name; /* PROM name */
phandle_t sdi_node; /* PROM node */
int sdi_slot;
- char *sdi_type; /* PROM name */
+ char *sdi_type; /* PROM device_type */
struct resource_list sdi_rl;
};
@@ -219,6 +220,11 @@ static int sbus_deactivate_resource(device_t, device_t, int, int,
struct resource *);
static int sbus_release_resource(device_t, device_t, int, int,
struct resource *);
+static ofw_bus_get_compat_t sbus_get_compat;
+static ofw_bus_get_model_t sbus_get_model;
+static ofw_bus_get_name_t sbus_get_name;
+static ofw_bus_get_node_t sbus_get_node;
+static ofw_bus_get_type_t sbus_get_type;
static struct sbus_devinfo * sbus_setup_dinfo(struct sbus_softc *sc,
phandle_t node, char *name);
@@ -246,6 +252,13 @@ static device_method_t sbus_methods[] = {
DEVMETHOD(bus_get_resource_list, sbus_get_resource_list),
DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource),
+ /* ofw_bus interface */
+ DEVMETHOD(ofw_bus_get_compat, sbus_get_compat),
+ DEVMETHOD(ofw_bus_get_model, sbus_get_model),
+ DEVMETHOD(ofw_bus_get_name, sbus_get_name),
+ DEVMETHOD(ofw_bus_get_node, sbus_get_node),
+ DEVMETHOD(ofw_bus_get_type, sbus_get_type),
+
{ 0, 0 }
};
@@ -460,6 +473,7 @@ sbus_setup_dinfo(struct sbus_softc *sc, phandle_t node, char *name)
sdi->sdi_node = node;
OF_getprop_alloc(node, "compatible", 1, (void **)&sdi->sdi_compat);
OF_getprop_alloc(node, "device_type", 1, (void **)&sdi->sdi_type);
+ OF_getprop_alloc(node, "model", 1, (void **)&sdi->sdi_model);
slot = -1;
nreg = OF_getprop_alloc(node, "reg", sizeof(*reg), (void **)&reg);
if (nreg == -1) {
@@ -524,6 +538,8 @@ sbus_destroy_dinfo(struct sbus_devinfo *dinfo)
resource_list_free(&dinfo->sdi_rl);
if (dinfo->sdi_compat != NULL)
free(dinfo->sdi_compat, M_OFWPROP);
+ if (dinfo->sdi_model != NULL)
+ free(dinfo->sdi_model, M_OFWPROP);
if (dinfo->sdi_type != NULL)
free(dinfo->sdi_type, M_OFWPROP);
free(dinfo, M_DEVBUF);
@@ -548,19 +564,12 @@ sbus_print_child(device_t dev, device_t child)
static void
sbus_probe_nomatch(device_t dev, device_t child)
{
- char *name;
- char *type;
+ const char *type;
- if (BUS_READ_IVAR(dev, child, SBUS_IVAR_NAME,
- (uintptr_t *)&name) != 0 ||
- BUS_READ_IVAR(dev, child, SBUS_IVAR_DEVICE_TYPE,
- (uintptr_t *)&type) != 0)
- return;
-
- if (type == NULL)
+ if ((type = ofw_bus_get_type(child)) == NULL)
type = "(unknown)";
device_printf(dev, "<%s>, type %s (no driver attached)\n",
- name, type);
+ ofw_bus_get_name(child), type);
}
static int
@@ -578,21 +587,9 @@ sbus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
case SBUS_IVAR_CLOCKFREQ:
*result = sc->sc_clockfreq;
break;
- case SBUS_IVAR_COMPAT:
- *result = (uintptr_t)dinfo->sdi_compat;
- break;
- case SBUS_IVAR_NAME:
- *result = (uintptr_t)dinfo->sdi_name;
- break;
- case SBUS_IVAR_NODE:
- *result = dinfo->sdi_node;
- break;
case SBUS_IVAR_SLOT:
*result = dinfo->sdi_slot;
break;
- case SBUS_IVAR_DEVICE_TYPE:
- *result = (uintptr_t)dinfo->sdi_type;
- break;
default:
return (ENOENT);
}
@@ -890,3 +887,48 @@ sbus_alloc_bustag(struct sbus_softc *sc)
sbt->bst_type = SBUS_BUS_SPACE;
return (sbt);
}
+
+const char *
+sbus_get_compat(device_t bus, device_t dev)
+{
+ struct sbus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->sdi_compat);
+}
+
+const char *
+sbus_get_model(device_t bus, device_t dev)
+{
+ struct sbus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->sdi_model);
+}
+
+const char *
+sbus_get_name(device_t bus, device_t dev)
+{
+ struct sbus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->sdi_name);
+}
+
+static phandle_t
+sbus_get_node(device_t bus, device_t dev)
+{
+ struct sbus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->sdi_node);
+}
+
+const char *
+sbus_get_type(device_t bus, device_t dev)
+{
+ struct sbus_devinfo *dinfo;
+
+ dinfo = device_get_ivars(dev);
+ return (dinfo->sdi_type);
+}
diff --git a/sys/sparc64/sbus/sbusvar.h b/sys/sparc64/sbus/sbusvar.h
index 6b5a438..1f4a05d 100644
--- a/sys/sparc64/sbus/sbusvar.h
+++ b/sys/sparc64/sbus/sbusvar.h
@@ -98,11 +98,7 @@
enum sbus_device_ivars {
SBUS_IVAR_BURSTSZ,
SBUS_IVAR_CLOCKFREQ,
- SBUS_IVAR_COMPAT,
- SBUS_IVAR_NAME,
- SBUS_IVAR_NODE,
SBUS_IVAR_SLOT,
- SBUS_IVAR_DEVICE_TYPE,
};
/*
@@ -113,11 +109,7 @@ enum sbus_device_ivars {
SBUS_ACCESSOR(burstsz, BURSTSZ, int)
SBUS_ACCESSOR(clockfreq, CLOCKFREQ, int)
-SBUS_ACCESSOR(compat, COMPAT, char *)
-SBUS_ACCESSOR(name, NAME, char *)
-SBUS_ACCESSOR(node, NODE, phandle_t)
SBUS_ACCESSOR(slot, SLOT, int)
-SBUS_ACCESSOR(device_type, DEVICE_TYPE, char *)
#undef SBUS_ACCESSOR
OpenPOWER on IntegriCloud