Lines Matching full:ringacc
15 #include <linux/soc/ti/k3-ringacc.h>
183 int (*init)(struct platform_device *pdev, struct k3_ringacc *ringacc);
204 * @ops: SoC specific ringacc operation
211 u32 num_rings; /* number of rings in Ringacc module */
332 struct k3_ring *k3_ringacc_request_ring(struct k3_ringacc *ringacc, in k3_ringacc_request_ring() argument
337 mutex_lock(&ringacc->req_lock); in k3_ringacc_request_ring()
339 if (!try_module_get(ringacc->dev->driver->owner)) in k3_ringacc_request_ring()
345 &ringacc->rm_gp_range->desc[0]; in k3_ringacc_request_ring()
349 id = find_next_zero_bit(ringacc->rings_inuse, size, in k3_ringacc_request_ring()
357 if (test_bit(id, ringacc->rings_inuse) && in k3_ringacc_request_ring()
358 !(ringacc->rings[id].flags & K3_RING_FLAG_SHARED)) in k3_ringacc_request_ring()
360 else if (ringacc->rings[id].flags & K3_RING_FLAG_SHARED) in k3_ringacc_request_ring()
364 proxy_id = find_first_zero_bit(ringacc->proxy_inuse, in k3_ringacc_request_ring()
365 ringacc->num_proxies); in k3_ringacc_request_ring()
366 if (proxy_id == ringacc->num_proxies) in k3_ringacc_request_ring()
371 set_bit(proxy_id, ringacc->proxy_inuse); in k3_ringacc_request_ring()
372 ringacc->rings[id].proxy_id = proxy_id; in k3_ringacc_request_ring()
373 dev_dbg(ringacc->dev, "Giving ring#%d proxy#%d\n", id, in k3_ringacc_request_ring()
376 dev_dbg(ringacc->dev, "Giving ring#%d\n", id); in k3_ringacc_request_ring()
379 set_bit(id, ringacc->rings_inuse); in k3_ringacc_request_ring()
381 ringacc->rings[id].use_count++; in k3_ringacc_request_ring()
382 mutex_unlock(&ringacc->req_lock); in k3_ringacc_request_ring()
383 return &ringacc->rings[id]; in k3_ringacc_request_ring()
386 module_put(ringacc->dev->driver->owner); in k3_ringacc_request_ring()
389 mutex_unlock(&ringacc->req_lock); in k3_ringacc_request_ring()
394 static int k3_dmaring_request_dual_ring(struct k3_ringacc *ringacc, int fwd_id, in k3_dmaring_request_dual_ring() argument
407 mutex_lock(&ringacc->req_lock); in k3_dmaring_request_dual_ring()
409 if (!try_module_get(ringacc->dev->driver->owner)) { in k3_dmaring_request_dual_ring()
414 if (test_bit(fwd_id, ringacc->rings_inuse)) { in k3_dmaring_request_dual_ring()
419 *fwd_ring = &ringacc->rings[fwd_id]; in k3_dmaring_request_dual_ring()
420 *compl_ring = &ringacc->rings[fwd_id + ringacc->num_rings]; in k3_dmaring_request_dual_ring()
421 set_bit(fwd_id, ringacc->rings_inuse); in k3_dmaring_request_dual_ring()
422 ringacc->rings[fwd_id].use_count++; in k3_dmaring_request_dual_ring()
423 dev_dbg(ringacc->dev, "Giving ring#%d\n", fwd_id); in k3_dmaring_request_dual_ring()
425 mutex_unlock(&ringacc->req_lock); in k3_dmaring_request_dual_ring()
429 module_put(ringacc->dev->driver->owner); in k3_dmaring_request_dual_ring()
431 mutex_unlock(&ringacc->req_lock); in k3_dmaring_request_dual_ring()
435 int k3_ringacc_request_rings_pair(struct k3_ringacc *ringacc, in k3_ringacc_request_rings_pair() argument
445 if (ringacc->dma_rings) in k3_ringacc_request_rings_pair()
446 return k3_dmaring_request_dual_ring(ringacc, fwd_id, in k3_ringacc_request_rings_pair()
449 *fwd_ring = k3_ringacc_request_ring(ringacc, fwd_id, 0); in k3_ringacc_request_rings_pair()
453 *compl_ring = k3_ringacc_request_ring(ringacc, compl_id, 0); in k3_ringacc_request_rings_pair()
466 struct k3_ringacc *ringacc = ring->parent; in k3_ringacc_ring_reset_sci() local
469 ring_cfg.nav_id = ringacc->tisci_dev_id; in k3_ringacc_ring_reset_sci()
474 ret = ringacc->tisci_ring_ops->set_cfg(ringacc->tisci, &ring_cfg); in k3_ringacc_ring_reset_sci()
476 dev_err(ringacc->dev, "TISCI reset ring fail (%d) ring_idx %d\n", in k3_ringacc_ring_reset_sci()
495 struct k3_ringacc *ringacc = ring->parent; in k3_ringacc_ring_reconfig_qmode_sci() local
498 ring_cfg.nav_id = ringacc->tisci_dev_id; in k3_ringacc_ring_reconfig_qmode_sci()
503 ret = ringacc->tisci_ring_ops->set_cfg(ringacc->tisci, &ring_cfg); in k3_ringacc_ring_reconfig_qmode_sci()
505 dev_err(ringacc->dev, "TISCI reconf qmode fail (%d) ring_idx %d\n", in k3_ringacc_ring_reconfig_qmode_sci()
571 struct k3_ringacc *ringacc = ring->parent; in k3_ringacc_ring_free_sci() local
574 ring_cfg.nav_id = ringacc->tisci_dev_id; in k3_ringacc_ring_free_sci()
578 ret = ringacc->tisci_ring_ops->set_cfg(ringacc->tisci, &ring_cfg); in k3_ringacc_ring_free_sci()
580 dev_err(ringacc->dev, "TISCI ring free fail (%d) ring_idx %d\n", in k3_ringacc_ring_free_sci()
586 struct k3_ringacc *ringacc; in k3_ringacc_ring_free() local
591 ringacc = ring->parent; in k3_ringacc_ring_free()
597 if (ringacc->dma_rings && (ring->flags & K3_RING_FLAG_REVERSE)) in k3_ringacc_ring_free()
602 if (!test_bit(ring->ring_id, ringacc->rings_inuse)) in k3_ringacc_ring_free()
605 mutex_lock(&ringacc->req_lock); in k3_ringacc_ring_free()
624 clear_bit(ring->proxy_id, ringacc->proxy_inuse); in k3_ringacc_ring_free()
630 clear_bit(ring->ring_id, ringacc->rings_inuse); in k3_ringacc_ring_free()
632 module_put(ringacc->dev->driver->owner); in k3_ringacc_ring_free()
635 mutex_unlock(&ringacc->req_lock); in k3_ringacc_ring_free()
675 struct k3_ringacc *ringacc = ring->parent; in k3_ringacc_ring_cfg_sci() local
678 if (!ringacc->tisci) in k3_ringacc_ring_cfg_sci()
681 ring_cfg.nav_id = ringacc->tisci_dev_id; in k3_ringacc_ring_cfg_sci()
691 ret = ringacc->tisci_ring_ops->set_cfg(ringacc->tisci, &ring_cfg); in k3_ringacc_ring_cfg_sci()
693 dev_err(ringacc->dev, "TISCI config ring fail (%d) ring_idx %d\n", in k3_ringacc_ring_cfg_sci()
701 struct k3_ringacc *ringacc; in k3_dmaring_cfg() local
710 ringacc = ring->parent; in k3_dmaring_cfg()
716 if (ringacc->dma_rings && (ring->flags & K3_RING_FLAG_REVERSE)) in k3_dmaring_cfg()
719 if (!test_bit(ring->ring_id, ringacc->rings_inuse)) in k3_dmaring_cfg()
728 dev_warn(ringacc->dev, "dma_dev is not provided for ring%d\n", in k3_dmaring_cfg()
730 ring->dma_dev = ringacc->dev; in k3_dmaring_cfg()
741 dev_err(ringacc->dev, "Failed to alloc ring mem\n"); in k3_dmaring_cfg()
755 reverse_ring = &ringacc->rings[ring->ring_id + ringacc->num_rings]; in k3_dmaring_cfg()
785 struct k3_ringacc *ringacc; in k3_ringacc_ring_cfg() local
791 ringacc = ring->parent; in k3_ringacc_ring_cfg()
793 if (ringacc->dma_rings) in k3_ringacc_ring_cfg()
799 !test_bit(ring->ring_id, ringacc->rings_inuse)) in k3_ringacc_ring_cfg()
805 dev_err(ringacc->dev, in k3_ringacc_ring_cfg()
814 * ring = k3_ringacc_request_ring(ringacc, ring_id, 0); # master user in k3_ringacc_ring_cfg()
816 * k3_ringacc_request_ring(ringacc, ring_id, K3_RING_FLAG_SHARED); in k3_ringacc_ring_cfg()
817 * k3_ringacc_request_ring(ringacc, ring_id, K3_RING_FLAG_SHARED); in k3_ringacc_ring_cfg()
828 ring->proxy = ringacc->proxy_target_base + in k3_ringacc_ring_cfg()
836 ring->dma_dev = ringacc->dev; in k3_ringacc_ring_cfg()
839 ring->dma_dev = ringacc->dev; in k3_ringacc_ring_cfg()
855 dev_err(ringacc->dev, "Failed to alloc ring mem\n"); in k3_ringacc_ring_cfg()
1285 struct k3_ringacc *ringacc = ERR_PTR(-EPROBE_DEFER); in of_k3_ringacc_get_by_phandle() local
1295 ringacc = entry; in of_k3_ringacc_get_by_phandle()
1301 return ringacc; in of_k3_ringacc_get_by_phandle()
1305 static int k3_ringacc_probe_dt(struct k3_ringacc *ringacc) in k3_ringacc_probe_dt() argument
1307 struct device_node *node = ringacc->dev->of_node; in k3_ringacc_probe_dt()
1308 struct device *dev = ringacc->dev; in k3_ringacc_probe_dt()
1317 ret = of_property_read_u32(node, "ti,num-rings", &ringacc->num_rings); in k3_ringacc_probe_dt()
1323 ringacc->tisci = ti_sci_get_by_phandle(node, "ti,sci"); in k3_ringacc_probe_dt()
1324 if (IS_ERR(ringacc->tisci)) { in k3_ringacc_probe_dt()
1325 ret = PTR_ERR(ringacc->tisci); in k3_ringacc_probe_dt()
1328 ringacc->tisci = NULL; in k3_ringacc_probe_dt()
1333 &ringacc->tisci_dev_id); in k3_ringacc_probe_dt()
1339 pdev->id = ringacc->tisci_dev_id; in k3_ringacc_probe_dt()
1341 ringacc->rm_gp_range = devm_ti_sci_get_of_resource(ringacc->tisci, dev, in k3_ringacc_probe_dt()
1342 ringacc->tisci_dev_id, in k3_ringacc_probe_dt()
1344 if (IS_ERR(ringacc->rm_gp_range)) { in k3_ringacc_probe_dt()
1346 return PTR_ERR(ringacc->rm_gp_range); in k3_ringacc_probe_dt()
1349 return ti_sci_inta_msi_domain_alloc_irqs(ringacc->dev, in k3_ringacc_probe_dt()
1350 ringacc->rm_gp_range); in k3_ringacc_probe_dt()
1366 struct k3_ringacc *ringacc) in k3_ringacc_init() argument
1378 ret = k3_ringacc_probe_dt(ringacc); in k3_ringacc_init()
1386 ringacc->dma_ring_reset_quirk = soc_data->dma_ring_reset_quirk; in k3_ringacc_init()
1397 ringacc->proxy_gcfg = devm_platform_ioremap_resource_byname(pdev, "proxy_gcfg"); in k3_ringacc_init()
1398 if (IS_ERR(ringacc->proxy_gcfg)) in k3_ringacc_init()
1399 return PTR_ERR(ringacc->proxy_gcfg); in k3_ringacc_init()
1401 ringacc->proxy_target_base = devm_platform_ioremap_resource_byname(pdev, in k3_ringacc_init()
1403 if (IS_ERR(ringacc->proxy_target_base)) in k3_ringacc_init()
1404 return PTR_ERR(ringacc->proxy_target_base); in k3_ringacc_init()
1406 ringacc->num_proxies = readl(&ringacc->proxy_gcfg->config) & in k3_ringacc_init()
1409 ringacc->rings = devm_kzalloc(dev, in k3_ringacc_init()
1410 sizeof(*ringacc->rings) * in k3_ringacc_init()
1411 ringacc->num_rings, in k3_ringacc_init()
1413 ringacc->rings_inuse = devm_bitmap_zalloc(dev, ringacc->num_rings, in k3_ringacc_init()
1415 ringacc->proxy_inuse = devm_bitmap_zalloc(dev, ringacc->num_proxies, in k3_ringacc_init()
1418 if (!ringacc->rings || !ringacc->rings_inuse || !ringacc->proxy_inuse) in k3_ringacc_init()
1421 for (i = 0; i < ringacc->num_rings; i++) { in k3_ringacc_init()
1422 ringacc->rings[i].rt = base_rt + in k3_ringacc_init()
1424 ringacc->rings[i].fifos = base_fifo + in k3_ringacc_init()
1426 ringacc->rings[i].parent = ringacc; in k3_ringacc_init()
1427 ringacc->rings[i].ring_id = i; in k3_ringacc_init()
1428 ringacc->rings[i].proxy_id = K3_RINGACC_PROXY_NOT_USED; in k3_ringacc_init()
1431 ringacc->tisci_ring_ops = &ringacc->tisci->ops.rm_ring_ops; in k3_ringacc_init()
1434 ringacc->num_rings, in k3_ringacc_init()
1435 ringacc->rm_gp_range->desc[0].start, in k3_ringacc_init()
1436 ringacc->rm_gp_range->desc[0].num, in k3_ringacc_init()
1437 ringacc->tisci_dev_id); in k3_ringacc_init()
1439 ringacc->dma_ring_reset_quirk ? "enabled" : "disabled"); in k3_ringacc_init()
1441 readl(&ringacc->proxy_gcfg->revision), ringacc->num_proxies); in k3_ringacc_init()
1458 { .compatible = "ti,am654-navss-ringacc", .data = &k3_ringacc_data, },
1467 struct k3_ringacc *ringacc; in k3_ringacc_dmarings_init() local
1471 ringacc = devm_kzalloc(dev, sizeof(*ringacc), GFP_KERNEL); in k3_ringacc_dmarings_init()
1472 if (!ringacc) in k3_ringacc_dmarings_init()
1475 ringacc->dev = dev; in k3_ringacc_dmarings_init()
1476 ringacc->dma_rings = true; in k3_ringacc_dmarings_init()
1477 ringacc->num_rings = data->num_rings; in k3_ringacc_dmarings_init()
1478 ringacc->tisci = data->tisci; in k3_ringacc_dmarings_init()
1479 ringacc->tisci_dev_id = data->tisci_dev_id; in k3_ringacc_dmarings_init()
1481 mutex_init(&ringacc->req_lock); in k3_ringacc_dmarings_init()
1487 ringacc->rings = devm_kzalloc(dev, in k3_ringacc_dmarings_init()
1488 sizeof(*ringacc->rings) * in k3_ringacc_dmarings_init()
1489 ringacc->num_rings * 2, in k3_ringacc_dmarings_init()
1491 ringacc->rings_inuse = devm_bitmap_zalloc(dev, ringacc->num_rings, in k3_ringacc_dmarings_init()
1494 if (!ringacc->rings || !ringacc->rings_inuse) in k3_ringacc_dmarings_init()
1497 for (i = 0; i < ringacc->num_rings; i++) { in k3_ringacc_dmarings_init()
1498 struct k3_ring *ring = &ringacc->rings[i]; in k3_ringacc_dmarings_init()
1501 ring->parent = ringacc; in k3_ringacc_dmarings_init()
1505 ring = &ringacc->rings[ringacc->num_rings + i]; in k3_ringacc_dmarings_init()
1508 ring->parent = ringacc; in k3_ringacc_dmarings_init()
1514 ringacc->tisci_ring_ops = &ringacc->tisci->ops.rm_ring_ops; in k3_ringacc_dmarings_init()
1516 dev_info(dev, "Number of rings: %u\n", ringacc->num_rings); in k3_ringacc_dmarings_init()
1518 return ringacc; in k3_ringacc_dmarings_init()
1526 struct k3_ringacc *ringacc; in k3_ringacc_probe() local
1533 ringacc = devm_kzalloc(dev, sizeof(*ringacc), GFP_KERNEL); in k3_ringacc_probe()
1534 if (!ringacc) in k3_ringacc_probe()
1537 ringacc->dev = dev; in k3_ringacc_probe()
1538 mutex_init(&ringacc->req_lock); in k3_ringacc_probe()
1539 ringacc->ops = &match_data->ops; in k3_ringacc_probe()
1541 ret = ringacc->ops->init(pdev, ringacc); in k3_ringacc_probe()
1545 dev_set_drvdata(dev, ringacc); in k3_ringacc_probe()
1548 list_add_tail(&ringacc->list, &k3_ringacc_list); in k3_ringacc_probe()
1556 struct k3_ringacc *ringacc = dev_get_drvdata(&pdev->dev); in k3_ringacc_remove() local
1559 list_del(&ringacc->list); in k3_ringacc_remove()
1568 .name = "k3-ringacc",
1576 MODULE_DESCRIPTION("TI Ringacc driver for K3 SOCs");