diff options
Diffstat (limited to 'drivers/staging/xillybus')
| -rw-r--r-- | drivers/staging/xillybus/Kconfig | 5 | ||||
| -rw-r--r-- | drivers/staging/xillybus/xillybus.h | 1 | ||||
| -rw-r--r-- | drivers/staging/xillybus/xillybus_core.c | 8 | ||||
| -rw-r--r-- | drivers/staging/xillybus/xillybus_of.c | 71 | ||||
| -rw-r--r-- | drivers/staging/xillybus/xillybus_pcie.c | 67 |
5 files changed, 58 insertions, 94 deletions
diff --git a/drivers/staging/xillybus/Kconfig b/drivers/staging/xillybus/Kconfig index b15f778b4c6..b53bdf12da0 100644 --- a/drivers/staging/xillybus/Kconfig +++ b/drivers/staging/xillybus/Kconfig @@ -4,7 +4,8 @@ config XILLYBUS tristate "Xillybus generic FPGA interface" - depends on PCI || (OF_ADDRESS && OF_IRQ) && m + depends on PCI || (OF_ADDRESS && OF_IRQ) + select CRC32 help Xillybus is a generic interface for peripherals designed on programmable logic (FPGA). The driver probes the hardware for @@ -16,7 +17,7 @@ if XILLYBUS config XILLYBUS_PCIE tristate "Xillybus over PCIe" - depends on PCI + depends on PCI_MSI help Set to M if you want Xillybus to use PCI Express for communicating with the FPGA. diff --git a/drivers/staging/xillybus/xillybus.h b/drivers/staging/xillybus/xillybus.h index e5e91d61288..78a749a7a1c 100644 --- a/drivers/staging/xillybus/xillybus.h +++ b/drivers/staging/xillybus/xillybus.h @@ -116,7 +116,6 @@ struct xilly_endpoint { */ struct pci_dev *pdev; struct device *dev; - struct resource res; /* OF devices only */ struct xilly_endpoint_hardware *ephw; struct list_head ep_list; diff --git a/drivers/staging/xillybus/xillybus_core.c b/drivers/staging/xillybus/xillybus_core.c index 2ebaf166038..fe8f9d28b03 100644 --- a/drivers/staging/xillybus/xillybus_core.c +++ b/drivers/staging/xillybus/xillybus_core.c @@ -2094,7 +2094,7 @@ struct xilly_endpoint *xillybus_init_endpoint(struct pci_dev *pdev, { struct xilly_endpoint *endpoint; - endpoint = kzalloc(sizeof(*endpoint), GFP_KERNEL); + endpoint = devm_kzalloc(dev, sizeof(*endpoint), GFP_KERNEL); if (!endpoint) { dev_err(dev, "Failed to allocate memory. Aborting.\n"); return NULL; @@ -2318,8 +2318,12 @@ static int __init xillybus_init(void) } xillybus_wq = alloc_workqueue(xillyname, 0, 0); + if (!xillybus_wq) { + class_destroy(xillybus_class); + rc = -ENOMEM; + } - return 0; /* Success */ + return rc; } static void __exit xillybus_exit(void) diff --git a/drivers/staging/xillybus/xillybus_of.c b/drivers/staging/xillybus/xillybus_of.c index 394bfea1af6..46ea010b4ac 100644 --- a/drivers/staging/xillybus/xillybus_of.c +++ b/drivers/staging/xillybus/xillybus_of.c @@ -19,6 +19,7 @@ #include <linux/of_address.h> #include <linux/of_device.h> #include <linux/of_platform.h> +#include <linux/err.h> #include "xillybus.h" MODULE_DESCRIPTION("Xillybus driver for Open Firmware"); @@ -31,7 +32,8 @@ static const char xillyname[] = "xillybus_of"; /* Match table for of_platform binding */ static struct of_device_id xillybus_of_match[] = { - { .compatible = "xlnx,xillybus-1.00.a", }, + { .compatible = "xillybus,xillybus-1.00.a", }, + { .compatible = "xlnx,xillybus-1.00.a", }, /* Deprecated */ {} }; @@ -53,6 +55,13 @@ static void xilly_dma_sync_single_for_device_of(struct xilly_endpoint *ep, dma_sync_single_for_device(ep->dev, dma_handle, size, direction); } +static void xilly_dma_sync_single_nop(struct xilly_endpoint *ep, + dma_addr_t dma_handle, + size_t size, + int direction) +{ +} + static dma_addr_t xilly_map_single_of(struct xilly_cleanup *mem, struct xilly_endpoint *ep, void *ptr, @@ -101,52 +110,53 @@ static struct xilly_endpoint_hardware of_hw = { .unmap_single = xilly_unmap_single_of }; +static struct xilly_endpoint_hardware of_hw_coherent = { + .owner = THIS_MODULE, + .hw_sync_sgl_for_cpu = xilly_dma_sync_single_nop, + .hw_sync_sgl_for_device = xilly_dma_sync_single_nop, + .map_single = xilly_map_single_of, + .unmap_single = xilly_unmap_single_of +}; + static int xilly_drv_probe(struct platform_device *op) { struct device *dev = &op->dev; struct xilly_endpoint *endpoint; int rc = 0; int irq; + struct resource res; + struct xilly_endpoint_hardware *ephw = &of_hw; + + if (of_property_read_bool(dev->of_node, "dma-coherent")) + ephw = &of_hw_coherent; - endpoint = xillybus_init_endpoint(NULL, dev, &of_hw); + endpoint = xillybus_init_endpoint(NULL, dev, ephw); if (!endpoint) return -ENOMEM; dev_set_drvdata(dev, endpoint); - rc = of_address_to_resource(dev->of_node, 0, &endpoint->res); + rc = of_address_to_resource(dev->of_node, 0, &res); if (rc) { dev_warn(endpoint->dev, "Failed to obtain device tree resource\n"); - goto failed_request_regions; + return rc; } - if (!request_mem_region(endpoint->res.start, - resource_size(&endpoint->res), xillyname)) { - dev_err(endpoint->dev, - "request_mem_region failed. Aborting.\n"); - rc = -EBUSY; - goto failed_request_regions; - } - - endpoint->registers = of_iomap(dev->of_node, 0); + endpoint->registers = devm_ioremap_resource(dev, &res); - if (!endpoint->registers) { - dev_err(endpoint->dev, - "Failed to map I/O memory. Aborting.\n"); - goto failed_iomap0; - } + if (IS_ERR(endpoint->registers)) + return PTR_ERR(endpoint->registers); irq = irq_of_parse_and_map(dev->of_node, 0); - rc = request_irq(irq, xillybus_isr, 0, xillyname, endpoint); + rc = devm_request_irq(dev, irq, xillybus_isr, 0, xillyname, endpoint); if (rc) { dev_err(endpoint->dev, "Failed to register IRQ handler. Aborting.\n"); - rc = -ENODEV; - goto failed_register_irq; + return -ENODEV; } rc = xillybus_endpoint_discovery(endpoint); @@ -154,18 +164,8 @@ static int xilly_drv_probe(struct platform_device *op) if (!rc) return 0; - free_irq(irq, endpoint); - -failed_register_irq: - iounmap(endpoint->registers); -failed_iomap0: - release_mem_region(endpoint->res.start, - resource_size(&endpoint->res)); - -failed_request_regions: xillybus_do_cleanup(&endpoint->cleanup, endpoint); - kfree(endpoint); return rc; } @@ -173,20 +173,11 @@ static int xilly_drv_remove(struct platform_device *op) { struct device *dev = &op->dev; struct xilly_endpoint *endpoint = dev_get_drvdata(dev); - int irq = irq_of_parse_and_map(dev->of_node, 0); xillybus_endpoint_remove(endpoint); - free_irq(irq, endpoint); - - iounmap(endpoint->registers); - release_mem_region(endpoint->res.start, - resource_size(&endpoint->res)); - xillybus_do_cleanup(&endpoint->cleanup, endpoint); - kfree(endpoint); - return 0; } diff --git a/drivers/staging/xillybus/xillybus_pcie.c b/drivers/staging/xillybus/xillybus_pcie.c index 1811aa76421..a4fe51c90e9 100644 --- a/drivers/staging/xillybus/xillybus_pcie.c +++ b/drivers/staging/xillybus/xillybus_pcie.c @@ -30,7 +30,7 @@ MODULE_LICENSE("GPL v2"); static const char xillyname[] = "xillybus_pcie"; -static DEFINE_PCI_DEVICE_TABLE(xillyids) = { +static const struct pci_device_id xillyids[] = { {PCI_DEVICE(PCI_VENDOR_ID_XILINX, PCI_DEVICE_ID_XILLYBUS)}, {PCI_DEVICE(PCI_VENDOR_ID_ALTERA, PCI_DEVICE_ID_XILLYBUS)}, {PCI_DEVICE(PCI_VENDOR_ID_ACTEL, PCI_DEVICE_ID_XILLYBUS)}, @@ -141,38 +141,32 @@ static int xilly_probe(struct pci_dev *pdev, pci_set_drvdata(pdev, endpoint); - rc = pci_enable_device(pdev); - - /* L0s has caused packet drops. No power saving, thank you. */ - - pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S); + rc = pcim_enable_device(pdev); if (rc) { dev_err(endpoint->dev, - "pci_enable_device() failed. Aborting.\n"); - goto no_enable; + "pcim_enable_device() failed. Aborting.\n"); + return rc; } + /* L0s has caused packet drops. No power saving, thank you. */ + + pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S); + if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { dev_err(endpoint->dev, "Incorrect BAR configuration. Aborting.\n"); - rc = -ENODEV; - goto bad_bar; + return -ENODEV; } - rc = pci_request_regions(pdev, xillyname); + rc = pcim_iomap_regions(pdev, 0x01, xillyname); if (rc) { dev_err(endpoint->dev, - "pci_request_regions() failed. Aborting.\n"); - goto failed_request_regions; + "pcim_iomap_regions() failed. Aborting.\n"); + return rc; } - endpoint->registers = pci_iomap(pdev, 0, 128); - - if (!endpoint->registers) { - dev_err(endpoint->dev, "Failed to map BAR 0. Aborting.\n"); - goto failed_iomap0; - } + endpoint->registers = pcim_iomap_table(pdev)[0]; pci_set_master(pdev); @@ -180,16 +174,15 @@ static int xilly_probe(struct pci_dev *pdev, if (pci_enable_msi(pdev)) { dev_err(endpoint->dev, "Failed to enable MSI interrupts. Aborting.\n"); - rc = -ENODEV; - goto failed_enable_msi; + return -ENODEV; } - rc = request_irq(pdev->irq, xillybus_isr, 0, xillyname, endpoint); + rc = devm_request_irq(&pdev->dev, pdev->irq, xillybus_isr, 0, + xillyname, endpoint); if (rc) { dev_err(endpoint->dev, "Failed to register MSI handler. Aborting.\n"); - rc = -ENODEV; - goto failed_register_msi; + return -ENODEV; } /* @@ -203,8 +196,7 @@ static int xilly_probe(struct pci_dev *pdev, endpoint->dma_using_dac = 0; else { dev_err(endpoint->dev, "Failed to set DMA mask. Aborting.\n"); - rc = -ENODEV; - goto failed_dmamask; + return -ENODEV; } rc = xillybus_endpoint_discovery(endpoint); @@ -212,22 +204,8 @@ static int xilly_probe(struct pci_dev *pdev, if (!rc) return 0; -failed_dmamask: - free_irq(pdev->irq, endpoint); -failed_register_msi: - pci_disable_msi(pdev); -failed_enable_msi: - /* pci_clear_master(pdev); Nobody else seems to do this */ - pci_iounmap(pdev, endpoint->registers); -failed_iomap0: - pci_release_regions(pdev); -failed_request_regions: -bad_bar: - pci_disable_device(pdev); -no_enable: xillybus_do_cleanup(&endpoint->cleanup, endpoint); - kfree(endpoint); return rc; } @@ -237,16 +215,7 @@ static void xilly_remove(struct pci_dev *pdev) xillybus_endpoint_remove(endpoint); - free_irq(pdev->irq, endpoint); - - pci_disable_msi(pdev); - pci_iounmap(pdev, endpoint->registers); - pci_release_regions(pdev); - pci_disable_device(pdev); - xillybus_do_cleanup(&endpoint->cleanup, endpoint); - - kfree(endpoint); } MODULE_DEVICE_TABLE(pci, xillyids); |
