2 * PCI driver for the Synopsys DesignWare DMA Controller
4 * Copyright (C) 2013 Intel Corporation
5 * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
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.
12 #include <linux/module.h>
13 #include <linux/pci.h>
14 #include <linux/device.h>
18 static struct dw_dma_platform_data dw_pci_pdata
= {
20 .chan_allocation_order
= CHAN_ALLOCATION_ASCENDING
,
21 .chan_priority
= CHAN_PRIORITY_ASCENDING
,
24 static int dw_pci_probe(struct pci_dev
*pdev
, const struct pci_device_id
*pid
)
26 struct dw_dma_chip
*chip
;
27 struct dw_dma_platform_data
*pdata
= (void *)pid
->driver_data
;
30 ret
= pcim_enable_device(pdev
);
34 ret
= pcim_iomap_regions(pdev
, 1 << 0, pci_name(pdev
));
36 dev_err(&pdev
->dev
, "I/O memory remapping failed\n");
41 pci_try_set_mwi(pdev
);
43 ret
= pci_set_dma_mask(pdev
, DMA_BIT_MASK(32));
47 ret
= pci_set_consistent_dma_mask(pdev
, DMA_BIT_MASK(32));
51 chip
= devm_kzalloc(&pdev
->dev
, sizeof(*chip
), GFP_KERNEL
);
55 chip
->dev
= &pdev
->dev
;
56 chip
->regs
= pcim_iomap_table(pdev
)[0];
57 chip
->irq
= pdev
->irq
;
59 ret
= dw_dma_probe(chip
, pdata
);
63 pci_set_drvdata(pdev
, chip
);
68 static void dw_pci_remove(struct pci_dev
*pdev
)
70 struct dw_dma_chip
*chip
= pci_get_drvdata(pdev
);
73 ret
= dw_dma_remove(chip
);
75 dev_warn(&pdev
->dev
, "can't remove device properly: %d\n", ret
);
78 static DEFINE_PCI_DEVICE_TABLE(dw_pci_id_table
) = {
80 { PCI_VDEVICE(INTEL
, 0x0827), (kernel_ulong_t
)&dw_pci_pdata
},
81 { PCI_VDEVICE(INTEL
, 0x0830), (kernel_ulong_t
)&dw_pci_pdata
},
84 { PCI_VDEVICE(INTEL
, 0x0f06), (kernel_ulong_t
)&dw_pci_pdata
},
85 { PCI_VDEVICE(INTEL
, 0x0f40), (kernel_ulong_t
)&dw_pci_pdata
},
88 MODULE_DEVICE_TABLE(pci
, dw_pci_id_table
);
90 static 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
,
97 module_pci_driver(dw_pci_driver
);
99 MODULE_LICENSE("GPL v2");
100 MODULE_DESCRIPTION("Synopsys DesignWare DMA Controller PCI driver");
101 MODULE_AUTHOR("Andy Shevchenko <andriy.shevchenko@linux.intel.com>");