diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2012-09-28 06:28:22 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2012-10-07 17:41:44 -0400 |
commit | 067bf748bde70154a1fe1734b01f82b827c65b23 (patch) | |
tree | 1890041b7285676be8b783abafa9d9d52296fcdf /drivers/mmc | |
parent | 2abeb5c5ded2e7f7d288058426fb0ae852adc77f (diff) |
mmc: sdhci-spear: add device tree bindings
This adds simple DT bindings for SDHCI SPEAr controller. It uses cd-gpios
from common mmc bindings.
This also fixes spear300-evb.dts with correct name for card detect binding.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/sdhci-spear.c | 57 |
1 files changed, 55 insertions, 2 deletions
diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c index 423da8194cd8..ecad282741d6 100644 --- a/drivers/mmc/host/sdhci-spear.c +++ b/drivers/mmc/host/sdhci-spear.c | |||
@@ -20,6 +20,8 @@ | |||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
22 | #include <linux/irq.h> | 22 | #include <linux/irq.h> |
23 | #include <linux/of.h> | ||
24 | #include <linux/of_gpio.h> | ||
23 | #include <linux/platform_device.h> | 25 | #include <linux/platform_device.h> |
24 | #include <linux/pm.h> | 26 | #include <linux/pm.h> |
25 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
@@ -68,8 +70,42 @@ static irqreturn_t sdhci_gpio_irq(int irq, void *dev_id) | |||
68 | return IRQ_HANDLED; | 70 | return IRQ_HANDLED; |
69 | } | 71 | } |
70 | 72 | ||
73 | #ifdef CONFIG_OF | ||
74 | static struct sdhci_plat_data * __devinit | ||
75 | sdhci_probe_config_dt(struct platform_device *pdev) | ||
76 | { | ||
77 | struct device_node *np = pdev->dev.of_node; | ||
78 | struct sdhci_plat_data *pdata = NULL; | ||
79 | int cd_gpio; | ||
80 | |||
81 | cd_gpio = of_get_named_gpio(np, "cd-gpios", 0); | ||
82 | if (!gpio_is_valid(cd_gpio)) | ||
83 | cd_gpio = -1; | ||
84 | |||
85 | /* If pdata is required */ | ||
86 | if (cd_gpio != -1) { | ||
87 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
88 | if (!pdata) { | ||
89 | dev_err(&pdev->dev, "DT: kzalloc failed\n"); | ||
90 | return ERR_PTR(-ENOMEM); | ||
91 | } | ||
92 | } | ||
93 | |||
94 | pdata->card_int_gpio = cd_gpio; | ||
95 | |||
96 | return pdata; | ||
97 | } | ||
98 | #else | ||
99 | static struct sdhci_plat_data * __devinit | ||
100 | sdhci_probe_config_dt(struct platform_device *pdev) | ||
101 | { | ||
102 | return ERR_PTR(-ENOSYS); | ||
103 | } | ||
104 | #endif | ||
105 | |||
71 | static int __devinit sdhci_probe(struct platform_device *pdev) | 106 | static int __devinit sdhci_probe(struct platform_device *pdev) |
72 | { | 107 | { |
108 | struct device_node *np = pdev->dev.of_node; | ||
73 | struct sdhci_host *host; | 109 | struct sdhci_host *host; |
74 | struct resource *iomem; | 110 | struct resource *iomem; |
75 | struct spear_sdhci *sdhci; | 111 | struct spear_sdhci *sdhci; |
@@ -110,8 +146,16 @@ static int __devinit sdhci_probe(struct platform_device *pdev) | |||
110 | goto put_clk; | 146 | goto put_clk; |
111 | } | 147 | } |
112 | 148 | ||
113 | /* overwrite platform_data */ | 149 | if (np) { |
114 | sdhci->data = dev_get_platdata(&pdev->dev); | 150 | sdhci->data = sdhci_probe_config_dt(pdev); |
151 | if (IS_ERR(sdhci->data)) { | ||
152 | dev_err(&pdev->dev, "DT: Failed to get pdata\n"); | ||
153 | return -ENODEV; | ||
154 | } | ||
155 | } else { | ||
156 | sdhci->data = dev_get_platdata(&pdev->dev); | ||
157 | } | ||
158 | |||
115 | pdev->dev.platform_data = sdhci; | 159 | pdev->dev.platform_data = sdhci; |
116 | 160 | ||
117 | if (pdev->dev.parent) | 161 | if (pdev->dev.parent) |
@@ -276,11 +320,20 @@ static int sdhci_resume(struct device *dev) | |||
276 | 320 | ||
277 | static SIMPLE_DEV_PM_OPS(sdhci_pm_ops, sdhci_suspend, sdhci_resume); | 321 | static SIMPLE_DEV_PM_OPS(sdhci_pm_ops, sdhci_suspend, sdhci_resume); |
278 | 322 | ||
323 | #ifdef CONFIG_OF | ||
324 | static const struct of_device_id sdhci_spear_id_table[] = { | ||
325 | { .compatible = "st,spear300-sdhci" }, | ||
326 | {} | ||
327 | }; | ||
328 | MODULE_DEVICE_TABLE(of, sdhci_spear_id_table); | ||
329 | #endif | ||
330 | |||
279 | static struct platform_driver sdhci_driver = { | 331 | static struct platform_driver sdhci_driver = { |
280 | .driver = { | 332 | .driver = { |
281 | .name = "sdhci", | 333 | .name = "sdhci", |
282 | .owner = THIS_MODULE, | 334 | .owner = THIS_MODULE, |
283 | .pm = &sdhci_pm_ops, | 335 | .pm = &sdhci_pm_ops, |
336 | .of_match_table = of_match_ptr(sdhci_spear_id_table), | ||
284 | }, | 337 | }, |
285 | .probe = sdhci_probe, | 338 | .probe = sdhci_probe, |
286 | .remove = __devexit_p(sdhci_remove), | 339 | .remove = __devexit_p(sdhci_remove), |