Lines Matching refs:ud
156 struct udma_dev *ud; member
250 static inline int udma_navss_psil_pair(struct udma_dev *ud, u32 src_thread, in udma_navss_psil_pair() argument
253 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in udma_navss_psil_pair()
262 static inline int udma_navss_psil_unpair(struct udma_dev *ud, u32 src_thread, in udma_navss_psil_unpair() argument
265 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in udma_navss_psil_unpair()
588 static struct udma_rflow *__udma_reserve_rflow(struct udma_dev *ud, int id) in __udma_reserve_rflow() argument
593 if (test_bit(id, ud->rflow_map)) { in __udma_reserve_rflow()
594 dev_err(ud->dev, "rflow%d is in use\n", id); in __udma_reserve_rflow()
598 bitmap_or(tmp, ud->rflow_map, ud->rflow_map_reserved, in __udma_reserve_rflow()
599 ud->rflow_cnt); in __udma_reserve_rflow()
601 id = find_next_zero_bit(tmp, ud->rflow_cnt, ud->rchan_cnt); in __udma_reserve_rflow()
602 if (id >= ud->rflow_cnt) in __udma_reserve_rflow()
606 __set_bit(id, ud->rflow_map); in __udma_reserve_rflow()
607 return &ud->rflows[id]; in __udma_reserve_rflow()
611 static struct udma_##res *__udma_reserve_##res(struct udma_dev *ud, \
615 if (test_bit(id, ud->res##_map)) { \
616 dev_err(ud->dev, "res##%d is in use\n", id); \
620 id = find_first_zero_bit(ud->res##_map, ud->res##_cnt); \
621 if (id == ud->res##_cnt) { \
626 __set_bit(id, ud->res##_map); \
627 return &ud->res##s[id]; \
635 struct udma_dev *ud = uc->ud; in udma_get_tchan() local
638 dev_dbg(ud->dev, "chan%d: already have tchan%d allocated\n", in udma_get_tchan()
643 uc->tchan = __udma_reserve_tchan(ud, -1); in udma_get_tchan()
654 struct udma_dev *ud = uc->ud; in udma_get_rchan() local
657 dev_dbg(ud->dev, "chan%d: already have rchan%d allocated\n", in udma_get_rchan()
662 uc->rchan = __udma_reserve_rchan(ud, -1); in udma_get_rchan()
673 struct udma_dev *ud = uc->ud; in udma_get_chan_pair() local
677 dev_info(ud->dev, "chan%d: already have %d pair allocated\n", in udma_get_chan_pair()
683 dev_err(ud->dev, "chan%d: already have tchan%d allocated\n", in udma_get_chan_pair()
687 dev_err(ud->dev, "chan%d: already have rchan%d allocated\n", in udma_get_chan_pair()
693 end = min(ud->tchan_cnt, ud->rchan_cnt); in udma_get_chan_pair()
695 if (!test_bit(chan_id, ud->tchan_map) && in udma_get_chan_pair()
696 !test_bit(chan_id, ud->rchan_map)) in udma_get_chan_pair()
703 __set_bit(chan_id, ud->tchan_map); in udma_get_chan_pair()
704 __set_bit(chan_id, ud->rchan_map); in udma_get_chan_pair()
705 uc->tchan = &ud->tchans[chan_id]; in udma_get_chan_pair()
706 uc->rchan = &ud->rchans[chan_id]; in udma_get_chan_pair()
715 struct udma_dev *ud = uc->ud; in udma_get_rflow() local
718 dev_dbg(ud->dev, "chan%d: already have rflow%d allocated\n", in udma_get_rflow()
724 dev_warn(ud->dev, "chan%d: does not have rchan??\n", uc->id); in udma_get_rflow()
726 uc->rflow = __udma_reserve_rflow(ud, flow_id); in udma_get_rflow()
736 struct udma_dev *ud = uc->ud; in udma_put_rchan() local
739 dev_dbg(ud->dev, "chan%d: put rchan%d\n", uc->id, in udma_put_rchan()
741 __clear_bit(uc->rchan->id, ud->rchan_map); in udma_put_rchan()
748 struct udma_dev *ud = uc->ud; in udma_put_tchan() local
751 dev_dbg(ud->dev, "chan%d: put tchan%d\n", uc->id, in udma_put_tchan()
753 __clear_bit(uc->tchan->id, ud->tchan_map); in udma_put_tchan()
760 struct udma_dev *ud = uc->ud; in udma_put_rflow() local
763 dev_dbg(ud->dev, "chan%d: put rflow%d\n", uc->id, in udma_put_rflow()
765 __clear_bit(uc->rflow->id, ud->rflow_map); in udma_put_rflow()
786 struct udma_dev *ud = uc->ud; in udma_alloc_tx_resources() local
793 ret = k3_nav_ringacc_request_rings_pair(ud->ringacc, uc->tchan->id, -1, in udma_alloc_tx_resources()
845 struct udma_dev *ud = uc->ud; in udma_alloc_rx_resources() local
864 fd_ring_id = ud->tchan_cnt + ud->echan_cnt + uc->rchan->id; in udma_alloc_rx_resources()
867 ret = k3_nav_ringacc_request_rings_pair(ud->ringacc, fd_ring_id, -1, in udma_alloc_rx_resources()
901 struct udma_dev *ud = uc->ud; in udma_alloc_tchan_sci_req() local
904 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in udma_alloc_tchan_sci_req()
929 dev_err(ud->dev, "tisci tx alloc failed %d\n", ret); in udma_alloc_tchan_sci_req()
936 struct udma_dev *ud = uc->ud; in udma_alloc_rchan_sci_req() local
942 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in udma_alloc_rchan_sci_req()
975 dev_err(ud->dev, "tisci rx %u cfg failed %d\n", in udma_alloc_rchan_sci_req()
1027 dev_err(ud->dev, "tisci rx %u flow %u cfg failed %d\n", in udma_alloc_rchan_sci_req()
1035 struct udma_dev *ud = uc->ud; in udma_alloc_chan_resources() local
1057 uc->config.src_thread = ud->psil_base + uc->tchan->id; in udma_alloc_chan_resources()
1058 uc->config.dst_thread = (ud->psil_base + uc->rchan->id) | 0x8000; in udma_alloc_chan_resources()
1066 uc->config.src_thread = ud->psil_base + uc->tchan->id; in udma_alloc_chan_resources()
1078 uc->config.dst_thread = (ud->psil_base + uc->rchan->id) | 0x8000; in udma_alloc_chan_resources()
1111 dev_warn(ud->dev, "chan%d: is running!\n", uc->id); in udma_alloc_chan_resources()
1114 dev_err(ud->dev, "chan%d: won't stop!\n", uc->id); in udma_alloc_chan_resources()
1120 ret = udma_navss_psil_pair(ud, uc->config.src_thread, uc->config.dst_thread); in udma_alloc_chan_resources()
1122 dev_err(ud->dev, "k3_nav_psil_request_link fail\n"); in udma_alloc_chan_resources()
1142 udma_navss_psil_unpair(uc->ud, uc->config.src_thread, uc->config.dst_thread); in udma_free_chan_resources()
1155 struct udma_dev *ud = dev_get_priv(dev); in udma_get_mmrs() local
1159 ud->mmrs[i] = (uint32_t *)devfdt_get_addr_name(dev, in udma_get_mmrs()
1161 if (!ud->mmrs[i]) in udma_get_mmrs()
1168 static int udma_setup_resources(struct udma_dev *ud) in udma_setup_resources() argument
1170 struct udevice *dev = ud->dev; in udma_setup_resources()
1175 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in udma_setup_resources()
1180 cap2 = udma_read(ud->mmrs[MMR_GCFG], 0x28); in udma_setup_resources()
1181 cap3 = udma_read(ud->mmrs[MMR_GCFG], 0x2c); in udma_setup_resources()
1183 ud->rflow_cnt = cap3 & 0x3fff; in udma_setup_resources()
1184 ud->tchan_cnt = cap2 & 0x1ff; in udma_setup_resources()
1185 ud->echan_cnt = (cap2 >> 9) & 0x1ff; in udma_setup_resources()
1186 ud->rchan_cnt = (cap2 >> 18) & 0x1ff; in udma_setup_resources()
1187 ch_count = ud->tchan_cnt + ud->rchan_cnt; in udma_setup_resources()
1189 ud->tchan_map = devm_kmalloc_array(dev, BITS_TO_LONGS(ud->tchan_cnt), in udma_setup_resources()
1191 ud->tchans = devm_kcalloc(dev, ud->tchan_cnt, sizeof(*ud->tchans), in udma_setup_resources()
1193 ud->rchan_map = devm_kmalloc_array(dev, BITS_TO_LONGS(ud->rchan_cnt), in udma_setup_resources()
1195 ud->rchans = devm_kcalloc(dev, ud->rchan_cnt, sizeof(*ud->rchans), in udma_setup_resources()
1197 ud->rflow_map = devm_kmalloc_array(dev, BITS_TO_LONGS(ud->rflow_cnt), in udma_setup_resources()
1199 ud->rflow_map_reserved = devm_kcalloc(dev, BITS_TO_LONGS(ud->rflow_cnt), in udma_setup_resources()
1202 ud->rflows = devm_kcalloc(dev, ud->rflow_cnt, sizeof(*ud->rflows), in udma_setup_resources()
1205 if (!ud->tchan_map || !ud->rchan_map || !ud->rflow_map || in udma_setup_resources()
1206 !ud->rflow_map_reserved || !ud->tchans || !ud->rchans || in udma_setup_resources()
1207 !ud->rflows) in udma_setup_resources()
1215 bitmap_set(ud->rflow_map_reserved, 0, ud->rchan_cnt); in udma_setup_resources()
1227 bitmap_zero(ud->tchan_map, ud->tchan_cnt); in udma_setup_resources()
1229 bitmap_fill(ud->tchan_map, ud->tchan_cnt); in udma_setup_resources()
1232 bitmap_clear(ud->tchan_map, rm_desc->start, in udma_setup_resources()
1240 bitmap_zero(ud->rchan_map, ud->rchan_cnt); in udma_setup_resources()
1241 bitmap_zero(ud->rflow_map, ud->rchan_cnt); in udma_setup_resources()
1243 bitmap_fill(ud->rchan_map, ud->rchan_cnt); in udma_setup_resources()
1244 bitmap_fill(ud->rflow_map, ud->rchan_cnt); in udma_setup_resources()
1247 bitmap_clear(ud->rchan_map, rm_desc->start, in udma_setup_resources()
1249 bitmap_clear(ud->rflow_map, rm_desc->start, in udma_setup_resources()
1257 bitmap_clear(ud->rflow_map, ud->rchan_cnt, in udma_setup_resources()
1258 ud->rflow_cnt - ud->rchan_cnt); in udma_setup_resources()
1260 bitmap_set(ud->rflow_map, ud->rchan_cnt, in udma_setup_resources()
1261 ud->rflow_cnt - ud->rchan_cnt); in udma_setup_resources()
1264 bitmap_clear(ud->rflow_map, rm_desc->start, in udma_setup_resources()
1269 ch_count -= bitmap_weight(ud->tchan_map, ud->tchan_cnt); in udma_setup_resources()
1270 ch_count -= bitmap_weight(ud->rchan_map, ud->rchan_cnt); in udma_setup_resources()
1274 ud->channels = devm_kcalloc(dev, ch_count, sizeof(*ud->channels), in udma_setup_resources()
1276 if (!ud->channels) in udma_setup_resources()
1281 ch_count, ud->tchan_cnt, ud->echan_cnt, ud->rchan_cnt, in udma_setup_resources()
1282 ud->rflow_cnt); in udma_setup_resources()
1289 struct udma_dev *ud = dev_get_priv(dev); in udma_probe() local
1293 struct udma_tisci_rm *tisci_rm = &ud->tisci_rm; in udma_probe()
1303 ud->ringacc = dev_get_priv(tmp); in udma_probe()
1304 if (IS_ERR(ud->ringacc)) in udma_probe()
1305 return PTR_ERR(ud->ringacc); in udma_probe()
1307 ud->match_data = (void *)dev_get_driver_data(dev); in udma_probe()
1308 ud->psil_base = ud->match_data->psil_base; in udma_probe()
1338 ud->dev = dev; in udma_probe()
1339 ud->ch_count = udma_setup_resources(ud); in udma_probe()
1340 if (ud->ch_count <= 0) in udma_probe()
1341 return ud->ch_count; in udma_probe()
1345 ud->ch_count, ud->tchan_cnt, ud->echan_cnt, ud->rchan_cnt, in udma_probe()
1347 dev_info(dev, "Number of rflows: %u\n", ud->rflow_cnt); in udma_probe()
1349 for (i = 0; i < ud->tchan_cnt; i++) { in udma_probe()
1350 struct udma_tchan *tchan = &ud->tchans[i]; in udma_probe()
1353 tchan->reg_rt = ud->mmrs[MMR_TCHANRT] + UDMA_CH_1000(i); in udma_probe()
1356 for (i = 0; i < ud->rchan_cnt; i++) { in udma_probe()
1357 struct udma_rchan *rchan = &ud->rchans[i]; in udma_probe()
1360 rchan->reg_rt = ud->mmrs[MMR_RCHANRT] + UDMA_CH_1000(i); in udma_probe()
1363 for (i = 0; i < ud->rflow_cnt; i++) { in udma_probe()
1364 struct udma_rflow *rflow = &ud->rflows[i]; in udma_probe()
1369 for (i = 0; i < ud->ch_count; i++) { in udma_probe()
1370 struct udma_chan *uc = &ud->channels[i]; in udma_probe()
1372 uc->ud = ud; in udma_probe()
1384 udma_read(ud->mmrs[MMR_GCFG], 0), in udma_probe()
1385 udma_read(ud->mmrs[MMR_GCFG], 0x20), in udma_probe()
1386 udma_read(ud->mmrs[MMR_GCFG], 0x24), in udma_probe()
1387 udma_read(ud->mmrs[MMR_GCFG], 0x28), in udma_probe()
1388 udma_read(ud->mmrs[MMR_GCFG], 0x2c)); in udma_probe()
1431 dev_err(uc->ud->dev, "size %zu is not supported\n", in udma_prep_dma_memcpy()
1502 struct udma_dev *ud = dev_get_priv(dev); in udma_transfer() local
1504 struct udma_chan *uc = &ud->channels[0]; in udma_transfer()
1523 struct udma_dev *ud = dev_get_priv(dma->dev); in udma_request() local
1529 if (dma->id >= (ud->rchan_cnt + ud->tchan_cnt)) { in udma_request()
1534 uc = &ud->channels[dma->id]; in udma_request()
1565 struct udma_dev *ud = dev_get_priv(dma->dev); in udma_rfree() local
1568 if (dma->id >= (ud->rchan_cnt + ud->tchan_cnt)) { in udma_rfree()
1572 uc = &ud->channels[dma->id]; in udma_rfree()
1585 struct udma_dev *ud = dev_get_priv(dma->dev); in udma_enable() local
1589 if (dma->id >= (ud->rchan_cnt + ud->tchan_cnt)) { in udma_enable()
1593 uc = &ud->channels[dma->id]; in udma_enable()
1602 struct udma_dev *ud = dev_get_priv(dma->dev); in udma_disable() local
1606 if (dma->id >= (ud->rchan_cnt + ud->tchan_cnt)) { in udma_disable()
1610 uc = &ud->channels[dma->id]; in udma_disable()
1622 struct udma_dev *ud = dev_get_priv(dma->dev); in udma_send() local
1634 if (dma->id >= (ud->rchan_cnt + ud->tchan_cnt)) { in udma_send()
1638 uc = &ud->channels[dma->id]; in udma_send()
1681 struct udma_dev *ud = dev_get_priv(dma->dev); in udma_receive() local
1690 if (dma->id >= (ud->rchan_cnt + ud->tchan_cnt)) { in udma_receive()
1694 uc = &ud->channels[dma->id]; in udma_receive()
1732 struct udma_dev *ud = dev_get_priv(dma->dev); in udma_of_xlate() local
1733 struct udma_chan *uc = &ud->channels[0]; in udma_of_xlate()
1737 for (val = 0; val < ud->ch_count; val++) { in udma_of_xlate()
1738 uc = &ud->channels[val]; in udma_of_xlate()
1743 if (val == ud->ch_count) in udma_of_xlate()
1755 dev_err(ud->dev, "No configuration for psi-l thread 0x%04x\n", in udma_of_xlate()
1786 struct udma_dev *ud = dev_get_priv(dma->dev); in udma_prepare_rcv_buf() local
1792 if (dma->id >= (ud->rchan_cnt + ud->tchan_cnt)) { in udma_prepare_rcv_buf()
1796 uc = &ud->channels[dma->id]; in udma_prepare_rcv_buf()
1830 struct udma_dev *ud = dev_get_priv(dma->dev); in udma_get_cfg() local
1833 if (dma->id >= (ud->rchan_cnt + ud->tchan_cnt)) { in udma_get_cfg()
1840 uc = &ud->channels[dma->id]; in udma_get_cfg()