1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Synopsys DesignWare Multimedia Card Interface driver
5 * Copyright (C) 2009 NXP Semiconductors
6 * Copyright (C) 2009, 2010 Imagination Technologies Ltd.
10 #include <linux/interrupt.h>
11 #include <linux/module.h>
13 #include <linux/irq.h>
14 #include <linux/platform_device.h>
15 #include <linux/pm_runtime.h>
16 #include <linux/slab.h>
17 #include <linux/mmc/host.h>
18 #include <linux/mmc/mmc.h>
20 #include <linux/clk.h>
23 #include "dw_mmc-pltfm.h"
25 int dw_mci_pltfm_register(struct platform_device
*pdev
,
26 const struct dw_mci_drv_data
*drv_data
)
29 struct resource
*regs
;
31 host
= devm_kzalloc(&pdev
->dev
, sizeof(struct dw_mci
), GFP_KERNEL
);
35 host
->irq
= platform_get_irq(pdev
, 0);
39 host
->drv_data
= drv_data
;
40 host
->dev
= &pdev
->dev
;
42 host
->pdata
= pdev
->dev
.platform_data
;
44 regs
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
45 host
->regs
= devm_ioremap_resource(&pdev
->dev
, regs
);
46 if (IS_ERR(host
->regs
))
47 return PTR_ERR(host
->regs
);
49 /* Get registers' physical base address */
50 host
->phy_regs
= regs
->start
;
52 platform_set_drvdata(pdev
, host
);
53 return dw_mci_probe(host
);
55 EXPORT_SYMBOL_GPL(dw_mci_pltfm_register
);
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
,
64 EXPORT_SYMBOL_GPL(dw_mci_pltfm_pmops
);
66 static const struct of_device_id dw_mci_pltfm_match
[] = {
67 { .compatible
= "snps,dw-mshc", },
68 { .compatible
= "altr,socfpga-dw-mshc", },
69 { .compatible
= "img,pistachio-dw-mshc", },
72 MODULE_DEVICE_TABLE(of
, dw_mci_pltfm_match
);
74 static int dw_mci_pltfm_probe(struct platform_device
*pdev
)
76 const struct dw_mci_drv_data
*drv_data
= NULL
;
77 const struct of_device_id
*match
;
79 if (pdev
->dev
.of_node
) {
80 match
= of_match_node(dw_mci_pltfm_match
, pdev
->dev
.of_node
);
81 drv_data
= match
->data
;
84 return dw_mci_pltfm_register(pdev
, drv_data
);
87 int dw_mci_pltfm_remove(struct platform_device
*pdev
)
89 struct dw_mci
*host
= platform_get_drvdata(pdev
);
94 EXPORT_SYMBOL_GPL(dw_mci_pltfm_remove
);
96 static struct platform_driver dw_mci_pltfm_driver
= {
97 .probe
= dw_mci_pltfm_probe
,
98 .remove
= dw_mci_pltfm_remove
,
101 .of_match_table
= dw_mci_pltfm_match
,
102 .pm
= &dw_mci_pltfm_pmops
,
106 module_platform_driver(dw_mci_pltfm_driver
);
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");