brcm2708: update against latest rpi-3.10.y branch
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-3.10 / 0099-mmc-Report-3.3V-support-in-caps.patch
1 From c24b41600f008f5662a467de17644d26a0c269fd Mon Sep 17 00:00:00 2001
2 From: popcornmix <popcornmix@gmail.com>
3 Date: Sat, 9 Nov 2013 17:42:58 +0000
4 Subject: [PATCH 099/174] mmc: Report 3.3V support in caps
5
6 sdhci: Use macros for out spin lock/unlock functions to reduce diffs with upstream code
7 ---
8 drivers/mmc/host/sdhci-bcm2708.c | 2 +
9 drivers/mmc/host/sdhci.c | 82 ++++++++++++++++++++++------------------
10 2 files changed, 47 insertions(+), 37 deletions(-)
11
12 --- a/drivers/mmc/host/sdhci-bcm2708.c
13 +++ b/drivers/mmc/host/sdhci-bcm2708.c
14 @@ -1282,6 +1282,8 @@ static int sdhci_bcm2708_probe(struct pl
15 host_priv->dma_chan, host_priv->dma_chan_base,
16 host_priv->dma_irq);
17
18 + // we support 3.3V
19 + host->caps |= SDHCI_CAN_VDD_330;
20 if (allow_highspeed)
21 host->mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;
22
23 --- a/drivers/mmc/host/sdhci.c
24 +++ b/drivers/mmc/host/sdhci.c
25 @@ -210,6 +210,14 @@ static void sdhci_spin_disable_schedule(
26 #endif
27 }
28
29 +
30 +#undef spin_lock_irqsave
31 +#define spin_lock_irqsave(host_lock, flags) sdhci_spin_lock_irqsave(container_of(host_lock, struct sdhci_host, lock), &flags)
32 +#define spin_unlock_irqrestore(host_lock, flags) sdhci_spin_unlock_irqrestore(container_of(host_lock, struct sdhci_host, lock), flags)
33 +
34 +#define spin_lock(host_lock) sdhci_spin_lock(container_of(host_lock, struct sdhci_host, lock))
35 +#define spin_unlock(host_lock) sdhci_spin_unlock(container_of(host_lock, struct sdhci_host, lock))
36 +
37 static void sdhci_clear_set_irqs(struct sdhci_host *host, u32 clear, u32 set)
38 {
39 u32 ier;
40 @@ -374,7 +382,7 @@ static void sdhci_led_control(struct led
41 struct sdhci_host *host = container_of(led, struct sdhci_host, led);
42 unsigned long flags;
43
44 - sdhci_spin_lock_irqsave(host, &flags);
45 + spin_lock_irqsave(&host->lock, flags);
46
47 if (host->runtime_suspended)
48 goto out;
49 @@ -384,7 +392,7 @@ static void sdhci_led_control(struct led
50 else
51 sdhci_activate_led(host);
52 out:
53 - sdhci_spin_unlock_irqrestore(host, flags);
54 + spin_unlock_irqrestore(&host->lock, flags);
55 }
56 #endif
57
58 @@ -1419,7 +1427,7 @@ static void sdhci_request(struct mmc_hos
59
60 sdhci_runtime_pm_get(host);
61
62 - sdhci_spin_lock_irqsave(host, &flags);
63 + spin_lock_irqsave(&host->lock, flags);
64
65 WARN_ON(host->mrq != NULL);
66
67 @@ -1477,9 +1485,9 @@ static void sdhci_request(struct mmc_hos
68 mmc->card->type == MMC_TYPE_MMC ?
69 MMC_SEND_TUNING_BLOCK_HS200 :
70 MMC_SEND_TUNING_BLOCK;
71 - sdhci_spin_unlock_irqrestore(host, flags);
72 + spin_unlock_irqrestore(&host->lock, flags);
73 sdhci_execute_tuning(mmc, tuning_opcode);
74 - sdhci_spin_lock_irqsave(host, &flags);
75 + spin_lock_irqsave(&host->lock, flags);
76
77 /* Restore original mmc_request structure */
78 host->mrq = mrq;
79 @@ -1493,7 +1501,7 @@ static void sdhci_request(struct mmc_hos
80 }
81
82 mmiowb();
83 - sdhci_spin_unlock_irqrestore(host, flags);
84 + spin_unlock_irqrestore(&host->lock, flags);
85 }
86
87 static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios)
88 @@ -1502,10 +1510,10 @@ static void sdhci_do_set_ios(struct sdhc
89 int vdd_bit = -1;
90 u8 ctrl;
91
92 - sdhci_spin_lock_irqsave(host, &flags);
93 + spin_lock_irqsave(&host->lock, flags);
94
95 if (host->flags & SDHCI_DEVICE_DEAD) {
96 - sdhci_spin_unlock_irqrestore(host, flags);
97 + spin_unlock_irqrestore(&host->lock, flags);
98 if (host->vmmc && ios->power_mode == MMC_POWER_OFF)
99 mmc_regulator_set_ocr(host->mmc, host->vmmc, 0);
100 return;
101 @@ -1532,9 +1540,9 @@ static void sdhci_do_set_ios(struct sdhc
102 vdd_bit = sdhci_set_power(host, ios->vdd);
103
104 if (host->vmmc && vdd_bit != -1) {
105 - sdhci_spin_unlock_irqrestore(host, flags);
106 + spin_unlock_irqrestore(&host->lock, flags);
107 mmc_regulator_set_ocr(host->mmc, host->vmmc, vdd_bit);
108 - sdhci_spin_lock_irqsave(host, &flags);
109 + spin_lock_irqsave(&host->lock, flags);
110 }
111
112 if (host->ops->platform_send_init_74_clocks)
113 @@ -1672,7 +1680,7 @@ static void sdhci_do_set_ios(struct sdhc
114 sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
115
116 mmiowb();
117 - sdhci_spin_unlock_irqrestore(host, flags);
118 + spin_unlock_irqrestore(&host->lock, flags);
119 }
120
121 static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
122 @@ -1720,7 +1728,7 @@ static int sdhci_check_ro(struct sdhci_h
123 unsigned long flags;
124 int is_readonly;
125
126 - sdhci_spin_lock_irqsave(host, &flags);
127 + spin_lock_irqsave(&host->lock, flags);
128
129 if (host->flags & SDHCI_DEVICE_DEAD)
130 is_readonly = 0;
131 @@ -1730,7 +1738,7 @@ static int sdhci_check_ro(struct sdhci_h
132 is_readonly = !(sdhci_readl(host, SDHCI_PRESENT_STATE)
133 & SDHCI_WRITE_PROTECT);
134
135 - sdhci_spin_unlock_irqrestore(host, flags);
136 + spin_unlock_irqrestore(&host->lock, flags);
137
138 /* This quirk needs to be replaced by a callback-function later */
139 return host->quirks & SDHCI_QUIRK_INVERTED_WRITE_PROTECT ?
140 @@ -1803,9 +1811,9 @@ static void sdhci_enable_sdio_irq(struct
141 struct sdhci_host *host = mmc_priv(mmc);
142 unsigned long flags;
143
144 - sdhci_spin_lock_irqsave(host, &flags);
145 + spin_lock_irqsave(&host->lock, flags);
146 sdhci_enable_sdio_irq_nolock(host, enable);
147 - sdhci_spin_unlock_irqrestore(host, flags);
148 + spin_unlock_irqrestore(&host->lock, flags);
149 }
150
151 static int sdhci_do_start_signal_voltage_switch(struct sdhci_host *host,
152 @@ -2149,7 +2157,7 @@ static void sdhci_card_event(struct mmc_
153 struct sdhci_host *host = mmc_priv(mmc);
154 unsigned long flags;
155
156 - sdhci_spin_lock_irqsave(host, &flags);
157 + spin_lock_irqsave(&host->lock, flags);
158
159 /* Check host->mrq first in case we are runtime suspended */
160 if (host->mrq &&
161 @@ -2166,7 +2174,7 @@ static void sdhci_card_event(struct mmc_
162 tasklet_schedule(&host->finish_tasklet);
163 }
164
165 - sdhci_spin_unlock_irqrestore(host, flags);
166 + spin_unlock_irqrestore(&host->lock, flags);
167 }
168
169 static const struct mmc_host_ops sdhci_ops = {
170 @@ -2205,14 +2213,14 @@ static void sdhci_tasklet_finish(unsigne
171
172 host = (struct sdhci_host*)param;
173
174 - sdhci_spin_lock_irqsave(host, &flags);
175 + spin_lock_irqsave(&host->lock, flags);
176
177 /*
178 * If this tasklet gets rescheduled while running, it will
179 * be run again afterwards but without any active request.
180 */
181 if (!host->mrq) {
182 - sdhci_spin_unlock_irqrestore(host, flags);
183 + spin_unlock_irqrestore(&host->lock, flags);
184 return;
185 }
186
187 @@ -2250,7 +2258,7 @@ static void sdhci_tasklet_finish(unsigne
188 #endif
189
190 mmiowb();
191 - sdhci_spin_unlock_irqrestore(host, flags);
192 + spin_unlock_irqrestore(&host->lock, flags);
193
194 mmc_request_done(host->mmc, mrq);
195 sdhci_runtime_pm_put(host);
196 @@ -2263,7 +2271,7 @@ static void sdhci_timeout_timer(unsigned
197
198 host = (struct sdhci_host*)data;
199
200 - sdhci_spin_lock_irqsave(host, &flags);
201 + spin_lock_irqsave(&host->lock, flags);
202
203 if (host->mrq) {
204 pr_err("%s: Timeout waiting for hardware "
205 @@ -2284,7 +2292,7 @@ static void sdhci_timeout_timer(unsigned
206 }
207
208 mmiowb();
209 - sdhci_spin_unlock_irqrestore(host, flags);
210 + spin_unlock_irqrestore(&host->lock, flags);
211 }
212
213 static void sdhci_tuning_timer(unsigned long data)
214 @@ -2294,11 +2302,11 @@ static void sdhci_tuning_timer(unsigned
215
216 host = (struct sdhci_host *)data;
217
218 - sdhci_spin_lock_irqsave(host, &flags);
219 + spin_lock_irqsave(&host->lock, flags);
220
221 host->flags |= SDHCI_NEEDS_RETUNING;
222
223 - sdhci_spin_unlock_irqrestore(host, flags);
224 + spin_unlock_irqrestore(&host->lock, flags);
225 }
226
227 /*****************************************************************************\
228 @@ -2522,10 +2530,10 @@ static irqreturn_t sdhci_irq(int irq, vo
229 u32 intmask, unexpected = 0;
230 int cardint = 0, max_loops = 16;
231
232 - sdhci_spin_lock(host);
233 + spin_lock(&host->lock);
234
235 if (host->runtime_suspended) {
236 - sdhci_spin_unlock(host);
237 + spin_unlock(&host->lock);
238 pr_warning("%s: got irq while runtime suspended\n",
239 mmc_hostname(host->mmc));
240 return IRQ_HANDLED;
241 @@ -2629,7 +2637,7 @@ again:
242 if (intmask && --max_loops)
243 goto again;
244 out:
245 - sdhci_spin_unlock(host);
246 + spin_unlock(&host->lock);
247
248 if (unexpected) {
249 pr_err("%s: Unexpected interrupt 0x%08x.\n",
250 @@ -2791,15 +2799,15 @@ int sdhci_runtime_suspend_host(struct sd
251 host->flags &= ~SDHCI_NEEDS_RETUNING;
252 }
253
254 - sdhci_spin_lock_irqsave(host, &flags);
255 + spin_lock_irqsave(&host->lock, flags);
256 sdhci_mask_irqs(host, SDHCI_INT_ALL_MASK);
257 - sdhci_spin_unlock_irqrestore(host, flags);
258 + spin_unlock_irqrestore(&host->lock, flags);
259
260 synchronize_irq(host->irq);
261
262 - sdhci_spin_lock_irqsave(host, &flags);
263 + spin_lock_irqsave(&host->lock, flags);
264 host->runtime_suspended = true;
265 - sdhci_spin_unlock_irqrestore(host, flags);
266 + spin_unlock_irqrestore(&host->lock, flags);
267
268 return ret;
269 }
270 @@ -2825,16 +2833,16 @@ int sdhci_runtime_resume_host(struct sdh
271 sdhci_do_start_signal_voltage_switch(host, &host->mmc->ios);
272 if ((host_flags & SDHCI_PV_ENABLED) &&
273 !(host->quirks2 & SDHCI_QUIRK2_PRESET_VALUE_BROKEN)) {
274 - sdhci_spin_lock_irqsave(host, &flags);
275 + spin_lock_irqsave(&host->lock, flags);
276 sdhci_enable_preset_value(host, true);
277 - sdhci_spin_unlock_irqrestore(host, flags);
278 + spin_unlock_irqrestore(&host->lock, flags);
279 }
280
281 /* Set the re-tuning expiration flag */
282 if (host->flags & SDHCI_USING_RETUNING_TIMER)
283 host->flags |= SDHCI_NEEDS_RETUNING;
284
285 - sdhci_spin_lock_irqsave(host, &flags);
286 + spin_lock_irqsave(&host->lock, flags);
287
288 host->runtime_suspended = false;
289
290 @@ -2845,7 +2853,7 @@ int sdhci_runtime_resume_host(struct sdh
291 /* Enable Card Detection */
292 sdhci_enable_card_detection(host);
293
294 - sdhci_spin_unlock_irqrestore(host, flags);
295 + spin_unlock_irqrestore(&host->lock, flags);
296
297 return ret;
298 }
299 @@ -3401,7 +3409,7 @@ void sdhci_remove_host(struct sdhci_host
300 unsigned long flags;
301
302 if (dead) {
303 - sdhci_spin_lock_irqsave(host, &flags);
304 + spin_lock_irqsave(&host->lock, flags);
305
306 host->flags |= SDHCI_DEVICE_DEAD;
307
308 @@ -3413,7 +3421,7 @@ void sdhci_remove_host(struct sdhci_host
309 tasklet_schedule(&host->finish_tasklet);
310 }
311
312 - sdhci_spin_unlock_irqrestore(host, flags);
313 + spin_unlock_irqrestore(&host->lock, flags);
314 }
315
316 sdhci_disable_card_detection(host);