diff options
| author | Marius Strobl <marius@FreeBSD.org> | 2004-08-12 17:41:33 +0000 |
|---|---|---|
| committer | Marius Strobl <marius@FreeBSD.org> | 2004-08-12 17:41:33 +0000 |
| commit | 26280d88d76716790cf28f23fdb0bda56533e9b6 (patch) | |
| tree | e750b2d26d6511903970a6a2a5d73da06845d58b /sys/dev | |
| parent | 9f7f340a0f9eb8af47d81687feb963fa612242e9 (diff) | |
Notes
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/esp/esp_sbus.c | 9 | ||||
| -rw-r--r-- | sys/dev/hme/if_hme_sbus.c | 7 | ||||
| -rw-r--r-- | sys/dev/isp/isp_sbus.c | 11 | ||||
| -rw-r--r-- | sys/dev/ofw/ofw_bus.h | 73 | ||||
| -rw-r--r-- | sys/dev/ofw/ofw_bus_if.m | 110 | ||||
| -rw-r--r-- | sys/dev/pcf/envctrl.c | 8 | ||||
| -rw-r--r-- | sys/dev/pcf/pcf_ebus.c | 15 | ||||
| -rw-r--r-- | sys/dev/puc/puc_ebus.c | 8 | ||||
| -rw-r--r-- | sys/dev/puc/puc_sbus.c | 8 | ||||
| -rw-r--r-- | sys/dev/sab/sab.c | 21 | ||||
| -rw-r--r-- | sys/dev/uart/uart_bus_ebus.c | 10 | ||||
| -rw-r--r-- | sys/dev/zs/zs_macio.c | 14 | ||||
| -rw-r--r-- | sys/dev/zs/zs_sbus.c | 73 |
13 files changed, 250 insertions, 117 deletions
diff --git a/sys/dev/esp/esp_sbus.c b/sys/dev/esp/esp_sbus.c index ec1e037967a9..eb32f1dde386 100644 --- a/sys/dev/esp/esp_sbus.c +++ b/sys/dev/esp/esp_sbus.c @@ -76,8 +76,9 @@ __FBSDID("$FreeBSD$"); #include <sys/lock.h> #include <sys/mutex.h> -#include <machine/bus.h> +#include <dev/ofw/ofw_bus.h> #include <dev/ofw/openfirm.h> +#include <machine/bus.h> #include <machine/ofw_machdep.h> #include <machine/resource.h> #include <sys/rman.h> @@ -168,9 +169,9 @@ static struct ncr53c9x_glue esp_sbus_glue = { static int esp_sbus_probe(device_t dev) { - char *name; + const char *name; - name = sbus_get_name(dev); + name = ofw_bus_get_name(dev); if (strcmp("SUNW,fas", name) == 0) { device_set_desc(dev, "Sun FAS366 Fast-Wide SCSI"); return (-10); @@ -189,7 +190,7 @@ esp_sbus_attach(device_t dev) int burst; esc->sc_dev = dev; - node = sbus_get_node(dev); + node = ofw_bus_get_node(dev); if (OF_getprop(node, "initiator-id", &sc->sc_id, sizeof(sc->sc_id)) == -1) sc->sc_id = 7;; diff --git a/sys/dev/hme/if_hme_sbus.c b/sys/dev/hme/if_hme_sbus.c index f2eac6d7b4da..06c0d8a6104a 100644 --- a/sys/dev/hme/if_hme_sbus.c +++ b/sys/dev/hme/if_hme_sbus.c @@ -51,8 +51,9 @@ __FBSDID("$FreeBSD$"); #include <sys/resource.h> #include <sys/socket.h> +#include <dev/ofw/ofw_bus.h> + #include <machine/bus.h> -#include <dev/ofw/openfirm.h> #include <machine/ofw_machdep.h> #include <machine/resource.h> @@ -131,9 +132,9 @@ MODULE_DEPEND(hme, ether, 1, 1, 1); static int hme_sbus_probe(device_t dev) { - char *name; + const char *name; - name = sbus_get_name(dev); + name = ofw_bus_get_name(dev); if (strcmp(name, "SUNW,qfe") == 0 || strcmp(name, "SUNW,hme") == 0) { device_set_desc(dev, "Sun HME 10/100 Ethernet"); diff --git a/sys/dev/isp/isp_sbus.c b/sys/dev/isp/isp_sbus.c index a1f912de87f1..5f87f3dbb08e 100644 --- a/sys/dev/isp/isp_sbus.c +++ b/sys/dev/isp/isp_sbus.c @@ -35,11 +35,12 @@ __FBSDID("$FreeBSD$"); #include <sys/kernel.h> #include <sys/module.h> #include <sys/resource.h> + +#include <dev/ofw/ofw_bus.h> + #include <machine/bus.h> #include <machine/resource.h> #include <sys/rman.h> -#include <dev/ofw/openfirm.h> -#include <machine/ofw_machdep.h> #include <sparc64/sbus/sbusvar.h> #include <dev/isp/isp_freebsd.h> @@ -110,7 +111,7 @@ static int isp_sbus_probe(device_t dev) { int found = 0; - char *name = sbus_get_name(dev); + const char *name = ofw_bus_get_name(dev); if (strcmp(name, "SUNW,isp") == 0 || strcmp(name, "QLGC,isp") == 0 || strcmp(name, "ptisp") == 0 || @@ -240,8 +241,8 @@ isp_sbus_attach(device_t dev) * would fail in trying to download (via poking) * FW. We give up on them. */ - if (strcmp("PTI,ptisp", sbus_get_name(dev)) == 0 || - strcmp("ptisp", sbus_get_name(dev)) == 0) { + if (strcmp("PTI,ptisp", ofw_bus_get_name(dev)) == 0 || + strcmp("ptisp", ofw_bus_get_name(dev)) == 0) { isp->isp_confopts |= ISP_CFG_NORELOAD; } diff --git a/sys/dev/ofw/ofw_bus.h b/sys/dev/ofw/ofw_bus.h new file mode 100644 index 000000000000..3f4fbae9754d --- /dev/null +++ b/sys/dev/ofw/ofw_bus.h @@ -0,0 +1,73 @@ +/*- + * Copyright (c) 2001, 2003 by Thomas Moestl <tmm@FreeBSD.org> + * Copyright (c) 2004 by Marius Strobl <marius@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. + * + * 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 OR CONTRIBUTORS 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. + * + * $FreeBSD$ + */ + +#ifndef _DEV_OFW_OFW_BUS_H_ +#define _DEV_OFW_OFW_BUS_H_ + +#include <sys/bus.h> + +#include <dev/ofw/openfirm.h> + +#include "ofw_bus_if.h" + +static __inline const char * +ofw_bus_get_compat(device_t dev) +{ + + return (OFW_BUS_GET_COMPAT(device_get_parent(dev), dev)); +} + +static __inline const char * +ofw_bus_get_model(device_t dev) +{ + + return (OFW_BUS_GET_MODEL(device_get_parent(dev), dev)); +} + +static __inline const char * +ofw_bus_get_name(device_t dev) +{ + + return (OFW_BUS_GET_NAME(device_get_parent(dev), dev)); +} + +static __inline phandle_t +ofw_bus_get_node(device_t dev) +{ + + return (OFW_BUS_GET_NODE(device_get_parent(dev), dev)); +} + +static __inline const char * +ofw_bus_get_type(device_t dev) +{ + + return (OFW_BUS_GET_TYPE(device_get_parent(dev), dev)); +} + +#endif /* !_DEV_OFW_OFW_BUS_H_ */ diff --git a/sys/dev/ofw/ofw_bus_if.m b/sys/dev/ofw/ofw_bus_if.m new file mode 100644 index 000000000000..87e4fcc41e28 --- /dev/null +++ b/sys/dev/ofw/ofw_bus_if.m @@ -0,0 +1,110 @@ +# Copyright (c) 2001, 2003 by Thomas Moestl <tmm@FreeBSD.org> +# Copyright (c) 2004 by Marius Strobl <marius@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. +# +# 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 OR CONTRIBUTORS 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. +# +# $FreeBSD$ + +#include <sys/bus.h> +#include <machine/bus.h> + +#include <dev/ofw/openfirm.h> + +INTERFACE ofw_bus; + +CODE { + static ofw_bus_get_compat_t ofw_bus_default_get_compat; + static ofw_bus_get_model_t ofw_bus_default_get_model; + static ofw_bus_get_name_t ofw_bus_default_get_name; + static ofw_bus_get_node_t ofw_bus_default_get_node; + static ofw_bus_get_type_t ofw_bus_default_get_type; + + static const char * + ofw_bus_default_get_compat(device_t bus, device_t dev) + { + + return (NULL); + } + + static const char * + ofw_bus_default_get_model(device_t bus, device_t dev) + { + + return (NULL); + } + + static const char * + ofw_bus_default_get_name(device_t bus, device_t dev) + { + + return (NULL); + } + + static phandle_t + ofw_bus_default_get_node(device_t bus, device_t dev) + { + + return (0); + } + + static const char * + ofw_bus_default_get_type(device_t bus, device_t dev) + { + + return (NULL); + } +}; + +# Get the alternate firmware name for the device dev on the bus. The default +# method will return NULL, which means the device doesn't have such a property. +METHOD const char * get_compat { + device_t bus; + device_t dev; +} DEFAULT ofw_bus_default_get_compat; + +# Get the firmware model name for the device dev on the bus. The default method +# will return NULL, which means the device doesn't have such a property. +METHOD const char * get_model { + device_t bus; + device_t dev; +} DEFAULT ofw_bus_default_get_model; + +# Get the firmware name for the device dev on the bus. The default method will +# return NULL, which means the device doesn't have such a property. +METHOD const char * get_name { + device_t bus; + device_t dev; +} DEFAULT ofw_bus_default_get_name; + +# 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. +METHOD phandle_t get_node { + device_t bus; + device_t dev; +} DEFAULT ofw_bus_default_get_node; + +# Get the firmware device type for the device dev on the bus. The default +# method will return NULL, which means the device doesn't have such a property. +METHOD const char * get_type { + device_t bus; + device_t dev; +} DEFAULT ofw_bus_default_get_type; diff --git a/sys/dev/pcf/envctrl.c b/sys/dev/pcf/envctrl.c index 74d87c7ac69e..7b5f0649a6d8 100644 --- a/sys/dev/pcf/envctrl.c +++ b/sys/dev/pcf/envctrl.c @@ -46,15 +46,13 @@ __FBSDID("$FreeBSD$"); #include <sys/resource.h> #include <sys/uio.h> +#include <dev/ofw/ofw_bus.h> + #include <machine/bus.h> #include <machine/resource.h> #include <sys/rman.h> -#include <dev/ofw/openfirm.h> - -#include <sparc64/ebus/ebusvar.h> - #include <dev/iicbus/iiconf.h> #include <dev/pcf/pcfvar.h> #include "iicbus_if.h" @@ -95,7 +93,7 @@ static int envctrl_probe(device_t dev) { - if (strcmp("SUNW,envctrl", ebus_get_name(dev)) == 0) { + if (strcmp("SUNW,envctrl", ofw_bus_get_name(dev)) == 0) { device_set_desc(dev, "EBus SUNW,envctrl"); return (0); } diff --git a/sys/dev/pcf/pcf_ebus.c b/sys/dev/pcf/pcf_ebus.c index 13b81102095f..b23c8dd5b5b8 100644 --- a/sys/dev/pcf/pcf_ebus.c +++ b/sys/dev/pcf/pcf_ebus.c @@ -70,15 +70,14 @@ __FBSDID("$FreeBSD$"); #include <sys/module.h> #include <sys/resource.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/ebus/ebusvar.h> - #include <dev/iicbus/iiconf.h> #include <dev/pcf/pcfvar.h> #include "iicbus_if.h" @@ -117,15 +116,15 @@ static driver_t pcf_ebus_driver = { static int pcf_ebus_probe(device_t dev) { - char *compat; + const char *compat; /* * We must not attach to this i2c device if this is a system with * a boot-bus controller. Additionally testing the compatibility * property will hopefully take care of this. */ - if (strcmp("i2c", ebus_get_name(dev)) == 0) { - compat = ebus_get_compat(dev); + if (strcmp("i2c", ofw_bus_get_name(dev)) == 0) { + compat = ofw_bus_get_compat(dev); if (compat != NULL && strcmp("i2cpcf,8584", compat) == 0) { device_set_desc(dev, "PCF8584 I2C bus controller"); return (0); @@ -146,7 +145,7 @@ pcf_ebus_attach(device_t dev) bzero(sc, sizeof(struct pcf_softc)); /* get OFW node of the pcf */ - if ((node = ebus_get_node(dev)) <= 0) { + if ((node = ofw_bus_get_node(dev)) <= 0) { device_printf(dev, "cannot get OFW node\n"); goto error; } diff --git a/sys/dev/puc/puc_ebus.c b/sys/dev/puc/puc_ebus.c index ce0184a73e4c..c7ddeb40153e 100644 --- a/sys/dev/puc/puc_ebus.c +++ b/sys/dev/puc/puc_ebus.c @@ -35,13 +35,13 @@ __FBSDID("$FreeBSD$"); #include <sys/module.h> #include <sys/bus.h> #include <sys/conf.h> + +#include <dev/ofw/ofw_bus.h> + #include <machine/bus.h> #include <sys/rman.h> #include <machine/resource.h> -#include <dev/ofw/openfirm.h> -#include <sparc64/ebus/ebusvar.h> - #define PUC_ENTRAILS 1 #include <dev/puc/pucvar.h> @@ -50,7 +50,7 @@ puc_ebus_probe(device_t dev) { const char *nm; - nm = ebus_get_name(dev); + nm = ofw_bus_get_name(dev); if (!strcmp(nm, "se")) { device_set_desc(dev, "Siemens SAB 82532 dual channel SCC"); return (0); diff --git a/sys/dev/puc/puc_sbus.c b/sys/dev/puc/puc_sbus.c index efc55c425037..47a2fb41303a 100644 --- a/sys/dev/puc/puc_sbus.c +++ b/sys/dev/puc/puc_sbus.c @@ -35,13 +35,13 @@ __FBSDID("$FreeBSD$"); #include <sys/module.h> #include <sys/bus.h> #include <sys/conf.h> + +#include <dev/ofw/ofw_bus.h> + #include <machine/bus.h> #include <sys/rman.h> #include <machine/resource.h> -#include <dev/ofw/openfirm.h> -#include <sparc64/sbus/sbusvar.h> - #define PUC_ENTRAILS 1 #include <dev/puc/pucvar.h> @@ -50,7 +50,7 @@ puc_sbus_probe(device_t dev) { const char *nm; - nm = sbus_get_name(dev); + nm = ofw_bus_get_name(dev); if (!strcmp(nm, "zs")) { device_set_desc(dev, "Zilog Z8530 dual channel SCC"); return (0); diff --git a/sys/dev/sab/sab.c b/sys/dev/sab/sab.c index eb9a4f3cf9fe..0b39f0dc3583 100644 --- a/sys/dev/sab/sab.c +++ b/sys/dev/sab/sab.c @@ -57,16 +57,18 @@ __FBSDID("$FreeBSD$"); #include <sys/mutex.h> #include <sys/module.h> #include <sys/proc.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 <sys/serial.h> #include <sys/syslog.h> #include <sys/tty.h> -#include <dev/ofw/openfirm.h> -#include <sparc64/ebus/ebusvar.h> - #include <dev/sab/sab82532reg.h> #define SAB_READ(sc, r) \ @@ -249,9 +251,10 @@ sab_probe(device_t dev) bus_space_tag_t tag; uint8_t r; int rid; + const char *name; - if (strcmp(ebus_get_name(dev), "se") != 0 && - strcmp(ebus_get_name(dev), "serial") != 0) + name = ofw_bus_get_name(dev); + if (strcmp(name, "se") != 0 && strcmp(name, "serial") != 0) return (ENXIO); rid = 0; res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, @@ -1191,25 +1194,25 @@ sabtty_cnputc(struct sabtty_softc *sc, int c) static int sabtty_console(device_t dev, char *mode, int len) { - device_t parent; phandle_t chosen; phandle_t options; + phandle_t parent; ihandle_t stdin; ihandle_t stdout; char output[32]; char input[32]; char name[32]; - 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 || OF_getprop(options, "output-device", output, sizeof(output)) == -1) return (0); - if (ebus_get_node(parent) != OF_instance_to_package(stdin) || - ebus_get_node(parent) != 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) || diff --git a/sys/dev/uart/uart_bus_ebus.c b/sys/dev/uart/uart_bus_ebus.c index e6430255f708..15e8bcb9899c 100644 --- a/sys/dev/uart/uart_bus_ebus.c +++ b/sys/dev/uart/uart_bus_ebus.c @@ -32,13 +32,13 @@ __FBSDID("$FreeBSD$"); #include <sys/bus.h> #include <sys/kernel.h> #include <sys/module.h> + +#include <dev/ofw/ofw_bus.h> + #include <machine/bus.h> #include <sys/rman.h> #include <machine/resource.h> -#include <dev/ofw/openfirm.h> -#include <sparc64/ebus/ebusvar.h> - #include <dev/uart/uart.h> #include <dev/uart/uart_bus.h> #include <dev/uart/uart_cpu.h> @@ -69,8 +69,8 @@ uart_ebus_probe(device_t dev) sc = device_get_softc(dev); sc->sc_class = NULL; - nm = ebus_get_name(dev); - cmpt = ebus_get_compat(dev); + nm = ofw_bus_get_name(dev); + cmpt = ofw_bus_get_compat(dev); if (!strcmp(nm, "su") || !strcmp(nm, "su_pnp") || (cmpt != NULL && (!strcmp(cmpt, "su") || !strcmp(cmpt, "su16550")))) { sc->sc_class = &uart_ns8250_class; diff --git a/sys/dev/zs/zs_macio.c b/sys/dev/zs/zs_macio.c index 182fe77698e3..3879a9edf5d1 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 796d076501eb..40b7ea4fd074 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); } |
