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
674 ret = regmap_write(xdev->rmap, vec_tbl_start, val); in xdma_set_vector_reg()
688 static int xdma_irq_init(struct xdma_device *xdev) in xdma_irq_init() argument
690 u32 irq = xdev->irq_start; in xdma_irq_init()
695 if (xdev->irq_num < XDMA_CHAN_NUM(xdev)) { in xdma_irq_init()
696 xdma_err(xdev, "not enough irq"); in xdma_irq_init()
701 for (i = 0; i < xdev->h2c_chan_num; i++) { in xdma_irq_init()
703 "xdma-h2c-channel", &xdev->h2c_chans[i]); in xdma_irq_init()
705 xdma_err(xdev, "H2C channel%d request irq%d failed: %d", in xdma_irq_init()
709 xdev->h2c_chans[i].irq = irq; in xdma_irq_init()
714 for (j = 0; j < xdev->c2h_chan_num; j++) { in xdma_irq_init()
716 "xdma-c2h-channel", &xdev->c2h_chans[j]); in xdma_irq_init()
718 xdma_err(xdev, "H2C channel%d request irq%d failed: %d", in xdma_irq_init()
722 xdev->c2h_chans[j].irq = irq; in xdma_irq_init()
727 ret = xdma_set_vector_reg(xdev, XDMA_IRQ_CHAN_VEC_NUM, 0, in xdma_irq_init()
728 XDMA_CHAN_NUM(xdev)); in xdma_irq_init()
730 xdma_err(xdev, "failed to set channel vectors: %d", ret); in xdma_irq_init()
735 user_irq_start = XDMA_CHAN_NUM(xdev); in xdma_irq_init()
736 if (xdev->irq_num > user_irq_start) { in xdma_irq_init()
737 ret = xdma_set_vector_reg(xdev, XDMA_IRQ_USER_VEC_NUM, in xdma_irq_init()
739 xdev->irq_num - user_irq_start); in xdma_irq_init()
741 xdma_err(xdev, "failed to set user vectors: %d", ret); in xdma_irq_init()
747 ret = regmap_write(xdev->rmap, XDMA_IRQ_CHAN_INT_EN_W1S, ~0); in xdma_irq_init()
755 free_irq(xdev->c2h_chans[j].irq, &xdev->c2h_chans[j]); in xdma_irq_init()
758 free_irq(xdev->h2c_chans[i].irq, &xdev->h2c_chans[i]); in xdma_irq_init()
778 struct xdma_device *xdev = platform_get_drvdata(pdev); in xdma_disable_user_irq() local
781 index = irq_num - xdev->irq_start; in xdma_disable_user_irq()
782 if (index < XDMA_CHAN_NUM(xdev) || index >= xdev->irq_num) { in xdma_disable_user_irq()
783 xdma_err(xdev, "invalid user irq number"); in xdma_disable_user_irq()
786 index -= XDMA_CHAN_NUM(xdev); in xdma_disable_user_irq()
788 regmap_write(xdev->rmap, XDMA_IRQ_USER_INT_EN_W1C, 1 << index); in xdma_disable_user_irq()
799 struct xdma_device *xdev = platform_get_drvdata(pdev); in xdma_enable_user_irq() local
803 index = irq_num - xdev->irq_start; in xdma_enable_user_irq()
804 if (index < XDMA_CHAN_NUM(xdev) || index >= xdev->irq_num) { in xdma_enable_user_irq()
805 xdma_err(xdev, "invalid user irq number"); in xdma_enable_user_irq()
808 index -= XDMA_CHAN_NUM(xdev); in xdma_enable_user_irq()
810 ret = regmap_write(xdev->rmap, XDMA_IRQ_USER_INT_EN_W1S, 1 << index); in xdma_enable_user_irq()
827 struct xdma_device *xdev = platform_get_drvdata(pdev); in xdma_get_user_irq() local
829 if (XDMA_CHAN_NUM(xdev) + user_irq_index >= xdev->irq_num) { in xdma_get_user_irq()
830 xdma_err(xdev, "invalid user irq index"); in xdma_get_user_irq()
834 return xdev->irq_start + XDMA_CHAN_NUM(xdev) + user_irq_index; in xdma_get_user_irq()
844 struct xdma_device *xdev = platform_get_drvdata(pdev); in xdma_remove() local
846 if (xdev->status & XDMA_DEV_STATUS_INIT_MSIX) in xdma_remove()
847 xdma_irq_fini(xdev); in xdma_remove()
849 if (xdev->status & XDMA_DEV_STATUS_REG_DMA) in xdma_remove()
850 dma_async_device_unregister(&xdev->dma_dev); in xdma_remove()
862 struct xdma_device *xdev; in xdma_probe() local
873 xdev = devm_kzalloc(&pdev->dev, sizeof(*xdev), GFP_KERNEL); in xdma_probe()
874 if (!xdev) in xdma_probe()
877 platform_set_drvdata(pdev, xdev); in xdma_probe()
878 xdev->pdev = pdev; in xdma_probe()
882 xdma_err(xdev, "failed to get irq resource"); in xdma_probe()
885 xdev->irq_start = res->start; in xdma_probe()
886 xdev->irq_num = res->end - res->start + 1; in xdma_probe()
890 xdma_err(xdev, "failed to get io resource"); in xdma_probe()
896 xdma_err(xdev, "ioremap failed"); in xdma_probe()
900 xdev->rmap = devm_regmap_init_mmio(&pdev->dev, reg_base, in xdma_probe()
902 if (!xdev->rmap) { in xdma_probe()
903 xdma_err(xdev, "config regmap failed: %d", ret); in xdma_probe()
906 INIT_LIST_HEAD(&xdev->dma_dev.channels); in xdma_probe()
908 ret = xdma_alloc_channels(xdev, DMA_MEM_TO_DEV); in xdma_probe()
910 xdma_err(xdev, "config H2C channels failed: %d", ret); in xdma_probe()
914 ret = xdma_alloc_channels(xdev, DMA_DEV_TO_MEM); in xdma_probe()
916 xdma_err(xdev, "config C2H channels failed: %d", ret); in xdma_probe()
920 dma_cap_set(DMA_SLAVE, xdev->dma_dev.cap_mask); in xdma_probe()
921 dma_cap_set(DMA_PRIVATE, xdev->dma_dev.cap_mask); in xdma_probe()
923 xdev->dma_dev.dev = &pdev->dev; in xdma_probe()
924 xdev->dma_dev.device_free_chan_resources = xdma_free_chan_resources; in xdma_probe()
925 xdev->dma_dev.device_alloc_chan_resources = xdma_alloc_chan_resources; in xdma_probe()
926 xdev->dma_dev.device_tx_status = dma_cookie_status; in xdma_probe()
927 xdev->dma_dev.device_prep_slave_sg = xdma_prep_device_sg; in xdma_probe()
928 xdev->dma_dev.device_config = xdma_device_config; in xdma_probe()
929 xdev->dma_dev.device_issue_pending = xdma_issue_pending; in xdma_probe()
930 xdev->dma_dev.filter.map = pdata->device_map; in xdma_probe()
931 xdev->dma_dev.filter.mapcnt = pdata->device_map_cnt; in xdma_probe()
932 xdev->dma_dev.filter.fn = xdma_filter_fn; in xdma_probe()
934 ret = dma_async_device_register(&xdev->dma_dev); in xdma_probe()
936 xdma_err(xdev, "failed to register Xilinx XDMA: %d", ret); in xdma_probe()
939 xdev->status |= XDMA_DEV_STATUS_REG_DMA; in xdma_probe()
941 ret = xdma_irq_init(xdev); in xdma_probe()
943 xdma_err(xdev, "failed to init msix: %d", ret); in xdma_probe()
946 xdev->status |= XDMA_DEV_STATUS_INIT_MSIX; in xdma_probe()