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/slab.h>
18 #include <linux/mmc/host.h>
19 #include <linux/mmc/mmc.h>
20 #include <linux/mmc/dw_mmc.h>
24 #define COMPLETE_BAR 0
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 __devinit
dw_mci_pci_probe(struct pci_dev
*pdev
,
41 const struct pci_device_id
*entries
)
46 ret
= pci_enable_device(pdev
);
49 if (pci_request_regions(pdev
, "dw_mmc_pci")) {
54 host
= kzalloc(sizeof(struct dw_mci
), GFP_KERNEL
);
60 host
->irq
= pdev
->irq
;
61 host
->irq_flags
= IRQF_SHARED
;
62 host
->dev
= &pdev
->dev
;
63 host
->pdata
= &pci_board_data
;
65 host
->regs
= pci_iomap(pdev
, PCI_BAR_NO
, COMPLETE_BAR
);
71 pci_set_drvdata(pdev
, host
);
72 ret
= dw_mci_probe(host
);
74 goto err_probe_failed
;
78 pci_iounmap(pdev
, host
->regs
);
82 pci_release_regions(pdev
);
84 pci_disable_device(pdev
);
88 static void __devexit
dw_mci_pci_remove(struct pci_dev
*pdev
)
90 struct dw_mci
*host
= pci_get_drvdata(pdev
);
93 pci_set_drvdata(pdev
, NULL
);
94 pci_release_regions(pdev
);
95 pci_iounmap(pdev
, host
->regs
);
97 pci_disable_device(pdev
);
100 #ifdef CONFIG_PM_SLEEP
101 static int dw_mci_pci_suspend(struct device
*dev
)
104 struct pci_dev
*pdev
= to_pci_dev(dev
);
105 struct dw_mci
*host
= pci_get_drvdata(pdev
);
107 ret
= dw_mci_suspend(host
);
111 static int dw_mci_pci_resume(struct device
*dev
)
114 struct pci_dev
*pdev
= to_pci_dev(dev
);
115 struct dw_mci
*host
= pci_get_drvdata(pdev
);
117 ret
= dw_mci_resume(host
);
121 #define dw_mci_pci_suspend NULL
122 #define dw_mci_pci_resume NULL
123 #endif /* CONFIG_PM_SLEEP */
125 static SIMPLE_DEV_PM_OPS(dw_mci_pci_pmops
, dw_mci_pci_suspend
, dw_mci_pci_resume
);
127 static DEFINE_PCI_DEVICE_TABLE(dw_mci_pci_id
) = {
128 { PCI_DEVICE(SYNOPSYS_DW_MCI_VENDOR_ID
, SYNOPSYS_DW_MCI_DEVICE_ID
) },
131 MODULE_DEVICE_TABLE(pci
, dw_mci_pci_id
);
133 static struct pci_driver dw_mci_pci_driver
= {
134 .name
= "dw_mmc_pci",
135 .id_table
= dw_mci_pci_id
,
136 .probe
= dw_mci_pci_probe
,
137 .remove
= dw_mci_pci_remove
,
139 .pm
= &dw_mci_pci_pmops
143 module_pci_driver(dw_mci_pci_driver
);
145 MODULE_DESCRIPTION("DW Multimedia Card PCI Interface driver");
146 MODULE_AUTHOR("Shashidhar Hiremath <shashidharh@vayavyalabs.com>");
147 MODULE_LICENSE("GPL v2");