Lines Matching full:ud
278 struct udma_dev *ud; member
400 static int navss_psil_pair(struct udma_dev *ud, u32 src_thread, u32 dst_thread) in navss_psil_pair() argument
402 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in navss_psil_pair()
410 static int navss_psil_unpair(struct udma_dev *ud, u32 src_thread, in navss_psil_unpair() argument
413 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in navss_psil_unpair()
468 struct device *dev = uc->ud->dev; in udma_dump_chan_stdata()
555 struct udma_dev *ud = container_of(work, typeof(*ud), purge_work); in udma_purge_desc_work() local
560 spin_lock_irqsave(&ud->lock, flags); in udma_purge_desc_work()
561 list_splice_tail_init(&ud->desc_to_purge, &head); in udma_purge_desc_work()
562 spin_unlock_irqrestore(&ud->lock, flags); in udma_purge_desc_work()
574 if (!list_empty(&ud->desc_to_purge)) in udma_purge_desc_work()
575 schedule_work(&ud->purge_work); in udma_purge_desc_work()
580 struct udma_dev *ud = to_udma_dev(vd->tx.chan->device); in udma_desc_free() local
594 spin_lock_irqsave(&ud->lock, flags); in udma_desc_free()
595 list_add_tail(&vd->node, &ud->desc_to_purge); in udma_desc_free()
596 spin_unlock_irqrestore(&ud->lock, flags); in udma_desc_free()
598 schedule_work(&ud->purge_work); in udma_desc_free()
646 return uc->ud->rx_flush.hwdescs[uc->config.pkt_mode].cppi5_desc_paddr; in udma_get_rx_flush_hwdesc_paddr()
825 uc->ud->ddev.device_free_chan_resources(&uc->vc.chan); in udma_reset_chan()
829 ret = uc->ud->ddev.device_alloc_chan_resources(&uc->vc.chan); in udma_reset_chan()
852 if (uc->ud->match_data->type == DMA_TYPE_UDMA && ucc->pkt_mode && in udma_start_desc()
914 uc->ud->match_data; in udma_start()
1160 dev_err(uc->ud->dev, "not matching descriptors!\n"); in udma_ring_irq_handler()
1220 * @ud: UDMA device
1234 static int __udma_alloc_gp_rflow_range(struct udma_dev *ud, int from, int cnt) in __udma_alloc_gp_rflow_range() argument
1241 tmp_from = ud->rchan_cnt; in __udma_alloc_gp_rflow_range()
1243 if (tmp_from < ud->rchan_cnt) in __udma_alloc_gp_rflow_range()
1246 if (tmp_from + cnt > ud->rflow_cnt) in __udma_alloc_gp_rflow_range()
1249 bitmap_or(tmp, ud->rflow_gp_map, ud->rflow_gp_map_allocated, in __udma_alloc_gp_rflow_range()
1250 ud->rflow_cnt); in __udma_alloc_gp_rflow_range()
1253 ud->rflow_cnt, in __udma_alloc_gp_rflow_range()
1255 if (start >= ud->rflow_cnt) in __udma_alloc_gp_rflow_range()
1261 bitmap_set(ud->rflow_gp_map_allocated, start, cnt); in __udma_alloc_gp_rflow_range()
1265 static int __udma_free_gp_rflow_range(struct udma_dev *ud, int from, int cnt) in __udma_free_gp_rflow_range() argument
1267 if (from < ud->rchan_cnt) in __udma_free_gp_rflow_range()
1269 if (from + cnt > ud->rflow_cnt) in __udma_free_gp_rflow_range()
1272 bitmap_clear(ud->rflow_gp_map_allocated, from, cnt); in __udma_free_gp_rflow_range()
1276 static struct udma_rflow *__udma_get_rflow(struct udma_dev *ud, int id) in __udma_get_rflow() argument
1285 if (id < 0 || id >= ud->rflow_cnt) in __udma_get_rflow()
1288 if (test_bit(id, ud->rflow_in_use)) in __udma_get_rflow()
1291 if (ud->rflow_gp_map) { in __udma_get_rflow()
1293 if (!test_bit(id, ud->rflow_gp_map) && in __udma_get_rflow()
1294 !test_bit(id, ud->rflow_gp_map_allocated)) in __udma_get_rflow()
1298 dev_dbg(ud->dev, "get rflow%d\n", id); in __udma_get_rflow()
1299 set_bit(id, ud->rflow_in_use); in __udma_get_rflow()
1300 return &ud->rflows[id]; in __udma_get_rflow()
1303 static void __udma_put_rflow(struct udma_dev *ud, struct udma_rflow *rflow) in __udma_put_rflow() argument
1305 if (!test_bit(rflow->id, ud->rflow_in_use)) { in __udma_put_rflow()
1306 dev_err(ud->dev, "attempt to put unused rflow%d\n", rflow->id); in __udma_put_rflow()
1310 dev_dbg(ud->dev, "put rflow%d\n", rflow->id); in __udma_put_rflow()
1311 clear_bit(rflow->id, ud->rflow_in_use); in __udma_put_rflow()
1315 static struct udma_##res *__udma_reserve_##res(struct udma_dev *ud, \
1320 if (test_bit(id, ud->res##_map)) { \
1321 dev_err(ud->dev, "res##%d is in use\n", id); \
1327 if (tpl >= ud->res##_tpl.levels) \
1328 tpl = ud->res##_tpl.levels - 1; \
1330 start = ud->res##_tpl.start_idx[tpl]; \
1332 id = find_next_zero_bit(ud->res##_map, ud->res##_cnt, \
1334 if (id == ud->res##_cnt) { \
1339 set_bit(id, ud->res##_map); \
1340 return &ud->res##s[id]; \
1349 struct udma_dev *ud = uc->ud; in bcdma_get_bchan() local
1353 dev_dbg(ud->dev, "chan%d: already have bchan%d allocated\n", in bcdma_get_bchan()
1365 tpl = ud->bchan_tpl.levels - 1; in bcdma_get_bchan()
1367 uc->bchan = __udma_reserve_bchan(ud, tpl, -1); in bcdma_get_bchan()
1378 struct udma_dev *ud = uc->ud; in udma_get_tchan() local
1381 dev_dbg(ud->dev, "chan%d: already have tchan%d allocated\n", in udma_get_tchan()
1391 uc->tchan = __udma_reserve_tchan(ud, uc->config.channel_tpl, in udma_get_tchan()
1396 if (ud->tflow_cnt) { in udma_get_tchan()
1405 if (test_bit(tflow_id, ud->tflow_map)) { in udma_get_tchan()
1406 dev_err(ud->dev, "tflow%d is in use\n", tflow_id); in udma_get_tchan()
1407 clear_bit(uc->tchan->id, ud->tchan_map); in udma_get_tchan()
1413 set_bit(tflow_id, ud->tflow_map); in udma_get_tchan()
1423 struct udma_dev *ud = uc->ud; in udma_get_rchan() local
1426 dev_dbg(ud->dev, "chan%d: already have rchan%d allocated\n", in udma_get_rchan()
1436 uc->rchan = __udma_reserve_rchan(ud, uc->config.channel_tpl, in udma_get_rchan()
1444 struct udma_dev *ud = uc->ud; in udma_get_chan_pair() local
1448 dev_info(ud->dev, "chan%d: already have %d pair allocated\n", in udma_get_chan_pair()
1454 dev_err(ud->dev, "chan%d: already have tchan%d allocated\n", in udma_get_chan_pair()
1458 dev_err(ud->dev, "chan%d: already have rchan%d allocated\n", in udma_get_chan_pair()
1464 end = min(ud->tchan_cnt, ud->rchan_cnt); in udma_get_chan_pair()
1469 chan_id = ud->tchan_tpl.start_idx[ud->tchan_tpl.levels - 1]; in udma_get_chan_pair()
1471 if (!test_bit(chan_id, ud->tchan_map) && in udma_get_chan_pair()
1472 !test_bit(chan_id, ud->rchan_map)) in udma_get_chan_pair()
1479 set_bit(chan_id, ud->tchan_map); in udma_get_chan_pair()
1480 set_bit(chan_id, ud->rchan_map); in udma_get_chan_pair()
1481 uc->tchan = &ud->tchans[chan_id]; in udma_get_chan_pair()
1482 uc->rchan = &ud->rchans[chan_id]; in udma_get_chan_pair()
1492 struct udma_dev *ud = uc->ud; in udma_get_rflow() local
1495 dev_err(ud->dev, "chan%d: does not have rchan??\n", uc->id); in udma_get_rflow()
1500 dev_dbg(ud->dev, "chan%d: already have rflow%d allocated\n", in udma_get_rflow()
1505 uc->rflow = __udma_get_rflow(ud, flow_id); in udma_get_rflow()
1512 struct udma_dev *ud = uc->ud; in bcdma_put_bchan() local
1515 dev_dbg(ud->dev, "chan%d: put bchan%d\n", uc->id, in bcdma_put_bchan()
1517 clear_bit(uc->bchan->id, ud->bchan_map); in bcdma_put_bchan()
1525 struct udma_dev *ud = uc->ud; in udma_put_rchan() local
1528 dev_dbg(ud->dev, "chan%d: put rchan%d\n", uc->id, in udma_put_rchan()
1530 clear_bit(uc->rchan->id, ud->rchan_map); in udma_put_rchan()
1537 struct udma_dev *ud = uc->ud; in udma_put_tchan() local
1540 dev_dbg(ud->dev, "chan%d: put tchan%d\n", uc->id, in udma_put_tchan()
1542 clear_bit(uc->tchan->id, ud->tchan_map); in udma_put_tchan()
1545 clear_bit(uc->tchan->tflow_id, ud->tflow_map); in udma_put_tchan()
1553 struct udma_dev *ud = uc->ud; in udma_put_rflow() local
1556 dev_dbg(ud->dev, "chan%d: put rflow%d\n", uc->id, in udma_put_rflow()
1558 __udma_put_rflow(ud, uc->rflow); in udma_put_rflow()
1580 struct udma_dev *ud = uc->ud; in bcdma_alloc_bchan_resources() local
1587 ret = k3_ringacc_request_rings_pair(ud->ringacc, uc->bchan->id, -1, in bcdma_alloc_bchan_resources()
1600 k3_configure_chan_coherency(&uc->vc.chan, ud->asel); in bcdma_alloc_bchan_resources()
1601 ring_cfg.asel = ud->asel; in bcdma_alloc_bchan_resources()
1638 struct udma_dev *ud = uc->ud; in udma_alloc_tx_resources() local
1650 ring_idx = ud->bchan_cnt + tchan->id; in udma_alloc_tx_resources()
1652 ret = k3_ringacc_request_rings_pair(ud->ringacc, ring_idx, -1, in udma_alloc_tx_resources()
1663 if (ud->match_data->type == DMA_TYPE_UDMA) { in udma_alloc_tx_resources()
1713 struct udma_dev *ud = uc->ud; in udma_alloc_rx_resources() local
1738 if (ud->tflow_cnt) in udma_alloc_rx_resources()
1739 fd_ring_id = ud->tflow_cnt + rflow->id; in udma_alloc_rx_resources()
1741 fd_ring_id = ud->bchan_cnt + ud->tchan_cnt + ud->echan_cnt + in udma_alloc_rx_resources()
1744 ret = k3_ringacc_request_rings_pair(ud->ringacc, fd_ring_id, -1, in udma_alloc_rx_resources()
1754 if (ud->match_data->type == DMA_TYPE_UDMA) { in udma_alloc_rx_resources()
1827 struct udma_dev *ud = uc->ud; in udma_tisci_m2m_channel_config() local
1828 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in udma_tisci_m2m_channel_config()
1841 if (ud->match_data->flags & UDMA_FLAG_BURST_SIZE) { in udma_tisci_m2m_channel_config()
1842 tpl = udma_get_chan_tpl_index(&ud->tchan_tpl, tchan->id); in udma_tisci_m2m_channel_config()
1844 burst_size = ud->match_data->burst_size[tpl]; in udma_tisci_m2m_channel_config()
1853 req_tx.tx_atype = ud->atype; in udma_tisci_m2m_channel_config()
1861 dev_err(ud->dev, "tchan%d cfg failed %d\n", tchan->id, ret); in udma_tisci_m2m_channel_config()
1871 req_rx.rx_atype = ud->atype; in udma_tisci_m2m_channel_config()
1879 dev_err(ud->dev, "rchan%d alloc failed %d\n", rchan->id, ret); in udma_tisci_m2m_channel_config()
1886 struct udma_dev *ud = uc->ud; in bcdma_tisci_m2m_channel_config() local
1887 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in bcdma_tisci_m2m_channel_config()
1895 if (ud->match_data->flags & UDMA_FLAG_BURST_SIZE) { in bcdma_tisci_m2m_channel_config()
1896 tpl = udma_get_chan_tpl_index(&ud->bchan_tpl, bchan->id); in bcdma_tisci_m2m_channel_config()
1898 burst_size = ud->match_data->burst_size[tpl]; in bcdma_tisci_m2m_channel_config()
1912 dev_err(ud->dev, "bchan%d cfg failed %d\n", bchan->id, ret); in bcdma_tisci_m2m_channel_config()
1919 struct udma_dev *ud = uc->ud; in udma_tisci_tx_channel_config() local
1920 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in udma_tisci_tx_channel_config()
1946 ud->match_data->flags & UDMA_FLAG_TDTYPE) { in udma_tisci_tx_channel_config()
1955 dev_err(ud->dev, "tchan%d cfg failed %d\n", tchan->id, ret); in udma_tisci_tx_channel_config()
1962 struct udma_dev *ud = uc->ud; in bcdma_tisci_tx_channel_config() local
1963 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in bcdma_tisci_tx_channel_config()
1973 if (ud->match_data->flags & UDMA_FLAG_TDTYPE) { in bcdma_tisci_tx_channel_config()
1982 dev_err(ud->dev, "tchan%d cfg failed %d\n", tchan->id, ret); in bcdma_tisci_tx_channel_config()
1991 struct udma_dev *ud = uc->ud; in udma_tisci_rx_channel_config() local
1992 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in udma_tisci_rx_channel_config()
2021 dev_err(ud->dev, "rchan%d cfg failed %d\n", rchan->id, ret); in udma_tisci_rx_channel_config()
2065 dev_err(ud->dev, "flow%d config failed: %d\n", rchan->id, ret); in udma_tisci_rx_channel_config()
2072 struct udma_dev *ud = uc->ud; in bcdma_tisci_rx_channel_config() local
2073 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in bcdma_tisci_rx_channel_config()
2085 dev_err(ud->dev, "rchan%d cfg failed %d\n", rchan->id, ret); in bcdma_tisci_rx_channel_config()
2092 struct udma_dev *ud = uc->ud; in pktdma_tisci_rx_channel_config() local
2093 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in pktdma_tisci_rx_channel_config()
2105 dev_err(ud->dev, "rchan%d cfg failed %d\n", uc->rchan->id, ret); in pktdma_tisci_rx_channel_config()
2130 dev_err(ud->dev, "flow%d config failed: %d\n", uc->rflow->id, in pktdma_tisci_rx_channel_config()
2139 struct udma_dev *ud = to_udma_dev(chan->device); in udma_alloc_chan_resources() local
2140 const struct udma_soc_data *soc_data = ud->soc_data; in udma_alloc_chan_resources()
2145 uc->dma_dev = ud->dev; in udma_alloc_chan_resources()
2158 uc->hdesc_pool = dma_pool_create(uc->name, ud->ddev.dev, in udma_alloc_chan_resources()
2160 ud->desc_align, in udma_alloc_chan_resources()
2163 dev_err(ud->ddev.dev, in udma_alloc_chan_resources()
2182 dev_dbg(uc->ud->dev, "%s: chan%d as MEM-to-MEM\n", __func__, in udma_alloc_chan_resources()
2201 uc->config.src_thread = ud->psil_base + uc->tchan->id; in udma_alloc_chan_resources()
2202 uc->config.dst_thread = (ud->psil_base + uc->rchan->id) | in udma_alloc_chan_resources()
2212 dev_dbg(uc->ud->dev, "%s: chan%d as MEM-to-DEV\n", __func__, in udma_alloc_chan_resources()
2219 uc->config.src_thread = ud->psil_base + uc->tchan->id; in udma_alloc_chan_resources()
2230 dev_dbg(uc->ud->dev, "%s: chan%d as DEV-to-MEM\n", __func__, in udma_alloc_chan_resources()
2238 uc->config.dst_thread = (ud->psil_base + uc->rchan->id) | in udma_alloc_chan_resources()
2248 dev_err(uc->ud->dev, "%s: chan%d invalid direction (%u)\n", in udma_alloc_chan_resources()
2260 dev_warn(ud->dev, "chan%d: is running!\n", uc->id); in udma_alloc_chan_resources()
2263 dev_err(ud->dev, "chan%d: won't stop!\n", uc->id); in udma_alloc_chan_resources()
2270 ret = navss_psil_pair(ud, uc->config.src_thread, uc->config.dst_thread); in udma_alloc_chan_resources()
2272 dev_err(ud->dev, "PSI-L pairing failed: 0x%04x -> 0x%04x\n", in udma_alloc_chan_resources()
2281 dev_err(ud->dev, "Failed to get ring irq (index: %u)\n", in udma_alloc_chan_resources()
2290 dev_err(ud->dev, "chan%d: ring irq request failed\n", uc->id); in udma_alloc_chan_resources()
2296 uc->irq_num_udma = ti_sci_inta_msi_get_virq(ud->dev, in udma_alloc_chan_resources()
2299 dev_err(ud->dev, "Failed to get udma irq (index: %u)\n", in udma_alloc_chan_resources()
2309 dev_err(ud->dev, "chan%d: UDMA irq request failed\n", in udma_alloc_chan_resources()
2326 navss_psil_unpair(ud, uc->config.src_thread, uc->config.dst_thread); in udma_alloc_chan_resources()
2345 struct udma_dev *ud = to_udma_dev(chan->device); in bcdma_alloc_chan_resources() local
2346 const struct udma_oes_offsets *oes = &ud->soc_data->oes; in bcdma_alloc_chan_resources()
2364 dev_dbg(uc->ud->dev, "%s: chan%d as MEM-to-MEM\n", __func__, in bcdma_alloc_chan_resources()
2378 dev_dbg(uc->ud->dev, "%s: chan%d as MEM-to-DEV\n", __func__, in bcdma_alloc_chan_resources()
2387 uc->config.src_thread = ud->psil_base + uc->tchan->id; in bcdma_alloc_chan_resources()
2398 dev_dbg(uc->ud->dev, "%s: chan%d as DEV-to-MEM\n", __func__, in bcdma_alloc_chan_resources()
2408 uc->config.dst_thread = (ud->psil_base + uc->rchan->id) | in bcdma_alloc_chan_resources()
2418 dev_err(uc->ud->dev, "%s: chan%d invalid direction (%u)\n", in bcdma_alloc_chan_resources()
2428 dev_warn(ud->dev, "chan%d: is running!\n", uc->id); in bcdma_alloc_chan_resources()
2431 dev_err(ud->dev, "chan%d: won't stop!\n", uc->id); in bcdma_alloc_chan_resources()
2442 uc->hdesc_pool = dma_pool_create(uc->name, ud->ddev.dev, in bcdma_alloc_chan_resources()
2444 ud->desc_align, in bcdma_alloc_chan_resources()
2447 dev_err(ud->ddev.dev, in bcdma_alloc_chan_resources()
2457 ret = navss_psil_pair(ud, uc->config.src_thread, in bcdma_alloc_chan_resources()
2460 dev_err(ud->dev, in bcdma_alloc_chan_resources()
2469 uc->irq_num_ring = ti_sci_inta_msi_get_virq(ud->dev, irq_ring_idx); in bcdma_alloc_chan_resources()
2471 dev_err(ud->dev, "Failed to get ring irq (index: %u)\n", in bcdma_alloc_chan_resources()
2480 dev_err(ud->dev, "chan%d: ring irq request failed\n", uc->id); in bcdma_alloc_chan_resources()
2486 uc->irq_num_udma = ti_sci_inta_msi_get_virq(ud->dev, in bcdma_alloc_chan_resources()
2489 dev_err(ud->dev, "Failed to get bcdma irq (index: %u)\n", in bcdma_alloc_chan_resources()
2499 dev_err(ud->dev, "chan%d: BCDMA irq request failed\n", in bcdma_alloc_chan_resources()
2519 navss_psil_unpair(ud, uc->config.src_thread, in bcdma_alloc_chan_resources()
2549 trigger_event = uc->ud->soc_data->bcdma_trigger_event_offset; in bcdma_router_config()
2558 struct udma_dev *ud = to_udma_dev(chan->device); in pktdma_alloc_chan_resources() local
2559 const struct udma_oes_offsets *oes = &ud->soc_data->oes; in pktdma_alloc_chan_resources()
2574 dev_dbg(uc->ud->dev, "%s: chan%d as MEM-to-DEV\n", __func__, in pktdma_alloc_chan_resources()
2583 uc->config.src_thread = ud->psil_base + uc->tchan->id; in pktdma_alloc_chan_resources()
2593 dev_dbg(uc->ud->dev, "%s: chan%d as DEV-to-MEM\n", __func__, in pktdma_alloc_chan_resources()
2603 uc->config.dst_thread = (ud->psil_base + uc->rchan->id) | in pktdma_alloc_chan_resources()
2612 dev_err(uc->ud->dev, "%s: chan%d invalid direction (%u)\n", in pktdma_alloc_chan_resources()
2622 dev_warn(ud->dev, "chan%d: is running!\n", uc->id); in pktdma_alloc_chan_resources()
2625 dev_err(ud->dev, "chan%d: won't stop!\n", uc->id); in pktdma_alloc_chan_resources()
2633 uc->config.hdesc_size, ud->desc_align, in pktdma_alloc_chan_resources()
2636 dev_err(ud->ddev.dev, in pktdma_alloc_chan_resources()
2646 ret = navss_psil_pair(ud, uc->config.src_thread, uc->config.dst_thread); in pktdma_alloc_chan_resources()
2648 dev_err(ud->dev, "PSI-L pairing failed: 0x%04x -> 0x%04x\n", in pktdma_alloc_chan_resources()
2655 uc->irq_num_ring = ti_sci_inta_msi_get_virq(ud->dev, irq_ring_idx); in pktdma_alloc_chan_resources()
2657 dev_err(ud->dev, "Failed to get ring irq (index: %u)\n", in pktdma_alloc_chan_resources()
2666 dev_err(ud->dev, "chan%d: ring irq request failed\n", uc->id); in pktdma_alloc_chan_resources()
2678 dev_dbg(ud->dev, in pktdma_alloc_chan_resources()
2683 dev_dbg(ud->dev, in pktdma_alloc_chan_resources()
2692 navss_psil_unpair(ud, uc->config.src_thread, uc->config.dst_thread); in pktdma_alloc_chan_resources()
2733 dev_err(uc->ud->dev, "Unsupported TR size of %zu\n", tr_size); in udma_alloc_tr_desc()
2757 uc->ud->desc_align); in udma_alloc_tr_desc()
2758 hwdesc->cppi5_desc_vaddr = dma_alloc_coherent(uc->ud->dev, in udma_alloc_tr_desc()
2868 if (uc->ud->match_data->type == DMA_TYPE_UDMA) in udma_prep_slave_sg_tr()
2880 dev_err(uc->ud->dev, "size %u is not supported\n", in udma_prep_slave_sg_tr()
2951 dev_err(uc->ud->dev, "%s: bad direction?\n", __func__); in udma_prep_slave_sg_triggered_tr()
2960 dev_err(uc->ud->dev, in udma_prep_slave_sg_triggered_tr()
2978 dev_err(uc->ud->dev, in udma_prep_slave_sg_triggered_tr()
2998 if (uc->ud->match_data->type == DMA_TYPE_UDMA) { in udma_prep_slave_sg_triggered_tr()
3014 dev_err(uc->ud->dev, "size %zu is not supported\n", in udma_prep_slave_sg_triggered_tr()
3165 d->static_tr.bstcnt > uc->ud->match_data->statictr_z_mask) in udma_configure_statictr()
3198 if (uc->ud->match_data->type == DMA_TYPE_UDMA) in udma_prep_slave_sg_pkt()
3213 dev_err(uc->ud->dev, in udma_prep_slave_sg_pkt()
3245 if (uc->ud->match_data->type == DMA_TYPE_PKTDMA || in udma_prep_slave_sg_pkt()
3251 dev_err(uc->ud->dev, in udma_prep_slave_sg_pkt()
3412 dev_err(uc->ud->dev, in udma_prep_slave_sg()
3443 dev_err(uc->ud->dev, "size %zu is not supported\n", in udma_prep_dma_cyclic_tr()
3455 if (uc->ud->match_data->type == DMA_TYPE_UDMA) in udma_prep_dma_cyclic_tr()
3525 if (uc->ud->match_data->type != DMA_TYPE_UDMA) in udma_prep_dma_cyclic_pkt()
3537 dev_err(uc->ud->dev, in udma_prep_dma_cyclic_pkt()
3593 dev_err(uc->ud->dev, "%s: bad direction?\n", __func__); in udma_prep_dma_cyclic()
3617 dev_err(uc->ud->dev, in udma_prep_dma_cyclic()
3655 dev_err(uc->ud->dev, "size %zu is not supported\n", in udma_prep_dma_memcpy()
3669 if (uc->ud->match_data->type != DMA_TYPE_UDMA) { in udma_prep_dma_memcpy()
3670 src |= (u64)uc->ud->asel << K3_ADDRESS_ASEL_SHIFT; in udma_prep_dma_memcpy()
3671 dest |= (u64)uc->ud->asel << K3_ADDRESS_ASEL_SHIFT; in udma_prep_dma_memcpy()
3909 dev_warn(uc->ud->dev, "chan%d teardown timeout!\n", in udma_synchronize()
3918 dev_warn(uc->ud->dev, "chan%d refused to stop!\n", uc->id); in udma_synchronize()
4000 struct udma_dev *ud = to_udma_dev(chan->device); in udma_free_chan_resources() local
4023 navss_psil_unpair(ud, uc->config.src_thread, in udma_free_chan_resources()
4059 struct udma_dev *ud; in udma_dma_filter_fn() local
4068 ud = uc->ud; in udma_dma_filter_fn()
4072 dev_err(ud->dev, "Invalid channel atype: %u\n", in udma_dma_filter_fn()
4078 dev_err(ud->dev, "Invalid channel asel: %u\n", in udma_dma_filter_fn()
4099 dev_err(ud->dev, "No configuration for psi-l thread 0x%04x\n", in udma_dma_filter_fn()
4108 if (ud->match_data->type == DMA_TYPE_BCDMA && in udma_dma_filter_fn()
4110 dev_err(ud->dev, in udma_dma_filter_fn()
4125 if (ud->match_data->type == DMA_TYPE_PKTDMA && in udma_dma_filter_fn()
4135 const struct udma_match_data *match_data = ud->match_data; in udma_dma_filter_fn()
4151 ucc->metadata_size, ud->desc_align); in udma_dma_filter_fn()
4153 dev_dbg(ud->dev, "chan%d: Remote thread: 0x%04x (%s)\n", uc->id, in udma_dma_filter_fn()
4159 dev_dbg(ud->dev, "chan%d: triggered channel (type: %u)\n", uc->id, in udma_dma_filter_fn()
4169 struct udma_dev *ud = ofdma->of_dma_data; in udma_of_xlate() local
4170 dma_cap_mask_t mask = ud->ddev.cap_mask; in udma_of_xlate()
4174 if (ud->match_data->type == DMA_TYPE_BCDMA) { in udma_of_xlate()
4189 if (ud->match_data->type == DMA_TYPE_UDMA) { in udma_of_xlate()
4205 dev_err(ud->dev, "get channel fail in %s.\n", __func__); in udma_of_xlate()
4362 static int udma_get_mmrs(struct platform_device *pdev, struct udma_dev *ud) in udma_get_mmrs() argument
4367 ud->mmrs[MMR_GCFG] = devm_platform_ioremap_resource_byname(pdev, mmr_names[MMR_GCFG]); in udma_get_mmrs()
4368 if (IS_ERR(ud->mmrs[MMR_GCFG])) in udma_get_mmrs()
4369 return PTR_ERR(ud->mmrs[MMR_GCFG]); in udma_get_mmrs()
4371 cap2 = udma_read(ud->mmrs[MMR_GCFG], 0x28); in udma_get_mmrs()
4372 cap3 = udma_read(ud->mmrs[MMR_GCFG], 0x2c); in udma_get_mmrs()
4374 switch (ud->match_data->type) { in udma_get_mmrs()
4376 ud->rflow_cnt = UDMA_CAP3_RFLOW_CNT(cap3); in udma_get_mmrs()
4377 ud->tchan_cnt = UDMA_CAP2_TCHAN_CNT(cap2); in udma_get_mmrs()
4378 ud->echan_cnt = UDMA_CAP2_ECHAN_CNT(cap2); in udma_get_mmrs()
4379 ud->rchan_cnt = UDMA_CAP2_RCHAN_CNT(cap2); in udma_get_mmrs()
4382 ud->bchan_cnt = BCDMA_CAP2_BCHAN_CNT(cap2); in udma_get_mmrs()
4383 ud->tchan_cnt = BCDMA_CAP2_TCHAN_CNT(cap2); in udma_get_mmrs()
4384 ud->rchan_cnt = BCDMA_CAP2_RCHAN_CNT(cap2); in udma_get_mmrs()
4385 ud->rflow_cnt = ud->rchan_cnt; in udma_get_mmrs()
4388 cap4 = udma_read(ud->mmrs[MMR_GCFG], 0x30); in udma_get_mmrs()
4389 ud->tchan_cnt = UDMA_CAP2_TCHAN_CNT(cap2); in udma_get_mmrs()
4390 ud->rchan_cnt = UDMA_CAP2_RCHAN_CNT(cap2); in udma_get_mmrs()
4391 ud->rflow_cnt = UDMA_CAP3_RFLOW_CNT(cap3); in udma_get_mmrs()
4392 ud->tflow_cnt = PKTDMA_CAP4_TFLOW_CNT(cap4); in udma_get_mmrs()
4399 if (i == MMR_BCHANRT && ud->bchan_cnt == 0) in udma_get_mmrs()
4401 if (i == MMR_TCHANRT && ud->tchan_cnt == 0) in udma_get_mmrs()
4403 if (i == MMR_RCHANRT && ud->rchan_cnt == 0) in udma_get_mmrs()
4406 ud->mmrs[i] = devm_platform_ioremap_resource_byname(pdev, mmr_names[i]); in udma_get_mmrs()
4407 if (IS_ERR(ud->mmrs[i])) in udma_get_mmrs()
4408 return PTR_ERR(ud->mmrs[i]); in udma_get_mmrs()
4414 static void udma_mark_resource_ranges(struct udma_dev *ud, unsigned long *map, in udma_mark_resource_ranges() argument
4420 dev_dbg(ud->dev, "ti_sci resource range for %s: %d:%d | %d:%d\n", name, in udma_mark_resource_ranges()
4433 static int udma_setup_resources(struct udma_dev *ud) in udma_setup_resources() argument
4436 struct device *dev = ud->dev; in udma_setup_resources()
4438 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in udma_setup_resources()
4442 cap3 = udma_read(ud->mmrs[MMR_GCFG], 0x2c); in udma_setup_resources()
4445 ud->tchan_tpl.levels = 2; in udma_setup_resources()
4446 ud->tchan_tpl.start_idx[0] = 8; in udma_setup_resources()
4449 ud->tchan_tpl.levels = 2; in udma_setup_resources()
4450 ud->tchan_tpl.start_idx[0] = 2; in udma_setup_resources()
4452 ud->tchan_tpl.levels = 3; in udma_setup_resources()
4453 ud->tchan_tpl.start_idx[1] = UDMA_CAP3_UCHAN_CNT(cap3); in udma_setup_resources()
4454 ud->tchan_tpl.start_idx[0] = UDMA_CAP3_HCHAN_CNT(cap3); in udma_setup_resources()
4456 ud->tchan_tpl.levels = 2; in udma_setup_resources()
4457 ud->tchan_tpl.start_idx[0] = UDMA_CAP3_HCHAN_CNT(cap3); in udma_setup_resources()
4459 ud->tchan_tpl.levels = 1; in udma_setup_resources()
4462 ud->rchan_tpl.levels = ud->tchan_tpl.levels; in udma_setup_resources()
4463 ud->rchan_tpl.start_idx[0] = ud->tchan_tpl.start_idx[0]; in udma_setup_resources()
4464 ud->rchan_tpl.start_idx[1] = ud->tchan_tpl.start_idx[1]; in udma_setup_resources()
4466 ud->tchan_map = devm_kmalloc_array(dev, BITS_TO_LONGS(ud->tchan_cnt), in udma_setup_resources()
4468 ud->tchans = devm_kcalloc(dev, ud->tchan_cnt, sizeof(*ud->tchans), in udma_setup_resources()
4470 ud->rchan_map = devm_kmalloc_array(dev, BITS_TO_LONGS(ud->rchan_cnt), in udma_setup_resources()
4472 ud->rchans = devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rchans), in udma_setup_resources()
4474 ud->rflow_gp_map = devm_kmalloc_array(dev, BITS_TO_LONGS(ud->rflow_cnt), in udma_setup_resources()
4477 ud->rflow_gp_map_allocated = devm_kcalloc(dev, in udma_setup_resources()
4478 BITS_TO_LONGS(ud->rflow_cnt), in udma_setup_resources()
4481 ud->rflow_in_use = devm_kcalloc(dev, BITS_TO_LONGS(ud->rflow_cnt), in udma_setup_resources()
4484 ud->rflows = devm_kcalloc(dev, ud->rflow_cnt, sizeof(*ud->rflows), in udma_setup_resources()
4487 if (!ud->tchan_map || !ud->rchan_map || !ud->rflow_gp_map || in udma_setup_resources()
4488 !ud->rflow_gp_map_allocated || !ud->tchans || !ud->rchans || in udma_setup_resources()
4489 !ud->rflows || !ud->rflow_in_use) in udma_setup_resources()
4497 bitmap_set(ud->rflow_gp_map_allocated, 0, ud->rchan_cnt); in udma_setup_resources()
4500 bitmap_set(ud->rflow_gp_map, 0, ud->rflow_cnt); in udma_setup_resources()
4516 bitmap_zero(ud->tchan_map, ud->tchan_cnt); in udma_setup_resources()
4518 bitmap_fill(ud->tchan_map, ud->tchan_cnt); in udma_setup_resources()
4520 udma_mark_resource_ranges(ud, ud->tchan_map, in udma_setup_resources()
4528 bitmap_zero(ud->rchan_map, ud->rchan_cnt); in udma_setup_resources()
4530 bitmap_fill(ud->rchan_map, ud->rchan_cnt); in udma_setup_resources()
4532 udma_mark_resource_ranges(ud, ud->rchan_map, in udma_setup_resources()
4549 ud->soc_data->oes.udma_rchan; in udma_setup_resources()
4554 ud->soc_data->oes.udma_rchan; in udma_setup_resources()
4558 ret = ti_sci_inta_msi_domain_alloc_irqs(ud->dev, &irq_res); in udma_setup_resources()
4561 dev_err(ud->dev, "Failed to allocate MSI interrupts\n"); in udma_setup_resources()
4569 bitmap_clear(ud->rflow_gp_map, ud->rchan_cnt, in udma_setup_resources()
4570 ud->rflow_cnt - ud->rchan_cnt); in udma_setup_resources()
4573 udma_mark_resource_ranges(ud, ud->rflow_gp_map, in udma_setup_resources()
4580 static int bcdma_setup_resources(struct udma_dev *ud) in bcdma_setup_resources() argument
4583 struct device *dev = ud->dev; in bcdma_setup_resources()
4585 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in bcdma_setup_resources()
4586 const struct udma_oes_offsets *oes = &ud->soc_data->oes; in bcdma_setup_resources()
4590 cap = udma_read(ud->mmrs[MMR_GCFG], 0x2c); in bcdma_setup_resources()
4592 ud->bchan_tpl.levels = 3; in bcdma_setup_resources()
4593 ud->bchan_tpl.start_idx[1] = BCDMA_CAP3_UBCHAN_CNT(cap); in bcdma_setup_resources()
4594 ud->bchan_tpl.start_idx[0] = BCDMA_CAP3_HBCHAN_CNT(cap); in bcdma_setup_resources()
4596 ud->bchan_tpl.levels = 2; in bcdma_setup_resources()
4597 ud->bchan_tpl.start_idx[0] = BCDMA_CAP3_HBCHAN_CNT(cap); in bcdma_setup_resources()
4599 ud->bchan_tpl.levels = 1; in bcdma_setup_resources()
4602 cap = udma_read(ud->mmrs[MMR_GCFG], 0x30); in bcdma_setup_resources()
4604 ud->rchan_tpl.levels = 3; in bcdma_setup_resources()
4605 ud->rchan_tpl.start_idx[1] = BCDMA_CAP4_URCHAN_CNT(cap); in bcdma_setup_resources()
4606 ud->rchan_tpl.start_idx[0] = BCDMA_CAP4_HRCHAN_CNT(cap); in bcdma_setup_resources()
4608 ud->rchan_tpl.levels = 2; in bcdma_setup_resources()
4609 ud->rchan_tpl.start_idx[0] = BCDMA_CAP4_HRCHAN_CNT(cap); in bcdma_setup_resources()
4611 ud->rchan_tpl.levels = 1; in bcdma_setup_resources()
4615 ud->tchan_tpl.levels = 3; in bcdma_setup_resources()
4616 ud->tchan_tpl.start_idx[1] = BCDMA_CAP4_UTCHAN_CNT(cap); in bcdma_setup_resources()
4617 ud->tchan_tpl.start_idx[0] = BCDMA_CAP4_HTCHAN_CNT(cap); in bcdma_setup_resources()
4619 ud->tchan_tpl.levels = 2; in bcdma_setup_resources()
4620 ud->tchan_tpl.start_idx[0] = BCDMA_CAP4_HTCHAN_CNT(cap); in bcdma_setup_resources()
4622 ud->tchan_tpl.levels = 1; in bcdma_setup_resources()
4625 ud->bchan_map = devm_kmalloc_array(dev, BITS_TO_LONGS(ud->bchan_cnt), in bcdma_setup_resources()
4627 ud->bchans = devm_kcalloc(dev, ud->bchan_cnt, sizeof(*ud->bchans), in bcdma_setup_resources()
4629 ud->tchan_map = devm_kmalloc_array(dev, BITS_TO_LONGS(ud->tchan_cnt), in bcdma_setup_resources()
4631 ud->tchans = devm_kcalloc(dev, ud->tchan_cnt, sizeof(*ud->tchans), in bcdma_setup_resources()
4633 ud->rchan_map = devm_kmalloc_array(dev, BITS_TO_LONGS(ud->rchan_cnt), in bcdma_setup_resources()
4635 ud->rchans = devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rchans), in bcdma_setup_resources()
4638 ud->rflow_in_use = devm_kcalloc(dev, BITS_TO_LONGS(ud->rchan_cnt), in bcdma_setup_resources()
4641 ud->rflows = devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rflows), in bcdma_setup_resources()
4644 if (!ud->bchan_map || !ud->tchan_map || !ud->rchan_map || in bcdma_setup_resources()
4645 !ud->rflow_in_use || !ud->bchans || !ud->tchans || !ud->rchans || in bcdma_setup_resources()
4646 !ud->rflows) in bcdma_setup_resources()
4653 if (i == RM_RANGE_BCHAN && ud->bchan_cnt == 0) in bcdma_setup_resources()
4655 if (i == RM_RANGE_TCHAN && ud->tchan_cnt == 0) in bcdma_setup_resources()
4657 if (i == RM_RANGE_RCHAN && ud->rchan_cnt == 0) in bcdma_setup_resources()
4669 if (ud->bchan_cnt) { in bcdma_setup_resources()
4672 bitmap_zero(ud->bchan_map, ud->bchan_cnt); in bcdma_setup_resources()
4674 bitmap_fill(ud->bchan_map, ud->bchan_cnt); in bcdma_setup_resources()
4676 udma_mark_resource_ranges(ud, ud->bchan_map, in bcdma_setup_resources()
4684 if (ud->tchan_cnt) { in bcdma_setup_resources()
4687 bitmap_zero(ud->tchan_map, ud->tchan_cnt); in bcdma_setup_resources()
4689 bitmap_fill(ud->tchan_map, ud->tchan_cnt); in bcdma_setup_resources()
4691 udma_mark_resource_ranges(ud, ud->tchan_map, in bcdma_setup_resources()
4699 if (ud->rchan_cnt) { in bcdma_setup_resources()
4702 bitmap_zero(ud->rchan_map, ud->rchan_cnt); in bcdma_setup_resources()
4704 bitmap_fill(ud->rchan_map, ud->rchan_cnt); in bcdma_setup_resources()
4706 udma_mark_resource_ranges(ud, ud->rchan_map, in bcdma_setup_resources()
4714 if (ud->bchan_cnt) { in bcdma_setup_resources()
4722 if (ud->tchan_cnt) { in bcdma_setup_resources()
4734 if (ud->rchan_cnt) { in bcdma_setup_resources()
4747 ret = ti_sci_inta_msi_domain_alloc_irqs(ud->dev, &irq_res); in bcdma_setup_resources()
4750 dev_err(ud->dev, "Failed to allocate MSI interrupts\n"); in bcdma_setup_resources()
4757 static int pktdma_setup_resources(struct udma_dev *ud) in pktdma_setup_resources() argument
4760 struct device *dev = ud->dev; in pktdma_setup_resources()
4762 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in pktdma_setup_resources()
4763 const struct udma_oes_offsets *oes = &ud->soc_data->oes; in pktdma_setup_resources()
4767 cap3 = udma_read(ud->mmrs[MMR_GCFG], 0x2c); in pktdma_setup_resources()
4769 ud->tchan_tpl.levels = 3; in pktdma_setup_resources()
4770 ud->tchan_tpl.start_idx[1] = UDMA_CAP3_UCHAN_CNT(cap3); in pktdma_setup_resources()
4771 ud->tchan_tpl.start_idx[0] = UDMA_CAP3_HCHAN_CNT(cap3); in pktdma_setup_resources()
4773 ud->tchan_tpl.levels = 2; in pktdma_setup_resources()
4774 ud->tchan_tpl.start_idx[0] = UDMA_CAP3_HCHAN_CNT(cap3); in pktdma_setup_resources()
4776 ud->tchan_tpl.levels = 1; in pktdma_setup_resources()
4779 ud->rchan_tpl.levels = ud->tchan_tpl.levels; in pktdma_setup_resources()
4780 ud->rchan_tpl.start_idx[0] = ud->tchan_tpl.start_idx[0]; in pktdma_setup_resources()
4781 ud->rchan_tpl.start_idx[1] = ud->tchan_tpl.start_idx[1]; in pktdma_setup_resources()
4783 ud->tchan_map = devm_kmalloc_array(dev, BITS_TO_LONGS(ud->tchan_cnt), in pktdma_setup_resources()
4785 ud->tchans = devm_kcalloc(dev, ud->tchan_cnt, sizeof(*ud->tchans), in pktdma_setup_resources()
4787 ud->rchan_map = devm_kmalloc_array(dev, BITS_TO_LONGS(ud->rchan_cnt), in pktdma_setup_resources()
4789 ud->rchans = devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rchans), in pktdma_setup_resources()
4791 ud->rflow_in_use = devm_kcalloc(dev, BITS_TO_LONGS(ud->rflow_cnt), in pktdma_setup_resources()
4794 ud->rflows = devm_kcalloc(dev, ud->rflow_cnt, sizeof(*ud->rflows), in pktdma_setup_resources()
4796 ud->tflow_map = devm_kmalloc_array(dev, BITS_TO_LONGS(ud->tflow_cnt), in pktdma_setup_resources()
4799 if (!ud->tchan_map || !ud->rchan_map || !ud->tflow_map || !ud->tchans || in pktdma_setup_resources()
4800 !ud->rchans || !ud->rflows || !ud->rflow_in_use) in pktdma_setup_resources()
4817 bitmap_zero(ud->tchan_map, ud->tchan_cnt); in pktdma_setup_resources()
4819 bitmap_fill(ud->tchan_map, ud->tchan_cnt); in pktdma_setup_resources()
4821 udma_mark_resource_ranges(ud, ud->tchan_map, in pktdma_setup_resources()
4828 bitmap_zero(ud->rchan_map, ud->rchan_cnt); in pktdma_setup_resources()
4830 bitmap_fill(ud->rchan_map, ud->rchan_cnt); in pktdma_setup_resources()
4832 udma_mark_resource_ranges(ud, ud->rchan_map, in pktdma_setup_resources()
4840 bitmap_zero(ud->rflow_in_use, ud->rflow_cnt); in pktdma_setup_resources()
4842 bitmap_fill(ud->rflow_in_use, ud->rflow_cnt); in pktdma_setup_resources()
4844 udma_mark_resource_ranges(ud, ud->rflow_in_use, in pktdma_setup_resources()
4853 bitmap_zero(ud->tflow_map, ud->tflow_cnt); in pktdma_setup_resources()
4855 bitmap_fill(ud->tflow_map, ud->tflow_cnt); in pktdma_setup_resources()
4857 udma_mark_resource_ranges(ud, ud->tflow_map, in pktdma_setup_resources()
4875 ret = ti_sci_inta_msi_domain_alloc_irqs(ud->dev, &irq_res); in pktdma_setup_resources()
4878 dev_err(ud->dev, "Failed to allocate MSI interrupts\n"); in pktdma_setup_resources()
4885 static int setup_resources(struct udma_dev *ud) in setup_resources() argument
4887 struct device *dev = ud->dev; in setup_resources()
4890 switch (ud->match_data->type) { in setup_resources()
4892 ret = udma_setup_resources(ud); in setup_resources()
4895 ret = bcdma_setup_resources(ud); in setup_resources()
4898 ret = pktdma_setup_resources(ud); in setup_resources()
4907 ch_count = ud->bchan_cnt + ud->tchan_cnt + ud->rchan_cnt; in setup_resources()
4908 if (ud->bchan_cnt) in setup_resources()
4909 ch_count -= bitmap_weight(ud->bchan_map, ud->bchan_cnt); in setup_resources()
4910 ch_count -= bitmap_weight(ud->tchan_map, ud->tchan_cnt); in setup_resources()
4911 ch_count -= bitmap_weight(ud->rchan_map, ud->rchan_cnt); in setup_resources()
4915 ud->channels = devm_kcalloc(dev, ch_count, sizeof(*ud->channels), in setup_resources()
4917 if (!ud->channels) in setup_resources()
4920 switch (ud->match_data->type) { in setup_resources()
4925 ud->tchan_cnt - bitmap_weight(ud->tchan_map, in setup_resources()
4926 ud->tchan_cnt), in setup_resources()
4927 ud->rchan_cnt - bitmap_weight(ud->rchan_map, in setup_resources()
4928 ud->rchan_cnt), in setup_resources()
4929 ud->rflow_cnt - bitmap_weight(ud->rflow_gp_map, in setup_resources()
4930 ud->rflow_cnt)); in setup_resources()
4936 ud->bchan_cnt - bitmap_weight(ud->bchan_map, in setup_resources()
4937 ud->bchan_cnt), in setup_resources()
4938 ud->tchan_cnt - bitmap_weight(ud->tchan_map, in setup_resources()
4939 ud->tchan_cnt), in setup_resources()
4940 ud->rchan_cnt - bitmap_weight(ud->rchan_map, in setup_resources()
4941 ud->rchan_cnt)); in setup_resources()
4947 ud->tchan_cnt - bitmap_weight(ud->tchan_map, in setup_resources()
4948 ud->tchan_cnt), in setup_resources()
4949 ud->rchan_cnt - bitmap_weight(ud->rchan_map, in setup_resources()
4950 ud->rchan_cnt)); in setup_resources()
4959 static int udma_setup_rx_flush(struct udma_dev *ud) in udma_setup_rx_flush() argument
4961 struct udma_rx_flush *rx_flush = &ud->rx_flush; in udma_setup_rx_flush()
4965 struct device *dev = ud->dev; in udma_setup_rx_flush()
4987 ud->desc_align); in udma_setup_rx_flush()
5027 ud->desc_align); in udma_setup_rx_flush()
5071 if (uc->ud->match_data->type == DMA_TYPE_BCDMA) { in udma_dbg_summary_show_chan()
5082 if (uc->ud->match_data->type == DMA_TYPE_PKTDMA) in udma_dbg_summary_show_chan()
5088 if (uc->ud->match_data->type == DMA_TYPE_PKTDMA) in udma_dbg_summary_show_chan()
5127 static enum dmaengine_alignment udma_get_copy_align(struct udma_dev *ud) in udma_get_copy_align() argument
5129 const struct udma_match_data *match_data = ud->match_data; in udma_get_copy_align()
5136 if (ud->bchan_cnt) in udma_get_copy_align()
5137 tpl = udma_get_chan_tpl_index(&ud->bchan_tpl, 0); in udma_get_copy_align()
5138 else if (ud->tchan_cnt) in udma_get_copy_align()
5139 tpl = udma_get_chan_tpl_index(&ud->tchan_tpl, 0); in udma_get_copy_align()
5166 struct udma_dev *ud; in udma_probe() local
5175 ud = devm_kzalloc(dev, sizeof(*ud), GFP_KERNEL); in udma_probe()
5176 if (!ud) in udma_probe()
5189 ud->match_data = match->data; in udma_probe()
5196 ud->soc_data = soc->data; in udma_probe()
5198 ret = udma_get_mmrs(pdev, ud); in udma_probe()
5202 ud->tisci_rm.tisci = ti_sci_get_by_phandle(dev->of_node, "ti,sci"); in udma_probe()
5203 if (IS_ERR(ud->tisci_rm.tisci)) in udma_probe()
5204 return PTR_ERR(ud->tisci_rm.tisci); in udma_probe()
5207 &ud->tisci_rm.tisci_dev_id); in udma_probe()
5212 pdev->id = ud->tisci_rm.tisci_dev_id; in udma_probe()
5215 &ud->tisci_rm.tisci_navss_dev_id); in udma_probe()
5221 if (ud->match_data->type == DMA_TYPE_UDMA) { in udma_probe()
5223 &ud->atype); in udma_probe()
5224 if (!ret && ud->atype > 2) { in udma_probe()
5225 dev_err(dev, "Invalid atype: %u\n", ud->atype); in udma_probe()
5230 &ud->asel); in udma_probe()
5231 if (!ret && ud->asel > 15) { in udma_probe()
5232 dev_err(dev, "Invalid asel: %u\n", ud->asel); in udma_probe()
5237 ud->tisci_rm.tisci_udmap_ops = &ud->tisci_rm.tisci->ops.rm_udmap_ops; in udma_probe()
5238 ud->tisci_rm.tisci_psil_ops = &ud->tisci_rm.tisci->ops.rm_psil_ops; in udma_probe()
5240 if (ud->match_data->type == DMA_TYPE_UDMA) { in udma_probe()
5241 ud->ringacc = of_k3_ringacc_get_by_phandle(dev->of_node, "ti,ringacc"); in udma_probe()
5245 ring_init_data.tisci = ud->tisci_rm.tisci; in udma_probe()
5246 ring_init_data.tisci_dev_id = ud->tisci_rm.tisci_dev_id; in udma_probe()
5247 if (ud->match_data->type == DMA_TYPE_BCDMA) { in udma_probe()
5248 ring_init_data.num_rings = ud->bchan_cnt + in udma_probe()
5249 ud->tchan_cnt + in udma_probe()
5250 ud->rchan_cnt; in udma_probe()
5252 ring_init_data.num_rings = ud->rflow_cnt + in udma_probe()
5253 ud->tflow_cnt; in udma_probe()
5256 ud->ringacc = k3_ringacc_dmarings_init(pdev, &ring_init_data); in udma_probe()
5259 if (IS_ERR(ud->ringacc)) in udma_probe()
5260 return PTR_ERR(ud->ringacc); in udma_probe()
5269 dma_cap_set(DMA_SLAVE, ud->ddev.cap_mask); in udma_probe()
5271 if (ud->match_data->type != DMA_TYPE_PKTDMA) { in udma_probe()
5272 dma_cap_set(DMA_CYCLIC, ud->ddev.cap_mask); in udma_probe()
5273 ud->ddev.device_prep_dma_cyclic = udma_prep_dma_cyclic; in udma_probe()
5276 ud->ddev.device_config = udma_slave_config; in udma_probe()
5277 ud->ddev.device_prep_slave_sg = udma_prep_slave_sg; in udma_probe()
5278 ud->ddev.device_issue_pending = udma_issue_pending; in udma_probe()
5279 ud->ddev.device_tx_status = udma_tx_status; in udma_probe()
5280 ud->ddev.device_pause = udma_pause; in udma_probe()
5281 ud->ddev.device_resume = udma_resume; in udma_probe()
5282 ud->ddev.device_terminate_all = udma_terminate_all; in udma_probe()
5283 ud->ddev.device_synchronize = udma_synchronize; in udma_probe()
5285 ud->ddev.dbg_summary_show = udma_dbg_summary_show; in udma_probe()
5288 switch (ud->match_data->type) { in udma_probe()
5290 ud->ddev.device_alloc_chan_resources = in udma_probe()
5294 ud->ddev.device_alloc_chan_resources = in udma_probe()
5296 ud->ddev.device_router_config = bcdma_router_config; in udma_probe()
5299 ud->ddev.device_alloc_chan_resources = in udma_probe()
5305 ud->ddev.device_free_chan_resources = udma_free_chan_resources; in udma_probe()
5307 ud->ddev.src_addr_widths = TI_UDMAC_BUSWIDTHS; in udma_probe()
5308 ud->ddev.dst_addr_widths = TI_UDMAC_BUSWIDTHS; in udma_probe()
5309 ud->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); in udma_probe()
5310 ud->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; in udma_probe()
5311 ud->ddev.desc_metadata_modes = DESC_METADATA_CLIENT | in udma_probe()
5313 if (ud->match_data->enable_memcpy_support && in udma_probe()
5314 !(ud->match_data->type == DMA_TYPE_BCDMA && ud->bchan_cnt == 0)) { in udma_probe()
5315 dma_cap_set(DMA_MEMCPY, ud->ddev.cap_mask); in udma_probe()
5316 ud->ddev.device_prep_dma_memcpy = udma_prep_dma_memcpy; in udma_probe()
5317 ud->ddev.directions |= BIT(DMA_MEM_TO_MEM); in udma_probe()
5320 ud->ddev.dev = dev; in udma_probe()
5321 ud->dev = dev; in udma_probe()
5322 ud->psil_base = ud->match_data->psil_base; in udma_probe()
5324 INIT_LIST_HEAD(&ud->ddev.channels); in udma_probe()
5325 INIT_LIST_HEAD(&ud->desc_to_purge); in udma_probe()
5327 ch_count = setup_resources(ud); in udma_probe()
5331 spin_lock_init(&ud->lock); in udma_probe()
5332 INIT_WORK(&ud->purge_work, udma_purge_desc_work); in udma_probe()
5334 ud->desc_align = 64; in udma_probe()
5335 if (ud->desc_align < dma_get_cache_alignment()) in udma_probe()
5336 ud->desc_align = dma_get_cache_alignment(); in udma_probe()
5338 ret = udma_setup_rx_flush(ud); in udma_probe()
5342 for (i = 0; i < ud->bchan_cnt; i++) { in udma_probe()
5343 struct udma_bchan *bchan = &ud->bchans[i]; in udma_probe()
5346 bchan->reg_rt = ud->mmrs[MMR_BCHANRT] + i * 0x1000; in udma_probe()
5349 for (i = 0; i < ud->tchan_cnt; i++) { in udma_probe()
5350 struct udma_tchan *tchan = &ud->tchans[i]; in udma_probe()
5353 tchan->reg_rt = ud->mmrs[MMR_TCHANRT] + i * 0x1000; in udma_probe()
5356 for (i = 0; i < ud->rchan_cnt; i++) { in udma_probe()
5357 struct udma_rchan *rchan = &ud->rchans[i]; in udma_probe()
5360 rchan->reg_rt = ud->mmrs[MMR_RCHANRT] + i * 0x1000; in udma_probe()
5363 for (i = 0; i < ud->rflow_cnt; i++) { in udma_probe()
5364 struct udma_rflow *rflow = &ud->rflows[i]; in udma_probe()
5370 struct udma_chan *uc = &ud->channels[i]; in udma_probe()
5372 uc->ud = ud; in udma_probe()
5385 vchan_init(&uc->vc, &ud->ddev); in udma_probe()
5393 ud->ddev.copy_align = udma_get_copy_align(ud); in udma_probe()
5395 ret = dma_async_device_register(&ud->ddev); in udma_probe()
5401 platform_set_drvdata(pdev, ud); in udma_probe()
5403 ret = of_dma_controller_register(dev->of_node, udma_of_xlate, ud); in udma_probe()
5406 dma_async_device_unregister(&ud->ddev); in udma_probe()