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()
123 static int cci_init_drvdata(struct pci_dev *pcidev) in cci_init_drvdata() argument
127 drvdata = devm_kzalloc(&pcidev->dev, sizeof(*drvdata), GFP_KERNEL); in cci_init_drvdata()
131 pci_set_drvdata(pcidev, drvdata); in cci_init_drvdata()
136 static void cci_remove_feature_devs(struct pci_dev *pcidev) in cci_remove_feature_devs() argument
138 struct cci_drvdata *drvdata = pci_get_drvdata(pcidev); in cci_remove_feature_devs()
142 cci_pci_free_irq(pcidev); in cci_remove_feature_devs()
145 static int *cci_pci_create_irq_table(struct pci_dev *pcidev, unsigned int nvec) in cci_pci_create_irq_table() argument
155 table[i] = pci_irq_vector(pcidev, i); in cci_pci_create_irq_table()
160 static int find_dfls_by_vsec(struct pci_dev *pcidev, struct dfl_fpga_enum_info *info) in find_dfls_by_vsec() argument
166 voff = pci_find_vsec_capability(pcidev, PCI_VENDOR_ID_INTEL, in find_dfls_by_vsec()
169 dev_dbg(&pcidev->dev, "%s no DFL VSEC found\n", __func__); in find_dfls_by_vsec()
174 pci_read_config_dword(pcidev, voff + PCI_VNDR_DFLS_CNT, &dfl_cnt); in find_dfls_by_vsec()
176 dev_err(&pcidev->dev, "%s too many DFLs %d > %d\n", in find_dfls_by_vsec()
183 dev_err(&pcidev->dev, "%s DFL VSEC too big for PCIe config space\n", in find_dfls_by_vsec()
190 pci_read_config_dword(pcidev, dfl_res_off, &dfl_res); in find_dfls_by_vsec()
194 dev_err(&pcidev->dev, "%s bad bir number %d\n", in find_dfls_by_vsec()
200 dev_err(&pcidev->dev, "%s DFL for BAR %d already specified\n", in find_dfls_by_vsec()
207 len = pci_resource_len(pcidev, bir); in find_dfls_by_vsec()
210 dev_err(&pcidev->dev, "%s bad offset %u >= %pa\n", in find_dfls_by_vsec()
215 dev_dbg(&pcidev->dev, "%s BAR %d offset 0x%x\n", __func__, bir, offset); in find_dfls_by_vsec()
219 start = pci_resource_start(pcidev, bir) + offset; in find_dfls_by_vsec()
228 static int find_dfls_by_default(struct pci_dev *pcidev, in find_dfls_by_default() argument
238 base = cci_pci_ioremap_bar0(pcidev); in find_dfls_by_default()
248 start = pci_resource_start(pcidev, 0); in find_dfls_by_default()
249 len = pci_resource_len(pcidev, 0); in find_dfls_by_default()
278 dev_err(&pcidev->dev, "bad BAR %d for port %d\n", in find_dfls_by_default()
284 start = pci_resource_start(pcidev, bar) + offset; in find_dfls_by_default()
285 len = pci_resource_len(pcidev, bar) - offset; in find_dfls_by_default()
290 start = pci_resource_start(pcidev, 0); in find_dfls_by_default()
291 len = pci_resource_len(pcidev, 0); in find_dfls_by_default()
299 pcim_iounmap_regions(pcidev, BIT(0)); in find_dfls_by_default()
305 static int cci_enumerate_feature_devs(struct pci_dev *pcidev) in cci_enumerate_feature_devs() argument
307 struct cci_drvdata *drvdata = pci_get_drvdata(pcidev); in cci_enumerate_feature_devs()
314 info = dfl_fpga_enum_info_alloc(&pcidev->dev); in cci_enumerate_feature_devs()
319 nvec = cci_pci_alloc_irq(pcidev); in cci_enumerate_feature_devs()
321 dev_err(&pcidev->dev, "Fail to alloc irq %d.\n", nvec); in cci_enumerate_feature_devs()
325 irq_table = cci_pci_create_irq_table(pcidev, nvec); in cci_enumerate_feature_devs()
337 ret = find_dfls_by_vsec(pcidev, info); in cci_enumerate_feature_devs()
339 ret = find_dfls_by_default(pcidev, info); in cci_enumerate_feature_devs()
347 dev_err(&pcidev->dev, "Enumeration failure\n"); in cci_enumerate_feature_devs()
356 cci_pci_free_irq(pcidev); in cci_enumerate_feature_devs()
364 int cci_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *pcidevid) in cci_pci_probe() argument
368 ret = pcim_enable_device(pcidev); in cci_pci_probe()
370 dev_err(&pcidev->dev, "Failed to enable device %d.\n", ret); in cci_pci_probe()
374 pci_set_master(pcidev); in cci_pci_probe()
376 ret = dma_set_mask_and_coherent(&pcidev->dev, DMA_BIT_MASK(64)); in cci_pci_probe()
378 ret = dma_set_mask_and_coherent(&pcidev->dev, DMA_BIT_MASK(32)); in cci_pci_probe()
380 dev_err(&pcidev->dev, "No suitable DMA support available.\n"); in cci_pci_probe()
384 ret = cci_init_drvdata(pcidev); in cci_pci_probe()
386 dev_err(&pcidev->dev, "Fail to init drvdata %d.\n", ret); in cci_pci_probe()
390 ret = cci_enumerate_feature_devs(pcidev); in cci_pci_probe()
392 dev_err(&pcidev->dev, "enumeration failure %d.\n", ret); in cci_pci_probe()
399 static int cci_pci_sriov_configure(struct pci_dev *pcidev, int num_vfs) in cci_pci_sriov_configure() argument
401 struct cci_drvdata *drvdata = pci_get_drvdata(pcidev); in cci_pci_sriov_configure()
409 pci_disable_sriov(pcidev); in cci_pci_sriov_configure()
424 ret = pci_enable_sriov(pcidev, num_vfs); in cci_pci_sriov_configure()
434 static void cci_pci_remove(struct pci_dev *pcidev) in cci_pci_remove() argument
436 if (dev_is_pf(&pcidev->dev)) in cci_pci_remove()
437 cci_pci_sriov_configure(pcidev, 0); in cci_pci_remove()
439 cci_remove_feature_devs(pcidev); in cci_pci_remove()