Lines Matching refs:xdev

127 #define xdma_err(xdev, fmt, args...)					\  argument
128 dev_err(&(xdev)->pdev->dev, fmt, ##args)
193 struct xdma_device *xdev = chan->xdev_hdl; in xdma_channel_init() local
196 ret = regmap_write(xdev->rmap, chan->base + XDMA_CHAN_CONTROL_W1C, in xdma_channel_init()
201 ret = regmap_write(xdev->rmap, chan->base + XDMA_CHAN_INTR_ENABLE, in xdma_channel_init()
285 struct xdma_device *xdev = xchan->xdev_hdl; in xdma_xfer_start() local
299 ret = regmap_write(xdev->rmap, xchan->base + XDMA_CHAN_CONTROL_W1C, in xdma_xfer_start()
306 xdma_err(xdev, "incorrect request direction"); in xdma_xfer_start()
314 ret = regmap_write(xdev->rmap, xchan->base + XDMA_SGDMA_DESC_LO, val); in xdma_xfer_start()
319 ret = regmap_write(xdev->rmap, xchan->base + XDMA_SGDMA_DESC_HI, val); in xdma_xfer_start()
327 ret = regmap_write(xdev->rmap, xchan->base + XDMA_SGDMA_DESC_ADJ, val); in xdma_xfer_start()
332 ret = regmap_write(xdev->rmap, xchan->base + XDMA_CHAN_CONTROL, in xdma_xfer_start()
346 static int xdma_alloc_channels(struct xdma_device *xdev, in xdma_alloc_channels() argument
349 struct xdma_platdata *pdata = dev_get_platdata(&xdev->pdev->dev); in xdma_alloc_channels()
358 chans = &xdev->h2c_chans; in xdma_alloc_channels()
359 chan_num = &xdev->h2c_chan_num; in xdma_alloc_channels()
363 chans = &xdev->c2h_chans; in xdma_alloc_channels()
364 chan_num = &xdev->c2h_chan_num; in xdma_alloc_channels()
366 xdma_err(xdev, "invalid direction specified"); in xdma_alloc_channels()
372 ret = regmap_read(xdev->rmap, base + i * XDMA_CHAN_STRIDE, in xdma_alloc_channels()
383 xdma_err(xdev, "does not probe any channel"); in xdma_alloc_channels()
387 *chans = devm_kcalloc(&xdev->pdev->dev, *chan_num, sizeof(**chans), in xdma_alloc_channels()
393 ret = regmap_read(xdev->rmap, base + i * XDMA_CHAN_STRIDE, in xdma_alloc_channels()
402 xdma_err(xdev, "invalid channel number"); in xdma_alloc_channels()
408 xchan->xdev_hdl = xdev; in xdma_alloc_channels()
416 vchan_init(&xchan->vchan, &xdev->dma_dev); in xdma_alloc_channels()
421 dev_info(&xdev->pdev->dev, "configured %d %s channels", j, in xdma_alloc_channels()
559 struct xdma_device *xdev = xdma_chan->xdev_hdl; in xdma_alloc_chan_resources() local
560 struct device *dev = xdev->dma_dev.dev; in xdma_alloc_chan_resources()
565 xdma_err(xdev, "unable to find pci device"); in xdma_alloc_chan_resources()
573 xdma_err(xdev, "unable to allocate descriptor pool"); in xdma_alloc_chan_resources()
589 struct xdma_device *xdev; in xdma_channel_isr() local
603 xdev = xchan->xdev_hdl; in xdma_channel_isr()
605 ret = regmap_read(xdev->rmap, xchan->base + XDMA_CHAN_COMPLETED_DESC, in xdma_channel_isr()
636 static void xdma_irq_fini(struct xdma_device *xdev) in xdma_irq_fini() argument
641 regmap_write(xdev->rmap, XDMA_IRQ_CHAN_INT_EN_W1C, ~0); in xdma_irq_fini()
644 for (i = 0; i < xdev->h2c_chan_num; i++) in xdma_irq_fini()
645 free_irq(xdev->h2c_chans[i].irq, &xdev->h2c_chans[i]); in xdma_irq_fini()
647 for (i = 0; i < xdev->c2h_chan_num; i++) in xdma_irq_fini()
648 free_irq(xdev->c2h_chans[i].irq, &xdev->c2h_chans[i]); in xdma_irq_fini()
658 static int xdma_set_vector_reg(struct xdma_device *xdev, u32 vec_tbl_start, in xdma_set_vector_reg() argument
676 ret = regmap_write(xdev->rmap, vec_tbl_start, val); in xdma_set_vector_reg()
690 static int xdma_irq_init(struct xdma_device *xdev) in xdma_irq_init() argument
692 u32 irq = xdev->irq_start; in xdma_irq_init()
697 if (xdev->irq_num < XDMA_CHAN_NUM(xdev)) { in xdma_irq_init()
698 xdma_err(xdev, "not enough irq"); in xdma_irq_init()
703 for (i = 0; i < xdev->h2c_chan_num; i++) { in xdma_irq_init()
705 "xdma-h2c-channel", &xdev->h2c_chans[i]); in xdma_irq_init()
707 xdma_err(xdev, "H2C channel%d request irq%d failed: %d", in xdma_irq_init()
711 xdev->h2c_chans[i].irq = irq; in xdma_irq_init()
716 for (j = 0; j < xdev->c2h_chan_num; j++) { in xdma_irq_init()
718 "xdma-c2h-channel", &xdev->c2h_chans[j]); in xdma_irq_init()
720 xdma_err(xdev, "C2H channel%d request irq%d failed: %d", in xdma_irq_init()
724 xdev->c2h_chans[j].irq = irq; in xdma_irq_init()
729 ret = xdma_set_vector_reg(xdev, XDMA_IRQ_CHAN_VEC_NUM, 0, in xdma_irq_init()
730 XDMA_CHAN_NUM(xdev)); in xdma_irq_init()
732 xdma_err(xdev, "failed to set channel vectors: %d", ret); in xdma_irq_init()
737 user_irq_start = XDMA_CHAN_NUM(xdev); in xdma_irq_init()
738 if (xdev->irq_num > user_irq_start) { in xdma_irq_init()
739 ret = xdma_set_vector_reg(xdev, XDMA_IRQ_USER_VEC_NUM, in xdma_irq_init()
741 xdev->irq_num - user_irq_start); in xdma_irq_init()
743 xdma_err(xdev, "failed to set user vectors: %d", ret); in xdma_irq_init()
749 ret = regmap_write(xdev->rmap, XDMA_IRQ_CHAN_INT_EN_W1S, ~0); in xdma_irq_init()
757 free_irq(xdev->c2h_chans[j].irq, &xdev->c2h_chans[j]); in xdma_irq_init()
760 free_irq(xdev->h2c_chans[i].irq, &xdev->h2c_chans[i]); in xdma_irq_init()
780 struct xdma_device *xdev = platform_get_drvdata(pdev); in xdma_disable_user_irq() local
783 index = irq_num - xdev->irq_start; in xdma_disable_user_irq()
784 if (index < XDMA_CHAN_NUM(xdev) || index >= xdev->irq_num) { in xdma_disable_user_irq()
785 xdma_err(xdev, "invalid user irq number"); in xdma_disable_user_irq()
788 index -= XDMA_CHAN_NUM(xdev); in xdma_disable_user_irq()
790 regmap_write(xdev->rmap, XDMA_IRQ_USER_INT_EN_W1C, 1 << index); in xdma_disable_user_irq()
801 struct xdma_device *xdev = platform_get_drvdata(pdev); in xdma_enable_user_irq() local
805 index = irq_num - xdev->irq_start; in xdma_enable_user_irq()
806 if (index < XDMA_CHAN_NUM(xdev) || index >= xdev->irq_num) { in xdma_enable_user_irq()
807 xdma_err(xdev, "invalid user irq number"); in xdma_enable_user_irq()
810 index -= XDMA_CHAN_NUM(xdev); in xdma_enable_user_irq()
812 ret = regmap_write(xdev->rmap, XDMA_IRQ_USER_INT_EN_W1S, 1 << index); in xdma_enable_user_irq()
829 struct xdma_device *xdev = platform_get_drvdata(pdev); in xdma_get_user_irq() local
831 if (XDMA_CHAN_NUM(xdev) + user_irq_index >= xdev->irq_num) { in xdma_get_user_irq()
832 xdma_err(xdev, "invalid user irq index"); in xdma_get_user_irq()
836 return xdev->irq_start + XDMA_CHAN_NUM(xdev) + user_irq_index; in xdma_get_user_irq()
846 struct xdma_device *xdev = platform_get_drvdata(pdev); in xdma_remove() local
848 if (xdev->status & XDMA_DEV_STATUS_INIT_MSIX) in xdma_remove()
849 xdma_irq_fini(xdev); in xdma_remove()
851 if (xdev->status & XDMA_DEV_STATUS_REG_DMA) in xdma_remove()
852 dma_async_device_unregister(&xdev->dma_dev); in xdma_remove()
864 struct xdma_device *xdev; in xdma_probe() local
875 xdev = devm_kzalloc(&pdev->dev, sizeof(*xdev), GFP_KERNEL); in xdma_probe()
876 if (!xdev) in xdma_probe()
879 platform_set_drvdata(pdev, xdev); in xdma_probe()
880 xdev->pdev = pdev; in xdma_probe()
884 xdma_err(xdev, "failed to get irq resource"); in xdma_probe()
887 xdev->irq_start = res->start; in xdma_probe()
888 xdev->irq_num = res->end - res->start + 1; in xdma_probe()
892 xdma_err(xdev, "failed to get io resource"); in xdma_probe()
898 xdma_err(xdev, "ioremap failed"); in xdma_probe()
902 xdev->rmap = devm_regmap_init_mmio(&pdev->dev, reg_base, in xdma_probe()
904 if (!xdev->rmap) { in xdma_probe()
905 xdma_err(xdev, "config regmap failed: %d", ret); in xdma_probe()
908 INIT_LIST_HEAD(&xdev->dma_dev.channels); in xdma_probe()
910 ret = xdma_alloc_channels(xdev, DMA_MEM_TO_DEV); in xdma_probe()
912 xdma_err(xdev, "config H2C channels failed: %d", ret); in xdma_probe()
916 ret = xdma_alloc_channels(xdev, DMA_DEV_TO_MEM); in xdma_probe()
918 xdma_err(xdev, "config C2H channels failed: %d", ret); in xdma_probe()
922 dma_cap_set(DMA_SLAVE, xdev->dma_dev.cap_mask); in xdma_probe()
923 dma_cap_set(DMA_PRIVATE, xdev->dma_dev.cap_mask); in xdma_probe()
925 xdev->dma_dev.dev = &pdev->dev; in xdma_probe()
926 xdev->dma_dev.device_free_chan_resources = xdma_free_chan_resources; in xdma_probe()
927 xdev->dma_dev.device_alloc_chan_resources = xdma_alloc_chan_resources; in xdma_probe()
928 xdev->dma_dev.device_tx_status = dma_cookie_status; in xdma_probe()
929 xdev->dma_dev.device_prep_slave_sg = xdma_prep_device_sg; in xdma_probe()
930 xdev->dma_dev.device_config = xdma_device_config; in xdma_probe()
931 xdev->dma_dev.device_issue_pending = xdma_issue_pending; in xdma_probe()
932 xdev->dma_dev.filter.map = pdata->device_map; in xdma_probe()
933 xdev->dma_dev.filter.mapcnt = pdata->device_map_cnt; in xdma_probe()
934 xdev->dma_dev.filter.fn = xdma_filter_fn; in xdma_probe()
936 ret = dma_async_device_register(&xdev->dma_dev); in xdma_probe()
938 xdma_err(xdev, "failed to register Xilinx XDMA: %d", ret); in xdma_probe()
941 xdev->status |= XDMA_DEV_STATUS_REG_DMA; in xdma_probe()
943 ret = xdma_irq_init(xdev); in xdma_probe()
945 xdma_err(xdev, "failed to init msix: %d", ret); in xdma_probe()
948 xdev->status |= XDMA_DEV_STATUS_INIT_MSIX; in xdma_probe()