Lines Matching refs:pcidev

42 static void __iomem *cci_pci_ioremap_bar0(struct pci_dev *pcidev)  in cci_pci_ioremap_bar0()  argument
44 if (pcim_iomap_regions(pcidev, BIT(0), DRV_NAME)) in cci_pci_ioremap_bar0()
47 return pcim_iomap_table(pcidev)[0]; in cci_pci_ioremap_bar0()
50 static int cci_pci_alloc_irq(struct pci_dev *pcidev) in cci_pci_alloc_irq() argument
52 int ret, nvec = pci_msix_vec_count(pcidev); in cci_pci_alloc_irq()
55 dev_dbg(&pcidev->dev, "fpga interrupt not supported\n"); in cci_pci_alloc_irq()
59 ret = pci_alloc_irq_vectors(pcidev, nvec, nvec, PCI_IRQ_MSIX); in cci_pci_alloc_irq()
66 static void cci_pci_free_irq(struct pci_dev *pcidev) in cci_pci_free_irq() argument
68 pci_free_irq_vectors(pcidev); in cci_pci_free_irq()
102 static int cci_init_drvdata(struct pci_dev *pcidev) in cci_init_drvdata() argument
106 drvdata = devm_kzalloc(&pcidev->dev, sizeof(*drvdata), GFP_KERNEL); in cci_init_drvdata()
110 pci_set_drvdata(pcidev, drvdata); in cci_init_drvdata()
115 static void cci_remove_feature_devs(struct pci_dev *pcidev) in cci_remove_feature_devs() argument
117 struct cci_drvdata *drvdata = pci_get_drvdata(pcidev); in cci_remove_feature_devs()
121 cci_pci_free_irq(pcidev); in cci_remove_feature_devs()
124 static int *cci_pci_create_irq_table(struct pci_dev *pcidev, unsigned int nvec) in cci_pci_create_irq_table() argument
134 table[i] = pci_irq_vector(pcidev, i); in cci_pci_create_irq_table()
139 static int find_dfls_by_vsec(struct pci_dev *pcidev, struct dfl_fpga_enum_info *info) in find_dfls_by_vsec() argument
145 while ((voff = pci_find_next_ext_capability(pcidev, voff, PCI_EXT_CAP_ID_VNDR))) { in find_dfls_by_vsec()
147 pci_read_config_dword(pcidev, voff + PCI_VNDR_HEADER, &vndr_hdr); in find_dfls_by_vsec()
150 pcidev->vendor == PCI_VENDOR_ID_INTEL) in find_dfls_by_vsec()
155 dev_dbg(&pcidev->dev, "%s no DFL VSEC found\n", __func__); in find_dfls_by_vsec()
160 pci_read_config_dword(pcidev, voff + PCI_VNDR_DFLS_CNT, &dfl_cnt); in find_dfls_by_vsec()
162 dev_err(&pcidev->dev, "%s too many DFLs %d > %d\n", in find_dfls_by_vsec()
169 dev_err(&pcidev->dev, "%s DFL VSEC too big for PCIe config space\n", in find_dfls_by_vsec()
176 pci_read_config_dword(pcidev, dfl_res_off, &dfl_res); in find_dfls_by_vsec()
180 dev_err(&pcidev->dev, "%s bad bir number %d\n", in find_dfls_by_vsec()
186 dev_err(&pcidev->dev, "%s DFL for BAR %d already specified\n", in find_dfls_by_vsec()
193 len = pci_resource_len(pcidev, bir); in find_dfls_by_vsec()
196 dev_err(&pcidev->dev, "%s bad offset %u >= %pa\n", in find_dfls_by_vsec()
201 dev_dbg(&pcidev->dev, "%s BAR %d offset 0x%x\n", __func__, bir, offset); in find_dfls_by_vsec()
205 start = pci_resource_start(pcidev, bir) + offset; in find_dfls_by_vsec()
214 static int find_dfls_by_default(struct pci_dev *pcidev, in find_dfls_by_default() argument
224 base = cci_pci_ioremap_bar0(pcidev); in find_dfls_by_default()
234 start = pci_resource_start(pcidev, 0); in find_dfls_by_default()
235 len = pci_resource_len(pcidev, 0); in find_dfls_by_default()
261 start = pci_resource_start(pcidev, bar) + offset; in find_dfls_by_default()
262 len = pci_resource_len(pcidev, bar) - offset; in find_dfls_by_default()
267 start = pci_resource_start(pcidev, 0); in find_dfls_by_default()
268 len = pci_resource_len(pcidev, 0); in find_dfls_by_default()
276 pcim_iounmap_regions(pcidev, BIT(0)); in find_dfls_by_default()
282 static int cci_enumerate_feature_devs(struct pci_dev *pcidev) in cci_enumerate_feature_devs() argument
284 struct cci_drvdata *drvdata = pci_get_drvdata(pcidev); in cci_enumerate_feature_devs()
291 info = dfl_fpga_enum_info_alloc(&pcidev->dev); in cci_enumerate_feature_devs()
296 nvec = cci_pci_alloc_irq(pcidev); in cci_enumerate_feature_devs()
298 dev_err(&pcidev->dev, "Fail to alloc irq %d.\n", nvec); in cci_enumerate_feature_devs()
302 irq_table = cci_pci_create_irq_table(pcidev, nvec); in cci_enumerate_feature_devs()
314 ret = find_dfls_by_vsec(pcidev, info); in cci_enumerate_feature_devs()
316 ret = find_dfls_by_default(pcidev, info); in cci_enumerate_feature_devs()
324 dev_err(&pcidev->dev, "Enumeration failure\n"); in cci_enumerate_feature_devs()
333 cci_pci_free_irq(pcidev); in cci_enumerate_feature_devs()
341 int cci_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *pcidevid) in cci_pci_probe() argument
345 ret = pcim_enable_device(pcidev); in cci_pci_probe()
347 dev_err(&pcidev->dev, "Failed to enable device %d.\n", ret); in cci_pci_probe()
351 ret = pci_enable_pcie_error_reporting(pcidev); in cci_pci_probe()
353 dev_info(&pcidev->dev, "PCIE AER unavailable %d.\n", ret); in cci_pci_probe()
355 pci_set_master(pcidev); in cci_pci_probe()
357 if (!pci_set_dma_mask(pcidev, DMA_BIT_MASK(64))) { in cci_pci_probe()
358 ret = pci_set_consistent_dma_mask(pcidev, DMA_BIT_MASK(64)); in cci_pci_probe()
361 } else if (!pci_set_dma_mask(pcidev, DMA_BIT_MASK(32))) { in cci_pci_probe()
362 ret = pci_set_consistent_dma_mask(pcidev, DMA_BIT_MASK(32)); in cci_pci_probe()
367 dev_err(&pcidev->dev, "No suitable DMA support available.\n"); in cci_pci_probe()
371 ret = cci_init_drvdata(pcidev); in cci_pci_probe()
373 dev_err(&pcidev->dev, "Fail to init drvdata %d.\n", ret); in cci_pci_probe()
377 ret = cci_enumerate_feature_devs(pcidev); in cci_pci_probe()
381 dev_err(&pcidev->dev, "enumeration failure %d.\n", ret); in cci_pci_probe()
384 pci_disable_pcie_error_reporting(pcidev); in cci_pci_probe()
388 static int cci_pci_sriov_configure(struct pci_dev *pcidev, int num_vfs) in cci_pci_sriov_configure() argument
390 struct cci_drvdata *drvdata = pci_get_drvdata(pcidev); in cci_pci_sriov_configure()
398 pci_disable_sriov(pcidev); in cci_pci_sriov_configure()
413 ret = pci_enable_sriov(pcidev, num_vfs); in cci_pci_sriov_configure()
423 static void cci_pci_remove(struct pci_dev *pcidev) in cci_pci_remove() argument
425 if (dev_is_pf(&pcidev->dev)) in cci_pci_remove()
426 cci_pci_sriov_configure(pcidev, 0); in cci_pci_remove()
428 cci_remove_feature_devs(pcidev); in cci_pci_remove()
429 pci_disable_pcie_error_reporting(pcidev); in cci_pci_remove()