Lines Matching refs:xdev

139 #define xdma_err(xdev, fmt, args...)					\  argument
140 dev_err(&(xdev)->pdev->dev, fmt, ##args)
224 struct xdma_device *xdev = chan->xdev_hdl; in xdma_channel_init() local
227 ret = regmap_write(xdev->rmap, chan->base + XDMA_CHAN_CONTROL_W1C, in xdma_channel_init()
232 ret = regmap_write(xdev->rmap, chan->base + XDMA_CHAN_INTR_ENABLE, in xdma_channel_init()
328 struct xdma_device *xdev = xchan->xdev_hdl; in xdma_xfer_start() local
342 ret = regmap_write(xdev->rmap, xchan->base + XDMA_CHAN_CONTROL_W1C, in xdma_xfer_start()
349 xdma_err(xdev, "incorrect request direction"); in xdma_xfer_start()
357 ret = regmap_write(xdev->rmap, xchan->base + XDMA_SGDMA_DESC_LO, val); in xdma_xfer_start()
362 ret = regmap_write(xdev->rmap, xchan->base + XDMA_SGDMA_DESC_HI, val); in xdma_xfer_start()
370 ret = regmap_write(xdev->rmap, xchan->base + XDMA_SGDMA_DESC_ADJ, val); in xdma_xfer_start()
375 ret = regmap_write(xdev->rmap, xchan->base + XDMA_CHAN_CONTROL, in xdma_xfer_start()
393 struct xdma_device *xdev = xchan->xdev_hdl; in xdma_xfer_stop() local
396 return regmap_write(xdev->rmap, xchan->base + XDMA_CHAN_CONTROL_W1C, in xdma_xfer_stop()
405 static int xdma_alloc_channels(struct xdma_device *xdev, in xdma_alloc_channels() argument
408 struct xdma_platdata *pdata = dev_get_platdata(&xdev->pdev->dev); in xdma_alloc_channels()
417 chans = &xdev->h2c_chans; in xdma_alloc_channels()
418 chan_num = &xdev->h2c_chan_num; in xdma_alloc_channels()
422 chans = &xdev->c2h_chans; in xdma_alloc_channels()
423 chan_num = &xdev->c2h_chan_num; in xdma_alloc_channels()
425 xdma_err(xdev, "invalid direction specified"); in xdma_alloc_channels()
431 ret = regmap_read(xdev->rmap, base + i * XDMA_CHAN_STRIDE, in xdma_alloc_channels()
442 xdma_err(xdev, "does not probe any channel"); in xdma_alloc_channels()
446 *chans = devm_kcalloc(&xdev->pdev->dev, *chan_num, sizeof(**chans), in xdma_alloc_channels()
452 ret = regmap_read(xdev->rmap, base + i * XDMA_CHAN_STRIDE, in xdma_alloc_channels()
461 xdma_err(xdev, "invalid channel number"); in xdma_alloc_channels()
467 xchan->xdev_hdl = xdev; in xdma_alloc_channels()
477 vchan_init(&xchan->vchan, &xdev->dma_dev); in xdma_alloc_channels()
482 dev_info(&xdev->pdev->dev, "configured %d %s channels", j, in xdma_alloc_channels()
541 struct xdma_device *xdev = xdma_chan->xdev_hdl; in xdma_synchronize() local
545 regmap_read(xdev->rmap, xdma_chan->base + XDMA_CHAN_STATUS, &st); in xdma_synchronize()
665 struct xdma_device *xdev = xdma_chan->xdev_hdl; in xdma_prep_dma_cyclic() local
678 xdma_err(xdev, "period size limited to %lu bytes\n", XDMA_DESC_BLEN_MAX); in xdma_prep_dma_cyclic()
683 xdma_err(xdev, "number of periods limited to %u\n", XDMA_DESC_ADJACENT); in xdma_prep_dma_cyclic()
811 struct xdma_device *xdev = xdma_chan->xdev_hdl; in xdma_alloc_chan_resources() local
812 struct device *dev = xdev->dma_dev.dev; in xdma_alloc_chan_resources()
817 xdma_err(xdev, "unable to find pci device"); in xdma_alloc_chan_resources()
824 xdma_err(xdev, "unable to allocate descriptor pool"); in xdma_alloc_chan_resources()
875 struct xdma_device *xdev = xchan->xdev_hdl; in xdma_channel_isr() local
893 ret = regmap_read(xdev->rmap, xchan->base + XDMA_CHAN_STATUS_RC, &st); in xdma_channel_isr()
903 xdma_err(xdev, "channel error, status register value: 0x%x", st); in xdma_channel_isr()
907 ret = regmap_read(xdev->rmap, xchan->base + XDMA_CHAN_COMPLETED_DESC, in xdma_channel_isr()
971 static void xdma_irq_fini(struct xdma_device *xdev) in xdma_irq_fini() argument
976 regmap_write(xdev->rmap, XDMA_IRQ_CHAN_INT_EN_W1C, ~0); in xdma_irq_fini()
979 for (i = 0; i < xdev->h2c_chan_num; i++) in xdma_irq_fini()
980 free_irq(xdev->h2c_chans[i].irq, &xdev->h2c_chans[i]); in xdma_irq_fini()
982 for (i = 0; i < xdev->c2h_chan_num; i++) in xdma_irq_fini()
983 free_irq(xdev->c2h_chans[i].irq, &xdev->c2h_chans[i]); in xdma_irq_fini()
993 static int xdma_set_vector_reg(struct xdma_device *xdev, u32 vec_tbl_start, in xdma_set_vector_reg() argument
1011 ret = regmap_write(xdev->rmap, vec_tbl_start, val); in xdma_set_vector_reg()
1025 static int xdma_irq_init(struct xdma_device *xdev) in xdma_irq_init() argument
1027 u32 irq = xdev->irq_start; in xdma_irq_init()
1032 if (xdev->irq_num < XDMA_CHAN_NUM(xdev)) { in xdma_irq_init()
1033 xdma_err(xdev, "not enough irq"); in xdma_irq_init()
1038 for (i = 0; i < xdev->h2c_chan_num; i++) { in xdma_irq_init()
1040 "xdma-h2c-channel", &xdev->h2c_chans[i]); in xdma_irq_init()
1042 xdma_err(xdev, "H2C channel%d request irq%d failed: %d", in xdma_irq_init()
1046 xdev->h2c_chans[i].irq = irq; in xdma_irq_init()
1051 for (j = 0; j < xdev->c2h_chan_num; j++) { in xdma_irq_init()
1053 "xdma-c2h-channel", &xdev->c2h_chans[j]); in xdma_irq_init()
1055 xdma_err(xdev, "C2H channel%d request irq%d failed: %d", in xdma_irq_init()
1059 xdev->c2h_chans[j].irq = irq; in xdma_irq_init()
1064 ret = xdma_set_vector_reg(xdev, XDMA_IRQ_CHAN_VEC_NUM, 0, in xdma_irq_init()
1065 XDMA_CHAN_NUM(xdev)); in xdma_irq_init()
1067 xdma_err(xdev, "failed to set channel vectors: %d", ret); in xdma_irq_init()
1072 user_irq_start = XDMA_CHAN_NUM(xdev); in xdma_irq_init()
1073 if (xdev->irq_num > user_irq_start) { in xdma_irq_init()
1074 ret = xdma_set_vector_reg(xdev, XDMA_IRQ_USER_VEC_NUM, in xdma_irq_init()
1076 xdev->irq_num - user_irq_start); in xdma_irq_init()
1078 xdma_err(xdev, "failed to set user vectors: %d", ret); in xdma_irq_init()
1084 ret = regmap_write(xdev->rmap, XDMA_IRQ_CHAN_INT_EN_W1S, ~0); in xdma_irq_init()
1092 free_irq(xdev->c2h_chans[j].irq, &xdev->c2h_chans[j]); in xdma_irq_init()
1095 free_irq(xdev->h2c_chans[i].irq, &xdev->h2c_chans[i]); in xdma_irq_init()
1115 struct xdma_device *xdev = platform_get_drvdata(pdev); in xdma_disable_user_irq() local
1118 index = irq_num - xdev->irq_start; in xdma_disable_user_irq()
1119 if (index < XDMA_CHAN_NUM(xdev) || index >= xdev->irq_num) { in xdma_disable_user_irq()
1120 xdma_err(xdev, "invalid user irq number"); in xdma_disable_user_irq()
1123 index -= XDMA_CHAN_NUM(xdev); in xdma_disable_user_irq()
1125 regmap_write(xdev->rmap, XDMA_IRQ_USER_INT_EN_W1C, 1 << index); in xdma_disable_user_irq()
1136 struct xdma_device *xdev = platform_get_drvdata(pdev); in xdma_enable_user_irq() local
1140 index = irq_num - xdev->irq_start; in xdma_enable_user_irq()
1141 if (index < XDMA_CHAN_NUM(xdev) || index >= xdev->irq_num) { in xdma_enable_user_irq()
1142 xdma_err(xdev, "invalid user irq number"); in xdma_enable_user_irq()
1145 index -= XDMA_CHAN_NUM(xdev); in xdma_enable_user_irq()
1147 ret = regmap_write(xdev->rmap, XDMA_IRQ_USER_INT_EN_W1S, 1 << index); in xdma_enable_user_irq()
1164 struct xdma_device *xdev = platform_get_drvdata(pdev); in xdma_get_user_irq() local
1166 if (XDMA_CHAN_NUM(xdev) + user_irq_index >= xdev->irq_num) { in xdma_get_user_irq()
1167 xdma_err(xdev, "invalid user irq index"); in xdma_get_user_irq()
1171 return xdev->irq_start + XDMA_CHAN_NUM(xdev) + user_irq_index; in xdma_get_user_irq()
1181 struct xdma_device *xdev = platform_get_drvdata(pdev); in xdma_remove() local
1183 if (xdev->status & XDMA_DEV_STATUS_INIT_MSIX) in xdma_remove()
1184 xdma_irq_fini(xdev); in xdma_remove()
1186 if (xdev->status & XDMA_DEV_STATUS_REG_DMA) in xdma_remove()
1187 dma_async_device_unregister(&xdev->dma_dev); in xdma_remove()
1197 struct xdma_device *xdev; in xdma_probe() local
1208 xdev = devm_kzalloc(&pdev->dev, sizeof(*xdev), GFP_KERNEL); in xdma_probe()
1209 if (!xdev) in xdma_probe()
1212 platform_set_drvdata(pdev, xdev); in xdma_probe()
1213 xdev->pdev = pdev; in xdma_probe()
1217 xdma_err(xdev, "failed to get irq resource"); in xdma_probe()
1220 xdev->irq_start = res->start; in xdma_probe()
1221 xdev->irq_num = resource_size(res); in xdma_probe()
1225 xdma_err(xdev, "failed to get io resource"); in xdma_probe()
1231 xdma_err(xdev, "ioremap failed"); in xdma_probe()
1235 xdev->rmap = devm_regmap_init_mmio(&pdev->dev, reg_base, in xdma_probe()
1237 if (IS_ERR(xdev->rmap)) { in xdma_probe()
1238 xdma_err(xdev, "config regmap failed: %pe", xdev->rmap); in xdma_probe()
1241 INIT_LIST_HEAD(&xdev->dma_dev.channels); in xdma_probe()
1243 ret = xdma_alloc_channels(xdev, DMA_MEM_TO_DEV); in xdma_probe()
1245 xdma_err(xdev, "config H2C channels failed: %d", ret); in xdma_probe()
1249 ret = xdma_alloc_channels(xdev, DMA_DEV_TO_MEM); in xdma_probe()
1251 xdma_err(xdev, "config C2H channels failed: %d", ret); in xdma_probe()
1255 dma_cap_set(DMA_SLAVE, xdev->dma_dev.cap_mask); in xdma_probe()
1256 dma_cap_set(DMA_PRIVATE, xdev->dma_dev.cap_mask); in xdma_probe()
1257 dma_cap_set(DMA_CYCLIC, xdev->dma_dev.cap_mask); in xdma_probe()
1258 dma_cap_set(DMA_INTERLEAVE, xdev->dma_dev.cap_mask); in xdma_probe()
1259 dma_cap_set(DMA_REPEAT, xdev->dma_dev.cap_mask); in xdma_probe()
1260 dma_cap_set(DMA_LOAD_EOT, xdev->dma_dev.cap_mask); in xdma_probe()
1262 xdev->dma_dev.dev = &pdev->dev; in xdma_probe()
1263 xdev->dma_dev.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT; in xdma_probe()
1264 xdev->dma_dev.device_free_chan_resources = xdma_free_chan_resources; in xdma_probe()
1265 xdev->dma_dev.device_alloc_chan_resources = xdma_alloc_chan_resources; in xdma_probe()
1266 xdev->dma_dev.device_tx_status = xdma_tx_status; in xdma_probe()
1267 xdev->dma_dev.device_prep_slave_sg = xdma_prep_device_sg; in xdma_probe()
1268 xdev->dma_dev.device_config = xdma_device_config; in xdma_probe()
1269 xdev->dma_dev.device_issue_pending = xdma_issue_pending; in xdma_probe()
1270 xdev->dma_dev.device_terminate_all = xdma_terminate_all; in xdma_probe()
1271 xdev->dma_dev.device_synchronize = xdma_synchronize; in xdma_probe()
1272 xdev->dma_dev.filter.map = pdata->device_map; in xdma_probe()
1273 xdev->dma_dev.filter.mapcnt = pdata->device_map_cnt; in xdma_probe()
1274 xdev->dma_dev.filter.fn = xdma_filter_fn; in xdma_probe()
1275 xdev->dma_dev.device_prep_dma_cyclic = xdma_prep_dma_cyclic; in xdma_probe()
1276 xdev->dma_dev.device_prep_interleaved_dma = xdma_prep_interleaved_dma; in xdma_probe()
1278 ret = dma_async_device_register(&xdev->dma_dev); in xdma_probe()
1280 xdma_err(xdev, "failed to register Xilinx XDMA: %d", ret); in xdma_probe()
1283 xdev->status |= XDMA_DEV_STATUS_REG_DMA; in xdma_probe()
1285 ret = xdma_irq_init(xdev); in xdma_probe()
1287 xdma_err(xdev, "failed to init msix: %d", ret); in xdma_probe()
1290 xdev->status |= XDMA_DEV_STATUS_INIT_MSIX; in xdma_probe()