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/dev/zs | |
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/dev/zs')
-rw-r--r-- | sys/dev/zs/zs_macio.c | 14 | ||||
-rw-r--r-- | sys/dev/zs/zs_sbus.c | 73 |
2 files changed, 17 insertions, 70 deletions
diff --git a/sys/dev/zs/zs_macio.c b/sys/dev/zs/zs_macio.c index 182fe77..3879a9e 100644 --- a/sys/dev/zs/zs_macio.c +++ b/sys/dev/zs/zs_macio.c @@ -37,8 +37,8 @@ __FBSDID("$FreeBSD$"); #include <machine/resource.h> #include <sys/rman.h> +#include <dev/ofw/ofw_bus.h> #include <dev/ofw/openfirm.h> -#include <powerpc/powermac/maciovar.h> #include <dev/zs/z8530reg.h> #include <dev/zs/z8530var.h> @@ -132,7 +132,7 @@ static int zs_macio_probe(device_t dev) { - if (strcmp(macio_get_name(dev), "escc") != 0 || + if (strcmp(ofw_bus_get_name(dev), "escc") != 0 || device_get_unit(dev) != 0) return (ENXIO); return (zs_probe(dev)); @@ -142,10 +142,8 @@ static int zs_macio_attach(device_t dev) { struct zs_macio_softc *sc; - struct macio_reg *reg; sc = device_get_softc(dev); - reg = macio_get_regs(dev); sc->sc_memres = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->sc_memrid, RF_ACTIVE); @@ -265,16 +263,15 @@ zstty_set_speed(struct zstty_softc *sc, int ospeed) int zstty_console(device_t dev, char *mode, int len) { - device_t parent; - phandle_t chosen, options; + phandle_t chosen, options, parent; ihandle_t stdin, stdout; phandle_t stdinp, stdoutp; char input[32], output[32]; const char *desc; - parent = device_get_parent(dev); chosen = OF_finddevice("/chosen"); options = OF_finddevice("/options"); + parent = ofw_bus_get_node(device_get_parent(dev)); if (OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1 || OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1 || OF_getprop(options, "input-device", input, sizeof(input)) == -1 || @@ -285,8 +282,7 @@ zstty_console(device_t dev, char *mode, int len) stdinp = OF_parent(OF_instance_to_package(stdin)); stdoutp = OF_parent(OF_instance_to_package(stdout)); desc = device_get_desc(dev); - if (macio_get_node(parent) == stdinp && - macio_get_node(parent) == stdoutp && + if (parent == stdinp && parent == stdoutp && input[3] == desc[3] && output[3] == desc[3]) { if (mode != NULL) strlcpy(mode, "57600,8,n,1,-", len); diff --git a/sys/dev/zs/zs_sbus.c b/sys/dev/zs/zs_sbus.c index 796d076..40b7ea4 100644 --- a/sys/dev/zs/zs_sbus.c +++ b/sys/dev/zs/zs_sbus.c @@ -34,16 +34,15 @@ __FBSDID("$FreeBSD$"); #include <sys/kernel.h> #include <sys/lock.h> #include <sys/module.h> + +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/openfirm.h> + #include <machine/bus.h> #include <machine/resource.h> #include <sys/rman.h> -#include <dev/ofw/openfirm.h> - #include <sparc64/fhc/fhcreg.h> -#include <sparc64/fhc/fhcvar.h> - -#include <sparc64/sbus/sbusvar.h> #include <dev/zs/z8530reg.h> #include <dev/zs/z8530var.h> @@ -59,12 +58,6 @@ __FBSDID("$FreeBSD$"); #define ZS_SBUS_DEF_SPEED (9600) -enum zs_device_ivars { - ZS_IVAR_NODE -}; - -__BUS_ACCESSOR(zs, node, ZS, NODE, phandle_t) - struct zs_sbus_softc { struct zs_softc sc_zs; struct resource *sc_irqres; @@ -74,15 +67,10 @@ struct zs_sbus_softc { int sc_memrid; }; -static int zs_fhc_probe(device_t dev); static int zs_fhc_attach(device_t dev); -static int zs_fhc_read_ivar(device_t dev, device_t child, int which, - uintptr_t *result); static int zs_sbus_probe(device_t dev); static int zs_sbus_attach(device_t dev); -static int zs_sbus_read_ivar(device_t dev, device_t child, int which, - uintptr_t *result); static int zs_sbus_detach(device_t dev); @@ -92,12 +80,11 @@ static int zstty_sbus_probe(device_t dev); static int zstty_keyboard(device_t dev); static device_method_t zs_fhc_methods[] = { - DEVMETHOD(device_probe, zs_fhc_probe), + DEVMETHOD(device_probe, zs_sbus_probe), DEVMETHOD(device_attach, zs_fhc_attach), DEVMETHOD(device_detach, zs_sbus_detach), DEVMETHOD(bus_print_child, bus_generic_print_child), - DEVMETHOD(bus_read_ivar, zs_fhc_read_ivar), { 0, 0 } }; @@ -108,7 +95,6 @@ static device_method_t zs_sbus_methods[] = { DEVMETHOD(device_detach, zs_sbus_detach), DEVMETHOD(bus_print_child, bus_generic_print_child), - DEVMETHOD(bus_read_ivar, zs_sbus_read_ivar), { 0, 0 } }; @@ -169,20 +155,10 @@ static uint8_t zs_sbus_init_reg[16] = { }; static int -zs_fhc_probe(device_t dev) -{ - - if (strcmp(fhc_get_name(dev), "zs") != 0 || - device_get_unit(dev) != 0) - return (ENXIO); - return (zs_probe(dev)); -} - -static int zs_sbus_probe(device_t dev) { - if (strcmp(sbus_get_name(dev), "zs") != 0 || + if (strcmp(ofw_bus_get_name(dev), "zs") != 0 || device_get_unit(dev) != 0) return (ENXIO); return (zs_probe(dev)); @@ -260,34 +236,6 @@ zs_sbus_detach(device_t dev) } static int -zs_fhc_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) -{ - - switch (which) { - case ZS_IVAR_NODE: - *result = fhc_get_node(dev); - break; - default: - return (ENOENT); - } - return (0); -} - -static int -zs_sbus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) -{ - - switch (which) { - case ZS_IVAR_NODE: - *result = sbus_get_node(dev); - break; - default: - return (ENOENT); - } - return (0); -} - -static int zstty_sbus_probe(device_t dev) { @@ -349,6 +297,7 @@ zstty_console(device_t dev, char *mode, int len) { phandle_t chosen; phandle_t options; + phandle_t parent; ihandle_t stdin; ihandle_t stdout; char output[32]; @@ -357,13 +306,14 @@ zstty_console(device_t dev, char *mode, int len) chosen = OF_finddevice("/chosen"); options = OF_finddevice("/options"); + parent = ofw_bus_get_node(device_get_parent(dev)); if (OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1 || OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1 || OF_getprop(options, "input-device", input, sizeof(input)) == -1 || OF_getprop(options, "output-device", output, sizeof(output)) == -1) return (0); - if (zs_get_node(dev) != OF_instance_to_package(stdin) || - zs_get_node(dev) != OF_instance_to_package(stdout)) + if (parent != OF_instance_to_package(stdin) || + parent != OF_instance_to_package(stdout)) return (0); if ((strcmp(input, device_get_desc(dev)) == 0 && strcmp(output, device_get_desc(dev)) == 0) || @@ -382,5 +332,6 @@ static int zstty_keyboard(device_t dev) { - return (OF_getproplen(zs_get_node(dev), "keyboard") == 0); + return (OF_getproplen(ofw_bus_get_node(device_get_parent(dev)), + "keyboard") == 0); } |