aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2013-06-05 08:26:46 -0400
committerVinod Koul <vinod.koul@intel.com>2013-07-05 02:10:45 -0400
commitfed42c198b45ece0b37eb25d37cbc4a9959c6522 (patch)
tree54ff01a90d2baff5c8aff7e7ece23e148e905265 /drivers/dma
parent9cade1a46c77dfc96d57a3ea6354e95b2a7fcf61 (diff)
dma: dw: add PCI part of the driver
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>
Diffstat (limited to 'drivers/dma')
-rw-r--r--drivers/dma/dw/Kconfig9
-rw-r--r--drivers/dma/dw/Makefile3
-rw-r--r--drivers/dma/dw/pci.c101
3 files changed, 113 insertions, 0 deletions
diff --git a/drivers/dma/dw/Kconfig b/drivers/dma/dw/Kconfig
index efd9e02a58eb..db2b41fab626 100644
--- a/drivers/dma/dw/Kconfig
+++ b/drivers/dma/dw/Kconfig
@@ -15,6 +15,15 @@ config DW_DMAC
15 Support the Synopsys DesignWare AHB DMA controller. This 15 Support the Synopsys DesignWare AHB DMA controller. This
16 can be integrated in chips such as the Atmel AT32ap7000. 16 can be integrated in chips such as the Atmel AT32ap7000.
17 17
18config DW_DMAC_PCI
19 tristate "Synopsys DesignWare AHB DMA PCI driver"
20 depends on PCI
21 select DW_DMAC_CORE
22 help
23 Support the Synopsys DesignWare AHB DMA controller on the
24 platfroms that enumerate it as a PCI device. For example,
25 Intel Medfield has integrated this GPDMA controller.
26
18config DW_DMAC_BIG_ENDIAN_IO 27config DW_DMAC_BIG_ENDIAN_IO
19 bool "Use big endian I/O register access" 28 bool "Use big endian I/O register access"
20 default y if AVR32 29 default y if AVR32
diff --git a/drivers/dma/dw/Makefile b/drivers/dma/dw/Makefile
index 47f36746c559..3eebd1ce2c6b 100644
--- a/drivers/dma/dw/Makefile
+++ b/drivers/dma/dw/Makefile
@@ -3,3 +3,6 @@ dw_dmac_core-objs := core.o
3 3
4obj-$(CONFIG_DW_DMAC) += dw_dmac.o 4obj-$(CONFIG_DW_DMAC) += dw_dmac.o
5dw_dmac-objs := platform.o 5dw_dmac-objs := platform.o
6
7obj-$(CONFIG_DW_DMAC_PCI) += dw_dmac_pci.o
8dw_dmac_pci-objs := pci.o
diff --git a/drivers/dma/dw/pci.c b/drivers/dma/dw/pci.c
new file mode 100644
index 000000000000..e89fc24b8293
--- /dev/null
+++ b/drivers/dma/dw/pci.c
@@ -0,0 +1,101 @@
1/*
2 * PCI driver for the Synopsys DesignWare DMA Controller
3 *
4 * Copyright (C) 2013 Intel Corporation
5 * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/module.h>
13#include <linux/pci.h>
14#include <linux/device.h>
15
16#include "internal.h"
17
18static struct dw_dma_platform_data dw_pci_pdata = {
19 .is_private = 1,
20 .chan_allocation_order = CHAN_ALLOCATION_ASCENDING,
21 .chan_priority = CHAN_PRIORITY_ASCENDING,
22};
23
24static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
25{
26 struct dw_dma_chip *chip;
27 struct dw_dma_platform_data *pdata = (void *)pid->driver_data;
28 int ret;
29
30 ret = pcim_enable_device(pdev);
31 if (ret)
32 return ret;
33
34 ret = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev));
35 if (ret) {
36 dev_err(&pdev->dev, "I/O memory remapping failed\n");
37 return ret;
38 }
39
40 pci_set_master(pdev);
41 pci_try_set_mwi(pdev);
42
43 ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
44 if (ret)
45 return ret;
46
47 ret = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
48 if (ret)
49 return ret;
50
51 chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
52 if (!chip)
53 return -ENOMEM;
54
55 chip->dev = &pdev->dev;
56 chip->regs = pcim_iomap_table(pdev)[0];
57 chip->irq = pdev->irq;
58
59 ret = dw_dma_probe(chip, pdata);
60 if (ret)
61 return ret;
62
63 pci_set_drvdata(pdev, chip);
64
65 return 0;
66}
67
68static void dw_pci_remove(struct pci_dev *pdev)
69{
70 struct dw_dma_chip *chip = pci_get_drvdata(pdev);
71 int ret;
72
73 ret = dw_dma_remove(chip);
74 if (ret)
75 dev_warn(&pdev->dev, "can't remove device properly: %d\n", ret);
76}
77
78static DEFINE_PCI_DEVICE_TABLE(dw_pci_id_table) = {
79 /* Medfield */
80 { PCI_VDEVICE(INTEL, 0x0827), (kernel_ulong_t)&dw_pci_pdata },
81 { PCI_VDEVICE(INTEL, 0x0830), (kernel_ulong_t)&dw_pci_pdata },
82
83 /* BayTrail */
84 { PCI_VDEVICE(INTEL, 0x0f06), (kernel_ulong_t)&dw_pci_pdata },
85 { PCI_VDEVICE(INTEL, 0x0f40), (kernel_ulong_t)&dw_pci_pdata },
86 { }
87};
88MODULE_DEVICE_TABLE(pci, dw_pci_id_table);
89
90static struct pci_driver dw_pci_driver = {
91 .name = "dw_dmac_pci",
92 .id_table = dw_pci_id_table,
93 .probe = dw_pci_probe,
94 .remove = dw_pci_remove,
95};
96
97module_pci_driver(dw_pci_driver);
98
99MODULE_LICENSE("GPL v2");
100MODULE_DESCRIPTION("Synopsys DesignWare DMA Controller PCI driver");
101MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>");