Lines Matching +full:simple +full:- +full:bus

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
32 #include <sys/bus.h>
44 * Bus interface.
49 static void simplebus_probe_nomatch(device_t bus, device_t child);
50 static int simplebus_print_child(device_t bus, device_t child);
53 static struct resource_list *simplebus_get_resource_list(device_t bus,
56 static ssize_t simplebus_get_property(device_t bus, device_t child,
62 static const struct ofw_bus_devinfo *simplebus_get_devinfo(device_t bus,
77 /* Bus interface */
125 * XXX We should attach only to pure' compatible = "simple-bus"',
128 * "syscon", "simple-bus"; is handled by fdt/syscon driver
129 * "simple-mfd", "simple-bus"; is handled by fdt/simple-mfd driver
132 ofw_bus_is_compatible(dev, "simple-mfd"))
136 * FDT data puts a "simple-bus" compatible string on many things that
140 if (!(ofw_bus_is_compatible(dev, "simple-bus") &&
146 device_set_desc(dev, "Flattened device tree simple bus");
159 if ((sc->flags & SB_FLAG_NO_RANGES) == 0 &&
160 simplebus_fill_ranges(sc->node, sc) < 0) {
170 for (node = OF_child(sc->node); node > 0; node = OF_peer(node))
171 simplebus_add_device(dev, node, 0, NULL, -1, NULL);
200 if (sc->ranges != NULL)
201 free(sc->ranges, M_DEVBUF);
214 sc->dev = dev;
215 sc->node = node;
220 sc->acells = 2;
221 OF_getencprop(node, "#address-cells", &sc->acells, sizeof(sc->acells));
222 sc->scells = 1;
223 OF_getencprop(node, "#size-cells", &sc->scells, sizeof(sc->scells));
235 err = OF_searchencprop(OF_parent(node), "#address-cells",
238 return (-1);
242 return (-1);
243 sc->nranges = nbase_ranges / sizeof(cell_t) /
244 (sc->acells + host_address_cells + sc->scells);
245 if (sc->nranges == 0)
248 sc->ranges = malloc(sc->nranges * sizeof(sc->ranges[0]),
253 for (i = 0, j = 0; i < sc->nranges; i++) {
254 sc->ranges[i].bus = 0;
255 for (k = 0; k < sc->acells; k++) {
256 sc->ranges[i].bus <<= 32;
257 sc->ranges[i].bus |= base_ranges[j++];
259 sc->ranges[i].host = 0;
261 sc->ranges[i].host <<= 32;
262 sc->ranges[i].host |= base_ranges[j++];
264 sc->ranges[i].size = 0;
265 for (k = 0; k < sc->scells; k++) {
266 sc->ranges[i].size <<= 32;
267 sc->ranges[i].size |= base_ranges[j++];
272 return (sc->nranges);
287 if (ofw_bus_gen_setup_devinfo(&ndi->obdinfo, node) != 0) {
293 resource_list_init(&ndi->rl);
294 ofw_bus_reg_to_rl(dev, node, sc->acells, sc->scells, &ndi->rl);
295 ofw_bus_intr_to_rl(dev, node, &ndi->rl, NULL);
312 ndi->obdinfo.obd_name);
313 resource_list_free(&ndi->rl);
314 ofw_bus_gen_destroy_devinfo(&ndi->obdinfo);
335 ndi->obdinfo.obd_node = -1;
336 resource_list_init(&ndi->rl);
343 simplebus_get_devinfo(device_t bus __unused, device_t child)
350 return (&ndi->obdinfo);
354 simplebus_get_resource_list(device_t bus __unused, device_t child)
361 return (&ndi->rl);
365 simplebus_get_property(device_t bus, device_t child, const char *propname,
381 return (-1);
419 return (-1);
434 simplebus_alloc_resource(device_t bus, device_t child, int type, int *rid,
442 sc = device_get_softc(bus);
452 rle = resource_list_find(&di->rl, type, *rid);
455 device_printf(bus, "no default resources for "
459 start = rle->start;
460 end = rle->end;
461 count = rle->count;
466 for (j = 0; j < sc->nranges; j++) {
467 if (start >= sc->ranges[j].bus && end <
468 sc->ranges[j].bus + sc->ranges[j].size) {
469 start -= sc->ranges[j].bus;
470 start += sc->ranges[j].host;
471 end -= sc->ranges[j].bus;
472 end += sc->ranges[j].host;
476 if (j == sc->nranges && sc->nranges != 0) {
478 device_printf(bus, "Could not map resource "
479 "%#jx-%#jx\n", start, end);
485 return (bus_generic_alloc_resource(bus, child, type, rid, start, end,
497 rv += resource_list_print_type(&di->rl, "mem", SYS_RES_MEMORY, "%#jx");
498 rv += resource_list_print_type(&di->rl, "irq", SYS_RES_IRQ, "%jd");
503 simplebus_probe_nomatch(device_t bus, device_t child)
516 device_printf(bus, "<%s>", name != NULL ? name : "unknown");
526 simplebus_print_child(device_t bus, device_t child)
530 rv = bus_print_child_header(bus, child);
534 rv += bus_print_child_footer(bus, child);