Blame view

drivers/mmc/host/dw_mmc-pltfm.c 3.22 KB
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
1
2
3
4
5
6
7
8
9
10
11
  /*
   * Synopsys DesignWare Multimedia Card Interface driver
   *
   * Copyright (C) 2009 NXP Semiconductors
   * Copyright (C) 2009, 2010 Imagination Technologies Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation; either version 2 of the License, or
   * (at your option) any later version.
   */
a3e2cd7f2   Thierry Reding   mmc: Convert to d...
12
  #include <linux/err.h>
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
13
14
15
16
17
18
19
20
21
  #include <linux/interrupt.h>
  #include <linux/module.h>
  #include <linux/io.h>
  #include <linux/irq.h>
  #include <linux/platform_device.h>
  #include <linux/slab.h>
  #include <linux/mmc/host.h>
  #include <linux/mmc/mmc.h>
  #include <linux/mmc/dw_mmc.h>
c91eab4b2   Thomas Abraham   mmc: dw_mmc: add ...
22
  #include <linux/of.h>
f629ba2c0   Addy Ke   mmc: dw_mmc: add ...
23
  #include <linux/clk.h>
c91eab4b2   Thomas Abraham   mmc: dw_mmc: add ...
24

62ca8034d   Shashidhar Hiremath   mmc: Support of P...
25
  #include "dw_mmc.h"
7725a52c0   Jingoo Han   mmc: dw_mmc-pltfm...
26
  #include "dw_mmc-pltfm.h"
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
27

800d78bfc   Thomas Abraham   mmc: dw_mmc: add ...
28
  int dw_mci_pltfm_register(struct platform_device *pdev,
bcc876669   Andy Shevchenko   mmc: dw_mmc-pltfm...
29
  			  const struct dw_mci_drv_data *drv_data)
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
30
31
32
  {
  	struct dw_mci *host;
  	struct resource	*regs;
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
33

bb8bdc77e   Thomas Abraham   mmc: dw_mmc: Use ...
34
  	host = devm_kzalloc(&pdev->dev, sizeof(struct dw_mci), GFP_KERNEL);
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
35
36
  	if (!host)
  		return -ENOMEM;
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
37
  	host->irq = platform_get_irq(pdev, 0);
bb8bdc77e   Thomas Abraham   mmc: dw_mmc: Use ...
38
39
  	if (host->irq < 0)
  		return host->irq;
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
40

800d78bfc   Thomas Abraham   mmc: dw_mmc: add ...
41
  	host->drv_data = drv_data;
4a90920c6   Thomas Abraham   mmc: dw_mmc: conv...
42
  	host->dev = &pdev->dev;
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
43
44
  	host->irq_flags = 0;
  	host->pdata = pdev->dev.platform_data;
bcc876669   Andy Shevchenko   mmc: dw_mmc-pltfm...
45
46
  
  	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
a3e2cd7f2   Thierry Reding   mmc: Convert to d...
47
48
49
  	host->regs = devm_ioremap_resource(&pdev->dev, regs);
  	if (IS_ERR(host->regs))
  		return PTR_ERR(host->regs);
bb8bdc77e   Thomas Abraham   mmc: dw_mmc: Use ...
50

45c7a4908   Jaehoon Chung   mmc: dw_mmc-pltfm...
51
52
  	/* Get registers' physical base address */
  	host->phy_regs = regs->start;
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
53
  	platform_set_drvdata(pdev, host);
dd3698002   Andy Shevchenko   mmc: dw_mmc: elim...
54
  	return dw_mci_probe(host);
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
55
  }
