brcm2708: update 4.1 patches
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.1 / 0076-bcm2835-sdhost-Improve-error-handling-and-recovery.patch
1 From 23d5b7edb052559fcac15a305d3f665aa432831c Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.org>
3 Date: Wed, 17 Jun 2015 11:36:53 +0100
4 Subject: [PATCH 076/148] bcm2835-sdhost: Improve error handling and recovery
5
6 1) Expose the hw_reset method to the MMC framework, removing many
7 internal calls by the driver.
8
9 2) Reduce overclock setting on error.
10
11 3) Increase timeout to cope with high capacity cards.
12
13 4) Add properties and parameters to control pio_limit and debug.
14
15 5) Reduce messages at probe time.
16 ---
17 arch/arm/boot/dts/overlays/README | 8 +-
18 arch/arm/boot/dts/overlays/sdhost-overlay.dts | 4 +-
19 drivers/mmc/host/bcm2835-sdhost.c | 578 ++++++++++++++++++--------
20 3 files changed, 404 insertions(+), 186 deletions(-)
21
22 --- a/arch/arm/boot/dts/overlays/README
23 +++ b/arch/arm/boot/dts/overlays/README
24 @@ -408,7 +408,13 @@ Info: Selects the bcm2835-sdhost SD/MM
25 Load: dtoverlay=sdhost,<param>=<val>
26 Params: overclock_50 Clock (in MHz) to use when the MMC framework
27 requests 50MHz
28 - force_pio Disable DMA support
29 +
30 + force_pio Disable DMA support (default off)
31 +
32 + pio_limit Number of blocks above which to use DMA
33 + (default 2)
34 +
35 + debug Enable debug output (default off)
36
37
38 Name: spi-bcm2708
39 --- a/arch/arm/boot/dts/overlays/sdhost-overlay.dts
40 +++ b/arch/arm/boot/dts/overlays/sdhost-overlay.dts
41 @@ -22,6 +22,7 @@
42 dma-names = "tx", "rx";
43 brcm,delay-after-stop = <0>;
44 brcm,overclock-50 = <0>;
45 + brcm,pio-limit = <2>;
46 status = "okay";
47 };
48 };
49 @@ -70,9 +71,10 @@
50 };
51
52 __overrides__ {
53 - delay_after_stop = <&sdhost>,"brcm,delay-after-stop:0";
54 overclock_50 = <&sdhost>,"brcm,overclock-50:0";
55 force_pio = <&sdhost>,"brcm,force-pio?";
56 + pio_limit = <&sdhost>,"brcm,pio-limit:0";
57 + debug = <&sdhost>,"brcm,debug?";
58 sdhost_freq = <&clk_sdhost>,"clock-frequency:0";
59 };
60 };
61 --- a/drivers/mmc/host/bcm2835-sdhost.c
62 +++ b/drivers/mmc/host/bcm2835-sdhost.c
63 @@ -90,9 +90,8 @@
64 /* Reserved */
65 #define SDHSTS_DATA_FLAG 0x01
66
67 -#define SDHSTS_TRANSFER_ERROR_MASK (SDHSTS_CRC16_ERROR|SDHSTS_REW_TIME_OUT|SDHSTS_FIFO_ERROR)
68 +#define SDHSTS_TRANSFER_ERROR_MASK (SDHSTS_CRC7_ERROR|SDHSTS_CRC16_ERROR|SDHSTS_REW_TIME_OUT|SDHSTS_FIFO_ERROR)
69 #define SDHSTS_ERROR_MASK (SDHSTS_CMD_TIME_OUT|SDHSTS_TRANSFER_ERROR_MASK)
70 -/* SDHSTS_CRC7_ERROR - ignore this as MMC cards generate this spuriously */
71
72 #define SDHCFG_BUSY_IRPT_EN (1<<10)
73 #define SDHCFG_BLOCK_IRPT_EN (1<<8)
74 @@ -111,16 +110,7 @@
75 #define SDEDM_READ_THRESHOLD_SHIFT 14
76 #define SDEDM_THRESHOLD_MASK 0x1f
77
78 -/* the inclusive limit in bytes under which PIO will be used instead of DMA */
79 -#ifdef CONFIG_MMC_BCM2835_SDHOST_PIO_DMA_BARRIER
80 -#define PIO_DMA_BARRIER CONFIG_MMC_BCM2835_SDHOST_PIO_DMA_BARRIER
81 -#else
82 -#define PIO_DMA_BARRIER 0
83 -#endif
84 -
85 -#define MIN_FREQ 400000
86 -#define TIMEOUT_VAL 0xE
87 -#define BCM2835_SDHOST_WRITE_DELAY(f) (((2 * 1000000) / f) + 1)
88 +#define MHZ 1000000
89
90 #ifndef BCM2708_PERI_BASE
91 #define BCM2708_PERI_BASE 0x20000000
92 @@ -138,19 +128,20 @@ struct bcm2835_host {
93
94 struct mmc_host *mmc;
95
96 - u32 timeout;
97 + u32 pio_timeout; /* In jiffies */
98
99 int clock; /* Current clock speed */
100
101 bool slow_card; /* Force 11-bit divisor */
102
103 unsigned int max_clk; /* Max possible freq */
104 - unsigned int timeout_clk; /* Timeout freq (KHz) */
105
106 struct tasklet_struct finish_tasklet; /* Tasklet structures */
107
108 struct timer_list timer; /* Timer for timeouts */
109
110 + struct timer_list pio_timer; /* PIO error detection timer */
111 +
112 struct sg_mapping_iter sg_miter; /* SG state for PIO */
113 unsigned int blocks; /* remaining PIO blocks */
114
115 @@ -170,6 +161,10 @@ struct bcm2835_host {
116
117 unsigned int use_busy:1; /* Wait for busy interrupt */
118
119 + unsigned int reduce_overclock:1; /* ...at the next opportunity */
120 +
121 + unsigned int debug:1; /* Enable debug output */
122 +
123 u32 thread_isr;
124
125 /*DMA part*/
126 @@ -185,7 +180,8 @@ struct bcm2835_host {
127 struct timeval stop_time; /* when the last stop was issued */
128 u32 delay_after_stop; /* minimum time between stop and subsequent data transfer */
129 u32 overclock_50; /* frequency to use when 50MHz is requested (in MHz) */
130 - u32 max_overclock; /* Highest reported */
131 + u32 overclock; /* Current frequency if overclocked, else zero */
132 + u32 pio_limit; /* Maximum block count for PIO (0 = always DMA) */
133 };
134
135
136 @@ -204,41 +200,79 @@ static inline u32 bcm2835_sdhost_read_re
137 return readl_relaxed(host->ioaddr + reg);
138 }
139
140 +static void bcm2835_sdhost_dumpcmd(struct bcm2835_host *host,
141 + struct mmc_command *cmd,
142 + const char *label)
143 +{
144 + if (cmd)
145 + pr_info("%s:%c%s op %d arg 0x%x flags 0x%x - resp %08x %08x %08x %08x, err %d\n",
146 + mmc_hostname(host->mmc),
147 + (cmd == host->cmd) ? '>' : ' ',
148 + label, cmd->opcode, cmd->arg, cmd->flags,
149 + cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3],
150 + cmd->error);
151 +}
152 +
153 static void bcm2835_sdhost_dumpregs(struct bcm2835_host *host)
154 {
155 - pr_info(DRIVER_NAME ": =========== REGISTER DUMP (%s)===========\n",
156 + bcm2835_sdhost_dumpcmd(host, host->mrq->sbc, "sbc");
157 + bcm2835_sdhost_dumpcmd(host, host->mrq->cmd, "cmd");
158 + if (host->mrq->data)
159 + pr_err("%s: data blocks %x blksz %x - err %d\n",
160 + mmc_hostname(host->mmc),
161 + host->mrq->data->blocks,
162 + host->mrq->data->blksz,
163 + host->mrq->data->error);
164 + bcm2835_sdhost_dumpcmd(host, host->mrq->stop, "stop");
165 +
166 + pr_info("%s: =========== REGISTER DUMP ===========\n",
167 mmc_hostname(host->mmc));
168
169 - pr_info(DRIVER_NAME ": SDCMD 0x%08x\n",
170 + pr_info("%s: SDCMD 0x%08x\n",
171 + mmc_hostname(host->mmc),
172 bcm2835_sdhost_read(host, SDCMD));
173 - pr_info(DRIVER_NAME ": SDARG 0x%08x\n",
174 + pr_info("%s: SDARG 0x%08x\n",
175 + mmc_hostname(host->mmc),
176 bcm2835_sdhost_read(host, SDARG));
177 - pr_info(DRIVER_NAME ": SDTOUT 0x%08x\n",
178 + pr_info("%s: SDTOUT 0x%08x\n",
179 + mmc_hostname(host->mmc),
180 bcm2835_sdhost_read(host, SDTOUT));
181 - pr_info(DRIVER_NAME ": SDCDIV 0x%08x\n",
182 + pr_info("%s: SDCDIV 0x%08x\n",
183 + mmc_hostname(host->mmc),
184 bcm2835_sdhost_read(host, SDCDIV));
185 - pr_info(DRIVER_NAME ": SDRSP0 0x%08x\n",
186 + pr_info("%s: SDRSP0 0x%08x\n",
187 + mmc_hostname(host->mmc),
188 bcm2835_sdhost_read(host, SDRSP0));
189 - pr_info(DRIVER_NAME ": SDRSP1 0x%08x\n",
190 + pr_info("%s: SDRSP1 0x%08x\n",
191 + mmc_hostname(host->mmc),
192 bcm2835_sdhost_read(host, SDRSP1));
193 - pr_info(DRIVER_NAME ": SDRSP2 0x%08x\n",
194 + pr_info("%s: SDRSP2 0x%08x\n",
195 + mmc_hostname(host->mmc),
196 bcm2835_sdhost_read(host, SDRSP2));
197 - pr_info(DRIVER_NAME ": SDRSP3 0x%08x\n",
198 + pr_info("%s: SDRSP3 0x%08x\n",
199 + mmc_hostname(host->mmc),
200 bcm2835_sdhost_read(host, SDRSP3));
201 - pr_info(DRIVER_NAME ": SDHSTS 0x%08x\n",
202 + pr_info("%s: SDHSTS 0x%08x\n",
203 + mmc_hostname(host->mmc),
204 bcm2835_sdhost_read(host, SDHSTS));
205 - pr_info(DRIVER_NAME ": SDVDD 0x%08x\n",
206 + pr_info("%s: SDVDD 0x%08x\n",
207 + mmc_hostname(host->mmc),
208 bcm2835_sdhost_read(host, SDVDD));
209 - pr_info(DRIVER_NAME ": SDEDM 0x%08x\n",
210 + pr_info("%s: SDEDM 0x%08x\n",
211 + mmc_hostname(host->mmc),
212 bcm2835_sdhost_read(host, SDEDM));
213 - pr_info(DRIVER_NAME ": SDHCFG 0x%08x\n",
214 + pr_info("%s: SDHCFG 0x%08x\n",
215 + mmc_hostname(host->mmc),
216 bcm2835_sdhost_read(host, SDHCFG));
217 - pr_info(DRIVER_NAME ": SDHBCT 0x%08x\n",
218 + pr_info("%s: SDHBCT 0x%08x\n",
219 + mmc_hostname(host->mmc),
220 bcm2835_sdhost_read(host, SDHBCT));
221 - pr_info(DRIVER_NAME ": SDHBLC 0x%08x\n",
222 + pr_info("%s: SDHBLC 0x%08x\n",
223 + mmc_hostname(host->mmc),
224 bcm2835_sdhost_read(host, SDHBLC));
225
226 - pr_debug(DRIVER_NAME ": ===========================================\n");
227 + pr_info("%s: ===========================================\n",
228 + mmc_hostname(host->mmc));
229 }
230
231
232 @@ -248,12 +282,10 @@ static void bcm2835_sdhost_set_power(str
233 }
234
235
236 -static void bcm2835_sdhost_reset(struct bcm2835_host *host)
237 +static void bcm2835_sdhost_reset_internal(struct bcm2835_host *host)
238 {
239 u32 temp;
240
241 - pr_debug("bcm2835_sdhost_reset\n");
242 -
243 bcm2835_sdhost_set_power(host, false);
244
245 bcm2835_sdhost_write(host, 0, SDCMD);
246 @@ -281,6 +313,20 @@ static void bcm2835_sdhost_reset(struct
247 mmiowb();
248 }
249
250 +
251 +static void bcm2835_sdhost_reset(struct mmc_host *mmc)
252 +{
253 + struct bcm2835_host *host = mmc_priv(mmc);
254 + unsigned long flags;
255 + if (host->debug)
256 + pr_info("%s: reset\n", mmc_hostname(mmc));
257 + spin_lock_irqsave(&host->lock, flags);
258 +
259 + bcm2835_sdhost_reset_internal(host);
260 +
261 + spin_unlock_irqrestore(&host->lock, flags);
262 +}
263 +
264 static void bcm2835_sdhost_set_ios(struct mmc_host *mmc, struct mmc_ios *ios);
265
266 static void bcm2835_sdhost_init(struct bcm2835_host *host, int soft)
267 @@ -290,7 +336,7 @@ static void bcm2835_sdhost_init(struct b
268 /* Set interrupt enables */
269 host->hcfg = SDHCFG_BUSY_IRPT_EN;
270
271 - bcm2835_sdhost_reset(host);
272 + bcm2835_sdhost_reset_internal(host);
273
274 if (soft) {
275 /* force clock reconfiguration */
276 @@ -420,6 +466,40 @@ static void bcm2835_sdhost_dma_complete(
277 spin_unlock_irqrestore(&host->lock, flags);
278 }
279
280 +static bool data_transfer_wait(struct bcm2835_host *host, const char *caller)
281 +{
282 + unsigned long timeout = 1000000;
283 + u32 hsts;
284 + while (timeout)
285 + {
286 + hsts = bcm2835_sdhost_read(host, SDHSTS);
287 + if (hsts & (SDHSTS_TRANSFER_ERROR_MASK |
288 + SDHSTS_DATA_FLAG)) {
289 + bcm2835_sdhost_write(host, SDHSTS_TRANSFER_ERROR_MASK,
290 + SDHSTS);
291 + break;
292 + }
293 + timeout--;
294 + }
295 +
296 + if (hsts & (SDHSTS_CRC16_ERROR |
297 + SDHSTS_CRC7_ERROR |
298 + SDHSTS_FIFO_ERROR)) {
299 + pr_err("%s: data error in %s - HSTS %x\n",
300 + mmc_hostname(host->mmc), caller, hsts);
301 + host->data->error = -EILSEQ;
302 + return false;
303 + } else if ((timeout == 0) ||
304 + (hsts & (SDHSTS_CMD_TIME_OUT |
305 + SDHSTS_REW_TIME_OUT))) {
306 + pr_err("%s: timeout in %s - HSTS %x\n",
307 + mmc_hostname(host->mmc), caller, hsts);
308 + host->data->error = -ETIMEDOUT;
309 + return false;
310 + }
311 + return true;
312 +}
313 +
314 static void bcm2835_sdhost_read_block_pio(struct bcm2835_host *host)
315 {
316 unsigned long flags;
317 @@ -443,35 +523,15 @@ static void bcm2835_sdhost_read_block_pi
318 buf = (u32 *)host->sg_miter.addr;
319
320 while (len) {
321 - while (1) {
322 - u32 hsts;
323 - hsts = bcm2835_sdhost_read(host, SDHSTS);
324 - if (hsts & SDHSTS_DATA_FLAG)
325 - break;
326 -
327 - if (hsts & SDHSTS_ERROR_MASK) {
328 - pr_err("%s: Transfer error - HSTS %x, HBCT %x - %x left\n",
329 - mmc_hostname(host->mmc),
330 - hsts,
331 - bcm2835_sdhost_read(host, SDHBCT),
332 - blksize + len);
333 - if (hsts & SDHSTS_REW_TIME_OUT)
334 - host->data->error = -ETIMEDOUT;
335 - else if (hsts & (SDHSTS_CRC16_ERROR ||
336 - SDHSTS_CRC7_ERROR))
337 - host->data->error = -EILSEQ;
338 - else {
339 - pr_err("%s: unexpected data error\n",
340 - mmc_hostname(host->mmc));
341 - bcm2835_sdhost_dumpregs(host);
342 - host->cmd->error = -EIO;
343 - }
344 - }
345 - }
346 + if (!data_transfer_wait(host, "read_block_pio"))
347 + break;
348
349 *(buf++) = bcm2835_sdhost_read(host, SDDATA);
350 len -= 4;
351 }
352 +
353 + if (host->data->error)
354 + break;
355 }
356
357 sg_miter_stop(&host->sg_miter);
358 @@ -502,11 +562,15 @@ static void bcm2835_sdhost_write_block_p
359 buf = host->sg_miter.addr;
360
361 while (len) {
362 - while (!(bcm2835_sdhost_read(host, SDHSTS) & SDHSTS_DATA_FLAG))
363 - continue;
364 + if (!data_transfer_wait(host, "write_block_pio"))
365 + break;
366 +
367 bcm2835_sdhost_write(host, *(buf++), SDDATA);
368 len -= 4;
369 }
370 +
371 + if (host->data->error)
372 + break;
373 }
374
375 sg_miter_stop(&host->sg_miter);
376 @@ -519,10 +583,15 @@ static void bcm2835_sdhost_transfer_pio(
377 {
378 BUG_ON(!host->data);
379
380 - if (host->data->flags & MMC_DATA_READ)
381 + if (host->data->flags & MMC_DATA_READ) {
382 bcm2835_sdhost_read_block_pio(host);
383 - else
384 + } else {
385 bcm2835_sdhost_write_block_pio(host);
386 +
387 + /* Start a timer in case a transfer error occurs because
388 + there is no error interrupt */
389 + mod_timer(&host->pio_timer, jiffies + host->pio_timeout);
390 + }
391 }
392
393
394 @@ -607,6 +676,7 @@ static void bcm2835_sdhost_prepare_data(
395 host->flush_fifo = 0;
396 host->data->bytes_xfered = 0;
397
398 + host->use_dma = host->have_dma && (data->blocks > host->pio_limit);
399 if (!host->use_dma) {
400 int flags;
401
402 @@ -619,8 +689,6 @@ static void bcm2835_sdhost_prepare_data(
403 host->blocks = data->blocks;
404 }
405
406 - host->use_dma = host->have_dma && data->blocks > PIO_DMA_BARRIER;
407 -
408 bcm2835_sdhost_set_transfer_irqs(host);
409
410 bcm2835_sdhost_write(host, data->blksz, SDHBCT);
411 @@ -638,22 +706,25 @@ void bcm2835_sdhost_send_command(struct
412
413 WARN_ON(host->cmd);
414
415 - if (1) {
416 - pr_debug("bcm2835_sdhost_send_command: %08x %08x (flags %x)\n",
417 - cmd->opcode, cmd->arg, (cmd->flags & 0xff) | (cmd->data ? cmd->data->flags : 0));
418 - if (cmd->data)
419 - pr_debug("bcm2835_sdhost_send_command: %s %d*%x\n",
420 - (cmd->data->flags & MMC_DATA_READ) ?
421 - "read" : "write", cmd->data->blocks,
422 - cmd->data->blksz);
423 - }
424 + if (cmd->data)
425 + pr_debug("%s: send_command %d 0x%x "
426 + "(flags 0x%x) - %s %d*%d\n",
427 + mmc_hostname(host->mmc),
428 + cmd->opcode, cmd->arg, cmd->flags,
429 + (cmd->data->flags & MMC_DATA_READ) ?
430 + "read" : "write", cmd->data->blocks,
431 + cmd->data->blksz);
432 + else
433 + pr_debug("%s: send_command %d 0x%x (flags 0x%x)\n",
434 + mmc_hostname(host->mmc),
435 + cmd->opcode, cmd->arg, cmd->flags);
436
437 /* Wait max 10 ms */
438 timeout = 1000;
439
440 while (bcm2835_sdhost_read(host, SDCMD) & SDCMD_NEW_FLAG) {
441 if (timeout == 0) {
442 - pr_err("%s: Previous command never completed.\n",
443 + pr_err("%s: previous command never completed.\n",
444 mmc_hostname(host->mmc));
445 bcm2835_sdhost_dumpregs(host);
446 cmd->error = -EIO;
447 @@ -666,16 +737,16 @@ void bcm2835_sdhost_send_command(struct
448
449 if ((1000-timeout)/100 > 1 && (1000-timeout)/100 > host->max_delay) {
450 host->max_delay = (1000-timeout)/100;
451 - pr_warning("Warning: SDHost controller hung for %d ms\n", host->max_delay);
452 + pr_warning("%s: controller hung for %d ms\n",
453 + mmc_hostname(host->mmc),
454 + host->max_delay);
455 }
456
457 timeout = jiffies;
458 -#ifdef CONFIG_ARCH_BCM2835
459 if (!cmd->data && cmd->busy_timeout > 9000)
460 timeout += DIV_ROUND_UP(cmd->busy_timeout, 1000) * HZ + HZ;
461 else
462 -#endif
463 - timeout += 10 * HZ;
464 + timeout += 10 * HZ;
465 mod_timer(&host->timer, timeout);
466
467 host->cmd = cmd;
468 @@ -685,7 +756,7 @@ void bcm2835_sdhost_send_command(struct
469 bcm2835_sdhost_write(host, cmd->arg, SDARG);
470
471 if ((cmd->flags & MMC_RSP_136) && (cmd->flags & MMC_RSP_BUSY)) {
472 - pr_err("%s: Unsupported response type!\n",
473 + pr_err("%s: unsupported response type!\n",
474 mmc_hostname(host->mmc));
475 cmd->error = -EINVAL;
476 tasklet_schedule(&host->finish_tasklet);
477 @@ -783,13 +854,6 @@ static void bcm2835_sdhost_transfer_comp
478 pr_debug("transfer_complete(error %d, stop %d)\n",
479 data->error, data->stop ? 1 : 0);
480
481 - if (data->error)
482 - /*
483 - * The controller needs a reset of internal state machines
484 - * upon error conditions.
485 - */
486 - bcm2835_sdhost_reset(host);
487 -
488 /*
489 * Need to send CMD12 if -
490 * a) open-ended multiblock transfer (no CMD23)
491 @@ -845,7 +909,7 @@ static void bcm2835_sdhost_finish_comman
492 #endif
493
494 if (timeout == 0) {
495 - pr_err("%s: Command never completed.\n",
496 + pr_err("%s: command never completed.\n",
497 mmc_hostname(host->mmc));
498 bcm2835_sdhost_dumpregs(host);
499 host->cmd->error = -EIO;
500 @@ -875,14 +939,23 @@ static void bcm2835_sdhost_finish_comman
501 {
502 u32 sdhsts = bcm2835_sdhost_read(host, SDHSTS);
503
504 - pr_debug("%s: error detected - CMD %x, HSTS %03x, EDM %x\n",
505 - mmc_hostname(host->mmc), sdcmd, sdhsts,
506 - bcm2835_sdhost_read(host, SDEDM));
507 -
508 - if (sdhsts & SDHSTS_CMD_TIME_OUT)
509 + if (host->debug)
510 + pr_info("%s: error detected - CMD %x, HSTS %03x, EDM %x\n",
511 + mmc_hostname(host->mmc), sdcmd, sdhsts,
512 + bcm2835_sdhost_read(host, SDEDM));
513 +
514 + if (sdhsts & SDHSTS_CMD_TIME_OUT) {
515 + switch (host->cmd->opcode) {
516 + case 5: case 52: case 53:
517 + /* Don't warn about SDIO commands */
518 + break;
519 + default:
520 + pr_err("%s: command timeout\n",
521 + mmc_hostname(host->mmc));
522 + break;
523 + }
524 host->cmd->error = -ETIMEDOUT;
525 - else
526 - {
527 + } else {
528 pr_err("%s: unexpected command error\n",
529 mmc_hostname(host->mmc));
530 bcm2835_sdhost_dumpregs(host);
531 @@ -897,11 +970,13 @@ static void bcm2835_sdhost_finish_comman
532 int i;
533 for (i = 0; i < 4; i++)
534 host->cmd->resp[3 - i] = bcm2835_sdhost_read(host, SDRSP0 + i*4);
535 - pr_debug("bcm2835_sdhost_finish_command: %08x %08x %08x %08x\n",
536 + pr_debug("%s: finish_command %08x %08x %08x %08x\n",
537 + mmc_hostname(host->mmc),
538 host->cmd->resp[0], host->cmd->resp[1], host->cmd->resp[2], host->cmd->resp[3]);
539 } else {
540 host->cmd->resp[0] = bcm2835_sdhost_read(host, SDRSP0);
541 - pr_debug("bcm2835_sdhost_finish_command: %08x\n",
542 + pr_debug("%s: finish_command %08x\n",
543 + mmc_hostname(host->mmc),
544 host->cmd->resp[0]);
545 }
546 }
547 @@ -932,7 +1007,7 @@ static void bcm2835_sdhost_finish_comman
548 }
549 }
550
551 -static void bcm2835_sdhost_timeout_timer(unsigned long data)
552 +static void bcm2835_sdhost_timeout(unsigned long data)
553 {
554 struct bcm2835_host *host;
555 unsigned long flags;
556 @@ -942,7 +1017,7 @@ static void bcm2835_sdhost_timeout_timer
557 spin_lock_irqsave(&host->lock, flags);
558
559 if (host->mrq) {
560 - pr_err("%s: Timeout waiting for hardware interrupt.\n",
561 + pr_err("%s: timeout waiting for hardware interrupt.\n",
562 mmc_hostname(host->mmc));
563 bcm2835_sdhost_dumpregs(host);
564
565 @@ -964,6 +1039,41 @@ static void bcm2835_sdhost_timeout_timer
566 spin_unlock_irqrestore(&host->lock, flags);
567 }
568
569 +static void bcm2835_sdhost_pio_timeout(unsigned long data)
570 +{
571 + struct bcm2835_host *host;
572 + unsigned long flags;
573 +
574 + host = (struct bcm2835_host *)data;
575 +
576 + spin_lock_irqsave(&host->lock, flags);
577 +
578 + if (host->data) {
579 + u32 hsts = bcm2835_sdhost_read(host, SDHSTS);
580 +
581 + if (hsts & SDHSTS_REW_TIME_OUT) {
582 + pr_err("%s: transfer timeout\n",
583 + mmc_hostname(host->mmc));
584 + if (host->debug)
585 + bcm2835_sdhost_dumpregs(host);
586 + } else {
587 + pr_err("%s: unexpected transfer timeout\n",
588 + mmc_hostname(host->mmc));
589 + bcm2835_sdhost_dumpregs(host);
590 + }
591 +
592 + bcm2835_sdhost_write(host, SDHSTS_TRANSFER_ERROR_MASK,
593 + SDHSTS);
594 +
595 + host->data->error = -ETIMEDOUT;
596 +
597 + bcm2835_sdhost_finish_data(host);
598 + }
599 +
600 + mmiowb();
601 + spin_unlock_irqrestore(&host->lock, flags);
602 +}
603 +
604 static void bcm2835_sdhost_enable_sdio_irq_nolock(struct bcm2835_host *host, int enable)
605 {
606 if (enable)
607 @@ -979,7 +1089,7 @@ static void bcm2835_sdhost_enable_sdio_i
608 struct bcm2835_host *host = mmc_priv(mmc);
609 unsigned long flags;
610
611 - pr_debug("bcm2835_sdhost_enable_sdio_irq(%d)\n", enable);
612 + pr_debug("%s: enable_sdio_irq(%d)\n", mmc_hostname(mmc), enable);
613 spin_lock_irqsave(&host->lock, flags);
614 bcm2835_sdhost_enable_sdio_irq_nolock(host, enable);
615 spin_unlock_irqrestore(&host->lock, flags);
616 @@ -987,11 +1097,12 @@ static void bcm2835_sdhost_enable_sdio_i
617
618 static u32 bcm2835_sdhost_busy_irq(struct bcm2835_host *host, u32 intmask)
619 {
620 - const u32 handled = (SDHSTS_CMD_TIME_OUT | SDHSTS_CRC16_ERROR |
621 - SDHSTS_CRC7_ERROR | SDHSTS_FIFO_ERROR);
622 + const u32 handled = (SDHSTS_REW_TIME_OUT | SDHSTS_CMD_TIME_OUT |
623 + SDHSTS_CRC16_ERROR | SDHSTS_CRC7_ERROR |
624 + SDHSTS_FIFO_ERROR);
625
626 if (!host->cmd) {
627 - pr_err("%s: Got command busy interrupt 0x%08x even "
628 + pr_err("%s: got command busy interrupt 0x%08x even "
629 "though no command operation was in progress.\n",
630 mmc_hostname(host->mmc), (unsigned)intmask);
631 bcm2835_sdhost_dumpregs(host);
632 @@ -999,7 +1110,7 @@ static u32 bcm2835_sdhost_busy_irq(struc
633 }
634
635 if (!host->use_busy) {
636 - pr_err("%s: Got command busy interrupt 0x%08x even "
637 + pr_err("%s: got command busy interrupt 0x%08x even "
638 "though not expecting one.\n",
639 mmc_hostname(host->mmc), (unsigned)intmask);
640 bcm2835_sdhost_dumpregs(host);
641 @@ -1007,14 +1118,28 @@ static u32 bcm2835_sdhost_busy_irq(struc
642 }
643 host->use_busy = 0;
644
645 - if (intmask & SDHSTS_CMD_TIME_OUT)
646 - host->cmd->error = -ETIMEDOUT;
647 - else if (intmask & (SDHSTS_CRC16_ERROR | SDHSTS_CRC7_ERROR |
648 - SDHSTS_FIFO_ERROR))
649 - host->cmd->error = -EILSEQ;
650 + if (intmask & SDHSTS_ERROR_MASK)
651 + {
652 + pr_err("sdhost_busy_irq: intmask %x, data %p\n", intmask, host->mrq->data);
653 + if (intmask & SDHSTS_CRC7_ERROR)
654 + host->cmd->error = -EILSEQ;
655 + else if (intmask & (SDHSTS_CRC16_ERROR |
656 + SDHSTS_FIFO_ERROR)) {
657 + if (host->mrq->data)
658 + host->mrq->data->error = -EILSEQ;
659 + else
660 + host->cmd->error = -EILSEQ;
661 + } else if (intmask & SDHSTS_REW_TIME_OUT) {
662 + if (host->mrq->data)
663 + host->mrq->data->error = -ETIMEDOUT;
664 + else
665 + host->cmd->error = -ETIMEDOUT;
666 + } else if (intmask & SDHSTS_CMD_TIME_OUT)
667 + host->cmd->error = -ETIMEDOUT;
668
669 - if (host->cmd->error)
670 + bcm2835_sdhost_dumpregs(host);
671 tasklet_schedule(&host->finish_tasklet);
672 + }
673 else
674 bcm2835_sdhost_finish_command(host);
675
676 @@ -1023,8 +1148,9 @@ static u32 bcm2835_sdhost_busy_irq(struc
677
678 static u32 bcm2835_sdhost_data_irq(struct bcm2835_host *host, u32 intmask)
679 {
680 - const u32 handled = (SDHSTS_CMD_TIME_OUT | SDHSTS_CRC16_ERROR |
681 - SDHSTS_CRC7_ERROR | SDHSTS_FIFO_ERROR);
682 + const u32 handled = (SDHSTS_REW_TIME_OUT |
683 + SDHSTS_CRC16_ERROR |
684 + SDHSTS_FIFO_ERROR);
685
686 /* There are no dedicated data/space available interrupt
687 status bits, so it is necessary to use the single shared
688 @@ -1034,13 +1160,19 @@ static u32 bcm2835_sdhost_data_irq(struc
689 if (!host->data)
690 return 0;
691
692 - // XXX FIFO_ERROR
693 - if (intmask & SDHSTS_CMD_TIME_OUT)
694 - host->cmd->error = -ETIMEDOUT;
695 - else if ((intmask & (SDHSTS_CRC16_ERROR | SDHSTS_CRC7_ERROR)) &&
696 - ((bcm2835_sdhost_read(host, SDCMD) & SDCMD_CMD_MASK)
697 - != MMC_BUS_TEST_R))
698 - host->cmd->error = -EILSEQ;
699 + if (intmask & (SDHSTS_CRC16_ERROR |
700 + SDHSTS_FIFO_ERROR |
701 + SDHSTS_REW_TIME_OUT)) {
702 + if (intmask & (SDHSTS_CRC16_ERROR |
703 + SDHSTS_FIFO_ERROR))
704 + host->data->error = -EILSEQ;
705 + else
706 + host->data->error = -ETIMEDOUT;
707 +
708 + bcm2835_sdhost_dumpregs(host);
709 + tasklet_schedule(&host->finish_tasklet);
710 + return handled;
711 + }
712
713 /* Use the block interrupt for writes after the first block */
714 if (host->data->flags & MMC_DATA_WRITE) {
715 @@ -1067,31 +1199,48 @@ static u32 bcm2835_sdhost_block_irq(stru
716 {
717 struct dma_chan *dma_chan;
718 u32 dir_data;
719 - const u32 handled = (SDHSTS_CMD_TIME_OUT | SDHSTS_CRC16_ERROR |
720 - SDHSTS_CRC7_ERROR | SDHSTS_FIFO_ERROR);
721 + const u32 handled = (SDHSTS_REW_TIME_OUT |
722 + SDHSTS_CRC16_ERROR |
723 + SDHSTS_FIFO_ERROR);
724
725 if (!host->data) {
726 - pr_err("%s: Got block interrupt 0x%08x even "
727 + pr_err("%s: got block interrupt 0x%08x even "
728 "though no data operation was in progress.\n",
729 mmc_hostname(host->mmc), (unsigned)intmask);
730 bcm2835_sdhost_dumpregs(host);
731 return handled;
732 }
733
734 - if (intmask & SDHSTS_CMD_TIME_OUT)
735 - host->cmd->error = -ETIMEDOUT;
736 - else if ((intmask & (SDHSTS_CRC16_ERROR | SDHSTS_CRC7_ERROR)) &&
737 - ((bcm2835_sdhost_read(host, SDCMD) & SDCMD_CMD_MASK)
738 - != MMC_BUS_TEST_R))
739 - host->cmd->error = -EILSEQ;
740 + if (intmask & (SDHSTS_CRC16_ERROR |
741 + SDHSTS_FIFO_ERROR |
742 + SDHSTS_REW_TIME_OUT)) {
743 + if (intmask & (SDHSTS_CRC16_ERROR |
744 + SDHSTS_FIFO_ERROR))
745 + host->data->error = -EILSEQ;
746 + else
747 + host->data->error = -ETIMEDOUT;
748 +
749 + if (host->debug)
750 + bcm2835_sdhost_dumpregs(host);
751 + tasklet_schedule(&host->finish_tasklet);
752 + return handled;
753 + }
754
755 if (!host->use_dma) {
756 BUG_ON(!host->blocks);
757 host->blocks--;
758 - if ((host->blocks == 0) || host->data->error)
759 + if ((host->blocks == 0) || host->data->error) {
760 + /* Cancel the timer */
761 + del_timer(&host->pio_timer);
762 +
763 bcm2835_sdhost_finish_data(host);
764 - else
765 + } else {
766 bcm2835_sdhost_transfer_pio(host);
767 +
768 + /* Reset the timer */
769 + mod_timer(&host->pio_timer,
770 + jiffies + host->pio_timeout);
771 + }
772 } else if (host->data->flags & MMC_DATA_WRITE) {
773 dma_chan = host->dma_chan_tx;
774 dir_data = DMA_TO_DEVICE;
775 @@ -1125,7 +1274,7 @@ static irqreturn_t bcm2835_sdhost_irq(in
776 SDHSTS_BLOCK_IRPT |
777 SDHSTS_SDIO_IRPT |
778 SDHSTS_DATA_FLAG);
779 - if ((handled == SDHSTS_DATA_FLAG) && // XXX
780 + if ((handled == SDHSTS_DATA_FLAG) &&
781 (loops == 0) && !host->data) {
782 pr_err("%s: sdhost_irq data interrupt 0x%08x even "
783 "though no data operation was in progress.\n",
784 @@ -1177,10 +1326,11 @@ static irqreturn_t bcm2835_sdhost_irq(in
785 spin_unlock(&host->lock);
786
787 if (early)
788 - pr_debug("%s: early %x (loops %d)\n", mmc_hostname(host->mmc), early, loops);
789 + pr_debug("%s: early %x (loops %d)\n",
790 + mmc_hostname(host->mmc), early, loops);
791
792 if (unexpected) {
793 - pr_err("%s: Unexpected interrupt 0x%08x.\n",
794 + pr_err("%s: unexpected interrupt 0x%08x.\n",
795 mmc_hostname(host->mmc), unexpected);
796 bcm2835_sdhost_dumpregs(host);
797 }
798 @@ -1227,8 +1377,22 @@ void bcm2835_sdhost_set_clock(struct bcm
799 int div = 0; /* Initialized for compiler warning */
800 unsigned int input_clock = clock;
801
802 - if (host->overclock_50 && (clock == 50000000))
803 - clock = host->overclock_50 * 1000000 + 999999;
804 + if (host->debug)
805 + pr_info("%s: set_clock(%d)\n", mmc_hostname(host->mmc), clock);
806 +
807 + if ((clock == 0) && host->reduce_overclock) {
808 + /* This is a reset following data corruption - reduce any
809 + overclock */
810 + host->reduce_overclock = 0;
811 + if (host->overclock_50 > 50) {
812 + pr_warn("%s: reducing overclock due to errors\n",
813 + mmc_hostname(host->mmc));
814 + host->overclock_50--;
815 + }
816 + }
817 +
818 + if (host->overclock_50 && (clock == 50*MHZ))
819 + clock = host->overclock_50 * MHZ + (MHZ - 1);
820
821 /* The SDCDIV register has 11 bits, and holds (div - 2).
822 But in data mode the max is 50MHz wihout a minimum, and only the
823 @@ -1275,17 +1439,34 @@ void bcm2835_sdhost_set_clock(struct bcm
824 clock = host->max_clk / (div + 2);
825 host->mmc->actual_clock = clock;
826
827 - if ((clock > input_clock) && (clock > host->max_overclock)) {
828 - pr_warn("%s: Overclocking to %dHz\n",
829 - mmc_hostname(host->mmc), clock);
830 - host->max_overclock = clock;
831 + if (clock > input_clock) {
832 + /* Save the closest value, to make it easier
833 + to reduce in the event of error */
834 + host->overclock_50 = (clock/MHZ);
835 +
836 + if (clock != host->overclock) {
837 + pr_warn("%s: overclocking to %dHz\n",
838 + mmc_hostname(host->mmc), clock);
839 + host->overclock = clock;
840 + }
841 + }
842 + else if ((clock == 50 * MHZ) && host->overclock)
843 + {
844 + pr_warn("%s: cancelling overclock\n",
845 + mmc_hostname(host->mmc));
846 + host->overclock = 0;
847 }
848
849 host->cdiv = div;
850 bcm2835_sdhost_write(host, host->cdiv, SDCDIV);
851
852 - pr_debug(DRIVER_NAME ": clock=%d -> max_clk=%d, cdiv=%x (actual clock %d)\n",
853 - input_clock, host->max_clk, host->cdiv, host->mmc->actual_clock);
854 + /* Set the timeout to 500ms */
855 + bcm2835_sdhost_write(host, host->mmc->actual_clock/2, SDTOUT);
856 +
857 + if (host->debug)
858 + pr_info("%s: clock=%d -> max_clk=%d, cdiv=%x (actual clock %d)\n",
859 + mmc_hostname(host->mmc), input_clock,
860 + host->max_clk, host->cdiv, host->mmc->actual_clock);
861 }
862
863 static void bcm2835_sdhost_request(struct mmc_host *mmc, struct mmc_request *mrq)
864 @@ -1293,29 +1474,32 @@ static void bcm2835_sdhost_request(struc
865 struct bcm2835_host *host;
866 unsigned long flags;
867
868 - if (1) {
869 + host = mmc_priv(mmc);
870 +
871 + if (host->debug) {
872 struct mmc_command *cmd = mrq->cmd;
873 - const char *src = "cmd";
874 BUG_ON(!cmd);
875 - pr_debug("bcm2835_sdhost_request: %s %08x %08x (flags %x)\n",
876 - src, cmd->opcode, cmd->arg, cmd->flags);
877 if (cmd->data)
878 - pr_debug("bcm2835_sdhost_request: %s %d*%d\n",
879 - (cmd->data->flags & MMC_DATA_READ) ?
880 - "read" : "write", cmd->data->blocks,
881 - cmd->data->blksz);
882 + pr_info("%s: cmd %d 0x%x (flags 0x%x) - %s %d*%d\n",
883 + mmc_hostname(mmc),
884 + cmd->opcode, cmd->arg, cmd->flags,
885 + (cmd->data->flags & MMC_DATA_READ) ?
886 + "read" : "write", cmd->data->blocks,
887 + cmd->data->blksz);
888 + else
889 + pr_info("%s: cmd %d 0x%x (flags 0x%x)\n",
890 + mmc_hostname(mmc),
891 + cmd->opcode, cmd->arg, cmd->flags);
892 }
893
894 if (mrq->data && !is_power_of_2(mrq->data->blksz)) {
895 - pr_err("%s: Unsupported block size (%d bytes)\n",
896 + pr_err("%s: unsupported block size (%d bytes)\n",
897 mmc_hostname(mmc), mrq->data->blksz);
898 mrq->cmd->error = -EINVAL;
899 mmc_request_done(mmc, mrq);
900 return;
901 }
902
903 - host = mmc_priv(mmc);
904 -
905 spin_lock_irqsave(&host->lock, flags);
906
907 WARN_ON(host->mrq != NULL);
908 @@ -1345,9 +1529,12 @@ static void bcm2835_sdhost_set_ios(struc
909 struct bcm2835_host *host = mmc_priv(mmc);
910 unsigned long flags;
911
912 - pr_debug("bcm2835_sdhost_set_ios: clock %d, pwr %d, bus_width %d, timing %d, vdd %d, drv_type %d\n",
913 - ios->clock, ios->power_mode, ios->bus_width,
914 - ios->timing, ios->signal_voltage, ios->drv_type);
915 + if (host->debug)
916 + pr_info("%s: ios clock %d, pwr %d, bus_width %d, "
917 + "timing %d, vdd %d, drv_type %d\n",
918 + mmc_hostname(mmc),
919 + ios->clock, ios->power_mode, ios->bus_width,
920 + ios->timing, ios->signal_voltage, ios->drv_type);
921
922 spin_lock_irqsave(&host->lock, flags);
923
924 @@ -1396,6 +1583,7 @@ static struct mmc_host_ops bcm2835_sdhos
925 .request = bcm2835_sdhost_request,
926 .set_ios = bcm2835_sdhost_set_ios,
927 .enable_sdio_irq = bcm2835_sdhost_enable_sdio_irq,
928 + .hw_reset = bcm2835_sdhost_reset,
929 .multi_io_quirk = bcm2835_sdhost_multi_io_quirk,
930 };
931
932 @@ -1423,15 +1611,24 @@ static void bcm2835_sdhost_tasklet_finis
933
934 mrq = host->mrq;
935
936 - /*
937 - * The controller needs a reset of internal state machines
938 - * upon error conditions.
939 - */
940 - if (((mrq->cmd && mrq->cmd->error) ||
941 - (mrq->data && (mrq->data->error ||
942 - (mrq->data->stop && mrq->data->stop->error))))) {
943 + /* Drop the overclock after any data corruption, or after any
944 + error overclocked */
945 + if (mrq->data && (mrq->data->error == -EILSEQ))
946 + host->reduce_overclock = 1;
947 + else if (host->overclock) {
948 + /* Convert timeout errors while overclocked to data errors,
949 + because the system recovers better. */
950 + if (mrq->cmd && mrq->cmd->error) {
951 + host->reduce_overclock = 1;
952 + if (mrq->cmd->error == -ETIMEDOUT)
953 + mrq->cmd->error = -EILSEQ;
954 + }
955
956 - bcm2835_sdhost_reset(host);
957 + if (mrq->data && mrq->data->error) {
958 + host->reduce_overclock = 1;
959 + if (mrq->data->error == -ETIMEDOUT)
960 + mrq->data->error = -EILSEQ;
961 + }
962 }
963
964 host->mrq = NULL;
965 @@ -1450,35 +1647,37 @@ int bcm2835_sdhost_add_host(struct bcm28
966 {
967 struct mmc_host *mmc;
968 struct dma_slave_config cfg;
969 + char pio_limit_string[20];
970 int ret;
971
972 mmc = host->mmc;
973
974 - bcm2835_sdhost_reset(host);
975 + bcm2835_sdhost_reset_internal(host);
976
977 mmc->f_max = host->max_clk;
978 mmc->f_min = host->max_clk / SDCDIV_MAX_CDIV;
979
980 - /* SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK */
981 - host->timeout_clk = mmc->f_max / 1000;
982 -#ifdef CONFIG_ARCH_BCM2835
983 - mmc->max_busy_timeout = (1 << 27) / host->timeout_clk;
984 -#endif
985 + mmc->max_busy_timeout = (~(unsigned int)0)/(mmc->f_max/1000);
986 +
987 + pr_debug("f_max %d, f_min %d, max_busy_timeout %d\n",
988 + mmc->f_max, mmc->f_min, mmc->max_busy_timeout);
989 +
990 /* host controller capabilities */
991 mmc->caps |= /* MMC_CAP_SDIO_IRQ |*/ MMC_CAP_4_BIT_DATA |
992 MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED |
993 - MMC_CAP_NEEDS_POLL |
994 + MMC_CAP_NEEDS_POLL | MMC_CAP_HW_RESET |
995 (ALLOW_CMD23 * MMC_CAP_CMD23);
996
997 spin_lock_init(&host->lock);
998
999 if (host->allow_dma) {
1000 - if (!host->dma_chan_tx || !host->dma_chan_rx ||
1001 - IS_ERR(host->dma_chan_tx) || IS_ERR(host->dma_chan_rx)) {
1002 - pr_err("%s: Unable to initialise DMA channels. Falling back to PIO\n", DRIVER_NAME);
1003 + if (IS_ERR_OR_NULL(host->dma_chan_tx) ||
1004 + IS_ERR_OR_NULL(host->dma_chan_rx)) {
1005 + pr_err("%s: unable to initialise DMA channels. "
1006 + "Falling back to PIO\n",
1007 + mmc_hostname(mmc));
1008 host->have_dma = false;
1009 } else {
1010 - pr_info("DMA channels allocated for the SDHost driver");
1011 host->have_dma = true;
1012
1013 cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
1014 @@ -1496,7 +1695,6 @@ int bcm2835_sdhost_add_host(struct bcm28
1015 ret = dmaengine_slave_config(host->dma_chan_rx, &cfg);
1016 }
1017 } else {
1018 - pr_info("Forcing PIO mode\n");
1019 host->have_dma = false;
1020 }
1021
1022 @@ -1512,18 +1710,23 @@ int bcm2835_sdhost_add_host(struct bcm28
1023 tasklet_init(&host->finish_tasklet,
1024 bcm2835_sdhost_tasklet_finish, (unsigned long)host);
1025
1026 - setup_timer(&host->timer, bcm2835_sdhost_timeout_timer, (unsigned long)host);
1027 + setup_timer(&host->timer, bcm2835_sdhost_timeout,
1028 + (unsigned long)host);
1029 +
1030 + setup_timer(&host->pio_timer, bcm2835_sdhost_pio_timeout,
1031 + (unsigned long)host);
1032
1033 bcm2835_sdhost_init(host, 0);
1034 #ifndef CONFIG_ARCH_BCM2835
1035 ret = request_irq(host->irq, bcm2835_sdhost_irq, 0 /*IRQF_SHARED*/,
1036 mmc_hostname(mmc), host);
1037 #else
1038 - ret = request_threaded_irq(host->irq, bcm2835_sdhost_irq, bcm2835_sdhost_thread_irq,
1039 + ret = request_threaded_irq(host->irq, bcm2835_sdhost_irq,
1040 + bcm2835_sdhost_thread_irq,
1041 IRQF_SHARED, mmc_hostname(mmc), host);
1042 #endif
1043 if (ret) {
1044 - pr_err("%s: Failed to request IRQ %d: %d\n",
1045 + pr_err("%s: failed to request IRQ %d: %d\n",
1046 mmc_hostname(mmc), host->irq, ret);
1047 goto untasklet;
1048 }
1049 @@ -1531,10 +1734,13 @@ int bcm2835_sdhost_add_host(struct bcm28
1050 mmiowb();
1051 mmc_add_host(mmc);
1052
1053 - pr_info("Load BCM2835 SDHost driver\n");
1054 - if (host->delay_after_stop)
1055 - pr_info("BCM2835 SDHost: delay_after_stop=%dus\n",
1056 - host->delay_after_stop);
1057 + pio_limit_string[0] = '\0';
1058 + if (host->have_dma && (host->pio_limit > 0))
1059 + sprintf(pio_limit_string, " (>%d)", host->pio_limit);
1060 + pr_info("%s: %s loaded - DMA %s%s\n",
1061 + mmc_hostname(mmc), DRIVER_NAME,
1062 + host->have_dma ? "enabled" : "disabled",
1063 + pio_limit_string);
1064
1065 return 0;
1066
1067 @@ -1562,7 +1768,7 @@ static int bcm2835_sdhost_probe(struct p
1068 mmc->ops = &bcm2835_sdhost_ops;
1069 host = mmc_priv(mmc);
1070 host->mmc = mmc;
1071 - host->timeout = msecs_to_jiffies(1000);
1072 + host->pio_timeout = msecs_to_jiffies(500);
1073 spin_lock_init(&host->lock);
1074
1075 iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1076 @@ -1588,8 +1794,12 @@ static int bcm2835_sdhost_probe(struct p
1077 of_property_read_u32(node,
1078 "brcm,overclock-50",
1079 &host->overclock_50);
1080 + of_property_read_u32(node,
1081 + "brcm,pio-limit",
1082 + &host->pio_limit);
1083 host->allow_dma = ALLOW_DMA &&
1084 !of_property_read_bool(node, "brcm,force-pio");
1085 + host->debug = of_property_read_bool(node, "brcm,debug");
1086 }
1087
1088 if (host->allow_dma) {