158158742SRafal Jaworowski /*- 206763f5eSNathan Whitehorn * Copyright (c) 2013 Nathan Whitehorn 358158742SRafal Jaworowski * All rights reserved. 458158742SRafal Jaworowski * 558158742SRafal Jaworowski * Redistribution and use in source and binary forms, with or without 658158742SRafal Jaworowski * modification, are permitted provided that the following conditions 758158742SRafal Jaworowski * are met: 858158742SRafal Jaworowski * 1. Redistributions of source code must retain the above copyright 958158742SRafal Jaworowski * notice, this list of conditions and the following disclaimer. 1058158742SRafal Jaworowski * 2. Redistributions in binary form must reproduce the above copyright 1158158742SRafal Jaworowski * notice, this list of conditions and the following disclaimer in the 1258158742SRafal Jaworowski * documentation and/or other materials provided with the distribution. 1358158742SRafal Jaworowski * 1458158742SRafal Jaworowski * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1558158742SRafal Jaworowski * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1658158742SRafal Jaworowski * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1758158742SRafal Jaworowski * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1858158742SRafal Jaworowski * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1958158742SRafal Jaworowski * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2058158742SRafal Jaworowski * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2158158742SRafal Jaworowski * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2258158742SRafal Jaworowski * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2358158742SRafal Jaworowski * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2458158742SRafal Jaworowski * SUCH DAMAGE. 2558158742SRafal Jaworowski */ 2658158742SRafal Jaworowski 2758158742SRafal Jaworowski #include <sys/cdefs.h> 2858158742SRafal Jaworowski __FBSDID("$FreeBSD$"); 2958158742SRafal Jaworowski #include <sys/param.h> 3058158742SRafal Jaworowski #include <sys/systm.h> 3158158742SRafal Jaworowski #include <sys/module.h> 3258158742SRafal Jaworowski #include <sys/bus.h> 3306763f5eSNathan Whitehorn #include <sys/conf.h> 3406763f5eSNathan Whitehorn #include <sys/kernel.h> 3558158742SRafal Jaworowski #include <sys/rman.h> 3658158742SRafal Jaworowski 3706763f5eSNathan Whitehorn #include <dev/ofw/openfirm.h> 3858158742SRafal Jaworowski #include <dev/ofw/ofw_bus.h> 3958158742SRafal Jaworowski #include <dev/ofw/ofw_bus_subr.h> 4058158742SRafal Jaworowski 41*2cc1ad9cSJayachandran C. #include <dev/fdt/simplebus.h> 4258158742SRafal Jaworowski 4358158742SRafal Jaworowski /* 4406763f5eSNathan Whitehorn * Bus interface. 4558158742SRafal Jaworowski */ 4606763f5eSNathan Whitehorn static int simplebus_probe(device_t dev); 4706763f5eSNathan Whitehorn static int simplebus_attach(device_t dev); 4858158742SRafal Jaworowski static struct resource *simplebus_alloc_resource(device_t, device_t, int, 4958158742SRafal Jaworowski int *, u_long, u_long, u_long, u_int); 5006763f5eSNathan Whitehorn static void simplebus_probe_nomatch(device_t bus, device_t child); 5106763f5eSNathan Whitehorn static int simplebus_print_child(device_t bus, device_t child); 5258158742SRafal Jaworowski 5358158742SRafal Jaworowski /* 5406763f5eSNathan Whitehorn * ofw_bus interface 5506763f5eSNathan Whitehorn */ 5606763f5eSNathan Whitehorn static const struct ofw_bus_devinfo *simplebus_get_devinfo(device_t bus, 5706763f5eSNathan Whitehorn device_t child); 5806763f5eSNathan Whitehorn 5906763f5eSNathan Whitehorn /* 6006763f5eSNathan Whitehorn * local methods 6106763f5eSNathan Whitehorn */ 6206763f5eSNathan Whitehorn 6306763f5eSNathan Whitehorn static int simplebus_fill_ranges(phandle_t node, 6406763f5eSNathan Whitehorn struct simplebus_softc *sc); 6506763f5eSNathan Whitehorn static struct simplebus_devinfo *simplebus_setup_dinfo(device_t dev, 6606763f5eSNathan Whitehorn phandle_t node); 6706763f5eSNathan Whitehorn 6806763f5eSNathan Whitehorn /* 6906763f5eSNathan Whitehorn * Driver methods. 7058158742SRafal Jaworowski */ 7158158742SRafal Jaworowski static device_method_t simplebus_methods[] = { 7258158742SRafal Jaworowski /* Device interface */ 7358158742SRafal Jaworowski DEVMETHOD(device_probe, simplebus_probe), 7458158742SRafal Jaworowski DEVMETHOD(device_attach, simplebus_attach), 7558158742SRafal Jaworowski 7658158742SRafal Jaworowski /* Bus interface */ 7758158742SRafal Jaworowski DEVMETHOD(bus_print_child, simplebus_print_child), 7806763f5eSNathan Whitehorn DEVMETHOD(bus_probe_nomatch, simplebus_probe_nomatch), 7906763f5eSNathan Whitehorn DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), 8006763f5eSNathan Whitehorn DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), 8158158742SRafal Jaworowski DEVMETHOD(bus_alloc_resource, simplebus_alloc_resource), 8206763f5eSNathan Whitehorn DEVMETHOD(bus_release_resource, bus_generic_release_resource), 8306763f5eSNathan Whitehorn DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 8406763f5eSNathan Whitehorn DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 8506763f5eSNathan Whitehorn DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), 8606763f5eSNathan Whitehorn DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str), 8758158742SRafal Jaworowski 8806763f5eSNathan Whitehorn /* ofw_bus interface */ 8958158742SRafal Jaworowski DEVMETHOD(ofw_bus_get_devinfo, simplebus_get_devinfo), 9058158742SRafal Jaworowski DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), 9158158742SRafal Jaworowski DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), 9258158742SRafal Jaworowski DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), 9358158742SRafal Jaworowski DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), 9458158742SRafal Jaworowski DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), 9558158742SRafal Jaworowski 9606763f5eSNathan Whitehorn DEVMETHOD_END 9758158742SRafal Jaworowski }; 9858158742SRafal Jaworowski 99*2cc1ad9cSJayachandran C. DEFINE_CLASS_0(simplebus, simplebus_driver, simplebus_methods, 100*2cc1ad9cSJayachandran C. sizeof(struct simplebus_softc)); 101*2cc1ad9cSJayachandran C. 10206763f5eSNathan Whitehorn static devclass_t simplebus_devclass; 1032d12d35cSIan Lepore EARLY_DRIVER_MODULE(simplebus, ofwbus, simplebus_driver, simplebus_devclass, 1042d12d35cSIan Lepore 0, 0, BUS_PASS_BUS); 1052d12d35cSIan Lepore EARLY_DRIVER_MODULE(simplebus, simplebus, simplebus_driver, simplebus_devclass, 106633dbf2eSIan Lepore 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); 10758158742SRafal Jaworowski 10858158742SRafal Jaworowski static int 10958158742SRafal Jaworowski simplebus_probe(device_t dev) 11058158742SRafal Jaworowski { 11158158742SRafal Jaworowski 112add35ed5SIan Lepore if (!ofw_bus_status_okay(dev)) 113add35ed5SIan Lepore return (ENXIO); 114add35ed5SIan Lepore 1152a74fe2cSIan Lepore /* 1162a74fe2cSIan Lepore * FDT data puts a "simple-bus" compatible string on many things that 1172a74fe2cSIan Lepore * have children but aren't really busses in our world. Without a 1182a74fe2cSIan Lepore * ranges property we will fail to attach, so just fail to probe too. 1192a74fe2cSIan Lepore */ 1202a74fe2cSIan Lepore if (!(ofw_bus_is_compatible(dev, "simple-bus") && 1212a74fe2cSIan Lepore ofw_bus_has_prop(dev, "ranges")) && 12206763f5eSNathan Whitehorn (ofw_bus_get_type(dev) == NULL || strcmp(ofw_bus_get_type(dev), 12306763f5eSNathan Whitehorn "soc") != 0)) 12458158742SRafal Jaworowski return (ENXIO); 12558158742SRafal Jaworowski 12658158742SRafal Jaworowski device_set_desc(dev, "Flattened device tree simple bus"); 12758158742SRafal Jaworowski 1282737a5a9SAleksandr Rybalko return (BUS_PROBE_GENERIC); 12958158742SRafal Jaworowski } 13058158742SRafal Jaworowski 13158158742SRafal Jaworowski static int 13258158742SRafal Jaworowski simplebus_attach(device_t dev) 13358158742SRafal Jaworowski { 13458158742SRafal Jaworowski struct simplebus_softc *sc; 13506763f5eSNathan Whitehorn struct simplebus_devinfo *di; 13606763f5eSNathan Whitehorn phandle_t node; 13706763f5eSNathan Whitehorn device_t cdev; 13858158742SRafal Jaworowski 13906763f5eSNathan Whitehorn node = ofw_bus_get_node(dev); 14058158742SRafal Jaworowski sc = device_get_softc(dev); 14158158742SRafal Jaworowski 14206763f5eSNathan Whitehorn sc->dev = dev; 14306763f5eSNathan Whitehorn sc->node = node; 14406763f5eSNathan Whitehorn 14558158742SRafal Jaworowski /* 14606763f5eSNathan Whitehorn * Some important numbers 14758158742SRafal Jaworowski */ 14806763f5eSNathan Whitehorn sc->acells = 2; 14906763f5eSNathan Whitehorn OF_getencprop(node, "#address-cells", &sc->acells, sizeof(sc->acells)); 15006763f5eSNathan Whitehorn sc->scells = 1; 15106763f5eSNathan Whitehorn OF_getencprop(node, "#size-cells", &sc->scells, sizeof(sc->scells)); 15258158742SRafal Jaworowski 15306763f5eSNathan Whitehorn if (simplebus_fill_ranges(node, sc) < 0) { 15406763f5eSNathan Whitehorn device_printf(dev, "could not get ranges\n"); 15506763f5eSNathan Whitehorn return (ENXIO); 15658158742SRafal Jaworowski } 15758158742SRafal Jaworowski 15806763f5eSNathan Whitehorn /* 15906763f5eSNathan Whitehorn * In principle, simplebus could have an interrupt map, but ignore that 16006763f5eSNathan Whitehorn * for now 16106763f5eSNathan Whitehorn */ 16258158742SRafal Jaworowski 16306763f5eSNathan Whitehorn for (node = OF_child(node); node > 0; node = OF_peer(node)) { 16406763f5eSNathan Whitehorn if ((di = simplebus_setup_dinfo(dev, node)) == NULL) 16506763f5eSNathan Whitehorn continue; 16606763f5eSNathan Whitehorn cdev = device_add_child(dev, NULL, -1); 16706763f5eSNathan Whitehorn if (cdev == NULL) { 16806763f5eSNathan Whitehorn device_printf(dev, "<%s>: device_add_child failed\n", 16906763f5eSNathan Whitehorn di->obdinfo.obd_name); 17006763f5eSNathan Whitehorn resource_list_free(&di->rl); 17106763f5eSNathan Whitehorn ofw_bus_gen_destroy_devinfo(&di->obdinfo); 17206763f5eSNathan Whitehorn free(di, M_DEVBUF); 17358158742SRafal Jaworowski continue; 17458158742SRafal Jaworowski } 17506763f5eSNathan Whitehorn device_set_ivars(cdev, di); 17658158742SRafal Jaworowski } 17758158742SRafal Jaworowski 17858158742SRafal Jaworowski return (bus_generic_attach(dev)); 17958158742SRafal Jaworowski } 18058158742SRafal Jaworowski 18158158742SRafal Jaworowski static int 18206763f5eSNathan Whitehorn simplebus_fill_ranges(phandle_t node, struct simplebus_softc *sc) 18358158742SRafal Jaworowski { 18406763f5eSNathan Whitehorn int host_address_cells; 18506763f5eSNathan Whitehorn cell_t *base_ranges; 18606763f5eSNathan Whitehorn ssize_t nbase_ranges; 18706763f5eSNathan Whitehorn int err; 18806763f5eSNathan Whitehorn int i, j, k; 18958158742SRafal Jaworowski 19006763f5eSNathan Whitehorn err = OF_searchencprop(OF_parent(node), "#address-cells", 19106763f5eSNathan Whitehorn &host_address_cells, sizeof(host_address_cells)); 19206763f5eSNathan Whitehorn if (err <= 0) 19306763f5eSNathan Whitehorn return (-1); 19458158742SRafal Jaworowski 19506763f5eSNathan Whitehorn nbase_ranges = OF_getproplen(node, "ranges"); 19606763f5eSNathan Whitehorn if (nbase_ranges < 0) 19706763f5eSNathan Whitehorn return (-1); 19806763f5eSNathan Whitehorn sc->nranges = nbase_ranges / sizeof(cell_t) / 19906763f5eSNathan Whitehorn (sc->acells + host_address_cells + sc->scells); 20006763f5eSNathan Whitehorn if (sc->nranges == 0) 20106763f5eSNathan Whitehorn return (0); 20258158742SRafal Jaworowski 20306763f5eSNathan Whitehorn sc->ranges = malloc(sc->nranges * sizeof(sc->ranges[0]), 20406763f5eSNathan Whitehorn M_DEVBUF, M_WAITOK); 20506763f5eSNathan Whitehorn base_ranges = malloc(nbase_ranges, M_DEVBUF, M_WAITOK); 20606763f5eSNathan Whitehorn OF_getencprop(node, "ranges", base_ranges, nbase_ranges); 20706763f5eSNathan Whitehorn 20806763f5eSNathan Whitehorn for (i = 0, j = 0; i < sc->nranges; i++) { 20906763f5eSNathan Whitehorn sc->ranges[i].bus = 0; 21006763f5eSNathan Whitehorn for (k = 0; k < sc->acells; k++) { 21106763f5eSNathan Whitehorn sc->ranges[i].bus <<= 32; 21206763f5eSNathan Whitehorn sc->ranges[i].bus |= base_ranges[j++]; 21306763f5eSNathan Whitehorn } 21406763f5eSNathan Whitehorn sc->ranges[i].host = 0; 21506763f5eSNathan Whitehorn for (k = 0; k < host_address_cells; k++) { 21606763f5eSNathan Whitehorn sc->ranges[i].host <<= 32; 21706763f5eSNathan Whitehorn sc->ranges[i].host |= base_ranges[j++]; 21806763f5eSNathan Whitehorn } 21906763f5eSNathan Whitehorn sc->ranges[i].size = 0; 22006763f5eSNathan Whitehorn for (k = 0; k < sc->scells; k++) { 22106763f5eSNathan Whitehorn sc->ranges[i].size <<= 32; 22206763f5eSNathan Whitehorn sc->ranges[i].size |= base_ranges[j++]; 22306763f5eSNathan Whitehorn } 22406763f5eSNathan Whitehorn } 22506763f5eSNathan Whitehorn 22606763f5eSNathan Whitehorn free(base_ranges, M_DEVBUF); 22706763f5eSNathan Whitehorn return (sc->nranges); 22806763f5eSNathan Whitehorn } 22906763f5eSNathan Whitehorn 23006763f5eSNathan Whitehorn static struct simplebus_devinfo * 23106763f5eSNathan Whitehorn simplebus_setup_dinfo(device_t dev, phandle_t node) 23206763f5eSNathan Whitehorn { 23306763f5eSNathan Whitehorn struct simplebus_softc *sc; 23406763f5eSNathan Whitehorn struct simplebus_devinfo *ndi; 23506763f5eSNathan Whitehorn 23606763f5eSNathan Whitehorn sc = device_get_softc(dev); 23706763f5eSNathan Whitehorn 23806763f5eSNathan Whitehorn ndi = malloc(sizeof(*ndi), M_DEVBUF, M_WAITOK | M_ZERO); 23906763f5eSNathan Whitehorn if (ofw_bus_gen_setup_devinfo(&ndi->obdinfo, node) != 0) { 24006763f5eSNathan Whitehorn free(ndi, M_DEVBUF); 24106763f5eSNathan Whitehorn return (NULL); 24206763f5eSNathan Whitehorn } 24306763f5eSNathan Whitehorn 24406763f5eSNathan Whitehorn resource_list_init(&ndi->rl); 2454b3d9160SZbigniew Bodek ofw_bus_reg_to_rl(dev, node, sc->acells, sc->scells, &ndi->rl); 246c47d4cdeSIan Lepore ofw_bus_intr_to_rl(dev, node, &ndi->rl); 24706763f5eSNathan Whitehorn 24806763f5eSNathan Whitehorn return (ndi); 24906763f5eSNathan Whitehorn } 25006763f5eSNathan Whitehorn 25106763f5eSNathan Whitehorn static const struct ofw_bus_devinfo * 25206763f5eSNathan Whitehorn simplebus_get_devinfo(device_t bus __unused, device_t child) 25306763f5eSNathan Whitehorn { 25406763f5eSNathan Whitehorn struct simplebus_devinfo *ndi; 25506763f5eSNathan Whitehorn 25606763f5eSNathan Whitehorn ndi = device_get_ivars(child); 25706763f5eSNathan Whitehorn return (&ndi->obdinfo); 25858158742SRafal Jaworowski } 25958158742SRafal Jaworowski 26058158742SRafal Jaworowski static struct resource * 26158158742SRafal Jaworowski simplebus_alloc_resource(device_t bus, device_t child, int type, int *rid, 26258158742SRafal Jaworowski u_long start, u_long end, u_long count, u_int flags) 26358158742SRafal Jaworowski { 26406763f5eSNathan Whitehorn struct simplebus_softc *sc; 26558158742SRafal Jaworowski struct simplebus_devinfo *di; 26658158742SRafal Jaworowski struct resource_list_entry *rle; 26706763f5eSNathan Whitehorn int j; 26806763f5eSNathan Whitehorn 26906763f5eSNathan Whitehorn sc = device_get_softc(bus); 27058158742SRafal Jaworowski 27158158742SRafal Jaworowski /* 27258158742SRafal Jaworowski * Request for the default allocation with a given rid: use resource 27358158742SRafal Jaworowski * list stored in the local device info. 27458158742SRafal Jaworowski */ 27558158742SRafal Jaworowski if ((start == 0UL) && (end == ~0UL)) { 27658158742SRafal Jaworowski if ((di = device_get_ivars(child)) == NULL) 27758158742SRafal Jaworowski return (NULL); 27858158742SRafal Jaworowski 27958158742SRafal Jaworowski if (type == SYS_RES_IOPORT) 28058158742SRafal Jaworowski type = SYS_RES_MEMORY; 28158158742SRafal Jaworowski 28206763f5eSNathan Whitehorn rle = resource_list_find(&di->rl, type, *rid); 28358158742SRafal Jaworowski if (rle == NULL) { 284089dfb09SAleksandr Rybalko if (bootverbose) 28558158742SRafal Jaworowski device_printf(bus, "no default resources for " 28658158742SRafal Jaworowski "rid = %d, type = %d\n", *rid, type); 28758158742SRafal Jaworowski return (NULL); 28858158742SRafal Jaworowski } 28958158742SRafal Jaworowski start = rle->start; 29058158742SRafal Jaworowski end = rle->end; 29158158742SRafal Jaworowski count = rle->count; 29258158742SRafal Jaworowski } 29358158742SRafal Jaworowski 29406763f5eSNathan Whitehorn if (type == SYS_RES_MEMORY) { 29506763f5eSNathan Whitehorn /* Remap through ranges property */ 29606763f5eSNathan Whitehorn for (j = 0; j < sc->nranges; j++) { 29706763f5eSNathan Whitehorn if (start >= sc->ranges[j].bus && end < 29806763f5eSNathan Whitehorn sc->ranges[j].bus + sc->ranges[j].size) { 29906763f5eSNathan Whitehorn start -= sc->ranges[j].bus; 30006763f5eSNathan Whitehorn start += sc->ranges[j].host; 30106763f5eSNathan Whitehorn end -= sc->ranges[j].bus; 30206763f5eSNathan Whitehorn end += sc->ranges[j].host; 30306763f5eSNathan Whitehorn break; 30406763f5eSNathan Whitehorn } 30506763f5eSNathan Whitehorn } 30606763f5eSNathan Whitehorn if (j == sc->nranges && sc->nranges != 0) { 30706763f5eSNathan Whitehorn if (bootverbose) 30806763f5eSNathan Whitehorn device_printf(bus, "Could not map resource " 30906763f5eSNathan Whitehorn "%#lx-%#lx\n", start, end); 31006763f5eSNathan Whitehorn 31106763f5eSNathan Whitehorn return (NULL); 31206763f5eSNathan Whitehorn } 31306763f5eSNathan Whitehorn } 3141f40dbc8SBrooks Davis 31558158742SRafal Jaworowski return (bus_generic_alloc_resource(bus, child, type, rid, start, end, 31658158742SRafal Jaworowski count, flags)); 31758158742SRafal Jaworowski } 31858158742SRafal Jaworowski 3191f40dbc8SBrooks Davis static int 32006763f5eSNathan Whitehorn simplebus_print_res(struct simplebus_devinfo *di) 3211f40dbc8SBrooks Davis { 32206763f5eSNathan Whitehorn int rv; 3231f40dbc8SBrooks Davis 32406763f5eSNathan Whitehorn rv = 0; 32506763f5eSNathan Whitehorn rv += resource_list_print_type(&di->rl, "mem", SYS_RES_MEMORY, "%#lx"); 32606763f5eSNathan Whitehorn rv += resource_list_print_type(&di->rl, "irq", SYS_RES_IRQ, "%ld"); 32706763f5eSNathan Whitehorn return (rv); 32806763f5eSNathan Whitehorn } 3291f40dbc8SBrooks Davis 33006763f5eSNathan Whitehorn static void 33106763f5eSNathan Whitehorn simplebus_probe_nomatch(device_t bus, device_t child) 33206763f5eSNathan Whitehorn { 333cca75397SWarner Losh const char *name, *type, *compat; 33406763f5eSNathan Whitehorn 33506763f5eSNathan Whitehorn if (!bootverbose) 33606763f5eSNathan Whitehorn return; 33706763f5eSNathan Whitehorn 33806763f5eSNathan Whitehorn name = ofw_bus_get_name(child); 33906763f5eSNathan Whitehorn type = ofw_bus_get_type(child); 340cca75397SWarner Losh compat = ofw_bus_get_compat(child); 34106763f5eSNathan Whitehorn 34206763f5eSNathan Whitehorn device_printf(bus, "<%s>", name != NULL ? name : "unknown"); 34306763f5eSNathan Whitehorn simplebus_print_res(device_get_ivars(child)); 344cca75397SWarner Losh if (!ofw_bus_status_okay(child)) 345cca75397SWarner Losh printf(" disabled"); 346cca75397SWarner Losh if (type) 347cca75397SWarner Losh printf(" type %s", type); 348cca75397SWarner Losh if (compat) 349cca75397SWarner Losh printf(" compat %s", compat); 350cca75397SWarner Losh printf(" (no driver attached)\n"); 3511f40dbc8SBrooks Davis } 3521f40dbc8SBrooks Davis 3531f40dbc8SBrooks Davis static int 35406763f5eSNathan Whitehorn simplebus_print_child(device_t bus, device_t child) 3551f40dbc8SBrooks Davis { 35606763f5eSNathan Whitehorn int rv; 3571f40dbc8SBrooks Davis 35806763f5eSNathan Whitehorn rv = bus_print_child_header(bus, child); 35906763f5eSNathan Whitehorn rv += simplebus_print_res(device_get_ivars(child)); 360cca75397SWarner Losh if (!ofw_bus_status_okay(child)) 361cca75397SWarner Losh rv += printf(" disabled"); 36206763f5eSNathan Whitehorn rv += bus_print_child_footer(bus, child); 36306763f5eSNathan Whitehorn return (rv); 3641f40dbc8SBrooks Davis } 365