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 SYNOPSYS_DW_MCI_VENDOR_ID 0x700
25 #define SYNOPSYS_DW_MCI_DEVICE_ID 0x1107
26 /* Defining the Capabilities */
27 #define DW_MCI_CAPABILITIES (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED |\
28 MMC_CAP_SD_HIGHSPEED | MMC_CAP_8_BIT_DATA |\
31 static struct dw_mci_board pci_board_data
= {
33 .caps
= DW_MCI_CAPABILITIES
,
34 .bus_hz
= 33 * 1000 * 1000,
35 .detect_delay_ms
= 200,
39 static int dw_mci_pci_probe(struct pci_dev
*pdev
,
40 const struct pci_device_id
*entries
)
45 ret
= pcim_enable_device(pdev
);
49 host
= devm_kzalloc(&pdev
->dev
, sizeof(struct dw_mci
), GFP_KERNEL
);
53 host
->irq
= pdev
->irq
;
54 host
->irq_flags
= IRQF_SHARED
;
55 host
->dev
= &pdev
->dev
;
56 host
->pdata
= &pci_board_data
;
58 ret
= pcim_iomap_regions(pdev
, 1 << PCI_BAR_NO
, pci_name(pdev
));
62 host
->regs
= pcim_iomap_table(pdev
)[PCI_BAR_NO
];
66 ret
= dw_mci_probe(host
);
70 pci_set_drvdata(pdev
, host
);
75 static void dw_mci_pci_remove(struct pci_dev
*pdev
)
77 struct dw_mci
*host
= pci_get_drvdata(pdev
);
82 #ifdef CONFIG_PM_SLEEP
83 static int dw_mci_pci_suspend(struct device
*dev
)
85 struct pci_dev
*pdev
= to_pci_dev(dev
);
86 struct dw_mci
*host
= pci_get_drvdata(pdev
);
88 return dw_mci_suspend(host
);
91 static int dw_mci_pci_resume(struct device
*dev
)
93 struct pci_dev
*pdev
= to_pci_dev(dev
);
94 struct dw_mci
*host
= pci_get_drvdata(pdev
);
96 return dw_mci_resume(host
);
99 #define dw_mci_pci_suspend NULL
100 #define dw_mci_pci_resume NULL
101 #endif /* CONFIG_PM_SLEEP */
103 static SIMPLE_DEV_PM_OPS(dw_mci_pci_pmops
, dw_mci_pci_suspend
, dw_mci_pci_resume
);
105 static DEFINE_PCI_DEVICE_TABLE(dw_mci_pci_id
) = {
106 { PCI_DEVICE(SYNOPSYS_DW_MCI_VENDOR_ID
, SYNOPSYS_DW_MCI_DEVICE_ID
) },
109 MODULE_DEVICE_TABLE(pci
, dw_mci_pci_id
);
111 static struct pci_driver dw_mci_pci_driver
= {
112 .name
= "dw_mmc_pci",
113 .id_table
= dw_mci_pci_id
,
114 .probe
= dw_mci_pci_probe
,
115 .remove
= dw_mci_pci_remove
,
117 .pm
= &dw_mci_pci_pmops
121 module_pci_driver(dw_mci_pci_driver
);
123 MODULE_DESCRIPTION("DW Multimedia Card PCI Interface driver");
124 MODULE_AUTHOR("Shashidhar Hiremath <shashidharh@vayavyalabs.com>");
125 MODULE_LICENSE("GPL v2");