]> git.baikalelectronics.ru Git - kernel.git/commitdiff
dma: dw: add PCI part of the driver
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Wed, 5 Jun 2013 12:26:46 +0000 (15:26 +0300)
committerVinod Koul <vinod.koul@intel.com>
Fri, 5 Jul 2013 06:10:45 +0000 (11:40 +0530)
This is the PCI part of the DesignWare DMAC driver. The controller is usually
used in the Intel hardware such as Intel Medfield.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
drivers/dma/dw/Kconfig
drivers/dma/dw/Makefile
drivers/dma/dw/pci.c [new file with mode: 0644]

index efd9e02a58eb398f7155734eb9f1af4776098185..db2b41fab626f85a46078e5f83533815597d7a4f 100644 (file)
@@ -15,6 +15,15 @@ config DW_DMAC
          Support the Synopsys DesignWare AHB DMA controller. This
          can be integrated in chips such as the Atmel AT32ap7000.
 
+config DW_DMAC_PCI
+       tristate "Synopsys DesignWare AHB DMA PCI driver"
+       depends on PCI
+       select DW_DMAC_CORE
+       help
+         Support the Synopsys DesignWare AHB DMA controller on the
+         platfroms that enumerate it as a PCI device. For example,
+         Intel Medfield has integrated this GPDMA controller.
+
 config DW_DMAC_BIG_ENDIAN_IO
        bool "Use big endian I/O register access"
        default y if AVR32
index 47f36746c55987381335fc51c56b0b2bf6e1dbf0..3eebd1ce2c6bb6ade135011a739ab6a3b7c9c426 100644 (file)
@@ -3,3 +3,6 @@ dw_dmac_core-objs       := core.o
 
 obj-$(CONFIG_DW_DMAC)          += dw_dmac.o
 dw_dmac-objs           := platform.o
+
+obj-$(CONFIG_DW_DMAC_PCI)      += dw_dmac_pci.o
+dw_dmac_pci-objs       := pci.o
diff --git a/drivers/dma/dw/pci.c b/drivers/dma/dw/pci.c
new file mode 100644 (file)
index 0000000..e89fc24
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * PCI driver for the Synopsys DesignWare DMA Controller
+ *
+ * Copyright (C) 2013 Intel Corporation
+ * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/device.h>
+
+#include "internal.h"
+
+static struct dw_dma_platform_data dw_pci_pdata = {
+       .is_private = 1,
+       .chan_allocation_order = CHAN_ALLOCATION_ASCENDING,
+       .chan_priority = CHAN_PRIORITY_ASCENDING,
+};
+
+static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
+{
+       struct dw_dma_chip *chip;
+       struct dw_dma_platform_data *pdata = (void *)pid->driver_data;
+       int ret;
+
+       ret = pcim_enable_device(pdev);
+       if (ret)
+               return ret;
+
+       ret = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev));
+       if (ret) {
+               dev_err(&pdev->dev, "I/O memory remapping failed\n");
+               return ret;
+       }
+
+       pci_set_master(pdev);
+       pci_try_set_mwi(pdev);
+
+       ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
+       if (ret)
+               return ret;
+
+       ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
+       if (ret)
+               return ret;
+
+       chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
+       if (!chip)
+               return -ENOMEM;
+
+       chip->dev = &pdev->dev;
+       chip->regs = pcim_iomap_table(pdev)[0];
+       chip->irq = pdev->irq;
+
+       ret = dw_dma_probe(chip, pdata);
+       if (ret)
+               return ret;
+
+       pci_set_drvdata(pdev, chip);
+
+       return 0;
+}
+
+static void dw_pci_remove(struct pci_dev *pdev)
+{
+       struct dw_dma_chip *chip = pci_get_drvdata(pdev);
+       int ret;
+
+       ret = dw_dma_remove(chip);
+       if (ret)
+               dev_warn(&pdev->dev, "can't remove device properly: %d\n", ret);
+}
+
+static DEFINE_PCI_DEVICE_TABLE(dw_pci_id_table) = {
+       /* Medfield */
+       { PCI_VDEVICE(INTEL, 0x0827), (kernel_ulong_t)&dw_pci_pdata },
+       { PCI_VDEVICE(INTEL, 0x0830), (kernel_ulong_t)&dw_pci_pdata },
+
+       /* BayTrail */
+       { PCI_VDEVICE(INTEL, 0x0f06), (kernel_ulong_t)&dw_pci_pdata },
+       { PCI_VDEVICE(INTEL, 0x0f40), (kernel_ulong_t)&dw_pci_pdata },
+       { }
+};
+MODULE_DEVICE_TABLE(pci, dw_pci_id_table);
+
+static struct pci_driver dw_pci_driver = {
+       .name           = "dw_dmac_pci",
+       .id_table       = dw_pci_id_table,
+       .probe          = dw_pci_probe,
+       .remove         = dw_pci_remove,
+};
+
+module_pci_driver(dw_pci_driver);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("Synopsys DesignWare DMA Controller PCI driver");
+MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>");