Index: dev/ofw/ofwbus.c =================================================================== --- dev/ofw/ofwbus.c (revision 0) +++ dev/ofw/ofwbus.c (revision 0) @@ -0,0 +1,319 @@ +/*- + * Copyright (C) 2010 Nathan Whitehorn + * 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 TOOLS GMBH 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 +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#ifdef __sparc64__ +#include +#include +#endif + +#include +#include +#include + +static void ofwbus_identify(driver_t *driver, device_t parent); +static int ofwbus_probe(device_t); +static int ofwbus_attach(device_t); +static const struct ofw_bus_devinfo *ofwbus_get_devinfo(device_t dev, + device_t child); +static struct resource_list *ofwbus_get_resource_list(device_t dev, + device_t child); +static int ofwbus_print_child(device_t dev, device_t child); + +static MALLOC_DEFINE(M_OFWBUS, "ofwbus", "OFW root device information"); + +struct ofwbus_devinfo { + struct ofw_bus_devinfo ofw_dinfo; + struct resource_list reslist; +}; + +static device_method_t ofwbus_methods[] = { + /* Device interface */ + DEVMETHOD(device_identify, ofwbus_identify), + DEVMETHOD(device_probe, ofwbus_probe), + DEVMETHOD(device_attach, ofwbus_attach), + + /* Bus interface */ + DEVMETHOD(bus_driver_added, bus_generic_driver_added), + DEVMETHOD(bus_add_child, bus_generic_add_child), + DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), + DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), + DEVMETHOD(bus_print_child, ofwbus_print_child), + DEVMETHOD(bus_get_resource_list, ofwbus_get_resource_list), + DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource), + DEVMETHOD(bus_release_resource, bus_generic_release_resource), + DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), + DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), + DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str), + + /* ofw_bus interface */ + DEVMETHOD(ofw_bus_get_devinfo, ofwbus_get_devinfo), + DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), + DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), + DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), + DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), + DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), + + { 0, 0 } +}; + +driver_t ofwbus_driver = { + "ofwbus", + ofwbus_methods, + 0 +}; + +static devclass_t ofwbus_devclass; + +EARLY_DRIVER_MODULE(ofwbus, nexus, ofwbus_driver, ofwbus_devclass, 0, 0, + BUS_PASS_BUS); + +static void +ofwbus_identify(driver_t *driver, device_t parent) +{ + if (OF_peer(0) == -1) + return; + + if (device_find_child(parent, "ofwbus", -1) == NULL) + BUS_ADD_CHILD(parent, 0, "ofwbus", 0); +} + +static int +ofwbus_probe(device_t dev) +{ + device_set_desc(dev, "Open Firmware"); + + return (BUS_PROBE_NOWILDCARD); +} + +static const char *const ofwbus_excl_name[] = { + "FJSV,system", + "aliases", + "associations", + "chosen", + "cmp", + "counter-timer", /* No separate device; handled by psycho/sbus */ + "failsafe", + "firewire-disk-mode", + "memory", + "openprom", + "options", + "packages", + "physical-memory", + "rsc", + "sgcn", + "todsg", + "virtual-memory", + NULL +}; + +static void +ofwbus_init_resource_list(phandle_t child, struct resource_list *reslist) +{ + phandle_t root; + int i, nreg, nintr, rid; + uint32_t acells, scells, icells; + uint32_t *reg, *intr; + uint64_t phys, size; + #if defined(__powerpc__) + phandle_t iparent; + #elif defined(__sparc64__) + int ign; + #endif + + resource_list_init(reslist); + nreg = OF_getprop_alloc(child, "reg", sizeof(*reg), (void **)®); + + root = OF_peer(0); + if (OF_getprop(root, "#address-cells", &acells, sizeof(acells)) < + sizeof(acells)) + acells = 1; + if (OF_getprop(root, "#size-cells", &scells, sizeof(scells)) < + sizeof(scells)) + scells = 1; + + i = 0; + rid = 0; + while (i < nreg) { + if (acells == 2) { + phys = reg[i+1]; + phys += (uint64_t)reg[i] << 32; + } else { + phys = reg[i]; + } + + i += acells; + + if (scells == 2) { + size = reg[i+1]; + size += (uint64_t)reg[i] << 32; + } else { + size = reg[i]; + } + + i += scells; + + if (size != 0) + resource_list_add(reslist, SYS_RES_MEMORY, + rid++, phys, phys + size - 1, size); + } + if (nreg > 0) + free(reg, M_OFWPROP); + + nintr = OF_getprop_alloc(child, "interrupts", sizeof(*intr), + (void **)&intr); + if (nintr > 0) { + #if defined(__powerpc__) + if (OF_getprop(child, "interrupt-parent", &iparent, + sizeof(iparent)) < sizeof(iparent)) { + free(intr, M_OFWPROP); + return; + } + + if (OF_getprop(iparent, "#interrupt-cells", &icells, + sizeof(icells)) < sizeof(icells)) + icells = 1; + #elif defined(__sparc64__) + if (OF_getprop(child, PCPU_GET(impl) < CPU_IMPL_ULTRASPARCIII ? + "upa-portid" : "portid", &ign, sizeof(ign)) <= 0) { + printf("could not determine portid\n"); + free(intr, M_OFWPROP); + return; + } + + /* XXX 7-bit MID on Starfire */ + ign = (ign << INTMAP_IGN_SHIFT) & INTMAP_IGN_MASK; + icells = 1; + #else + icells = 1; + #endif + + for (i = 0; i < nintr; i += icells) { + #if defined(__sparc64__) + resource_list_add(reslist, SYS_RES_IRQ, i/icells, + intr[i] | ign, intr[i] | ign, 1); + #elif defined(__powerpc__) + resource_list_add(reslist, SYS_RES_IRQ, i/icells, + INTR_VEC(iparent, intr[i]), + INTR_VEC(iparent, intr[i]), 1); + #else + resource_list_add(reslist, SYS_RES_IRQ, i/icells, + intr[i], 1); + #endif + } + free(intr, M_OFWPROP); + } +} + +static int +ofwbus_attach(device_t dev) +{ + phandle_t root, child; + device_t cdev; + struct ofwbus_devinfo *dinfo; + int i; + + root = OF_peer(0); + + for (child = OF_child(root); child != 0; child = OF_peer(child)) { + dinfo = malloc(sizeof(*dinfo), M_OFWBUS, M_WAITOK | M_ZERO); + + if (ofw_bus_gen_setup_devinfo(&dinfo->ofw_dinfo, child) != 0) { + free(dinfo, M_OFWBUS); + continue; + } + + /* Skip excluded nodes */ + for (i = 0; ofwbus_excl_name[i] != NULL; i++) + if (strcmp(dinfo->ofw_dinfo.obd_name, + ofwbus_excl_name[i]) == 0) + break; + if (ofwbus_excl_name[i] != NULL) { + ofw_bus_gen_destroy_devinfo(&dinfo->ofw_dinfo); + free(dinfo, M_OFWBUS); + continue; + } + + ofwbus_init_resource_list(child, &dinfo->reslist); + + cdev = device_add_child(dev, NULL, -1); + if (cdev == NULL) { + device_printf(dev, "<%s>: device_add_child failed\n", + dinfo->ofw_dinfo.obd_name); + ofw_bus_gen_destroy_devinfo(&dinfo->ofw_dinfo); + free(dinfo, M_OFWBUS); + continue; + } + device_set_ivars(cdev, dinfo); + } + + return (bus_generic_attach(dev)); +} + +static const struct ofw_bus_devinfo * +ofwbus_get_devinfo(device_t dev, device_t child) +{ + return (device_get_ivars(child)); +} + +static struct resource_list * +ofwbus_get_resource_list(device_t dev, device_t child) +{ + struct ofwbus_devinfo *dinfo; + + dinfo = device_get_ivars(child); + return (&dinfo->reslist); +} + +static int +ofwbus_print_child(device_t dev, device_t child) +{ + int rv; + struct ofwbus_devinfo *dinfo; + + dinfo = device_get_ivars(child); + + rv = bus_print_child_header(dev, child); + rv += resource_list_print_type(&dinfo->reslist, "mem", SYS_RES_MEMORY, + "%#lx"); + rv += resource_list_print_type(&dinfo->reslist, "irq", SYS_RES_IRQ, + "%ld"); + rv += bus_print_child_footer(dev, child); + return (rv); +} + Property changes on: dev/ofw/ofwbus.c ___________________________________________________________________ Added: svn:keywords + FreeBSD=%H Index: dev/powermac_nvram/powermac_nvram.c =================================================================== --- dev/powermac_nvram/powermac_nvram.c (revision 214603) +++ dev/powermac_nvram/powermac_nvram.c (working copy) @@ -83,7 +83,7 @@ static devclass_t powermac_nvram_devclass; -DRIVER_MODULE(powermac_nvram, nexus, powermac_nvram_driver, powermac_nvram_devclass, 0, 0); +DRIVER_MODULE(powermac_nvram, ofwbus, powermac_nvram_driver, powermac_nvram_devclass, 0, 0); /* * Cdev methods. Index: conf/files.powerpc =================================================================== --- conf/files.powerpc (revision 214603) +++ conf/files.powerpc (working copy) @@ -33,6 +33,7 @@ dev/mem/memutil.c optional mem dev/ofw/openfirm.c optional aim | fdt dev/ofw/openfirmio.c optional aim | fdt +dev/ofw/ofwbus.c optional aim dev/ofw/ofw_bus_if.m optional aim | fdt dev/ofw/ofw_if.m optional aim | fdt dev/ofw/ofw_bus_subr.c optional aim | fdt @@ -84,7 +85,6 @@ powerpc/aim/mmu_oea.c optional aim powerpc powerpc/aim/mmu_oea64.c optional aim powerpc/aim/mp_cpudep.c optional aim smp -powerpc/aim/nexus.c optional aim powerpc/aim/ofw_machdep.c optional aim powerpc/aim/ofwmagic.S optional aim powerpc/aim/slb.c optional aim powerpc64 @@ -127,7 +127,6 @@ powerpc/mpc85xx/isa.c optional mpc85xx isa powerpc/mpc85xx/lbc.c optional mpc85xx powerpc/mpc85xx/mpc85xx.c optional mpc85xx -powerpc/mpc85xx/nexus.c optional mpc85xx powerpc/mpc85xx/openpic_fdt.c optional fdt powerpc/mpc85xx/pci_fdt.c optional pci mpc85xx powerpc/ofw/ofw_cpu.c optional aim @@ -180,6 +179,7 @@ powerpc/powerpc/mem.c optional mem powerpc/powerpc/mmu_if.m standard powerpc/powerpc/mp_machdep.c optional smp +powerpc/powerpc/nexus.c standard powerpc/powerpc/openpic.c standard powerpc/powerpc/pic_if.m standard powerpc/powerpc/pmap_dispatch.c standard Index: conf/files.sparc64 =================================================================== --- conf/files.sparc64 (revision 214603) +++ conf/files.sparc64 (working copy) @@ -47,6 +47,7 @@ dev/ofw/ofw_console.c optional ofw_console dev/ofw/ofw_if.m standard dev/ofw/ofw_standard.c standard +dev/ofw/ofwbus.c standard dev/ofw/openfirm.c standard dev/ofw/openfirmio.c standard dev/ofw/openpromio.c standard Index: sparc64/fhc/fhc.c =================================================================== --- sparc64/fhc/fhc.c (revision 214603) +++ sparc64/fhc/fhc.c (working copy) @@ -122,9 +122,9 @@ EARLY_DRIVER_MODULE(fhc, central, fhc_driver, fhc_devclass, 0, 0, BUS_PASS_BUS); MODULE_DEPEND(fhc, central, 1, 1, 1); -EARLY_DRIVER_MODULE(fhc, nexus, fhc_driver, fhc_devclass, 0, 0, +EARLY_DRIVER_MODULE(fhc, ofwbus, fhc_driver, fhc_devclass, 0, 0, BUS_PASS_BUS); -MODULE_DEPEND(fhc, nexus, 1, 1, 1); +MODULE_DEPEND(fhc, ofwbus, 1, 1, 1); MODULE_VERSION(fhc, 1); static const struct intr_controller fhc_ic = { Index: sparc64/sparc64/nexus.c =================================================================== --- sparc64/sparc64/nexus.c (revision 214603) +++ sparc64/sparc64/nexus.c (working copy) @@ -50,31 +50,11 @@ #include #include #include -#include -#include #include #include #include -/* - * The nexus (which is a pseudo-bus actually) iterates over the nodes that - * hang from the Open Firmware root node and adds them as devices to this bus - * (except some special nodes which are excluded) so that drivers can be - * attached to them. - * - * Additionally, interrupt setup/teardown and some resource management are - * done at this level. - * - * Maybe this code should get into dev/ofw to some extent, as some of it should - * work for all Open Firmware based machines... - */ - -struct nexus_devinfo { - struct ofw_bus_devinfo ndi_obdinfo; - struct resource_list ndi_rl; -}; - struct nexus_softc { struct rman sc_intr_rman; struct rman sc_mem_rman; @@ -82,28 +62,18 @@ static device_probe_t nexus_probe; static device_attach_t nexus_attach; -static bus_print_child_t nexus_print_child; -static bus_add_child_t nexus_add_child; -static bus_probe_nomatch_t nexus_probe_nomatch; static bus_setup_intr_t nexus_setup_intr; static bus_teardown_intr_t nexus_teardown_intr; static bus_alloc_resource_t nexus_alloc_resource; static bus_activate_resource_t nexus_activate_resource; static bus_deactivate_resource_t nexus_deactivate_resource; static bus_release_resource_t nexus_release_resource; -static bus_get_resource_list_t nexus_get_resource_list; #ifdef SMP static bus_bind_intr_t nexus_bind_intr; #endif static bus_describe_intr_t nexus_describe_intr; static bus_get_dma_tag_t nexus_get_dma_tag; -static ofw_bus_get_devinfo_t nexus_get_devinfo; -static int nexus_inlist(const char *, const char *const *); -static struct nexus_devinfo * nexus_setup_dinfo(device_t, phandle_t); -static void nexus_destroy_dinfo(struct nexus_devinfo *); -static int nexus_print_res(struct nexus_devinfo *); - static device_method_t nexus_methods[] = { /* Device interface */ DEVMETHOD(device_probe, nexus_probe), @@ -114,11 +84,10 @@ DEVMETHOD(device_resume, bus_generic_resume), /* Bus interface */ - DEVMETHOD(bus_print_child, nexus_print_child), - DEVMETHOD(bus_probe_nomatch, nexus_probe_nomatch), + DEVMETHOD(bus_print_child, bus_generic_print_child), DEVMETHOD(bus_read_ivar, bus_generic_read_ivar), DEVMETHOD(bus_write_ivar, bus_generic_write_ivar), - DEVMETHOD(bus_add_child, nexus_add_child), + DEVMETHOD(bus_add_child, bus_generic_add_child), DEVMETHOD(bus_alloc_resource, nexus_alloc_resource), DEVMETHOD(bus_activate_resource, nexus_activate_resource), DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource), @@ -127,21 +96,12 @@ DEVMETHOD(bus_teardown_intr, nexus_teardown_intr), DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), DEVMETHOD(bus_get_resource, bus_generic_rl_get_resource), - DEVMETHOD(bus_get_resource_list, nexus_get_resource_list), #ifdef SMP DEVMETHOD(bus_bind_intr, nexus_bind_intr), #endif DEVMETHOD(bus_describe_intr, nexus_describe_intr), DEVMETHOD(bus_get_dma_tag, nexus_get_dma_tag), - /* ofw_bus interface */ - DEVMETHOD(ofw_bus_get_devinfo, nexus_get_devinfo), - DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), - DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), - DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), - DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), - DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), - KOBJMETHOD_END }; @@ -152,154 +112,38 @@ BUS_PASS_BUS); MODULE_VERSION(nexus, 1); -static const char *const nexus_excl_name[] = { - "FJSV,system", - "aliases", - "associations", - "chosen", - "cmp", - "counter-timer", /* No separate device; handled by psycho/sbus */ - "failsafe", - "memory", - "openprom", - "options", - "packages", - "physical-memory", - "rsc", - "sgcn", - "todsg", - "virtual-memory", - NULL -}; - -static const char *const nexus_excl_type[] = { - "core", - "cpu", - NULL -}; - extern struct bus_space_tag nexus_bustag; extern struct bus_dma_tag nexus_dmatag; static int -nexus_inlist(const char *name, const char *const *list) -{ - int i; - - if (name == NULL) - return (0); - for (i = 0; list[i] != NULL; i++) - if (strcmp(name, list[i]) == 0) - return (1); - return (0); -} - -#define NEXUS_EXCLUDED(name, type) \ - (nexus_inlist((name), nexus_excl_name) || \ - ((type) != NULL && nexus_inlist((type), nexus_excl_type))) - -static int nexus_probe(device_t dev) { + device_quiet(dev); - /* Nexus does always match. */ - device_set_desc(dev, "Open Firmware Nexus device"); - return (0); + return (bus_generic_probe(dev)); } static int nexus_attach(device_t dev) { - struct nexus_devinfo *ndi; struct nexus_softc *sc; - device_t cdev; - phandle_t node; - if (strcmp(device_get_name(device_get_parent(dev)), "root") == 0) { - node = OF_peer(0); - if (node == -1) - panic("%s: OF_peer failed.", __func__); + sc = device_get_softc(dev); + sc->sc_intr_rman.rm_type = RMAN_ARRAY; + sc->sc_intr_rman.rm_descr = "Interrupts"; + sc->sc_mem_rman.rm_type = RMAN_ARRAY; + sc->sc_mem_rman.rm_descr = "Device Memory"; + if (rman_init(&sc->sc_intr_rman) != 0 || + rman_init(&sc->sc_mem_rman) != 0 || + rman_manage_region(&sc->sc_intr_rman, 0, + IV_MAX - 1) != 0 || + rman_manage_region(&sc->sc_mem_rman, 0ULL, ~0ULL) != 0) + panic("%s: failed to set up rmans.", __func__); - sc = device_get_softc(dev); - sc->sc_intr_rman.rm_type = RMAN_ARRAY; - sc->sc_intr_rman.rm_descr = "Interrupts"; - sc->sc_mem_rman.rm_type = RMAN_ARRAY; - sc->sc_mem_rman.rm_descr = "Device Memory"; - if (rman_init(&sc->sc_intr_rman) != 0 || - rman_init(&sc->sc_mem_rman) != 0 || - rman_manage_region(&sc->sc_intr_rman, 0, - IV_MAX - 1) != 0 || - rman_manage_region(&sc->sc_mem_rman, 0ULL, ~0ULL) != 0) - panic("%s: failed to set up rmans.", __func__); - } else - node = ofw_bus_get_node(dev); - - /* - * Allow devices to identify. - */ - bus_generic_probe(dev); - - /* - * Now walk the OFW tree and attach top-level devices. - */ - for (node = OF_child(node); node > 0; node = OF_peer(node)) { - if ((ndi = nexus_setup_dinfo(dev, node)) == NULL) - continue; - cdev = device_add_child(dev, NULL, -1); - if (cdev == NULL) { - device_printf(dev, "<%s>: device_add_child failed\n", - ndi->ndi_obdinfo.obd_name); - nexus_destroy_dinfo(ndi); - continue; - } - device_set_ivars(cdev, ndi); - } return (bus_generic_attach(dev)); } -static device_t -nexus_add_child(device_t dev, u_int order, const char *name, int unit) -{ - device_t cdev; - struct nexus_devinfo *ndi; - - cdev = device_add_child_ordered(dev, order, name, unit); - if (cdev == NULL) - return (NULL); - - ndi = malloc(sizeof(*ndi), M_DEVBUF, M_WAITOK | M_ZERO); - ndi->ndi_obdinfo.obd_node = -1; - ndi->ndi_obdinfo.obd_name = strdup(name, M_OFWPROP); - resource_list_init(&ndi->ndi_rl); - device_set_ivars(cdev, ndi); - - return (cdev); -} - static int -nexus_print_child(device_t dev, device_t child) -{ - int rv; - - rv = bus_print_child_header(dev, child); - rv += nexus_print_res(device_get_ivars(child)); - rv += bus_print_child_footer(dev, child); - return (rv); -} - -static void -nexus_probe_nomatch(device_t dev, device_t child) -{ - const char *type; - - device_printf(dev, "<%s>", ofw_bus_get_name(child)); - nexus_print_res(device_get_ivars(child)); - type = ofw_bus_get_type(child); - printf(" type %s (no driver attached)\n", - type != NULL ? type : "unknown"); -} - -static int nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep) { @@ -353,20 +197,21 @@ } static struct resource * -nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, +nexus_alloc_resource(device_t nexus, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags) { struct nexus_softc *sc; struct rman *rm; struct resource *rv; struct resource_list_entry *rle; - device_t nexus; + device_t bus; int isdefault, needactivate, passthrough; isdefault = (start == 0UL && end == ~0UL); needactivate = flags & RF_ACTIVE; - passthrough = (device_get_parent(child) != bus); - nexus = bus; + bus = device_get_parent(child); + /* Check if parent is nexus/ofwbus or something higher up */ + passthrough = (bus != nexus && device_get_parent(bus) != nexus); while (strcmp(device_get_name(device_get_parent(nexus)), "root") != 0) nexus = device_get_parent(nexus); sc = device_get_softc(nexus); @@ -456,15 +301,6 @@ return (rman_release_resource(r)); } -static struct resource_list * -nexus_get_resource_list(device_t dev, device_t child) -{ - struct nexus_devinfo *ndi; - - ndi = device_get_ivars(child); - return (&ndi->ndi_rl); -} - static bus_dma_tag_t nexus_get_dma_tag(device_t bus, device_t child) { @@ -472,102 +308,3 @@ return (&nexus_dmatag); } -static const struct ofw_bus_devinfo * -nexus_get_devinfo(device_t dev, device_t child) -{ - struct nexus_devinfo *ndi; - - ndi = device_get_ivars(child); - return (&ndi->ndi_obdinfo); -} - -static struct nexus_devinfo * -nexus_setup_dinfo(device_t dev, phandle_t node) -{ - struct nexus_devinfo *ndi; - struct nexus_regs *reg; - bus_addr_t phys; - bus_size_t size; - uint32_t ign; - uint32_t *intr; - int i; - int nintr; - int nreg; - - ndi = malloc(sizeof(*ndi), M_DEVBUF, M_WAITOK | M_ZERO); - if (ofw_bus_gen_setup_devinfo(&ndi->ndi_obdinfo, node) != 0) { - free(ndi, M_DEVBUF); - return (NULL); - } - if (NEXUS_EXCLUDED(ndi->ndi_obdinfo.obd_name, - ndi->ndi_obdinfo.obd_type)) { - ofw_bus_gen_destroy_devinfo(&ndi->ndi_obdinfo); - free(ndi, M_DEVBUF); - return (NULL); - } - resource_list_init(&ndi->ndi_rl); - nreg = OF_getprop_alloc(node, "reg", sizeof(*reg), (void **)®); - if (nreg == -1) { - device_printf(dev, "<%s>: incomplete\n", - ndi->ndi_obdinfo.obd_name); - goto fail; - } - for (i = 0; i < nreg; i++) { - phys = NEXUS_REG_PHYS(®[i]); - size = NEXUS_REG_SIZE(®[i]); - /* Skip the dummy reg property of glue devices like ssm(4). */ - if (size != 0) - resource_list_add(&ndi->ndi_rl, SYS_RES_MEMORY, i, - phys, phys + size - 1, size); - } - free(reg, M_OFWPROP); - - nintr = OF_getprop_alloc(node, "interrupts", sizeof(*intr), - (void **)&intr); - if (nintr > 0) { - if (OF_getprop(node, PCPU_GET(impl) < CPU_IMPL_ULTRASPARCIII ? - "upa-portid" : "portid", &ign, sizeof(ign)) <= 0) { - device_printf(dev, "<%s>: could not determine portid\n", - ndi->ndi_obdinfo.obd_name); - free(intr, M_OFWPROP); - goto fail; - } - - /* XXX 7-bit MID on Starfire */ - ign = (ign << INTMAP_IGN_SHIFT) & INTMAP_IGN_MASK; - for (i = 0; i < nintr; i++) { - intr[i] |= ign; - resource_list_add(&ndi->ndi_rl, SYS_RES_IRQ, i, intr[i], - intr[i], 1); - } - free(intr, M_OFWPROP); - } - - return (ndi); - - fail: - nexus_destroy_dinfo(ndi); - return (NULL); -} - -static void -nexus_destroy_dinfo(struct nexus_devinfo *ndi) -{ - - resource_list_free(&ndi->ndi_rl); - ofw_bus_gen_destroy_devinfo(&ndi->ndi_obdinfo); - free(ndi, M_DEVBUF); -} - -static int -nexus_print_res(struct nexus_devinfo *ndi) -{ - int rv; - - rv = 0; - rv += resource_list_print_type(&ndi->ndi_rl, "mem", SYS_RES_MEMORY, - "%#lx"); - rv += resource_list_print_type(&ndi->ndi_rl, "irq", SYS_RES_IRQ, - "%ld"); - return (rv); -} Index: sparc64/sparc64/ssm.c =================================================================== --- sparc64/sparc64/ssm.c (revision 214603) +++ sparc64/sparc64/ssm.c (working copy) @@ -29,7 +29,7 @@ /* * Glue allowing devices beneath the scalable shared memory node to be - * treated like nexus(4) children + * treated like ofwbus(4) children */ #include @@ -40,8 +40,6 @@ #include -#include - static device_probe_t ssm_probe; static device_method_t ssm_methods[] = { @@ -56,10 +54,11 @@ }; static devclass_t ssm_devclass; +extern driver_t ofwbus_driver; -DEFINE_CLASS_1(ssm, ssm_driver, ssm_methods, 1 /* no softc */, nexus_driver); -EARLY_DRIVER_MODULE(ssm, nexus, ssm_driver, ssm_devclass, 0, 0, BUS_PASS_BUS); -MODULE_DEPEND(ssm, nexus, 1, 1, 1); +DEFINE_CLASS_1(ssm, ssm_driver, ssm_methods, 1 /* no softc */, ofwbus_driver); +EARLY_DRIVER_MODULE(ssm, ofwbus, ssm_driver, ssm_devclass, 0, 0, BUS_PASS_BUS); +MODULE_DEPEND(ssm, ofwbus, 1, 1, 1); MODULE_VERSION(ssm, 1); static int Index: sparc64/sparc64/upa.c =================================================================== --- sparc64/sparc64/upa.c (revision 214603) +++ sparc64/sparc64/upa.c (working copy) @@ -151,7 +151,7 @@ static devclass_t upa_devclass; DEFINE_CLASS_0(upa, upa_driver, upa_methods, sizeof(struct upa_softc)); -EARLY_DRIVER_MODULE(upa, nexus, upa_driver, upa_devclass, 0, 0, BUS_PASS_BUS); +EARLY_DRIVER_MODULE(upa, ofwbus, upa_driver, upa_devclass, 0, 0, BUS_PASS_BUS); static const struct intr_controller upa_ic = { upa_intr_enable, Index: sparc64/sparc64/sc_machdep.c =================================================================== --- sparc64/sparc64/sc_machdep.c (revision 214603) +++ sparc64/sparc64/sc_machdep.c (working copy) @@ -36,8 +36,6 @@ #include #include -#include - #include #include @@ -87,8 +85,7 @@ int unit; unit = device_get_unit(dev); - if (strcmp(ofw_bus_get_name(dev), SC_DRIVER_NAME) != 0 || - unit >= SC_MD_MAX) + if (unit >= SC_MD_MAX) return (ENXIO); device_set_desc(dev, "System console"); Index: sparc64/sparc64/jbusppm.c =================================================================== --- sparc64/sparc64/jbusppm.c (revision 214603) +++ sparc64/sparc64/jbusppm.c (working copy) @@ -89,7 +89,7 @@ DEFINE_CLASS_0(jbusppm, jbusppm_driver, jbusppm_methods, sizeof(struct jbusppm_softc)); -DRIVER_MODULE(jbusppm, nexus, jbusppm_driver, jbusppm_devclass, 0, 0); +DRIVER_MODULE(jbusppm, ofwbus, jbusppm_driver, jbusppm_devclass, 0, 0); static int jbusppm_probe(device_t dev) Index: sparc64/sparc64/schppm.c =================================================================== --- sparc64/sparc64/schppm.c (revision 214603) +++ sparc64/sparc64/schppm.c (working copy) @@ -80,7 +80,7 @@ DEFINE_CLASS_0(schppm, schppm_driver, schppm_methods, sizeof(struct schppm_softc)); -DRIVER_MODULE(schppm, nexus, schppm_driver, schppm_devclass, 0, 0); +DRIVER_MODULE(schppm, ofwbus, schppm_driver, schppm_devclass, 0, 0); static int schppm_probe(device_t dev) Index: sparc64/include/nexusvar.h =================================================================== --- sparc64/include/nexusvar.h (revision 214603) +++ sparc64/include/nexusvar.h (working copy) @@ -1,34 +0,0 @@ -/*- - * Copyright (c) 2010 Marius Strobl - * 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 AND CONTRIBUTORS ``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 _MACHINE_NEXUSVAR_H_ -#define _MACHINE_NEXUSVAR_H_ - -DECLARE_CLASS(nexus_driver); - -#endif /* _MACHINE_NEXUSVAR_H_ */ Index: sparc64/include/ofw_nexus.h =================================================================== --- sparc64/include/ofw_nexus.h (revision 214603) +++ sparc64/include/ofw_nexus.h (working copy) @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 1998, 1999 Eduardo E. Horvath - * Copyright (c) 1999 Matthew R. Green - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * 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 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. - * - * from: NetBSD: psychoreg.h,v 1.8 2001/09/10 16:17:06 eeh Exp - * - * $FreeBSD$ - */ - -#ifndef _MACHINE_OFW_NEXUS_H_ -#define _MACHINE_OFW_NEXUS_H_ - -/* - * These are the regs used for devices on the nexus. They apply to all of - * Fireplane/Safari, JBus and UPA. - */ - -struct nexus_regs { - uint32_t phys_hi; - uint32_t phys_lo; - uint32_t size_hi; - uint32_t size_lo; -}; - -#define NEXUS_REG_PHYS(r) \ - (((uint64_t)(r)->phys_hi << 32) | (uint64_t)(r)->phys_lo) -#define NEXUS_REG_SIZE(r) \ - (((uint64_t)(r)->size_hi << 32) | (uint64_t)(r)->size_lo) - -#endif /* !_MACHINE_OFW_NEXUS_H_ */ Index: sparc64/central/central.c =================================================================== --- sparc64/central/central.c (revision 214603) +++ sparc64/central/central.c (working copy) @@ -105,9 +105,9 @@ static devclass_t central_devclass; -EARLY_DRIVER_MODULE(central, nexus, central_driver, central_devclass, 0, 0, +EARLY_DRIVER_MODULE(central, ofwbus, central_driver, central_devclass, 0, 0, BUS_PASS_BUS); -MODULE_DEPEND(fhc, nexus, 1, 1, 1); +MODULE_DEPEND(fhc, ofwbus, 1, 1, 1); MODULE_VERSION(central, 1); static int Index: sparc64/pci/schizo.c =================================================================== --- sparc64/pci/schizo.c (revision 214603) +++ sparc64/pci/schizo.c (working copy) @@ -158,7 +158,7 @@ DEFINE_CLASS_0(pcib, schizo_driver, schizo_methods, sizeof(struct schizo_softc)); -DRIVER_MODULE(schizo, nexus, schizo_driver, schizo_devclass, 0, 0); +DRIVER_MODULE(schizo, ofwbus, schizo_driver, schizo_devclass, 0, 0); static SLIST_HEAD(, schizo_softc) schizo_softcs = SLIST_HEAD_INITIALIZER(schizo_softcs); Index: sparc64/pci/ofw_pcibus.c =================================================================== --- sparc64/pci/ofw_pcibus.c (revision 214603) +++ sparc64/pci/ofw_pcibus.c (working copy) @@ -244,7 +244,7 @@ * Note that we exclude the host-PCIe bridges here as these * have no configuration space implemented themselves. */ - if (strcmp(device_get_name(device_get_parent(pcib)), "nexus") == 0 && + if (strcmp(device_get_name(device_get_parent(pcib)), "ofwbus") == 0 && ofw_bus_get_type(pcib) != NULL && strcmp(ofw_bus_get_type(pcib), OFW_TYPE_PCIE) != 0 && (dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(pcib, Index: sparc64/pci/psycho.c =================================================================== --- sparc64/pci/psycho.c (revision 214603) +++ sparc64/pci/psycho.c (working copy) @@ -159,7 +159,7 @@ DEFINE_CLASS_0(pcib, psycho_driver, psycho_methods, sizeof(struct psycho_softc)); -DRIVER_MODULE(psycho, nexus, psycho_driver, psycho_devclass, 0, 0); +DRIVER_MODULE(psycho, ofwbus, psycho_driver, psycho_devclass, 0, 0); static SLIST_HEAD(, psycho_softc) psycho_softcs = SLIST_HEAD_INITIALIZER(psycho_softcs); Index: sparc64/pci/fire.c =================================================================== --- sparc64/pci/fire.c (revision 214603) +++ sparc64/pci/fire.c (working copy) @@ -172,9 +172,9 @@ static devclass_t fire_devclass; DEFINE_CLASS_0(pcib, fire_driver, fire_methods, sizeof(struct fire_softc)); -EARLY_DRIVER_MODULE(fire, nexus, fire_driver, fire_devclass, 0, 0, +EARLY_DRIVER_MODULE(fire, ofwbus, fire_driver, fire_devclass, 0, 0, BUS_PASS_BUS); -MODULE_DEPEND(fire, nexus, 1, 1, 1); +MODULE_DEPEND(fire, ofwbus, 1, 1, 1); static const struct intr_controller fire_ic = { fire_intr_enable, Index: sparc64/sbus/sbus.c =================================================================== --- sparc64/sbus/sbus.c (revision 214603) +++ sparc64/sbus/sbus.c (working copy) @@ -247,9 +247,9 @@ static devclass_t sbus_devclass; -EARLY_DRIVER_MODULE(sbus, nexus, sbus_driver, sbus_devclass, 0, 0, +EARLY_DRIVER_MODULE(sbus, ofwbus, sbus_driver, sbus_devclass, 0, 0, BUS_PASS_BUS); -MODULE_DEPEND(sbus, nexus, 1, 1, 1); +MODULE_DEPEND(sbus, ofwbus, 1, 1, 1); MODULE_VERSION(sbus, 1); #define OFW_SBUS_TYPE "sbus" Index: sparc64/ebus/ebus.c =================================================================== --- sparc64/ebus/ebus.c (revision 214603) +++ sparc64/ebus/ebus.c (working copy) @@ -166,9 +166,9 @@ * bridge to be registered as the nexus variant of the EBus bridges doesn't * employ its own one. */ -EARLY_DRIVER_MODULE(ebus, nexus, ebus_nexus_driver, ebus_devclass, 0, 0, +EARLY_DRIVER_MODULE(ebus, ofwbus, ebus_nexus_driver, ebus_devclass, 0, 0, BUS_PASS_BUS + 1); -MODULE_DEPEND(ebus, nexus, 1, 1, 1); +MODULE_DEPEND(ebus, ofwdump, 1, 1, 1); static device_method_t ebus_pci_methods[] = { /* Device interface */ Index: powerpc/powerpc/nexus.c =================================================================== --- powerpc/powerpc/nexus.c (revision 212494) +++ powerpc/powerpc/nexus.c (working copy) @@ -73,35 +73,10 @@ #include -#include "ofw_bus_if.h" #include "pic_if.h" -/* - * The nexus (which is a pseudo-bus actually) iterates over the nodes that - * exist in Open Firmware and adds them as devices to this bus so that drivers - * can be attached to them. - * - * Maybe this code should get into dev/ofw to some extent, as some of it should - * work for all Open Firmware based machines... - */ - static MALLOC_DEFINE(M_NEXUS, "nexus", "nexus device information"); -enum nexus_ivars { - NEXUS_IVAR_NODE, - NEXUS_IVAR_NAME, - NEXUS_IVAR_DEVICE_TYPE, - NEXUS_IVAR_COMPATIBLE, -}; - -struct nexus_devinfo { - phandle_t ndi_node; - /* Some common properties. */ - const char *ndi_name; - const char *ndi_device_type; - const char *ndi_compatible; -}; - struct nexus_softc { struct rman sc_rman; }; @@ -115,10 +90,6 @@ /* * Bus interface */ -static device_t nexus_add_child(device_t, u_int, const char *, int); -static void nexus_probe_nomatch(device_t, device_t); -static int nexus_read_ivar(device_t, device_t, int, uintptr_t *); -static int nexus_write_ivar(device_t, device_t, int, uintptr_t); #ifdef SMP static int nexus_bind_intr(device_t dev, device_t child, struct resource *irq, int cpu); @@ -138,19 +109,6 @@ static int nexus_release_resource(device_t, device_t, int, int, struct resource *); -/* - * OFW bus interface. - */ -static phandle_t nexus_ofw_get_node(device_t, device_t); -static const char *nexus_ofw_get_name(device_t, device_t); -static const char *nexus_ofw_get_type(device_t, device_t); -static const char *nexus_ofw_get_compat(device_t, device_t); - -/* - * Local routines - */ -static device_t nexus_device_from_node(device_t, phandle_t); - static device_method_t nexus_methods[] = { /* Device interface */ DEVMETHOD(device_probe, nexus_probe), @@ -161,12 +119,8 @@ DEVMETHOD(device_resume, bus_generic_resume), /* Bus interface. Resource management is business of the children... */ - DEVMETHOD(bus_add_child, nexus_add_child), + DEVMETHOD(bus_add_child, bus_generic_add_child), DEVMETHOD(bus_print_child, bus_generic_print_child), - DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str), - DEVMETHOD(bus_probe_nomatch, nexus_probe_nomatch), - DEVMETHOD(bus_read_ivar, nexus_read_ivar), - DEVMETHOD(bus_write_ivar, nexus_write_ivar), DEVMETHOD(bus_setup_intr, nexus_setup_intr), DEVMETHOD(bus_teardown_intr, nexus_teardown_intr), #ifdef SMP @@ -178,12 +132,6 @@ DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource), DEVMETHOD(bus_release_resource, nexus_release_resource), - /* OFW bus interface */ - DEVMETHOD(ofw_bus_get_node, nexus_ofw_get_node), - DEVMETHOD(ofw_bus_get_name, nexus_ofw_get_name), - DEVMETHOD(ofw_bus_get_type, nexus_ofw_get_type), - DEVMETHOD(ofw_bus_get_compat, nexus_ofw_get_compat), - { 0, 0 } }; @@ -195,27 +143,23 @@ static devclass_t nexus_devclass; -DRIVER_MODULE(nexus, root, nexus_driver, nexus_devclass, 0, 0); +EARLY_DRIVER_MODULE(nexus, root, nexus_driver, nexus_devclass, 0, 0, + BUS_PASS_BUS); static int nexus_probe(device_t dev) { - bus_generic_probe(dev); - device_set_desc(dev, "Open Firmware Nexus device"); - return (0); + device_quiet(dev); + + return (bus_generic_probe(dev)); } static int nexus_attach(device_t dev) { - phandle_t root; - phandle_t child; struct nexus_softc *sc; u_long start, end; - if ((root = OF_peer(0)) == -1) - panic("nexus_probe: OF_peer failed."); - sc = device_get_softc(dev); start = 0; @@ -229,114 +173,10 @@ rman_manage_region(&sc->sc_rman, start, end)) panic("nexus_probe IRQ rman"); - /* - * Now walk the OFW tree to locate top-level devices - */ - for (child = OF_child(root); child != 0; child = OF_peer(child)) { - if (child == -1) - panic("nexus_probe(): OF_child failed."); - (void)nexus_device_from_node(dev, child); - - } - return (bus_generic_attach(dev)); } -static void -nexus_probe_nomatch(device_t dev, device_t child) -{ - char *name, *type; - - if (BUS_READ_IVAR(dev, child, NEXUS_IVAR_NAME, - (uintptr_t *)&name) != 0 || - BUS_READ_IVAR(dev, child, NEXUS_IVAR_DEVICE_TYPE, - (uintptr_t *)&type) != 0) - return; - - if (type == NULL) - type = "(unknown)"; - - if (bootverbose) - device_printf(dev, "<%s>, type %s (no driver attached)\n", - name, type); -} - -static device_t -nexus_add_child(device_t dev, u_int order, const char *name, int unit) -{ - device_t child; - struct nexus_devinfo *dinfo; - - child = device_add_child_ordered(dev, order, name, unit); - if (child == NULL) - return (NULL); - - dinfo = malloc(sizeof(struct nexus_devinfo), M_NEXUS, M_NOWAIT|M_ZERO); - if (dinfo == NULL) - return (NULL); - - dinfo->ndi_node = -1; - dinfo->ndi_name = name; - device_set_ivars(child, dinfo); - - return (child); -} - - static int -nexus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) -{ - struct nexus_devinfo *dinfo; - - if ((dinfo = device_get_ivars(child)) == 0) - return (ENOENT); - switch (which) { - case NEXUS_IVAR_NODE: - *result = dinfo->ndi_node; - break; - case NEXUS_IVAR_NAME: - *result = (uintptr_t)dinfo->ndi_name; - break; - case NEXUS_IVAR_DEVICE_TYPE: - *result = (uintptr_t)dinfo->ndi_device_type; - break; - case NEXUS_IVAR_COMPATIBLE: - *result = (uintptr_t)dinfo->ndi_compatible; - break; - default: - return (ENOENT); - } - return 0; -} - -static int -nexus_write_ivar(device_t dev, device_t child, int which, uintptr_t value) -{ - struct nexus_devinfo *dinfo; - - if ((dinfo = device_get_ivars(child)) == 0) - return (ENOENT); - - switch (which) { - case NEXUS_IVAR_NAME: - return (EINVAL); - - /* Identified devices may want to set these */ - case NEXUS_IVAR_NODE: - dinfo->ndi_node = (phandle_t)value; - break; - - case NEXUS_IVAR_DEVICE_TYPE: - dinfo->ndi_device_type = (char *)value; - break; - - default: - return (ENOENT); - } - return 0; -} - -static int nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags, driver_filter_t *filter, driver_intr_t *ihand, void *arg, void **cookiep) { @@ -459,71 +299,3 @@ return (rman_release_resource(res)); } -static device_t -nexus_device_from_node(device_t parent, phandle_t node) -{ - device_t cdev; - struct nexus_devinfo *dinfo; - char *name, *type, *compatible; - - OF_getprop_alloc(node, "name", 1, (void **)&name); - OF_getprop_alloc(node, "device_type", 1, (void **)&type); - OF_getprop_alloc(node, "compatible", 1, (void **)&compatible); - cdev = device_add_child(parent, NULL, -1); - if (cdev != NULL) { - dinfo = malloc(sizeof(*dinfo), M_NEXUS, M_WAITOK); - dinfo->ndi_node = node; - dinfo->ndi_name = name; - dinfo->ndi_device_type = type; - dinfo->ndi_compatible = compatible; - device_set_ivars(cdev, dinfo); - } else - free(name, M_OFWPROP); - - return (cdev); -} - -static const char * -nexus_ofw_get_name(device_t bus, device_t dev) -{ - struct nexus_devinfo *dinfo; - - if ((dinfo = device_get_ivars(dev)) == NULL) - return (NULL); - - return (dinfo->ndi_name); -} - -static phandle_t -nexus_ofw_get_node(device_t bus, device_t dev) -{ - struct nexus_devinfo *dinfo; - - if ((dinfo = device_get_ivars(dev)) == NULL) - return (0); - - return (dinfo->ndi_node); -} - -static const char * -nexus_ofw_get_type(device_t bus, device_t dev) -{ - struct nexus_devinfo *dinfo; - - if ((dinfo = device_get_ivars(dev)) == NULL) - return (NULL); - - return (dinfo->ndi_device_type); -} - -static const char * -nexus_ofw_get_compat(device_t bus, device_t dev) -{ - struct nexus_devinfo *dinfo; - - if ((dinfo = device_get_ivars(dev)) == NULL) - return (NULL); - - return (dinfo->ndi_compatible); -} - Index: powerpc/aim/nexus.c =================================================================== --- powerpc/aim/nexus.c (revision 214603) +++ powerpc/aim/nexus.c (working copy) @@ -1,529 +0,0 @@ -/*- - * Copyright 1998 Massachusetts Institute of Technology - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby - * granted, provided that both the above copyright notice and this - * permission notice appear in all copies, that both the above - * copyright notice and this permission notice appear in all - * supporting documentation, and that the name of M.I.T. not be used - * in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. M.I.T. makes - * no representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied - * warranty. - * - * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS - * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT - * SHALL M.I.T. 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. - */ -/*- - * Copyright 2001 by Thomas Moestl . 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 AND CONTRIBUTORS ``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. - * - * from: FreeBSD: src/sys/i386/i386/nexus.c,v 1.43 2001/02/09 - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include "ofw_bus_if.h" -#include "pic_if.h" - -/* - * The nexus (which is a pseudo-bus actually) iterates over the nodes that - * exist in Open Firmware and adds them as devices to this bus so that drivers - * can be attached to them. - * - * Maybe this code should get into dev/ofw to some extent, as some of it should - * work for all Open Firmware based machines... - */ - -static MALLOC_DEFINE(M_NEXUS, "nexus", "nexus device information"); - -enum nexus_ivars { - NEXUS_IVAR_NODE, - NEXUS_IVAR_NAME, - NEXUS_IVAR_DEVICE_TYPE, - NEXUS_IVAR_COMPATIBLE, -}; - -struct nexus_devinfo { - phandle_t ndi_node; - /* Some common properties. */ - const char *ndi_name; - const char *ndi_device_type; - const char *ndi_compatible; -}; - -struct nexus_softc { - struct rman sc_rman; -}; - -/* - * Device interface - */ -static int nexus_probe(device_t); -static int nexus_attach(device_t); - -/* - * Bus interface - */ -static device_t nexus_add_child(device_t, u_int, const char *, int); -static void nexus_probe_nomatch(device_t, device_t); -static int nexus_read_ivar(device_t, device_t, int, uintptr_t *); -static int nexus_write_ivar(device_t, device_t, int, uintptr_t); -#ifdef SMP -static int nexus_bind_intr(device_t dev, device_t child, - struct resource *irq, int cpu); -#endif -static int nexus_config_intr(device_t dev, int irq, enum intr_trigger trig, - enum intr_polarity pol); -static int nexus_setup_intr(device_t, device_t, struct resource *, int, - driver_filter_t *, driver_intr_t *, void *, void **); -static int nexus_teardown_intr(device_t, device_t, struct resource *, - void *); -static struct resource *nexus_alloc_resource(device_t, device_t, int, int *, - u_long, u_long, u_long, u_int); -static int nexus_activate_resource(device_t, device_t, int, int, - struct resource *); -static int nexus_deactivate_resource(device_t, device_t, int, int, - struct resource *); -static int nexus_release_resource(device_t, device_t, int, int, - struct resource *); - -/* - * OFW bus interface. - */ -static phandle_t nexus_ofw_get_node(device_t, device_t); -static const char *nexus_ofw_get_name(device_t, device_t); -static const char *nexus_ofw_get_type(device_t, device_t); -static const char *nexus_ofw_get_compat(device_t, device_t); - -/* - * Local routines - */ -static device_t nexus_device_from_node(device_t, phandle_t); - -static device_method_t nexus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, nexus_probe), - DEVMETHOD(device_attach, nexus_attach), - DEVMETHOD(device_detach, bus_generic_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface. Resource management is business of the children... */ - DEVMETHOD(bus_add_child, nexus_add_child), - DEVMETHOD(bus_print_child, bus_generic_print_child), - DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str), - DEVMETHOD(bus_probe_nomatch, nexus_probe_nomatch), - DEVMETHOD(bus_read_ivar, nexus_read_ivar), - DEVMETHOD(bus_write_ivar, nexus_write_ivar), - DEVMETHOD(bus_setup_intr, nexus_setup_intr), - DEVMETHOD(bus_teardown_intr, nexus_teardown_intr), -#ifdef SMP - DEVMETHOD(bus_bind_intr, nexus_bind_intr), -#endif - DEVMETHOD(bus_config_intr, nexus_config_intr), - DEVMETHOD(bus_alloc_resource, nexus_alloc_resource), - DEVMETHOD(bus_activate_resource, nexus_activate_resource), - DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource), - DEVMETHOD(bus_release_resource, nexus_release_resource), - - /* OFW bus interface */ - DEVMETHOD(ofw_bus_get_node, nexus_ofw_get_node), - DEVMETHOD(ofw_bus_get_name, nexus_ofw_get_name), - DEVMETHOD(ofw_bus_get_type, nexus_ofw_get_type), - DEVMETHOD(ofw_bus_get_compat, nexus_ofw_get_compat), - - { 0, 0 } -}; - -static driver_t nexus_driver = { - "nexus", - nexus_methods, - sizeof(struct nexus_softc), -}; - -static devclass_t nexus_devclass; - -DRIVER_MODULE(nexus, root, nexus_driver, nexus_devclass, 0, 0); - -static int -nexus_probe(device_t dev) -{ - bus_generic_probe(dev); - device_set_desc(dev, "Open Firmware Nexus device"); - return (0); -} - -static int -nexus_attach(device_t dev) -{ - phandle_t root; - phandle_t child; - struct nexus_softc *sc; - u_long start, end; - - if ((root = OF_peer(0)) == -1) - panic("nexus_probe: OF_peer failed."); - - sc = device_get_softc(dev); - - start = 0; - end = MAX_PICS*INTR_VECTORS - 1; - - sc->sc_rman.rm_start = start; - sc->sc_rman.rm_end = end; - sc->sc_rman.rm_type = RMAN_ARRAY; - sc->sc_rman.rm_descr = "Interrupt request lines"; - if (rman_init(&sc->sc_rman) || - rman_manage_region(&sc->sc_rman, start, end)) - panic("nexus_probe IRQ rman"); - - /* - * Now walk the OFW tree to locate top-level devices - */ - for (child = OF_child(root); child != 0; child = OF_peer(child)) { - if (child == -1) - panic("nexus_probe(): OF_child failed."); - (void)nexus_device_from_node(dev, child); - - } - - return (bus_generic_attach(dev)); -} - -static void -nexus_probe_nomatch(device_t dev, device_t child) -{ - char *name, *type; - - if (BUS_READ_IVAR(dev, child, NEXUS_IVAR_NAME, - (uintptr_t *)&name) != 0 || - BUS_READ_IVAR(dev, child, NEXUS_IVAR_DEVICE_TYPE, - (uintptr_t *)&type) != 0) - return; - - if (type == NULL) - type = "(unknown)"; - - if (bootverbose) - device_printf(dev, "<%s>, type %s (no driver attached)\n", - name, type); -} - -static device_t -nexus_add_child(device_t dev, u_int order, const char *name, int unit) -{ - device_t child; - struct nexus_devinfo *dinfo; - - child = device_add_child_ordered(dev, order, name, unit); - if (child == NULL) - return (NULL); - - dinfo = malloc(sizeof(struct nexus_devinfo), M_NEXUS, M_NOWAIT|M_ZERO); - if (dinfo == NULL) - return (NULL); - - dinfo->ndi_node = -1; - dinfo->ndi_name = name; - device_set_ivars(child, dinfo); - - return (child); -} - - -static int -nexus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result) -{ - struct nexus_devinfo *dinfo; - - if ((dinfo = device_get_ivars(child)) == 0) - return (ENOENT); - switch (which) { - case NEXUS_IVAR_NODE: - *result = dinfo->ndi_node; - break; - case NEXUS_IVAR_NAME: - *result = (uintptr_t)dinfo->ndi_name; - break; - case NEXUS_IVAR_DEVICE_TYPE: - *result = (uintptr_t)dinfo->ndi_device_type; - break; - case NEXUS_IVAR_COMPATIBLE: - *result = (uintptr_t)dinfo->ndi_compatible; - break; - default: - return (ENOENT); - } - return 0; -} - -static int -nexus_write_ivar(device_t dev, device_t child, int which, uintptr_t value) -{ - struct nexus_devinfo *dinfo; - - if ((dinfo = device_get_ivars(child)) == 0) - return (ENOENT); - - switch (which) { - case NEXUS_IVAR_NAME: - return (EINVAL); - - /* Identified devices may want to set these */ - case NEXUS_IVAR_NODE: - dinfo->ndi_node = (phandle_t)value; - break; - - case NEXUS_IVAR_DEVICE_TYPE: - dinfo->ndi_device_type = (char *)value; - break; - - default: - return (ENOENT); - } - return 0; -} - -static int -nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags, - driver_filter_t *filter, driver_intr_t *ihand, void *arg, void **cookiep) -{ - driver_t *driver; - int error; - - /* somebody tried to setup an irq that failed to allocate! */ - if (res == NULL) - panic("nexus_setup_intr: NULL irq resource!"); - - *cookiep = 0; - if ((rman_get_flags(res) & RF_SHAREABLE) == 0) - flags |= INTR_EXCL; - - driver = device_get_driver(child); - - /* - * We depend here on rman_activate_resource() being idempotent. - */ - error = rman_activate_resource(res); - if (error) - return (error); - - error = powerpc_setup_intr(device_get_nameunit(child), - rman_get_start(res), filter, ihand, arg, flags, cookiep); - - return (error); -} - -static int -nexus_teardown_intr(device_t dev, device_t child, struct resource *res, - void *cookie) -{ - - return (powerpc_teardown_intr(cookie)); -} - -#ifdef SMP -static int -nexus_bind_intr(device_t dev, device_t child, struct resource *irq, int cpu) -{ - - return (powerpc_bind_intr(rman_get_start(irq), cpu)); -} -#endif - -static int -nexus_config_intr(device_t dev, int irq, enum intr_trigger trig, - enum intr_polarity pol) -{ - - return (powerpc_config_intr(irq, trig, pol)); -} - -/* - * Allocate resources at the behest of a child. This only handles interrupts, - * since I/O resources are handled by child busses. - */ -static struct resource * -nexus_alloc_resource(device_t bus, device_t child, int type, int *rid, - u_long start, u_long end, u_long count, u_int flags) -{ - struct nexus_softc *sc; - struct resource *rv; - - if (type != SYS_RES_IRQ) { - device_printf(bus, "unknown resource request from %s\n", - device_get_nameunit(child)); - return (NULL); - } - - if (count == 0 || start + count - 1 != end) { - device_printf(bus, "invalid IRQ allocation from %s\n", - device_get_nameunit(child)); - return (NULL); - } - - sc = device_get_softc(bus); - - rv = rman_reserve_resource(&sc->sc_rman, start, end, count, - flags, child); - if (rv == NULL) { - device_printf(bus, "IRQ allocation failed for %s\n", - device_get_nameunit(child)); - } else - rman_set_rid(rv, *rid); - - return (rv); -} - -static int -nexus_activate_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - - /* Not much to be done yet... */ - return (rman_activate_resource(res)); -} - -static int -nexus_deactivate_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - - /* Not much to be done yet... */ - return (rman_deactivate_resource(res)); -} - -static int -nexus_release_resource(device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - - if (type != SYS_RES_IRQ) { - device_printf(bus, "unknown resource request from %s\n", - device_get_nameunit(child)); - return (EINVAL); - } - - return (rman_release_resource(res)); -} - -static device_t -nexus_device_from_node(device_t parent, phandle_t node) -{ - device_t cdev; - struct nexus_devinfo *dinfo; - char *name, *type, *compatible; - - OF_getprop_alloc(node, "name", 1, (void **)&name); - OF_getprop_alloc(node, "device_type", 1, (void **)&type); - OF_getprop_alloc(node, "compatible", 1, (void **)&compatible); - cdev = device_add_child(parent, NULL, -1); - if (cdev != NULL) { - dinfo = malloc(sizeof(*dinfo), M_NEXUS, M_WAITOK); - dinfo->ndi_node = node; - dinfo->ndi_name = name; - dinfo->ndi_device_type = type; - dinfo->ndi_compatible = compatible; - device_set_ivars(cdev, dinfo); - } else - free(name, M_OFWPROP); - - return (cdev); -} - -static const char * -nexus_ofw_get_name(device_t bus, device_t dev) -{ - struct nexus_devinfo *dinfo; - - if ((dinfo = device_get_ivars(dev)) == NULL) - return (NULL); - - return (dinfo->ndi_name); -} - -static phandle_t -nexus_ofw_get_node(device_t bus, device_t dev) -{ - struct nexus_devinfo *dinfo; - - if ((dinfo = device_get_ivars(dev)) == NULL) - return (0); - - return (dinfo->ndi_node); -} - -static const char * -nexus_ofw_get_type(device_t bus, device_t dev) -{ - struct nexus_devinfo *dinfo; - - if ((dinfo = device_get_ivars(dev)) == NULL) - return (NULL); - - return (dinfo->ndi_device_type); -} - -static const char * -nexus_ofw_get_compat(device_t bus, device_t dev) -{ - struct nexus_devinfo *dinfo; - - if ((dinfo = device_get_ivars(dev)) == NULL) - return (NULL); - - return (dinfo->ndi_compatible); -} - Index: powerpc/psim/iobus.c =================================================================== --- powerpc/psim/iobus.c (revision 214603) +++ powerpc/psim/iobus.c (working copy) @@ -116,7 +116,7 @@ devclass_t iobus_devclass; -DRIVER_MODULE(iobus, nexus, iobus_driver, iobus_devclass, 0, 0); +DRIVER_MODULE(iobus, ofwbus, iobus_driver, iobus_devclass, 0, 0); static int iobus_probe(device_t dev) Index: powerpc/ofw/ofw_cpu.c =================================================================== --- powerpc/ofw/ofw_cpu.c (revision 214603) +++ powerpc/ofw/ofw_cpu.c (working copy) @@ -75,7 +75,7 @@ static devclass_t ofw_cpulist_devclass; -DRIVER_MODULE(ofw_cpulist, nexus, ofw_cpulist_driver, ofw_cpulist_devclass, +DRIVER_MODULE(ofw_cpulist, ofwbus, ofw_cpulist_driver, ofw_cpulist_devclass, 0, 0); static int Index: powerpc/mambo/mambo_openpic.c =================================================================== --- powerpc/mambo/mambo_openpic.c (revision 214603) +++ powerpc/mambo/mambo_openpic.c (working copy) @@ -110,7 +110,7 @@ static devclass_t openpicbus_devclass; -DRIVER_MODULE(openpicbus, nexus, openpicbus_mambo_driver, +DRIVER_MODULE(openpicbus, ofwbus, openpicbus_mambo_driver, openpicbus_devclass, 0, 0); DRIVER_MODULE(openpic, openpicbus, openpic_mambo_driver, openpic_devclass, 0, 0); @@ -132,15 +132,14 @@ openpicbus_mambo_attach(device_t dev) { uint64_t picaddr; - phandle_t nexus; + phandle_t root; struct openpicbus_softc *sc; sc = device_get_softc(dev); - nexus = OF_parent(ofw_bus_get_node(dev)); + root = OF_parent(ofw_bus_get_node(dev)); - OF_getprop(nexus,"platform-open-pic", - &picaddr,sizeof(picaddr)); + OF_getprop(root,"platform-open-pic", &picaddr, sizeof(picaddr)); sc->picaddr = picaddr; Index: powerpc/mambo/mambo.c =================================================================== --- powerpc/mambo/mambo.c (revision 214603) +++ powerpc/mambo/mambo.c (working copy) @@ -77,7 +77,7 @@ static devclass_t mambobus_devclass; -DRIVER_MODULE(mambo, nexus, mambobus_driver, mambobus_devclass, 0, 0); +DRIVER_MODULE(mambo, ofwbus, mambobus_driver, mambobus_devclass, 0, 0); static int mambobus_probe(device_t dev) Index: powerpc/mpc85xx/nexus.c =================================================================== --- powerpc/mpc85xx/nexus.c (revision 214603) +++ powerpc/mpc85xx/nexus.c (working copy) @@ -1,137 +0,0 @@ -/*- - * Copyright 1998 Massachusetts Institute of Technology - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby - * granted, provided that both the above copyright notice and this - * permission notice appear in all copies, that both the above - * copyright notice and this permission notice appear in all - * supporting documentation, and that the name of M.I.T. not be used - * in advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. M.I.T. makes - * no representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied - * warranty. - * - * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS - * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT - * SHALL M.I.T. 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. - */ -/*- - * Copyright 2001 by Thomas Moestl . 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 AND CONTRIBUTORS ``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. - * - * from: FreeBSD: src/sys/i386/i386/nexus.c,v 1.43 2001/02/09 - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Device interface - */ -static int nexus_probe(device_t); -static int nexus_activate_resource(device_t, device_t, int, int, - struct resource *); -static int nexus_deactivate_resource(device_t, device_t, int, int, - struct resource *); - -static device_method_t nexus_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, nexus_probe), - DEVMETHOD(device_attach, bus_generic_attach), - DEVMETHOD(device_detach, bus_generic_detach), - DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, bus_generic_suspend), - DEVMETHOD(device_resume, bus_generic_resume), - - /* Bus interface. Resource management is business of the children... */ - DEVMETHOD(bus_add_child, NULL), - DEVMETHOD(bus_print_child, bus_generic_print_child), - DEVMETHOD(bus_probe_nomatch, NULL), - DEVMETHOD(bus_read_ivar, NULL), - DEVMETHOD(bus_write_ivar, NULL), - DEVMETHOD(bus_setup_intr, NULL), - DEVMETHOD(bus_teardown_intr, NULL), - DEVMETHOD(bus_alloc_resource, NULL), - DEVMETHOD(bus_activate_resource, nexus_activate_resource), - DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource), - DEVMETHOD(bus_release_resource, NULL), - - { 0, 0 } -}; - -static driver_t nexus_driver = { - "nexus", - nexus_methods -}; - -static devclass_t nexus_devclass; - -DRIVER_MODULE(nexus, root, nexus_driver, nexus_devclass, 0, 0); - -static int -nexus_probe (device_t dev) -{ - - device_add_child(dev, "fdtbus", 0); - device_quiet(dev); - - return (BUS_PROBE_DEFAULT); -} - -static int -nexus_activate_resource (device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - - /* Not much to be done yet... */ - return (rman_activate_resource(res)); -} - -static int -nexus_deactivate_resource (device_t bus, device_t child, int type, int rid, - struct resource *res) -{ - - /* Not much to be done yet... */ - return (rman_deactivate_resource(res)); -} Index: powerpc/powermac/smu.c =================================================================== --- powerpc/powermac/smu.c (revision 214603) +++ powerpc/powermac/smu.c (working copy) @@ -200,7 +200,7 @@ static devclass_t smu_devclass; -DRIVER_MODULE(smu, nexus, smu_driver, smu_devclass, 0, 0); +DRIVER_MODULE(smu, ofwbus, smu_driver, smu_devclass, 0, 0); MALLOC_DEFINE(M_SMU, "smu", "SMU Sensor Information"); #define SMU_MAILBOX 0x8000860c Index: powerpc/powermac/grackle.c =================================================================== --- powerpc/powermac/grackle.c (revision 214603) +++ powerpc/powermac/grackle.c (working copy) @@ -142,7 +142,7 @@ static devclass_t grackle_devclass; -DRIVER_MODULE(grackle, nexus, grackle_driver, grackle_devclass, 0, 0); +DRIVER_MODULE(grackle, ofwbus, grackle_driver, grackle_devclass, 0, 0); static int grackle_probe(device_t dev) Index: powerpc/powermac/cpcht.c =================================================================== --- powerpc/powermac/cpcht.c (revision 214603) +++ powerpc/powermac/cpcht.c (working copy) @@ -176,7 +176,7 @@ static devclass_t cpcht_devclass; -DRIVER_MODULE(cpcht, nexus, cpcht_driver, cpcht_devclass, 0, 0); +DRIVER_MODULE(cpcht, ofwbus, cpcht_driver, cpcht_devclass, 0, 0); #define CPCHT_IOPORT_BASE 0xf4000000UL /* Hardwired */ #define CPCHT_IOPORT_SIZE 0x00400000UL Index: powerpc/powermac/uninorthpci.c =================================================================== --- powerpc/powermac/uninorthpci.c (revision 214603) +++ powerpc/powermac/uninorthpci.c (working copy) @@ -132,7 +132,7 @@ static devclass_t uninorth_devclass; -DRIVER_MODULE(uninorth, nexus, uninorth_driver, uninorth_devclass, 0, 0); +DRIVER_MODULE(uninorth, ofwbus, uninorth_driver, uninorth_devclass, 0, 0); static int uninorth_probe(device_t dev) Index: powerpc/powermac/uninorth.c =================================================================== --- powerpc/powermac/uninorth.c (revision 214603) +++ powerpc/powermac/uninorth.c (working copy) @@ -136,7 +136,7 @@ static devclass_t unin_chip_devclass; -DRIVER_MODULE(unin, nexus, unin_chip_driver, unin_chip_devclass, 0, 0); +DRIVER_MODULE(unin, ofwbus, unin_chip_driver, unin_chip_devclass, 0, 0); /* * Add an interrupt to the dev's resource list if present