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 | |
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>
-rw-r--r-- | Documentation/devicetree/bindings/mmc/sdhci-spear.txt | 21 | ||||
-rw-r--r-- | arch/arm/boot/dts/spear300-evb.dts | 3 | ||||
-rw-r--r-- | arch/arm/boot/dts/spear320-evb.dts | 2 | ||||
-rw-r--r-- | drivers/mmc/host/sdhci-spear.c | 57 |
4 files changed, 77 insertions, 6 deletions
diff --git a/Documentation/devicetree/bindings/mmc/sdhci-spear.txt b/Documentation/devicetree/bindings/mmc/sdhci-spear.txt new file mode 100644 index 000000000000..84d6e297908f --- /dev/null +++ b/Documentation/devicetree/bindings/mmc/sdhci-spear.txt | |||
@@ -0,0 +1,21 @@ | |||
1 | * SPEAr SDHCI Controller | ||
2 | |||
3 | This file documents differences between the core properties in mmc.txt | ||
4 | and the properties used by the sdhci-spear driver. | ||
5 | |||
6 | Required properties: | ||
7 | - compatible: "st,spear300-sdhci" | ||
8 | |||
9 | Optional properties: | ||
10 | - cd-gpios: card detect gpio, with zero flags. | ||
11 | |||
12 | If your board don't support these gpios then don't pass the entry. | ||
13 | |||
14 | Example: | ||
15 | |||
16 | sdhci@fc000000 { | ||
17 | compatible = "st,spear300-sdhci"; | ||
18 | reg = <0xfc000000 0x1000>; | ||
19 | |||
20 | cd-gpios = <&gpio0 6 0> | ||
21 | }; | ||
diff --git a/arch/arm/boot/dts/spear300-evb.dts b/arch/arm/boot/dts/spear300-evb.dts index d71b8d581e3d..1e7c7a8e2123 100644 --- a/arch/arm/boot/dts/spear300-evb.dts +++ b/arch/arm/boot/dts/spear300-evb.dts | |||
@@ -80,8 +80,7 @@ | |||
80 | }; | 80 | }; |
81 | 81 | ||
82 | sdhci@70000000 { | 82 | sdhci@70000000 { |
83 | int-gpio = <&gpio1 0 0>; | 83 | cd-gpios = <&gpio1 0 0>; |
84 | power-gpio = <&gpio1 2 1>; | ||
85 | status = "okay"; | 84 | status = "okay"; |
86 | }; | 85 | }; |
87 | 86 | ||
diff --git a/arch/arm/boot/dts/spear320-evb.dts b/arch/arm/boot/dts/spear320-evb.dts index e4e912f95024..082328bd64ab 100644 --- a/arch/arm/boot/dts/spear320-evb.dts +++ b/arch/arm/boot/dts/spear320-evb.dts | |||
@@ -103,8 +103,6 @@ | |||
103 | }; | 103 | }; |
104 | 104 | ||
105 | sdhci@70000000 { | 105 | sdhci@70000000 { |
106 | power-gpio = <&gpio0 2 1>; | ||
107 | power_always_enb; | ||
108 | status = "okay"; | 106 | status = "okay"; |
109 | }; | 107 | }; |
110 | 108 | ||
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), |