Index: simplebus.c =================================================================== --- simplebus.c (revision 230313) +++ simplebus.c (working copy) @@ -65,7 +65,6 @@ int sc_addr_cells; int sc_size_cells; u_long sc_start_pa; - u_long sc_start_va; u_long sc_size; }; @@ -155,17 +154,17 @@ struct simplebus_devinfo *di; struct simplebus_softc *sc; phandle_t dt_node, dt_child; + u_long vaddr; + u_long paddr; + u_long size; sc = device_get_softc(dev); - sc->sc_start_pa = fdt_immr_pa; - sc->sc_start_va = fdt_immr_va; - sc->sc_size = fdt_immr_size; - /* * Walk simple-bus and add direct subordinates as our children. */ dt_node = ofw_bus_get_node(dev); + fdt_get_range(dt_node, 0, &sc->sc_start_pa, &sc->sc_size); for (dt_child = OF_child(dt_node); dt_child != 0; dt_child = OF_peer(dt_child)) { @@ -185,19 +184,27 @@ } resource_list_init(&di->di_res); - - if (fdt_reg_to_rl(dt_child, &di->di_res, sc->sc_start_va)) { - device_printf(dev, "%s: could not process 'reg' " - "property\n", di->di_ofw.obd_name); - ofw_bus_gen_destroy_devinfo(&di->di_ofw); - free(di, M_SIMPLEBUS); - continue; + if (fdt_regsize(dt_child, &paddr, &size) == 0) { + paddr += sc->sc_start_pa; + if (bus_space_map(fdtbus_bs_tag, paddr, size, 0, + &vaddr) != 0) + panic("Couldn't map memory for device"); + if (fdt_reg_to_rl(dt_child, &di->di_res, vaddr)) { + device_printf(dev, + "%s: could not process 'reg' " + "property\n", di->di_ofw.obd_name); + bus_space_unmap(fdtbus_bs_tag, paddr, size); + ofw_bus_gen_destroy_devinfo(&di->di_ofw); + free(di, M_SIMPLEBUS); + continue; + } } if (fdt_intr_to_rl(dt_child, &di->di_res, di->di_intr_sl)) { device_printf(dev, "%s: could not process " "'interrupts' property\n", di->di_ofw.obd_name); resource_list_free(&di->di_res); + bus_space_unmap(fdtbus_bs_tag, paddr, size); ofw_bus_gen_destroy_devinfo(&di->di_ofw); free(di, M_SIMPLEBUS); continue; @@ -209,6 +216,7 @@ device_printf(dev, "could not add child: %s\n", di->di_ofw.obd_name); resource_list_free(&di->di_res); + bus_space_unmap(fdtbus_bs_tag, paddr, size); ofw_bus_gen_destroy_devinfo(&di->di_ofw); free(di, M_SIMPLEBUS); continue;