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 4106763f5eSNathan Whitehorn struct simplebus_range { 4206763f5eSNathan Whitehorn uint64_t bus; 4306763f5eSNathan Whitehorn uint64_t host; 4406763f5eSNathan Whitehorn uint64_t size; 4506763f5eSNathan Whitehorn }; 4658158742SRafal Jaworowski 4758158742SRafal Jaworowski struct simplebus_softc { 4806763f5eSNathan Whitehorn device_t dev; 4906763f5eSNathan Whitehorn phandle_t node; 5006763f5eSNathan Whitehorn 5106763f5eSNathan Whitehorn struct simplebus_range *ranges; 5206763f5eSNathan Whitehorn int nranges; 5306763f5eSNathan Whitehorn 5406763f5eSNathan Whitehorn pcell_t acells, scells; 5558158742SRafal Jaworowski }; 5658158742SRafal Jaworowski 5758158742SRafal Jaworowski struct simplebus_devinfo { 5806763f5eSNathan Whitehorn struct ofw_bus_devinfo obdinfo; 5906763f5eSNathan Whitehorn struct resource_list rl; 6058158742SRafal Jaworowski }; 6158158742SRafal Jaworowski 6258158742SRafal Jaworowski /* 6306763f5eSNathan Whitehorn * Bus interface. 6458158742SRafal Jaworowski */ 6506763f5eSNathan Whitehorn static int simplebus_probe(device_t dev); 6606763f5eSNathan Whitehorn static int simplebus_attach(device_t dev); 6758158742SRafal Jaworowski static struct resource *simplebus_alloc_resource(device_t, device_t, int, 6858158742SRafal Jaworowski int *, u_long, u_long, u_long, u_int); 6906763f5eSNathan Whitehorn static void simplebus_probe_nomatch(device_t bus, device_t child); 7006763f5eSNathan Whitehorn static int simplebus_print_child(device_t bus, device_t child); 7158158742SRafal Jaworowski 7258158742SRafal Jaworowski /* 7306763f5eSNathan Whitehorn * ofw_bus interface 7406763f5eSNathan Whitehorn */ 7506763f5eSNathan Whitehorn static const struct ofw_bus_devinfo *simplebus_get_devinfo(device_t bus, 7606763f5eSNathan Whitehorn device_t child); 7706763f5eSNathan Whitehorn 7806763f5eSNathan Whitehorn /* 7906763f5eSNathan Whitehorn * local methods 8006763f5eSNathan Whitehorn */ 8106763f5eSNathan Whitehorn 8206763f5eSNathan Whitehorn static int simplebus_fill_ranges(phandle_t node, 8306763f5eSNathan Whitehorn struct simplebus_softc *sc); 8406763f5eSNathan Whitehorn static struct simplebus_devinfo *simplebus_setup_dinfo(device_t dev, 8506763f5eSNathan Whitehorn phandle_t node); 8606763f5eSNathan Whitehorn 8706763f5eSNathan Whitehorn /* 8806763f5eSNathan Whitehorn * Driver methods. 8958158742SRafal Jaworowski */ 9058158742SRafal Jaworowski static device_method_t simplebus_methods[] = { 9158158742SRafal Jaworowski /* Device interface */ 9258158742SRafal Jaworowski DEVMETHOD(device_probe, simplebus_probe), 9358158742SRafal Jaworowski DEVMETHOD(device_attach, simplebus_attach), 9458158742SRafal Jaworowski 9558158742SRafal Jaworowski /* Bus interface */ 9658158742SRafal Jaworowski DEVMETHOD(bus_print_child, simplebus_print_child), 9706763f5eSNathan Whitehorn DEVMETHOD(bus_probe_nomatch, simplebus_probe_nomatch), 9806763f5eSNathan Whitehorn DEVMETHOD(bus_setup_intr, bus_generic_setup_intr), 9906763f5eSNathan Whitehorn DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr), 10058158742SRafal Jaworowski DEVMETHOD(bus_alloc_resource, simplebus_alloc_resource), 10106763f5eSNathan Whitehorn DEVMETHOD(bus_release_resource, bus_generic_release_resource), 10206763f5eSNathan Whitehorn DEVMETHOD(bus_activate_resource, bus_generic_activate_resource), 10306763f5eSNathan Whitehorn DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), 10406763f5eSNathan Whitehorn DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource), 10506763f5eSNathan Whitehorn DEVMETHOD(bus_child_pnpinfo_str, ofw_bus_gen_child_pnpinfo_str), 10658158742SRafal Jaworowski 10706763f5eSNathan Whitehorn /* ofw_bus interface */ 10858158742SRafal Jaworowski DEVMETHOD(ofw_bus_get_devinfo, simplebus_get_devinfo), 10958158742SRafal Jaworowski DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat), 11058158742SRafal Jaworowski DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model), 11158158742SRafal Jaworowski DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name), 11258158742SRafal Jaworowski DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node), 11358158742SRafal Jaworowski DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type), 11458158742SRafal Jaworowski 11506763f5eSNathan Whitehorn DEVMETHOD_END 11658158742SRafal Jaworowski }; 11758158742SRafal Jaworowski 11858158742SRafal Jaworowski static driver_t simplebus_driver = { 11958158742SRafal Jaworowski "simplebus", 12058158742SRafal Jaworowski simplebus_methods, 12158158742SRafal Jaworowski sizeof(struct simplebus_softc) 12258158742SRafal Jaworowski }; 12306763f5eSNathan Whitehorn static devclass_t simplebus_devclass; 1242d12d35cSIan Lepore EARLY_DRIVER_MODULE(simplebus, ofwbus, simplebus_driver, simplebus_devclass, 1252d12d35cSIan Lepore 0, 0, BUS_PASS_BUS); 1262d12d35cSIan Lepore EARLY_DRIVER_MODULE(simplebus, simplebus, simplebus_driver, simplebus_devclass, 127633dbf2eSIan Lepore 0, 0, BUS_PASS_BUS + BUS_PASS_ORDER_MIDDLE); 12858158742SRafal Jaworowski 12958158742SRafal Jaworowski static int 13058158742SRafal Jaworowski simplebus_probe(device_t dev) 13158158742SRafal Jaworowski { 13258158742SRafal Jaworowski 133add35ed5SIan Lepore if (!ofw_bus_status_okay(dev)) 134add35ed5SIan Lepore return (ENXIO); 135add35ed5SIan Lepore 1362a74fe2cSIan Lepore /* 1372a74fe2cSIan Lepore * FDT data puts a "simple-bus" compatible string on many things that 1382a74fe2cSIan Lepore * have children but aren't really busses in our world. Without a 1392a74fe2cSIan Lepore * ranges property we will fail to attach, so just fail to probe too. 1402a74fe2cSIan Lepore */ 1412a74fe2cSIan Lepore if (!(ofw_bus_is_compatible(dev, "simple-bus") && 1422a74fe2cSIan Lepore ofw_bus_has_prop(dev, "ranges")) && 14306763f5eSNathan Whitehorn (ofw_bus_get_type(dev) == NULL || strcmp(ofw_bus_get_type(dev), 14406763f5eSNathan Whitehorn "soc") != 0)) 14558158742SRafal Jaworowski return (ENXIO); 14658158742SRafal Jaworowski 14758158742SRafal Jaworowski device_set_desc(dev, "Flattened device tree simple bus"); 14858158742SRafal Jaworowski 1492737a5a9SAleksandr Rybalko return (BUS_PROBE_GENERIC); 15058158742SRafal Jaworowski } 15158158742SRafal Jaworowski 15258158742SRafal Jaworowski static int 15358158742SRafal Jaworowski simplebus_attach(device_t dev) 15458158742SRafal Jaworowski { 15558158742SRafal Jaworowski struct simplebus_softc *sc; 15606763f5eSNathan Whitehorn struct simplebus_devinfo *di; 15706763f5eSNathan Whitehorn phandle_t node; 15806763f5eSNathan Whitehorn device_t cdev; 15958158742SRafal Jaworowski 16006763f5eSNathan Whitehorn node = ofw_bus_get_node(dev); 16158158742SRafal Jaworowski sc = device_get_softc(dev); 16258158742SRafal Jaworowski 16306763f5eSNathan Whitehorn sc->dev = dev; 16406763f5eSNathan Whitehorn sc->node = node; 16506763f5eSNathan Whitehorn 16658158742SRafal Jaworowski /* 16706763f5eSNathan Whitehorn * Some important numbers 16858158742SRafal Jaworowski */ 16906763f5eSNathan Whitehorn sc->acells = 2; 17006763f5eSNathan Whitehorn OF_getencprop(node, "#address-cells", &sc->acells, sizeof(sc->acells)); 17106763f5eSNathan Whitehorn sc->scells = 1; 17206763f5eSNathan Whitehorn OF_getencprop(node, "#size-cells", &sc->scells, sizeof(sc->scells)); 17358158742SRafal Jaworowski 17406763f5eSNathan Whitehorn if (simplebus_fill_ranges(node, sc) < 0) { 17506763f5eSNathan Whitehorn device_printf(dev, "could not get ranges\n"); 17606763f5eSNathan Whitehorn return (ENXIO); 17758158742SRafal Jaworowski } 17858158742SRafal Jaworowski 17906763f5eSNathan Whitehorn /* 18006763f5eSNathan Whitehorn * In principle, simplebus could have an interrupt map, but ignore that 18106763f5eSNathan Whitehorn * for now 18206763f5eSNathan Whitehorn */ 18358158742SRafal Jaworowski 18406763f5eSNathan Whitehorn for (node = OF_child(node); node > 0; node = OF_peer(node)) { 18506763f5eSNathan Whitehorn if ((di = simplebus_setup_dinfo(dev, node)) == NULL) 18606763f5eSNathan Whitehorn continue; 18706763f5eSNathan Whitehorn cdev = device_add_child(dev, NULL, -1); 18806763f5eSNathan Whitehorn if (cdev == NULL) { 18906763f5eSNathan Whitehorn device_printf(dev, "<%s>: device_add_child failed\n", 19006763f5eSNathan Whitehorn di->obdinfo.obd_name); 19106763f5eSNathan Whitehorn resource_list_free(&di->rl); 19206763f5eSNathan Whitehorn ofw_bus_gen_destroy_devinfo(&di->obdinfo); 19306763f5eSNathan Whitehorn free(di, M_DEVBUF); 19458158742SRafal Jaworowski continue; 19558158742SRafal Jaworowski } 19606763f5eSNathan Whitehorn device_set_ivars(cdev, di); 19758158742SRafal Jaworowski } 19858158742SRafal Jaworowski 19958158742SRafal Jaworowski return (bus_generic_attach(dev)); 20058158742SRafal Jaworowski } 20158158742SRafal Jaworowski 20258158742SRafal Jaworowski static int 20306763f5eSNathan Whitehorn simplebus_fill_ranges(phandle_t node, struct simplebus_softc *sc) 20458158742SRafal Jaworowski { 20506763f5eSNathan Whitehorn int host_address_cells; 20606763f5eSNathan Whitehorn cell_t *base_ranges; 20706763f5eSNathan Whitehorn ssize_t nbase_ranges; 20806763f5eSNathan Whitehorn int err; 20906763f5eSNathan Whitehorn int i, j, k; 21058158742SRafal Jaworowski 21106763f5eSNathan Whitehorn err = OF_searchencprop(OF_parent(node), "#address-cells", 21206763f5eSNathan Whitehorn &host_address_cells, sizeof(host_address_cells)); 21306763f5eSNathan Whitehorn if (err <= 0) 21406763f5eSNathan Whitehorn return (-1); 21558158742SRafal Jaworowski 21606763f5eSNathan Whitehorn nbase_ranges = OF_getproplen(node, "ranges"); 21706763f5eSNathan Whitehorn if (nbase_ranges < 0) 21806763f5eSNathan Whitehorn return (-1); 21906763f5eSNathan Whitehorn sc->nranges = nbase_ranges / sizeof(cell_t) / 22006763f5eSNathan Whitehorn (sc->acells + host_address_cells + sc->scells); 22106763f5eSNathan Whitehorn if (sc->nranges == 0) 22206763f5eSNathan Whitehorn return (0); 22358158742SRafal Jaworowski 22406763f5eSNathan Whitehorn sc->ranges = malloc(sc->nranges * sizeof(sc->ranges[0]), 22506763f5eSNathan Whitehorn M_DEVBUF, M_WAITOK); 22606763f5eSNathan Whitehorn base_ranges = malloc(nbase_ranges, M_DEVBUF, M_WAITOK); 22706763f5eSNathan Whitehorn OF_getencprop(node, "ranges", base_ranges, nbase_ranges); 22806763f5eSNathan Whitehorn 22906763f5eSNathan Whitehorn for (i = 0, j = 0; i < sc->nranges; i++) { 23006763f5eSNathan Whitehorn sc->ranges[i].bus = 0; 23106763f5eSNathan Whitehorn for (k = 0; k < sc->acells; k++) { 23206763f5eSNathan Whitehorn sc->ranges[i].bus <<= 32; 23306763f5eSNathan Whitehorn sc->ranges[i].bus |= base_ranges[j++]; 23406763f5eSNathan Whitehorn } 23506763f5eSNathan Whitehorn sc->ranges[i].host = 0; 23606763f5eSNathan Whitehorn for (k = 0; k < host_address_cells; k++) { 23706763f5eSNathan Whitehorn sc->ranges[i].host <<= 32; 23806763f5eSNathan Whitehorn sc->ranges[i].host |= base_ranges[j++]; 23906763f5eSNathan Whitehorn } 24006763f5eSNathan Whitehorn sc->ranges[i].size = 0; 24106763f5eSNathan Whitehorn for (k = 0; k < sc->scells; k++) { 24206763f5eSNathan Whitehorn sc->ranges[i].size <<= 32; 24306763f5eSNathan Whitehorn sc->ranges[i].size |= base_ranges[j++]; 24406763f5eSNathan Whitehorn } 24506763f5eSNathan Whitehorn } 24606763f5eSNathan Whitehorn 24706763f5eSNathan Whitehorn free(base_ranges, M_DEVBUF); 24806763f5eSNathan Whitehorn return (sc->nranges); 24906763f5eSNathan Whitehorn } 25006763f5eSNathan Whitehorn 25106763f5eSNathan Whitehorn static struct simplebus_devinfo * 25206763f5eSNathan Whitehorn simplebus_setup_dinfo(device_t dev, phandle_t node) 25306763f5eSNathan Whitehorn { 25406763f5eSNathan Whitehorn struct simplebus_softc *sc; 25506763f5eSNathan Whitehorn struct simplebus_devinfo *ndi; 25606763f5eSNathan Whitehorn 25706763f5eSNathan Whitehorn sc = device_get_softc(dev); 25806763f5eSNathan Whitehorn 25906763f5eSNathan Whitehorn ndi = malloc(sizeof(*ndi), M_DEVBUF, M_WAITOK | M_ZERO); 26006763f5eSNathan Whitehorn if (ofw_bus_gen_setup_devinfo(&ndi->obdinfo, node) != 0) { 26106763f5eSNathan Whitehorn free(ndi, M_DEVBUF); 26206763f5eSNathan Whitehorn return (NULL); 26306763f5eSNathan Whitehorn } 26406763f5eSNathan Whitehorn 26506763f5eSNathan Whitehorn resource_list_init(&ndi->rl); 266*4b3d9160SZbigniew Bodek ofw_bus_reg_to_rl(dev, node, sc->acells, sc->scells, &ndi->rl); 267c47d4cdeSIan Lepore ofw_bus_intr_to_rl(dev, node, &ndi->rl); 26806763f5eSNathan Whitehorn 26906763f5eSNathan Whitehorn return (ndi); 27006763f5eSNathan Whitehorn } 27106763f5eSNathan Whitehorn 27206763f5eSNathan Whitehorn static const struct ofw_bus_devinfo * 27306763f5eSNathan Whitehorn simplebus_get_devinfo(device_t bus __unused, device_t child) 27406763f5eSNathan Whitehorn { 27506763f5eSNathan Whitehorn struct simplebus_devinfo *ndi; 27606763f5eSNathan Whitehorn 27706763f5eSNathan Whitehorn ndi = device_get_ivars(child); 27806763f5eSNathan Whitehorn return (&ndi->obdinfo); 27958158742SRafal Jaworowski } 28058158742SRafal Jaworowski 28158158742SRafal Jaworowski static struct resource * 28258158742SRafal Jaworowski simplebus_alloc_resource(device_t bus, device_t child, int type, int *rid, 28358158742SRafal Jaworowski u_long start, u_long end, u_long count, u_int flags) 28458158742SRafal Jaworowski { 28506763f5eSNathan Whitehorn struct simplebus_softc *sc; 28658158742SRafal Jaworowski struct simplebus_devinfo *di; 28758158742SRafal Jaworowski struct resource_list_entry *rle; 28806763f5eSNathan Whitehorn int j; 28906763f5eSNathan Whitehorn 29006763f5eSNathan Whitehorn sc = device_get_softc(bus); 29158158742SRafal Jaworowski 29258158742SRafal Jaworowski /* 29358158742SRafal Jaworowski * Request for the default allocation with a given rid: use resource 29458158742SRafal Jaworowski * list stored in the local device info. 29558158742SRafal Jaworowski */ 29658158742SRafal Jaworowski if ((start == 0UL) && (end == ~0UL)) { 29758158742SRafal Jaworowski if ((di = device_get_ivars(child)) == NULL) 29858158742SRafal Jaworowski return (NULL); 29958158742SRafal Jaworowski 30058158742SRafal Jaworowski if (type == SYS_RES_IOPORT) 30158158742SRafal Jaworowski type = SYS_RES_MEMORY; 30258158742SRafal Jaworowski 30306763f5eSNathan Whitehorn rle = resource_list_find(&di->rl, type, *rid); 30458158742SRafal Jaworowski if (rle == NULL) { 305089dfb09SAleksandr Rybalko if (bootverbose) 30658158742SRafal Jaworowski device_printf(bus, "no default resources for " 30758158742SRafal Jaworowski "rid = %d, type = %d\n", *rid, type); 30858158742SRafal Jaworowski return (NULL); 30958158742SRafal Jaworowski } 31058158742SRafal Jaworowski start = rle->start; 31158158742SRafal Jaworowski end = rle->end; 31258158742SRafal Jaworowski count = rle->count; 31358158742SRafal Jaworowski } 31458158742SRafal Jaworowski 31506763f5eSNathan Whitehorn if (type == SYS_RES_MEMORY) { 31606763f5eSNathan Whitehorn /* Remap through ranges property */ 31706763f5eSNathan Whitehorn for (j = 0; j < sc->nranges; j++) { 31806763f5eSNathan Whitehorn if (start >= sc->ranges[j].bus && end < 31906763f5eSNathan Whitehorn sc->ranges[j].bus + sc->ranges[j].size) { 32006763f5eSNathan Whitehorn start -= sc->ranges[j].bus; 32106763f5eSNathan Whitehorn start += sc->ranges[j].host; 32206763f5eSNathan Whitehorn end -= sc->ranges[j].bus; 32306763f5eSNathan Whitehorn end += sc->ranges[j].host; 32406763f5eSNathan Whitehorn break; 32506763f5eSNathan Whitehorn } 32606763f5eSNathan Whitehorn } 32706763f5eSNathan Whitehorn if (j == sc->nranges && sc->nranges != 0) { 32806763f5eSNathan Whitehorn if (bootverbose) 32906763f5eSNathan Whitehorn device_printf(bus, "Could not map resource " 33006763f5eSNathan Whitehorn "%#lx-%#lx\n", start, end); 33106763f5eSNathan Whitehorn 33206763f5eSNathan Whitehorn return (NULL); 33306763f5eSNathan Whitehorn } 33406763f5eSNathan Whitehorn } 3351f40dbc8SBrooks Davis 33658158742SRafal Jaworowski return (bus_generic_alloc_resource(bus, child, type, rid, start, end, 33758158742SRafal Jaworowski count, flags)); 33858158742SRafal Jaworowski } 33958158742SRafal Jaworowski 3401f40dbc8SBrooks Davis static int 34106763f5eSNathan Whitehorn simplebus_print_res(struct simplebus_devinfo *di) 3421f40dbc8SBrooks Davis { 34306763f5eSNathan Whitehorn int rv; 3441f40dbc8SBrooks Davis 34506763f5eSNathan Whitehorn rv = 0; 34606763f5eSNathan Whitehorn rv += resource_list_print_type(&di->rl, "mem", SYS_RES_MEMORY, "%#lx"); 34706763f5eSNathan Whitehorn rv += resource_list_print_type(&di->rl, "irq", SYS_RES_IRQ, "%ld"); 34806763f5eSNathan Whitehorn return (rv); 34906763f5eSNathan Whitehorn } 3501f40dbc8SBrooks Davis 35106763f5eSNathan Whitehorn static void 35206763f5eSNathan Whitehorn simplebus_probe_nomatch(device_t bus, device_t child) 35306763f5eSNathan Whitehorn { 354cca75397SWarner Losh const char *name, *type, *compat; 35506763f5eSNathan Whitehorn 35606763f5eSNathan Whitehorn if (!bootverbose) 35706763f5eSNathan Whitehorn return; 35806763f5eSNathan Whitehorn 35906763f5eSNathan Whitehorn name = ofw_bus_get_name(child); 36006763f5eSNathan Whitehorn type = ofw_bus_get_type(child); 361cca75397SWarner Losh compat = ofw_bus_get_compat(child); 36206763f5eSNathan Whitehorn 36306763f5eSNathan Whitehorn device_printf(bus, "<%s>", name != NULL ? name : "unknown"); 36406763f5eSNathan Whitehorn simplebus_print_res(device_get_ivars(child)); 365cca75397SWarner Losh if (!ofw_bus_status_okay(child)) 366cca75397SWarner Losh printf(" disabled"); 367cca75397SWarner Losh if (type) 368cca75397SWarner Losh printf(" type %s", type); 369cca75397SWarner Losh if (compat) 370cca75397SWarner Losh printf(" compat %s", compat); 371cca75397SWarner Losh printf(" (no driver attached)\n"); 3721f40dbc8SBrooks Davis } 3731f40dbc8SBrooks Davis 3741f40dbc8SBrooks Davis static int 37506763f5eSNathan Whitehorn simplebus_print_child(device_t bus, device_t child) 3761f40dbc8SBrooks Davis { 37706763f5eSNathan Whitehorn int rv; 3781f40dbc8SBrooks Davis 37906763f5eSNathan Whitehorn rv = bus_print_child_header(bus, child); 38006763f5eSNathan Whitehorn rv += simplebus_print_res(device_get_ivars(child)); 381cca75397SWarner Losh if (!ofw_bus_status_okay(child)) 382cca75397SWarner Losh rv += printf(" disabled"); 38306763f5eSNathan Whitehorn rv += bus_print_child_footer(bus, child); 38406763f5eSNathan Whitehorn return (rv); 3851f40dbc8SBrooks Davis } 386