2 * Synopsys DesignWare Multimedia Card PCI Interface driver
4 * Copyright (C) 2012 Vayavya Labs Pvt. Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
12 #include <linux/interrupt.h>
13 #include <linux/module.h>
15 #include <linux/irq.h>
16 #include <linux/pci.h>
17 #include <linux/pm_runtime.h>
18 #include <linux/slab.h>
19 #include <linux/mmc/host.h>
20 #include <linux/mmc/mmc.h>
21 #include <linux/mmc/dw_mmc.h>
25 #define SYNOPSYS_DW_MCI_VENDOR_ID 0x700
26 #define SYNOPSYS_DW_MCI_DEVICE_ID 0x1107
27 /* Defining the Capabilities */
28 #define DW_MCI_CAPABILITIES (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED |\
29 MMC_CAP_SD_HIGHSPEED | MMC_CAP_8_BIT_DATA |\
32 static struct dw_mci_board pci_board_data
= {
34 .caps
= DW_MCI_CAPABILITIES
,
35 .bus_hz
= 33 * 1000 * 1000,
36 .detect_delay_ms
= 200,
40 static int dw_mci_pci_probe(struct pci_dev
*pdev
,
41 const struct pci_device_id
*entries
)
46 ret
= pcim_enable_device(pdev
);
50 host
= devm_kzalloc(&pdev
->dev
, sizeof(struct dw_mci
), GFP_KERNEL
);
54 host
->irq
= pdev
->irq
;
55 host
->irq_flags
= IRQF_SHARED
;
56 host
->dev
= &pdev
->dev
;
57 host
->pdata
= &pci_board_data
;
59 ret
= pcim_iomap_regions(pdev
, 1 << PCI_BAR_NO
, pci_name(pdev
));
63 host
->regs
= pcim_iomap_table(pdev
)[PCI_BAR_NO
];
67 ret
= dw_mci_probe(host
);
71 pci_set_drvdata(pdev
, host
);
76 static void dw_mci_pci_remove(struct pci_dev
*pdev
)
78 struct dw_mci
*host
= pci_get_drvdata(pdev
);
83 static const struct dev_pm_ops dw_mci_pci_dev_pm_ops
= {
84 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend
,
85 pm_runtime_force_resume
)
86 SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend
,
87 dw_mci_runtime_resume
,
91 static const struct pci_device_id dw_mci_pci_id
[] = {
92 { PCI_DEVICE(SYNOPSYS_DW_MCI_VENDOR_ID
, SYNOPSYS_DW_MCI_DEVICE_ID
) },
95 MODULE_DEVICE_TABLE(pci
, dw_mci_pci_id
);
97 static struct pci_driver dw_mci_pci_driver
= {
99 .id_table
= dw_mci_pci_id
,
100 .probe
= dw_mci_pci_probe
,
101 .remove
= dw_mci_pci_remove
,
103 .pm
= &dw_mci_pci_dev_pm_ops
,
107 module_pci_driver(dw_mci_pci_driver
);
109 MODULE_DESCRIPTION("DW Multimedia Card PCI Interface driver");
110 MODULE_AUTHOR("Shashidhar Hiremath <shashidharh@vayavyalabs.com>");
111 MODULE_LICENSE("GPL v2");