]>
Commit | Line | Data |
---|---|---|
2874c5fd | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
62ca8034 SH |
2 | /* |
3 | * Synopsys DesignWare Multimedia Card Interface driver | |
4 | * | |
5 | * Copyright (C) 2009 NXP Semiconductors | |
6 | * Copyright (C) 2009, 2010 Imagination Technologies Ltd. | |
62ca8034 SH |
7 | */ |
8 | ||
a3e2cd7f | 9 | #include <linux/err.h> |
62ca8034 SH |
10 | #include <linux/interrupt.h> |
11 | #include <linux/module.h> | |
12 | #include <linux/io.h> | |
13 | #include <linux/irq.h> | |
14 | #include <linux/platform_device.h> | |
ee2112be | 15 | #include <linux/pm_runtime.h> |
62ca8034 SH |
16 | #include <linux/slab.h> |
17 | #include <linux/mmc/host.h> | |
18 | #include <linux/mmc/mmc.h> | |
c91eab4b | 19 | #include <linux/of.h> |
f629ba2c | 20 | #include <linux/clk.h> |
c91eab4b | 21 | |
62ca8034 | 22 | #include "dw_mmc.h" |
7725a52c | 23 | #include "dw_mmc-pltfm.h" |
62ca8034 | 24 | |
800d78bf | 25 | int dw_mci_pltfm_register(struct platform_device *pdev, |
bcc87666 | 26 | const struct dw_mci_drv_data *drv_data) |
62ca8034 SH |
27 | { |
28 | struct dw_mci *host; | |
29 | struct resource *regs; | |
62ca8034 | 30 | |
bb8bdc77 | 31 | host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), GFP_KERNEL); |
62ca8034 SH |
32 | if (!host) |
33 | return -ENOMEM; | |
34 | ||
62ca8034 | 35 | host->irq = platform_get_irq(pdev, 0); |
bb8bdc77 TA |
36 | if (host->irq < 0) |
37 | return host->irq; | |
62ca8034 | 38 | |
800d78bf | 39 | host->drv_data = drv_data; |
4a90920c | 40 | host->dev = &pdev->dev; |
62ca8034 SH |
41 | host->irq_flags = 0; |
42 | host->pdata = pdev->dev.platform_data; | |
bcc87666 AS |
43 | |
44 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | |
a3e2cd7f TR |
45 | host->regs = devm_ioremap_resource(&pdev->dev, regs); |
46 | if (IS_ERR(host->regs)) | |
47 | return PTR_ERR(host->regs); | |
bb8bdc77 | 48 | |
45c7a490 JC |
49 | /* Get registers' physical base address */ |
50 | host->phy_regs = regs->start; | |
51 | ||
62ca8034 | 52 | platform_set_drvdata(pdev, host); |
dd369800 | 53 | return dw_mci_probe(host); |
62ca8034 | 54 | } |
17403f23 TA |
55 | EXPORT_SYMBOL_GPL(dw_mci_pltfm_register); |
56 | ||
ee2112be SL |
57 | const struct dev_pm_ops dw_mci_pltfm_pmops = { |
58 | SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, | |
59 | pm_runtime_force_resume) | |
60 | SET_RUNTIME_PM_OPS(dw_mci_runtime_suspend, | |
61 | dw_mci_runtime_resume, | |
62 | NULL) | |
63 | }; | |
17403f23 | 64 | EXPORT_SYMBOL_GPL(dw_mci_pltfm_pmops); |
62ca8034 | 65 | |
c91eab4b TA |
66 | static const struct of_device_id dw_mci_pltfm_match[] = { |
67 | { .compatible = "snps,dw-mshc", }, | |
aaaaeb7a JC |
68 | { .compatible = "altr,socfpga-dw-mshc", }, |
69 | { .compatible = "img,pistachio-dw-mshc", }, | |
c91eab4b TA |
70 | {}, |
71 | }; | |
72 | MODULE_DEVICE_TABLE(of, dw_mci_pltfm_match); | |
73 | ||
b177a530 HS |
74 | static int dw_mci_pltfm_probe(struct platform_device *pdev) |
75 | { | |
c73e41c8 HS |
76 | const struct dw_mci_drv_data *drv_data = NULL; |
77 | const struct of_device_id *match; | |
78 | ||
79 | if (pdev->dev.of_node) { | |
80 | match = of_match_node(dw_mci_pltfm_match, pdev->dev.of_node); | |
81 | drv_data = match->data; | |
82 | } | |
83 | ||
84 | return dw_mci_pltfm_register(pdev, drv_data); | |
b177a530 HS |
85 | } |
86 | ||
87 | int dw_mci_pltfm_remove(struct platform_device *pdev) | |
88 | { | |
89 | struct dw_mci *host = platform_get_drvdata(pdev); | |
90 | ||
91 | dw_mci_remove(host); | |
92 | return 0; | |
93 | } | |
94 | EXPORT_SYMBOL_GPL(dw_mci_pltfm_remove); | |
95 | ||
62ca8034 | 96 | static struct platform_driver dw_mci_pltfm_driver = { |
49480cf2 | 97 | .probe = dw_mci_pltfm_probe, |
4e608e4e | 98 | .remove = dw_mci_pltfm_remove, |
62ca8034 SH |
99 | .driver = { |
100 | .name = "dw_mmc", | |
cf109bc0 | 101 | .of_match_table = dw_mci_pltfm_match, |
62ca8034 SH |
102 | .pm = &dw_mci_pltfm_pmops, |
103 | }, | |
104 | }; | |
105 | ||
49480cf2 | 106 | module_platform_driver(dw_mci_pltfm_driver); |
62ca8034 SH |
107 | |
108 | MODULE_DESCRIPTION("DW Multimedia Card Interface driver"); | |
109 | MODULE_AUTHOR("NXP Semiconductor VietNam"); | |
110 | MODULE_AUTHOR("Imagination Technologies Ltd"); | |
111 | MODULE_LICENSE("GPL v2"); |