| 1 | From 66983857a54479d76ce6dbd8399e1276698bd3c5 Mon Sep 17 00:00:00 2001 |
| 2 | From: San Mehat <san@google.com> |
| 3 | Date: Tue, 11 Nov 2008 09:35:36 -0800 |
| 4 | Subject: [PATCH 094/134] mmc: sd: Add new CONFIG_MMC_PARANOID_SD_INIT for enabling retries during SD detection |
| 5 | |
| 6 | Signed-off-by: San Mehat <san@google.com> |
| 7 | --- |
| 8 | drivers/mmc/core/Kconfig | 8 ++++++++ |
| 9 | drivers/mmc/core/sd.c | 24 ++++++++++++++++++++++-- |
| 10 | 2 files changed, 30 insertions(+), 2 deletions(-) |
| 11 | |
| 12 | --- a/drivers/mmc/core/Kconfig |
| 13 | +++ b/drivers/mmc/core/Kconfig |
| 14 | @@ -14,3 +14,11 @@ config MMC_UNSAFE_RESUME |
| 15 | This option is usually just for embedded systems which use |
| 16 | a MMC/SD card for rootfs. Most people should say N here. |
| 17 | |
| 18 | +config MMC_PARANOID_SD_INIT |
| 19 | + bool "Enable paranoid SD card initialization (EXPERIMENTAL)" |
| 20 | + help |
| 21 | + If you say Y here, the MMC layer will be extra paranoid |
| 22 | + about re-trying SD init requests. This can be a useful |
| 23 | + work-around for buggy controllers and hardware. Enable |
| 24 | + if you are experiencing issues with SD detection. |
| 25 | + |
| 26 | --- a/drivers/mmc/core/sd.c |
| 27 | +++ b/drivers/mmc/core/sd.c |
| 28 | @@ -336,7 +336,9 @@ static int mmc_sd_init_card(struct mmc_h |
| 29 | int err; |
| 30 | u32 cid[4]; |
| 31 | unsigned int max_dtr; |
| 32 | - |
| 33 | +#ifdef CONFIG_MMC_PARANOID_SD_INIT |
| 34 | + int retries; |
| 35 | +#endif |
| 36 | BUG_ON(!host); |
| 37 | WARN_ON(!host->claimed); |
| 38 | |
| 39 | @@ -439,11 +441,29 @@ static int mmc_sd_init_card(struct mmc_h |
| 40 | err = mmc_decode_scr(card); |
| 41 | if (err < 0) |
| 42 | goto free_card; |
| 43 | - |
| 44 | /* |
| 45 | * Fetch switch information from card. |
| 46 | */ |
| 47 | +#ifdef CONFIG_MMC_PARANOID_SD_INIT |
| 48 | + for (retries = 1; retries <= 3; retries++) { |
| 49 | + err = mmc_read_switch(card); |
| 50 | + if (!err) { |
| 51 | + if (retries > 1) { |
| 52 | + printk(KERN_WARNING |
| 53 | + "%s: recovered\n", |
| 54 | + mmc_hostname(host)); |
| 55 | + } |
| 56 | + break; |
| 57 | + } else { |
| 58 | + printk(KERN_WARNING |
| 59 | + "%s: read switch failed (attempt %d)\n", |
| 60 | + mmc_hostname(host), retries); |
| 61 | + } |
| 62 | + } |
| 63 | +#else |
| 64 | err = mmc_read_switch(card); |
| 65 | +#endif |
| 66 | + |
| 67 | if (err) |
| 68 | goto free_card; |
| 69 | } |
| 70 | |