Lines Matching +full:pcfg +full:-
1 // SPDX-License-Identifier: GPL-2.0-or-later
19 #include <linux/dma-mapping.h>
46 CCTRL6, /* Cacheable write-through, allocate on writes only */
47 CCTRL7, /* Cacheable write-back, allocate on writes only */
245 * at 1byte/burst for P<->M and M<->M respectively.
247 * should be enough for P<->M and M<->M respectively.
314 struct pl330_config *pcfg; member
382 /* Index of the last submitted request or -1 if the DMA is stopped */
417 /* DMA-Engine Channel */
443 /* For D-to-M and M-to-D channels */
447 /* DMA-mapped view of the FIFO; may differ if an IOMMU is present */
460 /* DMA-Engine Device */
473 struct pl330_config pcfg; member
508 .quirk = "arm,pl330-broken-no-flushp",
512 .quirk = "arm,pl330-periph-burst",
555 return thrd->req[0].desc != NULL && thrd->req[1].desc != NULL; in _queue_full()
560 return thrd->dmac->manager == thrd; in is_manager()
563 /* If manager of the thread is in Non-Secure mode */
566 return (thrd->dmac->pcfg.mode & DMAC_MODE_NS) ? true : false; in _manager_ns()
652 cnt--; /* DMAC increments by 1 internally */ in _emit_LP()
670 enum pl330_cond cond = arg->cond; in _emit_LPEND()
671 bool forever = arg->forever; in _emit_LPEND()
672 unsigned loop = arg->loop; in _emit_LPEND()
673 u8 bjump = arg->bjump; in _emit_LPEND()
844 u8 chan = arg->chan; in _emit_GO()
845 u32 addr = arg->addr; in _emit_GO()
846 unsigned ns = arg->ns; in _emit_GO()
864 /* Returns Time-Out */
867 void __iomem *regs = thrd->dmac->base; in _until_dmac_idle()
876 } while (--loops); in _until_dmac_idle()
887 void __iomem *regs = thrd->dmac->base; in _execute_DBGINSN()
890 /* If timed out due to halted state-machine */ in _execute_DBGINSN()
892 dev_err(thrd->dmac->ddma.dev, "DMAC halted!\n"); in _execute_DBGINSN()
899 val |= (thrd->id << 8); /* Channel Number */ in _execute_DBGINSN()
912 void __iomem *regs = thrd->dmac->base; in _state()
918 val = readl(regs + CS(thrd->id)) & 0xf; in _state()
970 void __iomem *regs = thrd->dmac->base; in _stop()
988 if (inten & (1 << thrd->ev)) in _stop()
989 writel(1 << thrd->ev, regs + INTCLR); in _stop()
991 writel(inten & ~(1 << thrd->ev), regs + INTEN); in _stop()
997 void __iomem *regs = thrd->dmac->base; in _trigger()
1009 idx = 1 - thrd->lstenq; in _trigger()
1010 if (thrd->req[idx].desc != NULL) { in _trigger()
1011 req = &thrd->req[idx]; in _trigger()
1013 idx = thrd->lstenq; in _trigger()
1014 if (thrd->req[idx].desc != NULL) in _trigger()
1015 req = &thrd->req[idx]; in _trigger()
1025 if (idx == thrd->req_running) in _trigger()
1028 desc = req->desc; in _trigger()
1030 ns = desc->rqcfg.nonsecure ? 1 : 0; in _trigger()
1032 /* See 'Abort Sources' point-4 at Page 2-25 */ in _trigger()
1034 dev_info(thrd->dmac->ddma.dev, "%s:%d Recipe for ABORT!\n", in _trigger()
1037 go.chan = thrd->id; in _trigger()
1038 go.addr = req->mc_bus; in _trigger()
1043 writel(readl(regs + INTEN) | (1 << thrd->ev), regs + INTEN); in _trigger()
1048 thrd->req_running = idx; in _trigger()
1093 struct pl330_config *pcfg = pxs->desc->rqcfg.pcfg; in _ldst_memtomem() local
1095 /* check lock-up free version */ in _ldst_memtomem()
1096 if (get_revision(pcfg->periph_id) >= PERIPH_REV_R1P0) { in _ldst_memtomem()
1097 while (cyc--) { in _ldst_memtomem()
1102 while (cyc--) { in _ldst_memtomem()
1190 if (!(pl330->quirks & PL330_QUIRK_BROKEN_NO_FLUSHP)) in _ldst_peripheral()
1191 off += _emit_FLUSHP(dry_run, &buf[off], pxs->desc->peri); in _ldst_peripheral()
1192 while (cyc--) { in _ldst_peripheral()
1193 off += _emit_WFP(dry_run, &buf[off], cond, pxs->desc->peri); in _ldst_peripheral()
1194 off += _emit_load(dry_run, &buf[off], cond, pxs->desc->rqtype, in _ldst_peripheral()
1195 pxs->desc->peri); in _ldst_peripheral()
1196 off += _emit_store(dry_run, &buf[off], cond, pxs->desc->rqtype, in _ldst_peripheral()
1197 pxs->desc->peri); in _ldst_peripheral()
1207 enum pl330_cond cond = BRST_LEN(pxs->ccr) > 1 ? BURST : SINGLE; in _bursts()
1209 if (pl330->quirks & PL330_QUIRK_PERIPH_BURST) in _bursts()
1212 switch (pxs->desc->rqtype) { in _bursts()
1235 * for mem-to-mem, mem-to-dev or dev-to-mem.
1247 * dregs_len = (total bytes - BURST_TO_BYTE(bursts, ccr)) / in _dregs()
1253 dregs_ccr = pxs->ccr; in _dregs()
1256 dregs_ccr |= (((transfer_length - 1) & 0xf) << in _dregs()
1258 dregs_ccr |= (((transfer_length - 1) & 0xf) << in _dregs()
1261 switch (pxs->desc->rqtype) { in _dregs()
1326 * which is 8-bits and hence 255 in _loop()
1328 cycmax = (255 - (szlp + szlpend)) / szbrst; in _loop()
1347 lpend.bjump = off - ljmp1; in _loop()
1354 lpend.bjump = off - ljmp0; in _loop()
1369 struct pl330_xfer *x = &pxs->desc->px; in _setup_loops()
1370 u32 ccr = pxs->ccr; in _setup_loops()
1371 unsigned long c, bursts = BYTE_TO_BURST(x->bytes, ccr); in _setup_loops()
1372 int num_dregs = (x->bytes - BURST_TO_BYTE(bursts, ccr)) / in _setup_loops()
1379 bursts -= c; in _setup_loops()
1390 struct pl330_xfer *x = &pxs->desc->px; in _setup_xfer()
1393 /* DMAMOV SAR, x->src_addr */ in _setup_xfer()
1394 off += _emit_MOV(dry_run, &buf[off], SAR, x->src_addr); in _setup_xfer()
1395 /* DMAMOV DAR, x->dst_addr */ in _setup_xfer()
1396 off += _emit_MOV(dry_run, &buf[off], DAR, x->dst_addr); in _setup_xfer()
1412 struct _pl330_req *req = &thrd->req[index]; in _setup_req()
1413 u8 *buf = req->mc_cpu; in _setup_req()
1416 PL330_DBGMC_START(req->mc_bus); in _setup_req()
1419 off += _emit_MOV(dry_run, &buf[off], CCR, pxs->ccr); in _setup_req()
1424 off += _emit_SEV(dry_run, &buf[off], thrd->ev); in _setup_req()
1435 if (rqc->src_inc) in _prepare_ccr()
1438 if (rqc->dst_inc) in _prepare_ccr()
1442 if (rqc->privileged) in _prepare_ccr()
1444 if (rqc->nonsecure) in _prepare_ccr()
1446 if (rqc->insnaccess) in _prepare_ccr()
1449 ccr |= (((rqc->brst_len - 1) & 0xf) << CC_SRCBRSTLEN_SHFT); in _prepare_ccr()
1450 ccr |= (((rqc->brst_len - 1) & 0xf) << CC_DSTBRSTLEN_SHFT); in _prepare_ccr()
1452 ccr |= (rqc->brst_size << CC_SRCBRSTSIZE_SHFT); in _prepare_ccr()
1453 ccr |= (rqc->brst_size << CC_DSTBRSTSIZE_SHFT); in _prepare_ccr()
1455 ccr |= (rqc->scctl << CC_SRCCCTRL_SHFT); in _prepare_ccr()
1456 ccr |= (rqc->dcctl << CC_DSTCCTRL_SHFT); in _prepare_ccr()
1458 ccr |= (rqc->swap << CC_SWAP_SHFT); in _prepare_ccr()
1471 struct pl330_dmac *pl330 = thrd->dmac; in pl330_submit_req()
1478 switch (desc->rqtype) { in pl330_submit_req()
1489 return -ENOTSUPP; in pl330_submit_req()
1492 if (pl330->state == DYING in pl330_submit_req()
1493 || pl330->dmac_tbd.reset_chan & (1 << thrd->id)) { in pl330_submit_req()
1494 dev_info(thrd->dmac->ddma.dev, "%s:%d\n", in pl330_submit_req()
1496 return -EAGAIN; in pl330_submit_req()
1499 /* If request for non-existing peripheral */ in pl330_submit_req()
1500 if (desc->rqtype != DMA_MEM_TO_MEM && in pl330_submit_req()
1501 desc->peri >= pl330->pcfg.num_peri) { in pl330_submit_req()
1502 dev_info(thrd->dmac->ddma.dev, in pl330_submit_req()
1504 __func__, __LINE__, desc->peri); in pl330_submit_req()
1505 return -EINVAL; in pl330_submit_req()
1508 spin_lock_irqsave(&pl330->lock, flags); in pl330_submit_req()
1511 ret = -EAGAIN; in pl330_submit_req()
1517 desc->rqcfg.nonsecure = 0; in pl330_submit_req()
1519 desc->rqcfg.nonsecure = 1; in pl330_submit_req()
1521 ccr = _prepare_ccr(&desc->rqcfg); in pl330_submit_req()
1523 idx = thrd->req[0].desc == NULL ? 0 : 1; in pl330_submit_req()
1531 if (ret > pl330->mcbufsz / 2) { in pl330_submit_req()
1532 dev_info(pl330->ddma.dev, "%s:%d Try increasing mcbufsz (%i/%i)\n", in pl330_submit_req()
1533 __func__, __LINE__, ret, pl330->mcbufsz / 2); in pl330_submit_req()
1534 ret = -ENOMEM; in pl330_submit_req()
1539 thrd->lstenq = idx; in pl330_submit_req()
1540 thrd->req[idx].desc = desc; in pl330_submit_req()
1546 spin_unlock_irqrestore(&pl330->lock, flags); in pl330_submit_req()
1559 pch = desc->pchan; in dma_pl330_rqcb()
1565 spin_lock_irqsave(&pch->lock, flags); in dma_pl330_rqcb()
1567 desc->status = DONE; in dma_pl330_rqcb()
1569 spin_unlock_irqrestore(&pch->lock, flags); in dma_pl330_rqcb()
1571 tasklet_schedule(&pch->task); in dma_pl330_rqcb()
1580 spin_lock_irqsave(&pl330->lock, flags); in pl330_dotask()
1583 if (pl330->dmac_tbd.reset_dmac) { in pl330_dotask()
1584 pl330->state = DYING; in pl330_dotask()
1586 pl330->dmac_tbd.reset_mngr = true; in pl330_dotask()
1588 pl330->dmac_tbd.reset_dmac = false; in pl330_dotask()
1591 if (pl330->dmac_tbd.reset_mngr) { in pl330_dotask()
1592 _stop(pl330->manager); in pl330_dotask()
1594 pl330->dmac_tbd.reset_chan = (1 << pl330->pcfg.num_chan) - 1; in pl330_dotask()
1596 pl330->dmac_tbd.reset_mngr = false; in pl330_dotask()
1599 for (i = 0; i < pl330->pcfg.num_chan; i++) { in pl330_dotask()
1601 if (pl330->dmac_tbd.reset_chan & (1 << i)) { in pl330_dotask()
1602 struct pl330_thread *thrd = &pl330->channels[i]; in pl330_dotask()
1603 void __iomem *regs = pl330->base; in pl330_dotask()
1608 if (readl(regs + FSC) & (1 << thrd->id)) in pl330_dotask()
1613 spin_unlock_irqrestore(&pl330->lock, flags); in pl330_dotask()
1614 dma_pl330_rqcb(thrd->req[1 - thrd->lstenq].desc, err); in pl330_dotask()
1615 dma_pl330_rqcb(thrd->req[thrd->lstenq].desc, err); in pl330_dotask()
1616 spin_lock_irqsave(&pl330->lock, flags); in pl330_dotask()
1618 thrd->req[0].desc = NULL; in pl330_dotask()
1619 thrd->req[1].desc = NULL; in pl330_dotask()
1620 thrd->req_running = -1; in pl330_dotask()
1623 pl330->dmac_tbd.reset_chan &= ~(1 << i); in pl330_dotask()
1627 spin_unlock_irqrestore(&pl330->lock, flags); in pl330_dotask()
1641 regs = pl330->base; in pl330_update()
1643 spin_lock_irqsave(&pl330->lock, flags); in pl330_update()
1647 pl330->dmac_tbd.reset_mngr = true; in pl330_update()
1649 pl330->dmac_tbd.reset_mngr = false; in pl330_update()
1651 val = readl(regs + FSC) & ((1 << pl330->pcfg.num_chan) - 1); in pl330_update()
1652 pl330->dmac_tbd.reset_chan |= val; in pl330_update()
1655 while (i < pl330->pcfg.num_chan) { in pl330_update()
1657 dev_info(pl330->ddma.dev, in pl330_update()
1658 "Reset Channel-%d\t CS-%x FTC-%x\n", in pl330_update()
1661 _stop(&pl330->channels[i]); in pl330_update()
1669 if (pl330->pcfg.num_events < 32 in pl330_update()
1670 && val & ~((1 << pl330->pcfg.num_events) - 1)) { in pl330_update()
1671 pl330->dmac_tbd.reset_dmac = true; in pl330_update()
1672 dev_err(pl330->ddma.dev, "%s:%d Unexpected!\n", __func__, in pl330_update()
1678 for (ev = 0; ev < pl330->pcfg.num_events; ev++) { in pl330_update()
1690 id = pl330->events[ev]; in pl330_update()
1692 thrd = &pl330->channels[id]; in pl330_update()
1694 active = thrd->req_running; in pl330_update()
1695 if (active == -1) /* Aborted */ in pl330_update()
1699 descdone = thrd->req[active].desc; in pl330_update()
1700 thrd->req[active].desc = NULL; in pl330_update()
1702 thrd->req_running = -1; in pl330_update()
1708 list_add_tail(&descdone->rqd, &pl330->req_done); in pl330_update()
1713 while (!list_empty(&pl330->req_done)) { in pl330_update()
1714 descdone = list_first_entry(&pl330->req_done, in pl330_update()
1716 list_del(&descdone->rqd); in pl330_update()
1717 spin_unlock_irqrestore(&pl330->lock, flags); in pl330_update()
1719 spin_lock_irqsave(&pl330->lock, flags); in pl330_update()
1723 spin_unlock_irqrestore(&pl330->lock, flags); in pl330_update()
1725 if (pl330->dmac_tbd.reset_dmac in pl330_update()
1726 || pl330->dmac_tbd.reset_mngr in pl330_update()
1727 || pl330->dmac_tbd.reset_chan) { in pl330_update()
1729 tasklet_schedule(&pl330->tasks); in pl330_update()
1738 struct pl330_dmac *pl330 = thrd->dmac; in _alloc_event()
1741 for (ev = 0; ev < pl330->pcfg.num_events; ev++) in _alloc_event()
1742 if (pl330->events[ev] == -1) { in _alloc_event()
1743 pl330->events[ev] = thrd->id; in _alloc_event()
1747 return -1; in _alloc_event()
1752 return pl330->pcfg.irq_ns & (1 << i); in _chan_ns()
1763 if (pl330->state == DYING) in pl330_request_channel()
1766 chans = pl330->pcfg.num_chan; in pl330_request_channel()
1769 thrd = &pl330->channels[i]; in pl330_request_channel()
1770 if ((thrd->free) && (!_manager_ns(thrd) || in pl330_request_channel()
1772 thrd->ev = _alloc_event(thrd); in pl330_request_channel()
1773 if (thrd->ev >= 0) { in pl330_request_channel()
1774 thrd->free = false; in pl330_request_channel()
1775 thrd->lstenq = 1; in pl330_request_channel()
1776 thrd->req[0].desc = NULL; in pl330_request_channel()
1777 thrd->req[1].desc = NULL; in pl330_request_channel()
1778 thrd->req_running = -1; in pl330_request_channel()
1791 struct pl330_dmac *pl330 = thrd->dmac; in _free_event()
1794 if (ev >= 0 && ev < pl330->pcfg.num_events in _free_event()
1795 && pl330->events[ev] == thrd->id) in _free_event()
1796 pl330->events[ev] = -1; in _free_event()
1801 if (!thrd || thrd->free) in pl330_release_channel()
1806 dma_pl330_rqcb(thrd->req[1 - thrd->lstenq].desc, PL330_ERR_ABORT); in pl330_release_channel()
1807 dma_pl330_rqcb(thrd->req[thrd->lstenq].desc, PL330_ERR_ABORT); in pl330_release_channel()
1809 _free_event(thrd, thrd->ev); in pl330_release_channel()
1810 thrd->free = true; in pl330_release_channel()
1818 void __iomem *regs = pl330->base; in read_dmac_config()
1823 pl330->pcfg.data_bus_width = 8 * (1 << val); in read_dmac_config()
1827 pl330->pcfg.data_buf_dep = val + 1; in read_dmac_config()
1832 pl330->pcfg.num_chan = val; in read_dmac_config()
1838 pl330->pcfg.num_peri = val; in read_dmac_config()
1839 pl330->pcfg.peri_ns = readl(regs + CR4); in read_dmac_config()
1841 pl330->pcfg.num_peri = 0; in read_dmac_config()
1846 pl330->pcfg.mode |= DMAC_MODE_NS; in read_dmac_config()
1848 pl330->pcfg.mode &= ~DMAC_MODE_NS; in read_dmac_config()
1853 pl330->pcfg.num_events = val; in read_dmac_config()
1855 pl330->pcfg.irq_ns = readl(regs + CR3); in read_dmac_config()
1860 struct pl330_dmac *pl330 = thrd->dmac; in _reset_thread()
1862 thrd->req[0].mc_cpu = pl330->mcode_cpu in _reset_thread()
1863 + (thrd->id * pl330->mcbufsz); in _reset_thread()
1864 thrd->req[0].mc_bus = pl330->mcode_bus in _reset_thread()
1865 + (thrd->id * pl330->mcbufsz); in _reset_thread()
1866 thrd->req[0].desc = NULL; in _reset_thread()
1868 thrd->req[1].mc_cpu = thrd->req[0].mc_cpu in _reset_thread()
1869 + pl330->mcbufsz / 2; in _reset_thread()
1870 thrd->req[1].mc_bus = thrd->req[0].mc_bus in _reset_thread()
1871 + pl330->mcbufsz / 2; in _reset_thread()
1872 thrd->req[1].desc = NULL; in _reset_thread()
1874 thrd->req_running = -1; in _reset_thread()
1879 int chans = pl330->pcfg.num_chan; in dmac_alloc_threads()
1884 pl330->channels = kcalloc(1 + chans, sizeof(*thrd), in dmac_alloc_threads()
1886 if (!pl330->channels) in dmac_alloc_threads()
1887 return -ENOMEM; in dmac_alloc_threads()
1891 thrd = &pl330->channels[i]; in dmac_alloc_threads()
1892 thrd->id = i; in dmac_alloc_threads()
1893 thrd->dmac = pl330; in dmac_alloc_threads()
1895 thrd->free = true; in dmac_alloc_threads()
1899 thrd = &pl330->channels[chans]; in dmac_alloc_threads()
1900 thrd->id = chans; in dmac_alloc_threads()
1901 thrd->dmac = pl330; in dmac_alloc_threads()
1902 thrd->free = false; in dmac_alloc_threads()
1903 pl330->manager = thrd; in dmac_alloc_threads()
1910 int chans = pl330->pcfg.num_chan; in dmac_alloc_resources()
1917 pl330->mcode_cpu = dma_alloc_attrs(pl330->ddma.dev, in dmac_alloc_resources()
1918 chans * pl330->mcbufsz, in dmac_alloc_resources()
1919 &pl330->mcode_bus, GFP_KERNEL, in dmac_alloc_resources()
1921 if (!pl330->mcode_cpu) { in dmac_alloc_resources()
1922 dev_err(pl330->ddma.dev, "%s:%d Can't allocate memory!\n", in dmac_alloc_resources()
1924 return -ENOMEM; in dmac_alloc_resources()
1929 dev_err(pl330->ddma.dev, "%s:%d Can't to create channels for DMAC!\n", in dmac_alloc_resources()
1931 dma_free_attrs(pl330->ddma.dev, in dmac_alloc_resources()
1932 chans * pl330->mcbufsz, in dmac_alloc_resources()
1933 pl330->mcode_cpu, pl330->mcode_bus, in dmac_alloc_resources()
1946 if ((pl330->pcfg.periph_id & 0xfffff) != PERIPH_ID_VAL) { in pl330_add()
1947 dev_err(pl330->ddma.dev, "PERIPH_ID 0x%x !\n", in pl330_add()
1948 pl330->pcfg.periph_id); in pl330_add()
1949 return -EINVAL; in pl330_add()
1955 if (pl330->pcfg.num_events == 0) { in pl330_add()
1956 dev_err(pl330->ddma.dev, "%s:%d Can't work without events!\n", in pl330_add()
1958 return -EINVAL; in pl330_add()
1961 spin_lock_init(&pl330->lock); in pl330_add()
1963 INIT_LIST_HEAD(&pl330->req_done); in pl330_add()
1966 if (!pl330->mcbufsz) in pl330_add()
1967 pl330->mcbufsz = MCODE_BUFF_PER_REQ * 2; in pl330_add()
1970 for (i = 0; i < pl330->pcfg.num_events; i++) in pl330_add()
1971 pl330->events[i] = -1; in pl330_add()
1976 dev_err(pl330->ddma.dev, "Unable to create channels for DMAC\n"); in pl330_add()
1980 tasklet_setup(&pl330->tasks, pl330_dotask); in pl330_add()
1982 pl330->state = INIT; in pl330_add()
1993 for (i = 0; i < pl330->pcfg.num_chan; i++) { in dmac_free_threads()
1994 thrd = &pl330->channels[i]; in dmac_free_threads()
1999 kfree(pl330->channels); in dmac_free_threads()
2006 pl330->state = UNINIT; in pl330_del()
2008 tasklet_kill(&pl330->tasks); in pl330_del()
2013 dma_free_attrs(pl330->ddma.dev, in pl330_del()
2014 pl330->pcfg.num_chan * pl330->mcbufsz, pl330->mcode_cpu, in pl330_del()
2015 pl330->mcode_bus, DMA_ATTR_PRIVILEGED); in pl330_del()
2041 list_for_each_entry(desc, &pch->work_list, node) { in fill_queue()
2044 if (desc->status == BUSY) in fill_queue()
2047 ret = pl330_submit_req(pch->thread, desc); in fill_queue()
2049 desc->status = BUSY; in fill_queue()
2050 } else if (ret == -EAGAIN) { in fill_queue()
2055 desc->status = DONE; in fill_queue()
2056 dev_err(pch->dmac->ddma.dev, "%s:%d Bad Desc(%d)\n", in fill_queue()
2057 __func__, __LINE__, desc->txd.cookie); in fill_queue()
2058 tasklet_schedule(&pch->task); in fill_queue()
2070 spin_lock_irqsave(&pch->lock, flags); in pl330_tasklet()
2073 list_for_each_entry_safe(desc, _dt, &pch->work_list, node) in pl330_tasklet()
2074 if (desc->status == DONE) { in pl330_tasklet()
2075 if (!pch->cyclic) in pl330_tasklet()
2076 dma_cookie_complete(&desc->txd); in pl330_tasklet()
2077 list_move_tail(&desc->node, &pch->completed_list); in pl330_tasklet()
2083 if (list_empty(&pch->work_list)) { in pl330_tasklet()
2084 spin_lock(&pch->thread->dmac->lock); in pl330_tasklet()
2085 _stop(pch->thread); in pl330_tasklet()
2086 spin_unlock(&pch->thread->dmac->lock); in pl330_tasklet()
2088 pch->active = false; in pl330_tasklet()
2091 spin_lock(&pch->thread->dmac->lock); in pl330_tasklet()
2092 _start(pch->thread); in pl330_tasklet()
2093 spin_unlock(&pch->thread->dmac->lock); in pl330_tasklet()
2096 while (!list_empty(&pch->completed_list)) { in pl330_tasklet()
2099 desc = list_first_entry(&pch->completed_list, in pl330_tasklet()
2102 dmaengine_desc_get_callback(&desc->txd, &cb); in pl330_tasklet()
2104 if (pch->cyclic) { in pl330_tasklet()
2105 desc->status = PREP; in pl330_tasklet()
2106 list_move_tail(&desc->node, &pch->work_list); in pl330_tasklet()
2108 pch->active = true; in pl330_tasklet()
2109 spin_lock(&pch->thread->dmac->lock); in pl330_tasklet()
2110 _start(pch->thread); in pl330_tasklet()
2111 spin_unlock(&pch->thread->dmac->lock); in pl330_tasklet()
2115 desc->status = FREE; in pl330_tasklet()
2116 list_move_tail(&desc->node, &pch->dmac->desc_pool); in pl330_tasklet()
2119 dma_descriptor_unmap(&desc->txd); in pl330_tasklet()
2122 spin_unlock_irqrestore(&pch->lock, flags); in pl330_tasklet()
2124 spin_lock_irqsave(&pch->lock, flags); in pl330_tasklet()
2127 spin_unlock_irqrestore(&pch->lock, flags); in pl330_tasklet()
2131 pm_runtime_mark_last_busy(pch->dmac->ddma.dev); in pl330_tasklet()
2132 pm_runtime_put_autosuspend(pch->dmac->ddma.dev); in pl330_tasklet()
2139 int count = dma_spec->args_count; in of_dma_pl330_xlate()
2140 struct pl330_dmac *pl330 = ofdma->of_dma_data; in of_dma_pl330_xlate()
2149 chan_id = dma_spec->args[0]; in of_dma_pl330_xlate()
2150 if (chan_id >= pl330->num_peripherals) in of_dma_pl330_xlate()
2153 return dma_get_slave_channel(&pl330->peripherals[chan_id].chan); in of_dma_pl330_xlate()
2159 struct pl330_dmac *pl330 = pch->dmac; in pl330_alloc_chan_resources()
2162 spin_lock_irqsave(&pl330->lock, flags); in pl330_alloc_chan_resources()
2165 pch->cyclic = false; in pl330_alloc_chan_resources()
2167 pch->thread = pl330_request_channel(pl330); in pl330_alloc_chan_resources()
2168 if (!pch->thread) { in pl330_alloc_chan_resources()
2169 spin_unlock_irqrestore(&pl330->lock, flags); in pl330_alloc_chan_resources()
2170 return -ENOMEM; in pl330_alloc_chan_resources()
2173 tasklet_setup(&pch->task, pl330_tasklet); in pl330_alloc_chan_resources()
2175 spin_unlock_irqrestore(&pl330->lock, flags); in pl330_alloc_chan_resources()
2181 * We need the data direction between the DMAC (the dma-mapping "device") and
2201 if (pch->dir != DMA_NONE) in pl330_unprep_slave_fifo()
2202 dma_unmap_resource(pch->chan.device->dev, pch->fifo_dma, in pl330_unprep_slave_fifo()
2203 1 << pch->burst_sz, pch->dir, 0); in pl330_unprep_slave_fifo()
2204 pch->dir = DMA_NONE; in pl330_unprep_slave_fifo()
2211 struct device *dev = pch->chan.device->dev; in pl330_prep_slave_fifo()
2215 if (pch->dir == dma_dir) in pl330_prep_slave_fifo()
2219 pch->fifo_dma = dma_map_resource(dev, pch->fifo_addr, in pl330_prep_slave_fifo()
2220 1 << pch->burst_sz, dma_dir, 0); in pl330_prep_slave_fifo()
2221 if (dma_mapping_error(dev, pch->fifo_dma)) in pl330_prep_slave_fifo()
2224 pch->dir = dma_dir; in pl330_prep_slave_fifo()
2246 if (slave_config->dst_addr) in pl330_config_write()
2247 pch->fifo_addr = slave_config->dst_addr; in pl330_config_write()
2248 if (slave_config->dst_addr_width) in pl330_config_write()
2249 pch->burst_sz = __ffs(slave_config->dst_addr_width); in pl330_config_write()
2250 pch->burst_len = fixup_burst_len(slave_config->dst_maxburst, in pl330_config_write()
2251 pch->dmac->quirks); in pl330_config_write()
2253 if (slave_config->src_addr) in pl330_config_write()
2254 pch->fifo_addr = slave_config->src_addr; in pl330_config_write()
2255 if (slave_config->src_addr_width) in pl330_config_write()
2256 pch->burst_sz = __ffs(slave_config->src_addr_width); in pl330_config_write()
2257 pch->burst_len = fixup_burst_len(slave_config->src_maxburst, in pl330_config_write()
2258 pch->dmac->quirks); in pl330_config_write()
2269 memcpy(&pch->slave_config, slave_config, sizeof(*slave_config)); in pl330_config()
2279 struct pl330_dmac *pl330 = pch->dmac; in pl330_terminate_all()
2282 pm_runtime_get_sync(pl330->ddma.dev); in pl330_terminate_all()
2283 spin_lock_irqsave(&pch->lock, flags); in pl330_terminate_all()
2285 spin_lock(&pl330->lock); in pl330_terminate_all()
2286 _stop(pch->thread); in pl330_terminate_all()
2287 pch->thread->req[0].desc = NULL; in pl330_terminate_all()
2288 pch->thread->req[1].desc = NULL; in pl330_terminate_all()
2289 pch->thread->req_running = -1; in pl330_terminate_all()
2290 spin_unlock(&pl330->lock); in pl330_terminate_all()
2292 power_down = pch->active; in pl330_terminate_all()
2293 pch->active = false; in pl330_terminate_all()
2296 list_for_each_entry(desc, &pch->submitted_list, node) { in pl330_terminate_all()
2297 desc->status = FREE; in pl330_terminate_all()
2298 dma_cookie_complete(&desc->txd); in pl330_terminate_all()
2301 list_for_each_entry(desc, &pch->work_list , node) { in pl330_terminate_all()
2302 desc->status = FREE; in pl330_terminate_all()
2303 dma_cookie_complete(&desc->txd); in pl330_terminate_all()
2306 list_splice_tail_init(&pch->submitted_list, &pl330->desc_pool); in pl330_terminate_all()
2307 list_splice_tail_init(&pch->work_list, &pl330->desc_pool); in pl330_terminate_all()
2308 list_splice_tail_init(&pch->completed_list, &pl330->desc_pool); in pl330_terminate_all()
2309 spin_unlock_irqrestore(&pch->lock, flags); in pl330_terminate_all()
2310 pm_runtime_mark_last_busy(pl330->ddma.dev); in pl330_terminate_all()
2312 pm_runtime_put_autosuspend(pl330->ddma.dev); in pl330_terminate_all()
2313 pm_runtime_put_autosuspend(pl330->ddma.dev); in pl330_terminate_all()
2328 struct pl330_dmac *pl330 = pch->dmac; in pl330_pause()
2331 pm_runtime_get_sync(pl330->ddma.dev); in pl330_pause()
2332 spin_lock_irqsave(&pch->lock, flags); in pl330_pause()
2334 spin_lock(&pl330->lock); in pl330_pause()
2335 _stop(pch->thread); in pl330_pause()
2336 spin_unlock(&pl330->lock); in pl330_pause()
2338 spin_unlock_irqrestore(&pch->lock, flags); in pl330_pause()
2339 pm_runtime_mark_last_busy(pl330->ddma.dev); in pl330_pause()
2340 pm_runtime_put_autosuspend(pl330->ddma.dev); in pl330_pause()
2348 struct pl330_dmac *pl330 = pch->dmac; in pl330_free_chan_resources()
2351 tasklet_kill(&pch->task); in pl330_free_chan_resources()
2353 pm_runtime_get_sync(pch->dmac->ddma.dev); in pl330_free_chan_resources()
2354 spin_lock_irqsave(&pl330->lock, flags); in pl330_free_chan_resources()
2356 pl330_release_channel(pch->thread); in pl330_free_chan_resources()
2357 pch->thread = NULL; in pl330_free_chan_resources()
2359 if (pch->cyclic) in pl330_free_chan_resources()
2360 list_splice_tail_init(&pch->work_list, &pch->dmac->desc_pool); in pl330_free_chan_resources()
2362 spin_unlock_irqrestore(&pl330->lock, flags); in pl330_free_chan_resources()
2363 pm_runtime_mark_last_busy(pch->dmac->ddma.dev); in pl330_free_chan_resources()
2364 pm_runtime_put_autosuspend(pch->dmac->ddma.dev); in pl330_free_chan_resources()
2371 struct pl330_thread *thrd = pch->thread; in pl330_get_current_xferred_count()
2372 struct pl330_dmac *pl330 = pch->dmac; in pl330_get_current_xferred_count()
2373 void __iomem *regs = thrd->dmac->base; in pl330_get_current_xferred_count()
2376 pm_runtime_get_sync(pl330->ddma.dev); in pl330_get_current_xferred_count()
2378 if (desc->rqcfg.src_inc) { in pl330_get_current_xferred_count()
2379 val = readl(regs + SA(thrd->id)); in pl330_get_current_xferred_count()
2380 addr = desc->px.src_addr; in pl330_get_current_xferred_count()
2382 val = readl(regs + DA(thrd->id)); in pl330_get_current_xferred_count()
2383 addr = desc->px.dst_addr; in pl330_get_current_xferred_count()
2385 pm_runtime_mark_last_busy(pch->dmac->ddma.dev); in pl330_get_current_xferred_count()
2386 pm_runtime_put_autosuspend(pl330->ddma.dev); in pl330_get_current_xferred_count()
2392 return val - addr; in pl330_get_current_xferred_count()
2413 spin_lock_irqsave(&pch->lock, flags); in pl330_tx_status()
2414 spin_lock(&pch->thread->dmac->lock); in pl330_tx_status()
2416 if (pch->thread->req_running != -1) in pl330_tx_status()
2417 running = pch->thread->req[pch->thread->req_running].desc; in pl330_tx_status()
2419 last_enq = pch->thread->req[pch->thread->lstenq].desc; in pl330_tx_status()
2422 list_for_each_entry(desc, &pch->work_list, node) { in pl330_tx_status()
2423 if (desc->status == DONE) in pl330_tx_status()
2424 transferred = desc->bytes_requested; in pl330_tx_status()
2428 else if (desc->status == BUSY) in pl330_tx_status()
2436 transferred = desc->bytes_requested; in pl330_tx_status()
2439 residual += desc->bytes_requested - transferred; in pl330_tx_status()
2440 if (desc->txd.cookie == cookie) { in pl330_tx_status()
2441 switch (desc->status) { in pl330_tx_status()
2454 if (desc->last) in pl330_tx_status()
2457 spin_unlock(&pch->thread->dmac->lock); in pl330_tx_status()
2458 spin_unlock_irqrestore(&pch->lock, flags); in pl330_tx_status()
2471 spin_lock_irqsave(&pch->lock, flags); in pl330_issue_pending()
2472 if (list_empty(&pch->work_list)) { in pl330_issue_pending()
2478 WARN_ON(list_empty(&pch->submitted_list)); in pl330_issue_pending()
2479 pch->active = true; in pl330_issue_pending()
2480 pm_runtime_get_sync(pch->dmac->ddma.dev); in pl330_issue_pending()
2482 list_splice_tail_init(&pch->submitted_list, &pch->work_list); in pl330_issue_pending()
2483 spin_unlock_irqrestore(&pch->lock, flags); in pl330_issue_pending()
2485 pl330_tasklet(&pch->task); in pl330_issue_pending()
2496 struct dma_pl330_chan *pch = to_pchan(tx->chan); in pl330_tx_submit()
2500 spin_lock_irqsave(&pch->lock, flags); in pl330_tx_submit()
2503 while (!list_empty(&last->node)) { in pl330_tx_submit()
2504 desc = list_entry(last->node.next, struct dma_pl330_desc, node); in pl330_tx_submit()
2505 if (pch->cyclic) { in pl330_tx_submit()
2506 desc->txd.callback = last->txd.callback; in pl330_tx_submit()
2507 desc->txd.callback_param = last->txd.callback_param; in pl330_tx_submit()
2509 desc->last = false; in pl330_tx_submit()
2511 dma_cookie_assign(&desc->txd); in pl330_tx_submit()
2513 list_move_tail(&desc->node, &pch->submitted_list); in pl330_tx_submit()
2516 last->last = true; in pl330_tx_submit()
2517 cookie = dma_cookie_assign(&last->txd); in pl330_tx_submit()
2518 list_add_tail(&last->node, &pch->submitted_list); in pl330_tx_submit()
2519 spin_unlock_irqrestore(&pch->lock, flags); in pl330_tx_submit()
2526 desc->rqcfg.swap = SWAP_NO; in _init_desc()
2527 desc->rqcfg.scctl = CCTRL0; in _init_desc()
2528 desc->rqcfg.dcctl = CCTRL0; in _init_desc()
2529 desc->txd.tx_submit = pl330_tx_submit; in _init_desc()
2531 INIT_LIST_HEAD(&desc->node); in _init_desc()
2567 desc = list_entry(pool->next, in pluck_desc()
2570 list_del_init(&desc->node); in pluck_desc()
2572 desc->status = PREP; in pluck_desc()
2573 desc->txd.callback = NULL; in pluck_desc()
2583 struct pl330_dmac *pl330 = pch->dmac; in pl330_get_desc()
2584 u8 *peri_id = pch->chan.private; in pl330_get_desc()
2588 desc = pluck_desc(&pl330->desc_pool, &pl330->pool_lock); in pl330_get_desc()
2603 desc->pchan = pch; in pl330_get_desc()
2604 desc->txd.cookie = 0; in pl330_get_desc()
2605 async_tx_ack(&desc->txd); in pl330_get_desc()
2607 desc->peri = peri_id ? pch->chan.chan_id : 0; in pl330_get_desc()
2608 desc->rqcfg.pcfg = &pch->dmac->pcfg; in pl330_get_desc()
2610 dma_async_tx_descriptor_init(&desc->txd, &pch->chan); in pl330_get_desc()
2618 px->bytes = len; in fill_px()
2619 px->dst_addr = dst; in fill_px()
2620 px->src_addr = src; in fill_px()
2630 dev_err(pch->dmac->ddma.dev, "%s:%d Unable to fetch desc\n", in __pl330_prep_dma_memcpy()
2639 * going to be word-unaligned and more than 200MB, in __pl330_prep_dma_memcpy()
2645 fill_px(&desc->px, dst, src, len); in __pl330_prep_dma_memcpy()
2653 struct dma_pl330_chan *pch = desc->pchan; in get_burst_len()
2654 struct pl330_dmac *pl330 = pch->dmac; in get_burst_len()
2657 burst_len = pl330->pcfg.data_bus_width / 8; in get_burst_len()
2658 burst_len *= pl330->pcfg.data_buf_dep / pl330->pcfg.num_chan; in get_burst_len()
2659 burst_len >>= desc->rqcfg.brst_size; in get_burst_len()
2675 struct pl330_dmac *pl330 = pch->dmac; in pl330_prep_dma_cyclic()
2684 dev_err(pch->dmac->ddma.dev, "%s:%d Invalid dma direction\n", in pl330_prep_dma_cyclic()
2689 pl330_config_write(chan, &pch->slave_config, direction); in pl330_prep_dma_cyclic()
2699 dev_err(pch->dmac->ddma.dev, "%s:%d Unable to fetch desc\n", in pl330_prep_dma_cyclic()
2705 spin_lock_irqsave(&pl330->pool_lock, iflags); in pl330_prep_dma_cyclic()
2707 while (!list_empty(&first->node)) { in pl330_prep_dma_cyclic()
2708 desc = list_entry(first->node.next, in pl330_prep_dma_cyclic()
2710 list_move_tail(&desc->node, &pl330->desc_pool); in pl330_prep_dma_cyclic()
2713 list_move_tail(&first->node, &pl330->desc_pool); in pl330_prep_dma_cyclic()
2715 spin_unlock_irqrestore(&pl330->pool_lock, iflags); in pl330_prep_dma_cyclic()
2722 desc->rqcfg.src_inc = 1; in pl330_prep_dma_cyclic()
2723 desc->rqcfg.dst_inc = 0; in pl330_prep_dma_cyclic()
2725 dst = pch->fifo_dma; in pl330_prep_dma_cyclic()
2728 desc->rqcfg.src_inc = 0; in pl330_prep_dma_cyclic()
2729 desc->rqcfg.dst_inc = 1; in pl330_prep_dma_cyclic()
2730 src = pch->fifo_dma; in pl330_prep_dma_cyclic()
2737 desc->rqtype = direction; in pl330_prep_dma_cyclic()
2738 desc->rqcfg.brst_size = pch->burst_sz; in pl330_prep_dma_cyclic()
2739 desc->rqcfg.brst_len = pch->burst_len; in pl330_prep_dma_cyclic()
2740 desc->bytes_requested = period_len; in pl330_prep_dma_cyclic()
2741 fill_px(&desc->px, dst, src, period_len); in pl330_prep_dma_cyclic()
2746 list_add_tail(&desc->node, &first->node); in pl330_prep_dma_cyclic()
2754 pch->cyclic = true; in pl330_prep_dma_cyclic()
2756 return &desc->txd; in pl330_prep_dma_cyclic()
2771 pl330 = pch->dmac; in pl330_prep_dma_memcpy()
2777 desc->rqcfg.src_inc = 1; in pl330_prep_dma_memcpy()
2778 desc->rqcfg.dst_inc = 1; in pl330_prep_dma_memcpy()
2779 desc->rqtype = DMA_MEM_TO_MEM; in pl330_prep_dma_memcpy()
2782 burst = pl330->pcfg.data_bus_width / 8; in pl330_prep_dma_memcpy()
2789 while ((src | dst | len) & (burst - 1)) in pl330_prep_dma_memcpy()
2792 desc->rqcfg.brst_size = 0; in pl330_prep_dma_memcpy()
2793 while (burst != (1 << desc->rqcfg.brst_size)) in pl330_prep_dma_memcpy()
2794 desc->rqcfg.brst_size++; in pl330_prep_dma_memcpy()
2796 desc->rqcfg.brst_len = get_burst_len(desc, len); in pl330_prep_dma_memcpy()
2801 if (burst * 8 < pl330->pcfg.data_bus_width) in pl330_prep_dma_memcpy()
2802 desc->rqcfg.brst_len = 1; in pl330_prep_dma_memcpy()
2804 desc->bytes_requested = len; in pl330_prep_dma_memcpy()
2806 return &desc->txd; in pl330_prep_dma_memcpy()
2818 spin_lock_irqsave(&pl330->pool_lock, flags); in __pl330_giveback_desc()
2820 while (!list_empty(&first->node)) { in __pl330_giveback_desc()
2821 desc = list_entry(first->node.next, in __pl330_giveback_desc()
2823 list_move_tail(&desc->node, &pl330->desc_pool); in __pl330_giveback_desc()
2826 list_move_tail(&first->node, &pl330->desc_pool); in __pl330_giveback_desc()
2828 spin_unlock_irqrestore(&pl330->pool_lock, flags); in __pl330_giveback_desc()
2844 pl330_config_write(chan, &pch->slave_config, direction); in pl330_prep_slave_sg()
2855 struct pl330_dmac *pl330 = pch->dmac; in pl330_prep_slave_sg()
2857 dev_err(pch->dmac->ddma.dev, in pl330_prep_slave_sg()
2868 list_add_tail(&desc->node, &first->node); in pl330_prep_slave_sg()
2871 desc->rqcfg.src_inc = 1; in pl330_prep_slave_sg()
2872 desc->rqcfg.dst_inc = 0; in pl330_prep_slave_sg()
2873 fill_px(&desc->px, pch->fifo_dma, sg_dma_address(sg), in pl330_prep_slave_sg()
2876 desc->rqcfg.src_inc = 0; in pl330_prep_slave_sg()
2877 desc->rqcfg.dst_inc = 1; in pl330_prep_slave_sg()
2878 fill_px(&desc->px, sg_dma_address(sg), pch->fifo_dma, in pl330_prep_slave_sg()
2882 desc->rqcfg.brst_size = pch->burst_sz; in pl330_prep_slave_sg()
2883 desc->rqcfg.brst_len = pch->burst_len; in pl330_prep_slave_sg()
2884 desc->rqtype = direction; in pl330_prep_slave_sg()
2885 desc->bytes_requested = sg_dma_len(sg); in pl330_prep_slave_sg()
2889 return &desc->txd; in pl330_prep_slave_sg()
2910 struct pl330_dmac *pl330 = s->private; in pl330_debugfs_show()
2913 chans = pl330->pcfg.num_chan; in pl330_debugfs_show()
2914 pchs = pl330->num_peripherals; in pl330_debugfs_show()
2918 seq_puts(s, "--------\t-----\n"); in pl330_debugfs_show()
2920 struct pl330_thread *thrd = &pl330->channels[ch]; in pl330_debugfs_show()
2921 int found = -1; in pl330_debugfs_show()
2924 struct dma_pl330_chan *pch = &pl330->peripherals[pr]; in pl330_debugfs_show()
2926 if (!pch->thread || thrd->id != pch->thread->id) in pl330_debugfs_show()
2932 seq_printf(s, "%d\t\t", thrd->id); in pl330_debugfs_show()
2933 if (found == -1) in pl330_debugfs_show()
2934 seq_puts(s, "--\n"); in pl330_debugfs_show()
2946 debugfs_create_file(dev_name(pl330->ddma.dev), in init_pl330_debugfs()
2967 clk_unprepare(pcdev->pclk); in pl330_suspend()
2977 ret = clk_prepare(pcdev->pclk); in pl330_resume()
2993 struct pl330_config *pcfg; in pl330_probe() local
3000 struct device_node *np = adev->dev.of_node; in pl330_probe()
3002 ret = dma_set_mask_and_coherent(&adev->dev, DMA_BIT_MASK(32)); in pl330_probe()
3007 pl330 = devm_kzalloc(&adev->dev, sizeof(*pl330), GFP_KERNEL); in pl330_probe()
3009 return -ENOMEM; in pl330_probe()
3011 pd = &pl330->ddma; in pl330_probe()
3012 pd->dev = &adev->dev; in pl330_probe()
3014 pl330->mcbufsz = 0; in pl330_probe()
3019 pl330->quirks |= of_quirks[i].id; in pl330_probe()
3021 res = &adev->res; in pl330_probe()
3022 pl330->base = devm_ioremap_resource(&adev->dev, res); in pl330_probe()
3023 if (IS_ERR(pl330->base)) in pl330_probe()
3024 return PTR_ERR(pl330->base); in pl330_probe()
3028 pl330->rstc = devm_reset_control_get_optional(&adev->dev, "dma"); in pl330_probe()
3029 if (IS_ERR(pl330->rstc)) { in pl330_probe()
3030 return dev_err_probe(&adev->dev, PTR_ERR(pl330->rstc), "Failed to get reset!\n"); in pl330_probe()
3032 ret = reset_control_deassert(pl330->rstc); in pl330_probe()
3034 dev_err(&adev->dev, "Couldn't deassert the device from reset!\n"); in pl330_probe()
3039 pl330->rstc_ocp = devm_reset_control_get_optional(&adev->dev, "dma-ocp"); in pl330_probe()
3040 if (IS_ERR(pl330->rstc_ocp)) { in pl330_probe()
3041 return dev_err_probe(&adev->dev, PTR_ERR(pl330->rstc_ocp), in pl330_probe()
3044 ret = reset_control_deassert(pl330->rstc_ocp); in pl330_probe()
3046 dev_err(&adev->dev, "Couldn't deassert the device from OCP reset!\n"); in pl330_probe()
3052 irq = adev->irq[i]; in pl330_probe()
3054 ret = devm_request_irq(&adev->dev, irq, in pl330_probe()
3056 dev_name(&adev->dev), pl330); in pl330_probe()
3064 pcfg = &pl330->pcfg; in pl330_probe()
3066 pcfg->periph_id = adev->periphid; in pl330_probe()
3071 INIT_LIST_HEAD(&pl330->desc_pool); in pl330_probe()
3072 spin_lock_init(&pl330->pool_lock); in pl330_probe()
3075 if (!add_desc(&pl330->desc_pool, &pl330->pool_lock, in pl330_probe()
3077 dev_warn(&adev->dev, "unable to allocate desc\n"); in pl330_probe()
3079 INIT_LIST_HEAD(&pd->channels); in pl330_probe()
3082 num_chan = max_t(int, pcfg->num_peri, pcfg->num_chan); in pl330_probe()
3084 pl330->num_peripherals = num_chan; in pl330_probe()
3086 pl330->peripherals = kcalloc(num_chan, sizeof(*pch), GFP_KERNEL); in pl330_probe()
3087 if (!pl330->peripherals) { in pl330_probe()
3088 ret = -ENOMEM; in pl330_probe()
3093 pch = &pl330->peripherals[i]; in pl330_probe()
3095 pch->chan.private = adev->dev.of_node; in pl330_probe()
3096 INIT_LIST_HEAD(&pch->submitted_list); in pl330_probe()
3097 INIT_LIST_HEAD(&pch->work_list); in pl330_probe()
3098 INIT_LIST_HEAD(&pch->completed_list); in pl330_probe()
3099 spin_lock_init(&pch->lock); in pl330_probe()
3100 pch->thread = NULL; in pl330_probe()
3101 pch->chan.device = pd; in pl330_probe()
3102 pch->dmac = pl330; in pl330_probe()
3103 pch->dir = DMA_NONE; in pl330_probe()
3106 list_add_tail(&pch->chan.device_node, &pd->channels); in pl330_probe()
3109 dma_cap_set(DMA_MEMCPY, pd->cap_mask); in pl330_probe()
3110 if (pcfg->num_peri) { in pl330_probe()
3111 dma_cap_set(DMA_SLAVE, pd->cap_mask); in pl330_probe()
3112 dma_cap_set(DMA_CYCLIC, pd->cap_mask); in pl330_probe()
3113 dma_cap_set(DMA_PRIVATE, pd->cap_mask); in pl330_probe()
3116 pd->device_alloc_chan_resources = pl330_alloc_chan_resources; in pl330_probe()
3117 pd->device_free_chan_resources = pl330_free_chan_resources; in pl330_probe()
3118 pd->device_prep_dma_memcpy = pl330_prep_dma_memcpy; in pl330_probe()
3119 pd->device_prep_dma_cyclic = pl330_prep_dma_cyclic; in pl330_probe()
3120 pd->device_tx_status = pl330_tx_status; in pl330_probe()
3121 pd->device_prep_slave_sg = pl330_prep_slave_sg; in pl330_probe()
3122 pd->device_config = pl330_config; in pl330_probe()
3123 pd->device_pause = pl330_pause; in pl330_probe()
3124 pd->device_terminate_all = pl330_terminate_all; in pl330_probe()
3125 pd->device_issue_pending = pl330_issue_pending; in pl330_probe()
3126 pd->src_addr_widths = PL330_DMA_BUSWIDTHS; in pl330_probe()
3127 pd->dst_addr_widths = PL330_DMA_BUSWIDTHS; in pl330_probe()
3128 pd->directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV); in pl330_probe()
3129 pd->residue_granularity = DMA_RESIDUE_GRANULARITY_BURST; in pl330_probe()
3130 pd->max_burst = PL330_MAX_BURST; in pl330_probe()
3134 dev_err(&adev->dev, "unable to register DMAC\n"); in pl330_probe()
3138 if (adev->dev.of_node) { in pl330_probe()
3139 ret = of_dma_controller_register(adev->dev.of_node, in pl330_probe()
3142 dev_err(&adev->dev, in pl330_probe()
3151 ret = dma_set_max_seg_size(&adev->dev, 1900800); in pl330_probe()
3153 dev_err(&adev->dev, "unable to set the seg size\n"); in pl330_probe()
3157 dev_info(&adev->dev, in pl330_probe()
3158 "Loaded driver for PL330 DMAC-%x\n", adev->periphid); in pl330_probe()
3159 dev_info(&adev->dev, in pl330_probe()
3160 "\tDBUFF-%ux%ubytes Num_Chans-%u Num_Peri-%u Num_Events-%u\n", in pl330_probe()
3161 pcfg->data_buf_dep, pcfg->data_bus_width / 8, pcfg->num_chan, in pl330_probe()
3162 pcfg->num_peri, pcfg->num_events); in pl330_probe()
3164 pm_runtime_irq_safe(&adev->dev); in pl330_probe()
3165 pm_runtime_use_autosuspend(&adev->dev); in pl330_probe()
3166 pm_runtime_set_autosuspend_delay(&adev->dev, PL330_AUTOSUSPEND_DELAY); in pl330_probe()
3167 pm_runtime_mark_last_busy(&adev->dev); in pl330_probe()
3168 pm_runtime_put_autosuspend(&adev->dev); in pl330_probe()
3173 list_for_each_entry_safe(pch, _p, &pl330->ddma.channels, in pl330_probe()
3177 list_del(&pch->chan.device_node); in pl330_probe()
3180 if (pch->thread) { in pl330_probe()
3181 pl330_terminate_all(&pch->chan); in pl330_probe()
3182 pl330_free_chan_resources(&pch->chan); in pl330_probe()
3188 if (pl330->rstc_ocp) in pl330_probe()
3189 reset_control_assert(pl330->rstc_ocp); in pl330_probe()
3191 if (pl330->rstc) in pl330_probe()
3192 reset_control_assert(pl330->rstc); in pl330_probe()
3202 pm_runtime_get_noresume(pl330->ddma.dev); in pl330_remove()
3204 if (adev->dev.of_node) in pl330_remove()
3205 of_dma_controller_free(adev->dev.of_node); in pl330_remove()
3208 irq = adev->irq[i]; in pl330_remove()
3210 devm_free_irq(&adev->dev, irq, pl330); in pl330_remove()
3213 dma_async_device_unregister(&pl330->ddma); in pl330_remove()
3216 list_for_each_entry_safe(pch, _p, &pl330->ddma.channels, in pl330_remove()
3220 list_del(&pch->chan.device_node); in pl330_remove()
3223 if (pch->thread) { in pl330_remove()
3224 pl330_terminate_all(&pch->chan); in pl330_remove()
3225 pl330_free_chan_resources(&pch->chan); in pl330_remove()
3231 if (pl330->rstc_ocp) in pl330_remove()
3232 reset_control_assert(pl330->rstc_ocp); in pl330_remove()
3234 if (pl330->rstc) in pl330_remove()
3235 reset_control_assert(pl330->rstc); in pl330_remove()
3251 .name = "dma-pl330",