Lines Matching +full:edma +full:- +full:err

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2018-2019 Synopsys, Inc. and/or its affiliates.
4 * Synopsys DesignWare eDMA PCIe driver
13 #include <linux/dma/edma.h>
14 #include <linux/pci-epf.h>
18 #include "dw-edma-core.h"
40 /* eDMA registers location */
42 /* eDMA memory linked list location */
45 /* eDMA memory data location */
56 /* eDMA registers location */
60 /* eDMA memory linked list location */
62 /* Channel 0 - BAR 2, offset 0 Mbytes, size 2 Kbytes */
64 /* Channel 1 - BAR 2, offset 2 Mbytes, size 2 Kbytes */
68 /* Channel 0 - BAR 2, offset 4 Mbytes, size 2 Kbytes */
70 /* Channel 1 - BAR 2, offset 6 Mbytes, size 2 Kbytes */
73 /* eDMA memory data location */
75 /* Channel 0 - BAR 2, offset 8 Mbytes, size 2 Kbytes */
77 /* Channel 1 - BAR 2, offset 9 Mbytes, size 2 Kbytes */
81 /* Channel 0 - BAR 2, offset 10 Mbytes, size 2 Kbytes */
83 /* Channel 1 - BAR 2, offset 11 Mbytes, size 2 Kbytes */
108 pcibios_resource_to_bus(pdev->bus, &region, &res); in dw_edma_pcie_address()
134 pci_dbg(pdev, "Detected PCIe Vendor-Specific Extended Capability DMA\n"); in dw_edma_pcie_get_vsec_dma_data()
142 pdata->mf = map; in dw_edma_pcie_get_vsec_dma_data()
143 pdata->rg.bar = FIELD_GET(DW_PCIE_VSEC_DMA_BAR, val); in dw_edma_pcie_get_vsec_dma_data()
146 pdata->wr_ch_cnt = min_t(u16, pdata->wr_ch_cnt, in dw_edma_pcie_get_vsec_dma_data()
148 pdata->rd_ch_cnt = min_t(u16, pdata->rd_ch_cnt, in dw_edma_pcie_get_vsec_dma_data()
156 pdata->rg.off = off; in dw_edma_pcie_get_vsec_dma_data()
162 struct dw_edma_pcie_data *pdata = (void *)pid->driver_data; in dw_edma_pcie_probe()
164 struct device *dev = &pdev->dev; in dw_edma_pcie_probe()
166 int err, nr_irqs; in dw_edma_pcie_probe() local
170 err = pcim_enable_device(pdev); in dw_edma_pcie_probe()
171 if (err) { in dw_edma_pcie_probe()
173 return err; in dw_edma_pcie_probe()
179 * Tries to find if exists a PCIe Vendor-Specific Extended Capability in dw_edma_pcie_probe()
194 err = pcim_iomap_regions(pdev, mask, pci_name(pdev)); in dw_edma_pcie_probe()
195 if (err) { in dw_edma_pcie_probe()
196 pci_err(pdev, "eDMA BAR I/O remapping failed\n"); in dw_edma_pcie_probe()
197 return err; in dw_edma_pcie_probe()
203 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in dw_edma_pcie_probe()
204 if (err) { in dw_edma_pcie_probe()
206 return err; in dw_edma_pcie_probe()
212 return -ENOMEM; in dw_edma_pcie_probe()
220 return -EPERM; in dw_edma_pcie_probe()
224 chip->dev = dev; in dw_edma_pcie_probe()
226 chip->mf = vsec_data.mf; in dw_edma_pcie_probe()
227 chip->nr_irqs = nr_irqs; in dw_edma_pcie_probe()
228 chip->ops = &dw_edma_pcie_plat_ops; in dw_edma_pcie_probe()
230 chip->ll_wr_cnt = vsec_data.wr_ch_cnt; in dw_edma_pcie_probe()
231 chip->ll_rd_cnt = vsec_data.rd_ch_cnt; in dw_edma_pcie_probe()
233 chip->reg_base = pcim_iomap_table(pdev)[vsec_data.rg.bar]; in dw_edma_pcie_probe()
234 if (!chip->reg_base) in dw_edma_pcie_probe()
235 return -ENOMEM; in dw_edma_pcie_probe()
237 for (i = 0; i < chip->ll_wr_cnt; i++) { in dw_edma_pcie_probe()
238 struct dw_edma_region *ll_region = &chip->ll_region_wr[i]; in dw_edma_pcie_probe()
239 struct dw_edma_region *dt_region = &chip->dt_region_wr[i]; in dw_edma_pcie_probe()
243 ll_region->vaddr.io = pcim_iomap_table(pdev)[ll_block->bar]; in dw_edma_pcie_probe()
244 if (!ll_region->vaddr.io) in dw_edma_pcie_probe()
245 return -ENOMEM; in dw_edma_pcie_probe()
247 ll_region->vaddr.io += ll_block->off; in dw_edma_pcie_probe()
248 ll_region->paddr = pci_bus_address(pdev, ll_block->bar); in dw_edma_pcie_probe()
249 ll_region->paddr += ll_block->off; in dw_edma_pcie_probe()
250 ll_region->sz = ll_block->sz; in dw_edma_pcie_probe()
252 dt_region->vaddr.io = pcim_iomap_table(pdev)[dt_block->bar]; in dw_edma_pcie_probe()
253 if (!dt_region->vaddr.io) in dw_edma_pcie_probe()
254 return -ENOMEM; in dw_edma_pcie_probe()
256 dt_region->vaddr.io += dt_block->off; in dw_edma_pcie_probe()
257 dt_region->paddr = pci_bus_address(pdev, dt_block->bar); in dw_edma_pcie_probe()
258 dt_region->paddr += dt_block->off; in dw_edma_pcie_probe()
259 dt_region->sz = dt_block->sz; in dw_edma_pcie_probe()
262 for (i = 0; i < chip->ll_rd_cnt; i++) { in dw_edma_pcie_probe()
263 struct dw_edma_region *ll_region = &chip->ll_region_rd[i]; in dw_edma_pcie_probe()
264 struct dw_edma_region *dt_region = &chip->dt_region_rd[i]; in dw_edma_pcie_probe()
268 ll_region->vaddr.io = pcim_iomap_table(pdev)[ll_block->bar]; in dw_edma_pcie_probe()
269 if (!ll_region->vaddr.io) in dw_edma_pcie_probe()
270 return -ENOMEM; in dw_edma_pcie_probe()
272 ll_region->vaddr.io += ll_block->off; in dw_edma_pcie_probe()
273 ll_region->paddr = pci_bus_address(pdev, ll_block->bar); in dw_edma_pcie_probe()
274 ll_region->paddr += ll_block->off; in dw_edma_pcie_probe()
275 ll_region->sz = ll_block->sz; in dw_edma_pcie_probe()
277 dt_region->vaddr.io = pcim_iomap_table(pdev)[dt_block->bar]; in dw_edma_pcie_probe()
278 if (!dt_region->vaddr.io) in dw_edma_pcie_probe()
279 return -ENOMEM; in dw_edma_pcie_probe()
281 dt_region->vaddr.io += dt_block->off; in dw_edma_pcie_probe()
282 dt_region->paddr = pci_bus_address(pdev, dt_block->bar); in dw_edma_pcie_probe()
283 dt_region->paddr += dt_block->off; in dw_edma_pcie_probe()
284 dt_region->sz = dt_block->sz; in dw_edma_pcie_probe()
288 if (chip->mf == EDMA_MF_EDMA_LEGACY) in dw_edma_pcie_probe()
289 pci_dbg(pdev, "Version:\teDMA Port Logic (0x%x)\n", chip->mf); in dw_edma_pcie_probe()
290 else if (chip->mf == EDMA_MF_EDMA_UNROLL) in dw_edma_pcie_probe()
291 pci_dbg(pdev, "Version:\teDMA Unroll (0x%x)\n", chip->mf); in dw_edma_pcie_probe()
292 else if (chip->mf == EDMA_MF_HDMA_COMPAT) in dw_edma_pcie_probe()
293 pci_dbg(pdev, "Version:\tHDMA Compatible (0x%x)\n", chip->mf); in dw_edma_pcie_probe()
295 pci_dbg(pdev, "Version:\tUnknown (0x%x)\n", chip->mf); in dw_edma_pcie_probe()
299 chip->reg_base); in dw_edma_pcie_probe()
302 for (i = 0; i < chip->ll_wr_cnt; i++) { in dw_edma_pcie_probe()
305 vsec_data.ll_wr[i].off, chip->ll_region_wr[i].sz, in dw_edma_pcie_probe()
306 chip->ll_region_wr[i].vaddr.io, &chip->ll_region_wr[i].paddr); in dw_edma_pcie_probe()
310 vsec_data.dt_wr[i].off, chip->dt_region_wr[i].sz, in dw_edma_pcie_probe()
311 chip->dt_region_wr[i].vaddr.io, &chip->dt_region_wr[i].paddr); in dw_edma_pcie_probe()
314 for (i = 0; i < chip->ll_rd_cnt; i++) { in dw_edma_pcie_probe()
317 vsec_data.ll_rd[i].off, chip->ll_region_rd[i].sz, in dw_edma_pcie_probe()
318 chip->ll_region_rd[i].vaddr.io, &chip->ll_region_rd[i].paddr); in dw_edma_pcie_probe()
322 vsec_data.dt_rd[i].off, chip->dt_region_rd[i].sz, in dw_edma_pcie_probe()
323 chip->dt_region_rd[i].vaddr.io, &chip->dt_region_rd[i].paddr); in dw_edma_pcie_probe()
326 pci_dbg(pdev, "Nr. IRQs:\t%u\n", chip->nr_irqs); in dw_edma_pcie_probe()
331 return -EPERM; in dw_edma_pcie_probe()
334 /* Starting eDMA driver */ in dw_edma_pcie_probe()
335 err = dw_edma_probe(chip); in dw_edma_pcie_probe()
336 if (err) { in dw_edma_pcie_probe()
337 pci_err(pdev, "eDMA probe failed\n"); in dw_edma_pcie_probe()
338 return err; in dw_edma_pcie_probe()
350 int err; in dw_edma_pcie_remove() local
352 /* Stopping eDMA driver */ in dw_edma_pcie_remove()
353 err = dw_edma_remove(chip); in dw_edma_pcie_remove()
354 if (err) in dw_edma_pcie_remove()
355 pci_warn(pdev, "can't remove device properly: %d\n", err); in dw_edma_pcie_remove()
368 .name = "dw-edma-pcie",
377 MODULE_DESCRIPTION("Synopsys DesignWare eDMA PCIe driver");