Lines Matching +full:qman +full:- +full:channel +full:- +full:id
1 /*-
2 * Copyright (c) 2011-2012 Semihalf.
98 for (i = 0; i < sc->sc_base.nranges; i++) { in fman_activate_resource()
99 if (rman_is_region_manager(res, &sc->rman) != 0) { in fman_activate_resource()
100 bt = rman_get_bustag(sc->mem_res); in fman_activate_resource()
102 rman_get_bushandle(sc->mem_res), in fman_activate_resource()
103 rman_get_start(res) - in fman_activate_resource()
104 rman_get_start(sc->mem_res), in fman_activate_resource()
141 KASSERT(rle->res != NULL, in fman_release_resource()
143 rle->res = NULL; in fman_release_resource()
172 KASSERT(rle->res == NULL, in fman_alloc_resource()
175 start = rle->start; in fman_alloc_resource()
176 count = ulmax(count, rle->count); in fman_alloc_resource()
177 end = ulmax(rle->end, start + count - 1); in fman_alloc_resource()
183 for (i = 0; i < sc->sc_base.nranges; i++) { in fman_alloc_resource()
184 if (start >= sc->sc_base.ranges[i].bus && end < in fman_alloc_resource()
185 sc->sc_base.ranges[i].bus + sc->sc_base.ranges[i].size) { in fman_alloc_resource()
186 start += rman_get_start(sc->mem_res); in fman_alloc_resource()
187 end += rman_get_start(sc->mem_res); in fman_alloc_resource()
188 res = rman_reserve_resource(&sc->rman, start, in fman_alloc_resource()
203 rle->res = res; in fman_alloc_resource()
221 err = OF_searchencprop(OF_parent(node), "#address-cells", in fman_fill_ranges()
224 return (-1); in fman_fill_ranges()
228 return (-1); in fman_fill_ranges()
229 sc->nranges = nbase_ranges / sizeof(cell_t) / in fman_fill_ranges()
230 (sc->acells + host_address_cells + sc->scells); in fman_fill_ranges()
231 if (sc->nranges == 0) in fman_fill_ranges()
234 sc->ranges = malloc(sc->nranges * sizeof(sc->ranges[0]), in fman_fill_ranges()
239 for (i = 0, j = 0; i < sc->nranges; i++) { in fman_fill_ranges()
240 sc->ranges[i].bus = 0; in fman_fill_ranges()
241 for (k = 0; k < sc->acells; k++) { in fman_fill_ranges()
242 sc->ranges[i].bus <<= 32; in fman_fill_ranges()
243 sc->ranges[i].bus |= base_ranges[j++]; in fman_fill_ranges()
245 sc->ranges[i].host = 0; in fman_fill_ranges()
247 sc->ranges[i].host <<= 32; in fman_fill_ranges()
248 sc->ranges[i].host |= base_ranges[j++]; in fman_fill_ranges()
250 sc->ranges[i].size = 0; in fman_fill_ranges()
251 for (k = 0; k < sc->scells; k++) { in fman_fill_ranges()
252 sc->ranges[i].size <<= 32; in fman_fill_ranges()
253 sc->ranges[i].size |= base_ranges[j++]; in fman_fill_ranges()
258 return (sc->nranges); in fman_fill_ranges()
273 muram_handle = FM_MURAM_ConfigAndInit(cfg->mem_base_addr + in fman_init()
276 device_printf(cfg->fman_device, "couldn't init FM MURAM module" in fman_init()
280 sc->muram_handle = muram_handle; in fman_init()
283 fm_params.fmId = cfg->fm_id; in fman_init()
284 /* XXX we support only one partition thus each fman has master id */ in fman_init()
287 fm_params.baseAddr = cfg->mem_base_addr; in fman_init()
302 fm_params.f_Exception = cfg->exception_callback; in fman_init()
303 fm_params.f_BusError = cfg->bus_error_callback; in fman_init()
304 fm_params.h_App = cfg->fman_device; in fman_init()
305 fm_params.irq = cfg->irq_num; in fman_init()
306 fm_params.errIrq = cfg->err_irq_num; in fman_init()
313 device_printf(cfg->fman_device, "couldn't configure FM " in fman_init()
322 device_printf(cfg->fman_device, "couldn't init FM module\n"); in fman_init()
328 device_printf(cfg->fman_device, "couldn't get FM revision\n"); in fman_init()
332 device_printf(cfg->fman_device, "Hardware version: %d.%d.\n", in fman_init()
336 simplebus_init(sc->sc_base.dev, 0); in fman_init()
338 node = ofw_bus_get_node(sc->sc_base.dev); in fman_init()
339 fman_fill_ranges(node, &sc->sc_base); in fman_init()
340 sc->rman.rm_type = RMAN_ARRAY; in fman_init()
341 sc->rman.rm_descr = "FMan range"; in fman_init()
342 rman_init_from_resource(&sc->rman, sc->mem_res); in fman_init()
344 simplebus_add_device(sc->sc_base.dev, node, 0, NULL, -1, NULL); in fman_init()
362 device_printf(sc->sc_base.dev, "FMan exception occurred.\n"); in fman_exception_callback()
372 device_printf(sc->sc_base.dev, "FMan error occurred.\n"); in fman_error_callback()
387 *fmh = sc->fm_handle; in fman_get_handle()
397 *muramh = sc->muram_handle; in fman_get_muram_handle()
407 *fm_base = rman_get_bushandle(sc->mem_res); in fman_get_bushandle()
421 sc->sc_base.dev = dev; in fman_attach()
430 if (OF_getencprop(node, "fsl,qman-channel-range", qchan_range, in fman_attach()
432 device_printf(dev, "Missing QMan channel range property!\n"); in fman_attach()
435 sc->qman_chan_base = qchan_range[0]; in fman_attach()
436 sc->qman_chan_count = qchan_range[1]; in fman_attach()
437 sc->mem_rid = 0; in fman_attach()
438 sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->mem_rid, in fman_attach()
440 if (!sc->mem_res) { in fman_attach()
445 sc->irq_rid = 0; in fman_attach()
446 sc->irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irq_rid, in fman_attach()
448 if (!sc->irq_res) { in fman_attach()
453 sc->err_irq_rid = 1; in fman_attach()
454 sc->err_irq_res = bus_alloc_resource_any(dev, SYS_RES_IRQ, in fman_attach()
455 &sc->err_irq_rid, RF_ACTIVE | RF_SHAREABLE); in fman_attach()
456 if (!sc->err_irq_res) { in fman_attach()
464 cfg.mem_base_addr = rman_get_bushandle(sc->mem_res); in fman_attach()
465 cfg.irq_num = (uintptr_t)sc->irq_res; in fman_attach()
466 cfg.err_irq_num = (uintptr_t)sc->err_irq_res; in fman_attach()
470 sc->fm_handle = fman_init(sc, &cfg); in fman_attach()
471 if (sc->fm_handle == NULL) { in fman_attach()
491 if (sc->muram_handle) { in fman_detach()
492 FM_MURAM_Free(sc->muram_handle); in fman_detach()
495 if (sc->fm_handle) { in fman_detach()
496 FM_Free(sc->fm_handle); in fman_detach()
499 if (sc->mem_res) { in fman_detach()
500 bus_release_resource(dev, SYS_RES_MEMORY, sc->mem_rid, in fman_detach()
501 sc->mem_res); in fman_detach()
504 if (sc->irq_res) { in fman_detach()
505 bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid, in fman_detach()
506 sc->irq_res); in fman_detach()
509 if (sc->irq_res) { in fman_detach()
510 bus_release_resource(dev, SYS_RES_IRQ, sc->err_irq_rid, in fman_detach()
511 sc->err_irq_res); in fman_detach()
547 for (i = 0; i < sc->qman_chan_count; i++) { in fman_qman_channel_id()
549 return (sc->qman_chan_base + i); in fman_qman_channel_id()