Commit | Line | Data |
---|---|---|
2874c5fd | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
62ca8034 SH |
2 | /* |
3 | * Synopsys DesignWare Multimedia Card PCI Interface driver | |
4 | * | |
5 | * Copyright (C) 2012 Vayavya Labs Pvt. Ltd. | |
62ca8034 SH |
6 | */ |
7 | ||
8 | #include <linux/interrupt.h> | |
9 | #include <linux/module.h> | |
10 | #include <linux/io.h> | |
11 | #include <linux/irq.h> | |
12 | #include <linux/pci.h> | |
53b27288 | 13 | #include <linux/pm_runtime.h> |
62ca8034 SH |
14 | #include <linux/slab.h> |
15 | #include <linux/mmc/host.h> | |
16 | #include <linux/mmc/mmc.h> | |
62ca8034 SH |
17 | #include "dw_mmc.h" |
18 | ||
19 | #define PCI_BAR_NO 2 | |
62ca8034 SH |
20 | #define SYNOPSYS_DW_MCI_VENDOR_ID 0x700 |
21 | #define SYNOPSYS_DW_MCI_DEVICE_ID 0x1107 | |
22 | /* Defining the Capabilities */ | |
23 | #define DW_MCI_CAPABILITIES (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED |\ | |
24 | MMC_CAP_SD_HIGHSPEED | MMC_CAP_8_BIT_DATA |\ | |
25 | MMC_CAP_SDIO_IRQ) | |
26 | ||
27 | static struct dw_mci_board pci_board_data = { | |
62ca8034 SH |
28 | .caps = DW_MCI_CAPABILITIES, |
29 | .bus_hz = 33 * 1000 * 1000, | |
30 | .detect_delay_ms = 200, | |
31 | .fifo_depth = 32, | |
32 | }; | |
33 | ||
c3be1efd | 34 | static int dw_mci_pci_probe(struct pci_dev *pdev, |
13959741 | 35 | const struct pci_device_id *entries) |
62ca8034 SH |
36 | { |
37 | struct dw_mci *host; | |
38 | int ret; | |
39 | ||
13959741 | 40 | ret = pcim_enable_device(pdev); |
62ca8034 SH |
41 | if (ret) |
42 | return ret; | |
62ca8034 | 43 | |
13959741 AS |
44 | host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), GFP_KERNEL); |
45 | if (!host) | |
46 | return -ENOMEM; | |
62ca8034 SH |
47 | |
48 | host->irq = pdev->irq; | |
49 | host->irq_flags = IRQF_SHARED; | |
4a90920c | 50 | host->dev = &pdev->dev; |
62ca8034 SH |
51 | host->pdata = &pci_board_data; |
52 | ||
13959741 AS |
53 | ret = pcim_iomap_regions(pdev, 1 << PCI_BAR_NO, pci_name(pdev)); |
54 | if (ret) | |
55 | return ret; | |
56 | ||
afeb52d6 | 57 | host->regs = pcim_iomap_table(pdev)[PCI_BAR_NO]; |
62ca8034 | 58 | |
638585f6 AS |
59 | pci_set_master(pdev); |
60 | ||
62ca8034 SH |
61 | ret = dw_mci_probe(host); |
62 | if (ret) | |
13959741 AS |
63 | return ret; |
64 | ||
65 | pci_set_drvdata(pdev, host); | |
62ca8034 | 66 | |
13959741 | 67 | return 0; |
62ca8034 SH |
68 | } |
69 | ||
6e0ee714 | 70 | static void dw_mci_pci_remove(struct pci_dev *pdev) |
62ca8034 SH |
71 | { |
72 | struct dw_mci *host = pci_get_drvdata(pdev); | |
73 | ||
74 | dw_mci_remove(host); | |
62ca8034 SH |
75 | } |
76 | ||
53b27288 SL |
77 | static const struct dev_pm_ops dw_mci_pci_dev_pm_ops = { |
78 | SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, | |
79 | pm_runtime_force_resume) | |
80 | SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend, | |
81 | dw_mci_runtime_resume, | |
82 | NULL) | |
83 | }; | |
62ca8034 | 84 | |
9baa3c34 | 85 | static const struct pci_device_id dw_mci_pci_id[] = { |
62ca8034 SH |
86 | { PCI_DEVICE(SYNOPSYS_DW_MCI_VENDOR_ID, SYNOPSYS_DW_MCI_DEVICE_ID) }, |
87 | {} | |
88 | }; | |
89 | MODULE_DEVICE_TABLE(pci, dw_mci_pci_id); | |
90 | ||
91 | static struct pci_driver dw_mci_pci_driver = { | |
92 | .name = "dw_mmc_pci", | |
93 | .id_table = dw_mci_pci_id, | |
94 | .probe = dw_mci_pci_probe, | |
4e608e4e | 95 | .remove = dw_mci_pci_remove, |
62ca8034 | 96 | .driver = { |
53b27288 | 97 | .pm = &dw_mci_pci_dev_pm_ops, |
62ca8034 SH |
98 | }, |
99 | }; | |
100 | ||
350e3e00 | 101 | module_pci_driver(dw_mci_pci_driver); |
62ca8034 SH |
102 | |
103 | MODULE_DESCRIPTION("DW Multimedia Card PCI Interface driver"); | |
104 | MODULE_AUTHOR("Shashidhar Hiremath <shashidharh@vayavyalabs.com>"); | |
105 | MODULE_LICENSE("GPL v2"); |