aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/host/sdhci-dove.c
diff options
context:
space:
mode:
authorSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>2014-05-22 18:16:52 -0400
committerChris Ball <chris@printf.net>2014-05-23 08:42:02 -0400
commitc5ee249069367fa0529de007f7119a157ce4a4ad (patch)
tree4e726c486adc297d6d9bad485713ea383b507de4 /drivers/mmc/host/sdhci-dove.c
parent708dce3f0a9018b55eeae5cdf23a2ebe69590c38 (diff)
mmc: sdhci-dove: use mmc_of_parse() and remove card_tasklet CD handler
f8ec589b86f6 ("mmc: sdhci-dove: allow GPIOs to be used for card detection on Dove" added a gpio based card detect interrupt handler that was hooked up into card_tasket. 3560db8e247a ("mmc: sdhci: push card_tasklet into threaded irq handler") now removed that very card_tasklet causing sdhci-dove to fail on build with: drivers/mmc/host/sdhci-dove.c: In function 'sdhci_dove_carddetect_irq': drivers/mmc/host/sdhci-dove.c:42:24: error: 'struct sdhci_host' has no member named 'card_tasklet' To fix both the build error and get a working gpio card detection without card_tasklet, replace sdhci_get_of_property() with more recent mmc_of_parse(). It takes care of gpio-based card detect passed through DT already and allows to remove the offending code sections dealing with removed card_tasklet. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Chris Ball <chris@printf.net>
Diffstat (limited to 'drivers/mmc/host/sdhci-dove.c')
-rw-r--r--drivers/mmc/host/sdhci-dove.c74
1 files changed, 5 insertions, 69 deletions
diff --git a/drivers/mmc/host/sdhci-dove.c b/drivers/mmc/host/sdhci-dove.c
index 0d315f4496c8..e6278ec007d7 100644
--- a/drivers/mmc/host/sdhci-dove.c
+++ b/drivers/mmc/host/sdhci-dove.c
@@ -21,28 +21,17 @@
21 21
22#include <linux/clk.h> 22#include <linux/clk.h>
23#include <linux/err.h> 23#include <linux/err.h>
24#include <linux/gpio.h>
25#include <linux/io.h> 24#include <linux/io.h>
26#include <linux/mmc/host.h> 25#include <linux/mmc/host.h>
27#include <linux/module.h> 26#include <linux/module.h>
28#include <linux/of.h> 27#include <linux/of.h>
29#include <linux/of_gpio.h>
30 28
31#include "sdhci-pltfm.h" 29#include "sdhci-pltfm.h"
32 30
33struct sdhci_dove_priv { 31struct sdhci_dove_priv {
34 struct clk *clk; 32 struct clk *clk;
35 int gpio_cd;
36}; 33};
37 34
38static irqreturn_t sdhci_dove_carddetect_irq(int irq, void *data)
39{
40 struct sdhci_host *host = data;
41
42 tasklet_schedule(&host->card_tasklet);
43 return IRQ_HANDLED;
44}
45
46static u16 sdhci_dove_readw(struct sdhci_host *host, int reg) 35static u16 sdhci_dove_readw(struct sdhci_host *host, int reg)
47{ 36{
48 u16 ret; 37 u16 ret;
@@ -60,8 +49,6 @@ static u16 sdhci_dove_readw(struct sdhci_host *host, int reg)
60 49
61static u32 sdhci_dove_readl(struct sdhci_host *host, int reg) 50static u32 sdhci_dove_readl(struct sdhci_host *host, int reg)
62{ 51{
63 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
64 struct sdhci_dove_priv *priv = pltfm_host->priv;
65 u32 ret; 52 u32 ret;
66 53
67 ret = readl(host->ioaddr + reg); 54 ret = readl(host->ioaddr + reg);
@@ -71,14 +58,6 @@ static u32 sdhci_dove_readl(struct sdhci_host *host, int reg)
71 /* Mask the support for 3.0V */ 58 /* Mask the support for 3.0V */
72 ret &= ~SDHCI_CAN_VDD_300; 59 ret &= ~SDHCI_CAN_VDD_300;
73 break; 60 break;
74 case SDHCI_PRESENT_STATE:
75 if (gpio_is_valid(priv->gpio_cd)) {
76 if (gpio_get_value(priv->gpio_cd) == 0)
77 ret |= SDHCI_CARD_PRESENT;
78 else
79 ret &= ~SDHCI_CARD_PRESENT;
80 }
81 break;
82 } 61 }
83 return ret; 62 return ret;
84} 63}
@@ -117,28 +96,9 @@ static int sdhci_dove_probe(struct platform_device *pdev)
117 96
118 priv->clk = devm_clk_get(&pdev->dev, NULL); 97 priv->clk = devm_clk_get(&pdev->dev, NULL);
119 98
120 if (pdev->dev.of_node) {
121 priv->gpio_cd = of_get_named_gpio(pdev->dev.of_node,
122 "cd-gpios", 0);
123 } else {
124 priv->gpio_cd = -EINVAL;
125 }
126
127 if (gpio_is_valid(priv->gpio_cd)) {
128 ret = gpio_request(priv->gpio_cd, "sdhci-cd");
129 if (ret) {
130 dev_err(&pdev->dev, "card detect gpio request failed: %d\n",
131 ret);
132 return ret;
133 }
134 gpio_direction_input(priv->gpio_cd);
135 }
136
137 host = sdhci_pltfm_init(pdev, &sdhci_dove_pdata, 0); 99 host = sdhci_pltfm_init(pdev, &sdhci_dove_pdata, 0);
138 if (IS_ERR(host)) { 100 if (IS_ERR(host))
139 ret = PTR_ERR(host); 101 return PTR_ERR(host);
140 goto err_sdhci_pltfm_init;
141 }
142 102
143 pltfm_host = sdhci_priv(host); 103 pltfm_host = sdhci_priv(host);
144 pltfm_host->priv = priv; 104 pltfm_host->priv = priv;
@@ -146,39 +106,20 @@ static int sdhci_dove_probe(struct platform_device *pdev)
146 if (!IS_ERR(priv->clk)) 106 if (!IS_ERR(priv->clk))
147 clk_prepare_enable(priv->clk); 107 clk_prepare_enable(priv->clk);
148 108
149 sdhci_get_of_property(pdev); 109 ret = mmc_of_parse(host->mmc);
110 if (ret)
111 goto err_sdhci_add;
150 112
151 ret = sdhci_add_host(host); 113 ret = sdhci_add_host(host);
152 if (ret) 114 if (ret)
153 goto err_sdhci_add; 115 goto err_sdhci_add;
154 116
155 /*
156 * We must request the IRQ after sdhci_add_host(), as the tasklet only
157 * gets setup in sdhci_add_host() and we oops.
158 */
159 if (gpio_is_valid(priv->gpio_cd)) {
160 ret = request_irq(gpio_to_irq(priv->gpio_cd),
161 sdhci_dove_carddetect_irq,
162 IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
163 mmc_hostname(host->mmc), host);
164 if (ret) {
165 dev_err(&pdev->dev, "card detect irq request failed: %d\n",
166 ret);
167 goto err_request_irq;
168 }
169 }
170
171 return 0; 117 return 0;
172 118
173err_request_irq:
174 sdhci_remove_host(host, 0);
175err_sdhci_add: 119err_sdhci_add:
176 if (!IS_ERR(priv->clk)) 120 if (!IS_ERR(priv->clk))
177 clk_disable_unprepare(priv->clk); 121 clk_disable_unprepare(priv->clk);
178 sdhci_pltfm_free(pdev); 122 sdhci_pltfm_free(pdev);
179err_sdhci_pltfm_init:
180 if (gpio_is_valid(priv->gpio_cd))
181 gpio_free(priv->gpio_cd);
182 return ret; 123 return ret;
183} 124}
184 125
@@ -190,11 +131,6 @@ static int sdhci_dove_remove(struct platform_device *pdev)
190 131
191 sdhci_pltfm_unregister(pdev); 132 sdhci_pltfm_unregister(pdev);
192 133
193 if (gpio_is_valid(priv->gpio_cd)) {
194 free_irq(gpio_to_irq(priv->gpio_cd), host);
195 gpio_free(priv->gpio_cd);
196 }
197
198 if (!IS_ERR(priv->clk)) 134 if (!IS_ERR(priv->clk))
199 clk_disable_unprepare(priv->clk); 135 clk_disable_unprepare(priv->clk);
200 136