Lines Matching full:pdma
216 struct xgene_dma *pdma; member
248 * @pdma: X-Gene DMA device structure reference
272 struct xgene_dma *pdma; member
344 static bool is_pq_enabled(struct xgene_dma *pdma) in is_pq_enabled() argument
348 val = ioread32(pdma->csr_efuse + XGENE_SOC_JTAG1_SHADOW); in is_pq_enabled()
1014 struct xgene_dma *pdma = (struct xgene_dma *)id; in xgene_dma_err_isr() local
1018 val = ioread32(pdma->csr_dma + XGENE_DMA_INT); in xgene_dma_err_isr()
1021 iowrite32(val, pdma->csr_dma + XGENE_DMA_INT); in xgene_dma_err_isr()
1026 dev_err(pdma->dev, in xgene_dma_err_isr()
1036 iowrite32(ring->num, ring->pdma->csr_ring + XGENE_DMA_RING_STATE); in xgene_dma_wr_ring_state()
1039 iowrite32(ring->state[i], ring->pdma->csr_ring + in xgene_dma_wr_ring_state()
1083 ring->pdma->csr_ring + XGENE_DMA_RING_ID); in xgene_dma_setup_ring()
1087 ring->pdma->csr_ring + XGENE_DMA_RING_ID_BUF); in xgene_dma_setup_ring()
1101 val = ioread32(ring->pdma->csr_ring + XGENE_DMA_RING_NE_INT_MODE); in xgene_dma_setup_ring()
1103 iowrite32(val, ring->pdma->csr_ring + XGENE_DMA_RING_NE_INT_MODE); in xgene_dma_setup_ring()
1112 val = ioread32(ring->pdma->csr_ring + in xgene_dma_clear_ring()
1115 iowrite32(val, ring->pdma->csr_ring + in xgene_dma_clear_ring()
1121 iowrite32(ring_id, ring->pdma->csr_ring + XGENE_DMA_RING_ID); in xgene_dma_clear_ring()
1123 iowrite32(0, ring->pdma->csr_ring + XGENE_DMA_RING_ID_BUF); in xgene_dma_clear_ring()
1129 ring->cmd_base = ring->pdma->csr_ring_cmd + in xgene_dma_set_ring_cmd()
1172 dma_free_coherent(ring->pdma->dev, ring->size, in xgene_dma_delete_ring_one()
1191 ring->pdma = chan->pdma; in xgene_dma_create_ring_one()
1193 ring->num = chan->pdma->ring_num++; in xgene_dma_create_ring_one()
1257 static int xgene_dma_init_rings(struct xgene_dma *pdma) in xgene_dma_init_rings() argument
1262 ret = xgene_dma_create_chan_rings(&pdma->chan[i]); in xgene_dma_init_rings()
1265 xgene_dma_delete_chan_rings(&pdma->chan[j]); in xgene_dma_init_rings()
1273 static void xgene_dma_enable(struct xgene_dma *pdma) in xgene_dma_enable() argument
1278 val = ioread32(pdma->csr_dma + XGENE_DMA_GCR); in xgene_dma_enable()
1281 iowrite32(val, pdma->csr_dma + XGENE_DMA_GCR); in xgene_dma_enable()
1284 static void xgene_dma_disable(struct xgene_dma *pdma) in xgene_dma_disable() argument
1288 val = ioread32(pdma->csr_dma + XGENE_DMA_GCR); in xgene_dma_disable()
1290 iowrite32(val, pdma->csr_dma + XGENE_DMA_GCR); in xgene_dma_disable()
1293 static void xgene_dma_mask_interrupts(struct xgene_dma *pdma) in xgene_dma_mask_interrupts() argument
1300 pdma->csr_dma + XGENE_DMA_RING_INT0_MASK); in xgene_dma_mask_interrupts()
1302 pdma->csr_dma + XGENE_DMA_RING_INT1_MASK); in xgene_dma_mask_interrupts()
1304 pdma->csr_dma + XGENE_DMA_RING_INT2_MASK); in xgene_dma_mask_interrupts()
1306 pdma->csr_dma + XGENE_DMA_RING_INT3_MASK); in xgene_dma_mask_interrupts()
1308 pdma->csr_dma + XGENE_DMA_RING_INT4_MASK); in xgene_dma_mask_interrupts()
1311 iowrite32(XGENE_DMA_INT_ALL_MASK, pdma->csr_dma + XGENE_DMA_INT_MASK); in xgene_dma_mask_interrupts()
1314 static void xgene_dma_unmask_interrupts(struct xgene_dma *pdma) in xgene_dma_unmask_interrupts() argument
1321 pdma->csr_dma + XGENE_DMA_RING_INT0_MASK); in xgene_dma_unmask_interrupts()
1323 pdma->csr_dma + XGENE_DMA_RING_INT1_MASK); in xgene_dma_unmask_interrupts()
1325 pdma->csr_dma + XGENE_DMA_RING_INT2_MASK); in xgene_dma_unmask_interrupts()
1327 pdma->csr_dma + XGENE_DMA_RING_INT3_MASK); in xgene_dma_unmask_interrupts()
1329 pdma->csr_dma + XGENE_DMA_RING_INT4_MASK); in xgene_dma_unmask_interrupts()
1333 pdma->csr_dma + XGENE_DMA_INT_MASK); in xgene_dma_unmask_interrupts()
1336 static void xgene_dma_init_hw(struct xgene_dma *pdma) in xgene_dma_init_hw() argument
1342 pdma->csr_dma + XGENE_DMA_CFG_RING_WQ_ASSOC); in xgene_dma_init_hw()
1345 if (is_pq_enabled(pdma)) in xgene_dma_init_hw()
1347 pdma->csr_dma + XGENE_DMA_RAID6_CONT); in xgene_dma_init_hw()
1349 dev_info(pdma->dev, "PQ is disabled in HW\n"); in xgene_dma_init_hw()
1351 xgene_dma_enable(pdma); in xgene_dma_init_hw()
1352 xgene_dma_unmask_interrupts(pdma); in xgene_dma_init_hw()
1355 val = ioread32(pdma->csr_dma + XGENE_DMA_IPBRR); in xgene_dma_init_hw()
1358 dev_info(pdma->dev, in xgene_dma_init_hw()
1364 static int xgene_dma_init_ring_mngr(struct xgene_dma *pdma) in xgene_dma_init_ring_mngr() argument
1366 if (ioread32(pdma->csr_ring + XGENE_DMA_RING_CLKEN) && in xgene_dma_init_ring_mngr()
1367 (!ioread32(pdma->csr_ring + XGENE_DMA_RING_SRST))) in xgene_dma_init_ring_mngr()
1370 iowrite32(0x3, pdma->csr_ring + XGENE_DMA_RING_CLKEN); in xgene_dma_init_ring_mngr()
1371 iowrite32(0x0, pdma->csr_ring + XGENE_DMA_RING_SRST); in xgene_dma_init_ring_mngr()
1374 iowrite32(0x0, pdma->csr_ring + XGENE_DMA_RING_MEM_RAM_SHUTDOWN); in xgene_dma_init_ring_mngr()
1377 ioread32(pdma->csr_ring + XGENE_DMA_RING_MEM_RAM_SHUTDOWN); in xgene_dma_init_ring_mngr()
1382 if (ioread32(pdma->csr_ring + XGENE_DMA_RING_BLK_MEM_RDY) in xgene_dma_init_ring_mngr()
1384 dev_err(pdma->dev, in xgene_dma_init_ring_mngr()
1391 pdma->csr_ring + XGENE_DMA_RING_THRESLD0_SET1); in xgene_dma_init_ring_mngr()
1393 pdma->csr_ring + XGENE_DMA_RING_THRESLD1_SET1); in xgene_dma_init_ring_mngr()
1395 pdma->csr_ring + XGENE_DMA_RING_HYSTERESIS); in xgene_dma_init_ring_mngr()
1399 pdma->csr_ring + XGENE_DMA_RING_CONFIG); in xgene_dma_init_ring_mngr()
1404 static int xgene_dma_init_mem(struct xgene_dma *pdma) in xgene_dma_init_mem() argument
1408 ret = xgene_dma_init_ring_mngr(pdma); in xgene_dma_init_mem()
1413 iowrite32(0x0, pdma->csr_dma + XGENE_DMA_MEM_RAM_SHUTDOWN); in xgene_dma_init_mem()
1416 ioread32(pdma->csr_dma + XGENE_DMA_MEM_RAM_SHUTDOWN); in xgene_dma_init_mem()
1421 if (ioread32(pdma->csr_dma + XGENE_DMA_BLK_MEM_RDY) in xgene_dma_init_mem()
1423 dev_err(pdma->dev, in xgene_dma_init_mem()
1431 static int xgene_dma_request_irqs(struct xgene_dma *pdma) in xgene_dma_request_irqs() argument
1437 ret = devm_request_irq(pdma->dev, pdma->err_irq, xgene_dma_err_isr, in xgene_dma_request_irqs()
1438 0, "dma_error", pdma); in xgene_dma_request_irqs()
1440 dev_err(pdma->dev, in xgene_dma_request_irqs()
1441 "Failed to register error IRQ %d\n", pdma->err_irq); in xgene_dma_request_irqs()
1447 chan = &pdma->chan[i]; in xgene_dma_request_irqs()
1455 devm_free_irq(pdma->dev, pdma->err_irq, pdma); in xgene_dma_request_irqs()
1458 chan = &pdma->chan[i]; in xgene_dma_request_irqs()
1470 static void xgene_dma_free_irqs(struct xgene_dma *pdma) in xgene_dma_free_irqs() argument
1476 devm_free_irq(pdma->dev, pdma->err_irq, pdma); in xgene_dma_free_irqs()
1479 chan = &pdma->chan[i]; in xgene_dma_free_irqs()
1503 is_pq_enabled(chan->pdma)) { in xgene_dma_set_caps()
1507 !is_pq_enabled(chan->pdma)) { in xgene_dma_set_caps()
1531 static int xgene_dma_async_register(struct xgene_dma *pdma, int id) in xgene_dma_async_register() argument
1533 struct xgene_dma_chan *chan = &pdma->chan[id]; in xgene_dma_async_register()
1534 struct dma_device *dma_dev = &pdma->dma_dev[id]; in xgene_dma_async_register()
1566 dev_info(pdma->dev, in xgene_dma_async_register()
1574 static int xgene_dma_init_async(struct xgene_dma *pdma) in xgene_dma_init_async() argument
1579 ret = xgene_dma_async_register(pdma, i); in xgene_dma_init_async()
1582 dma_async_device_unregister(&pdma->dma_dev[j]); in xgene_dma_init_async()
1583 tasklet_kill(&pdma->chan[j].tasklet); in xgene_dma_init_async()
1593 static void xgene_dma_async_unregister(struct xgene_dma *pdma) in xgene_dma_async_unregister() argument
1598 dma_async_device_unregister(&pdma->dma_dev[i]); in xgene_dma_async_unregister()
1601 static void xgene_dma_init_channels(struct xgene_dma *pdma) in xgene_dma_init_channels() argument
1606 pdma->ring_num = XGENE_DMA_RING_NUM; in xgene_dma_init_channels()
1609 chan = &pdma->chan[i]; in xgene_dma_init_channels()
1610 chan->dev = pdma->dev; in xgene_dma_init_channels()
1611 chan->pdma = pdma; in xgene_dma_init_channels()
1618 struct xgene_dma *pdma) in xgene_dma_get_resources() argument
1630 pdma->csr_dma = devm_ioremap(&pdev->dev, res->start, in xgene_dma_get_resources()
1632 if (!pdma->csr_dma) { in xgene_dma_get_resources()
1644 pdma->csr_ring = devm_ioremap(&pdev->dev, res->start, in xgene_dma_get_resources()
1646 if (!pdma->csr_ring) { in xgene_dma_get_resources()
1658 pdma->csr_ring_cmd = devm_ioremap(&pdev->dev, res->start, in xgene_dma_get_resources()
1660 if (!pdma->csr_ring_cmd) { in xgene_dma_get_resources()
1665 pdma->csr_ring_cmd += XGENE_DMA_RING_CMD_SM_OFFSET; in xgene_dma_get_resources()
1674 pdma->csr_efuse = devm_ioremap(&pdev->dev, res->start, in xgene_dma_get_resources()
1676 if (!pdma->csr_efuse) { in xgene_dma_get_resources()
1686 pdma->err_irq = irq; in xgene_dma_get_resources()
1694 pdma->chan[i - 1].rx_irq = irq; in xgene_dma_get_resources()
1702 struct xgene_dma *pdma; in xgene_dma_probe() local
1705 pdma = devm_kzalloc(&pdev->dev, sizeof(*pdma), GFP_KERNEL); in xgene_dma_probe()
1706 if (!pdma) in xgene_dma_probe()
1709 pdma->dev = &pdev->dev; in xgene_dma_probe()
1710 platform_set_drvdata(pdev, pdma); in xgene_dma_probe()
1712 ret = xgene_dma_get_resources(pdev, pdma); in xgene_dma_probe()
1716 pdma->clk = devm_clk_get(&pdev->dev, NULL); in xgene_dma_probe()
1717 if (IS_ERR(pdma->clk) && !ACPI_COMPANION(&pdev->dev)) { in xgene_dma_probe()
1719 return PTR_ERR(pdma->clk); in xgene_dma_probe()
1723 if (!IS_ERR(pdma->clk)) { in xgene_dma_probe()
1724 ret = clk_prepare_enable(pdma->clk); in xgene_dma_probe()
1732 ret = xgene_dma_init_mem(pdma); in xgene_dma_probe()
1743 xgene_dma_init_channels(pdma); in xgene_dma_probe()
1746 ret = xgene_dma_init_rings(pdma); in xgene_dma_probe()
1750 ret = xgene_dma_request_irqs(pdma); in xgene_dma_probe()
1755 xgene_dma_init_hw(pdma); in xgene_dma_probe()
1758 ret = xgene_dma_init_async(pdma); in xgene_dma_probe()
1765 xgene_dma_free_irqs(pdma); in xgene_dma_probe()
1769 xgene_dma_delete_chan_rings(&pdma->chan[i]); in xgene_dma_probe()
1773 if (!IS_ERR(pdma->clk)) in xgene_dma_probe()
1774 clk_disable_unprepare(pdma->clk); in xgene_dma_probe()
1781 struct xgene_dma *pdma = platform_get_drvdata(pdev); in xgene_dma_remove() local
1785 xgene_dma_async_unregister(pdma); in xgene_dma_remove()
1788 xgene_dma_mask_interrupts(pdma); in xgene_dma_remove()
1789 xgene_dma_disable(pdma); in xgene_dma_remove()
1790 xgene_dma_free_irqs(pdma); in xgene_dma_remove()
1793 chan = &pdma->chan[i]; in xgene_dma_remove()
1798 if (!IS_ERR(pdma->clk)) in xgene_dma_remove()
1799 clk_disable_unprepare(pdma->clk); in xgene_dma_remove()