17403f235   Thomas Abraham   mmc: dw_mmc: prep...
56
  EXPORT_SYMBOL_GPL(dw_mci_pltfm_register);
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
57
58
59
60
61
62
  #ifdef CONFIG_PM_SLEEP
  /*
   * TODO: we should probably disable the clock to the card in the suspend path.
   */
  static int dw_mci_pltfm_suspend(struct device *dev)
  {
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
63
  	struct dw_mci *host = dev_get_drvdata(dev);
dd3698002   Andy Shevchenko   mmc: dw_mmc: elim...
64
  	return dw_mci_suspend(host);
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
65
66
67
68
  }
  
  static int dw_mci_pltfm_resume(struct device *dev)
  {
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
69
  	struct dw_mci *host = dev_get_drvdata(dev);
dd3698002   Andy Shevchenko   mmc: dw_mmc: elim...
70
  	return dw_mci_resume(host);
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
71
  }
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
72
  #endif /* CONFIG_PM_SLEEP */
17403f235   Thomas Abraham   mmc: dw_mmc: prep...
73
74
  SIMPLE_DEV_PM_OPS(dw_mci_pltfm_pmops, dw_mci_pltfm_suspend, dw_mci_pltfm_resume);
  EXPORT_SYMBOL_GPL(dw_mci_pltfm_pmops);
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
75

c91eab4b2   Thomas Abraham   mmc: dw_mmc: add ...
76
77
  static const struct of_device_id dw_mci_pltfm_match[] = {
  	{ .compatible = "snps,dw-mshc", },
aaaaeb7a9   Jaehoon Chung   mmc: dw_mmc: remo...
78
79
  	{ .compatible = "altr,socfpga-dw-mshc", },
  	{ .compatible = "img,pistachio-dw-mshc", },
c91eab4b2   Thomas Abraham   mmc: dw_mmc: add ...
80
81
82
  	{},
  };
  MODULE_DEVICE_TABLE(of, dw_mci_pltfm_match);
b177a530b   Heiko Stübner   mmc: dw_mmc-pltfm...
83
84
  static int dw_mci_pltfm_probe(struct platform_device *pdev)
  {
c73e41c89   Heiko Stübner   mmc: dw_mmc-pltfm...
85
86
87
88
89
90
91
92
93
  	const struct dw_mci_drv_data *drv_data = NULL;
  	const struct of_device_id *match;
  
  	if (pdev->dev.of_node) {
  		match = of_match_node(dw_mci_pltfm_match, pdev->dev.of_node);
  		drv_data = match->data;
  	}
  
  	return dw_mci_pltfm_register(pdev, drv_data);
b177a530b   Heiko Stübner   mmc: dw_mmc-pltfm...
94
95
96
97
98
99
100
101
102
103
  }
  
  int dw_mci_pltfm_remove(struct platform_device *pdev)
  {
  	struct dw_mci *host = platform_get_drvdata(pdev);
  
  	dw_mci_remove(host);
  	return 0;
  }
  EXPORT_SYMBOL_GPL(dw_mci_pltfm_remove);
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
104
  static struct platform_driver dw_mci_pltfm_driver = {
49480cf2c   Andy Shevchenko   mmc: dw_mmc: use ...
105
  	.probe		= dw_mci_pltfm_probe,
4e608e4ed   Greg Kroah-Hartman   Drivers: mmc: rem...
106
  	.remove		= dw_mci_pltfm_remove,
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
107
108
  	.driver		= {
  		.name		= "dw_mmc",
cf109bc0e   Sachin Kamat   mmc: dw_mmc: Remo...
109
  		.of_match_table	= dw_mci_pltfm_match,
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
110
111
112
  		.pm		= &dw_mci_pltfm_pmops,
  	},
  };
49480cf2c   Andy Shevchenko   mmc: dw_mmc: use ...
113
  module_platform_driver(dw_mci_pltfm_driver);
62ca8034d   Shashidhar Hiremath   mmc: Support of P...
114
115
116
117
118
  
  MODULE_DESCRIPTION("DW Multimedia Card Interface driver");
  MODULE_AUTHOR("NXP Semiconductor VietNam");
  MODULE_AUTHOR("Imagination Technologies Ltd");
  MODULE_LICENSE("GPL v2");