aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core/sd.c
diff options
context:
space:
mode:
authorAndy Ross <andy.ross@windriver.com>2011-01-03 13:36:56 -0500
committerChris Ball <cjb@laptop.org>2011-01-08 23:52:25 -0500
commit807e8e40673d9628fa7dcdd14423424b4ee5f43b (patch)
treeca95bdb69d07f0169bbfc5388e15745b9811513e /drivers/mmc/core/sd.c
parent08c82dfad2458f8f9b83126224a85e7ea9e2b046 (diff)
mmc: Fix sd/sdio/mmc initialization frequency retries
Rewrite and clean up mmc_rescan() to properly retry frequencies lower than 400kHz. Failures can happen both in sd_send_* calls and mmc_attach_*. Break out "mmc_rescan_try_freq" from the frequency selection loop. Symmetrize claim/release logic in mmc_attach_* API, and move the sd_send_* calls there to make mmc_rescan easier to read. Signed-off-by: Andy Ross <andy.ross@windriver.com> Reviewed-and-Tested-by: Hein Tibosch <hein_tibosch@yahoo.es> Reviewed-by: Chris Ball <cjb@laptop.org> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc/core/sd.c')
-rw-r--r--drivers/mmc/core/sd.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index de062ebd8b26..d18c32bca99b 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -764,13 +764,18 @@ static void mmc_sd_attach_bus_ops(struct mmc_host *host)
764/* 764/*
765 * Starting point for SD card init. 765 * Starting point for SD card init.
766 */ 766 */
767int mmc_attach_sd(struct mmc_host *host, u32 ocr) 767int mmc_attach_sd(struct mmc_host *host)
768{ 768{
769 int err; 769 int err;
770 u32 ocr;
770 771
771 BUG_ON(!host); 772 BUG_ON(!host);
772 WARN_ON(!host->claimed); 773 WARN_ON(!host->claimed);
773 774
775 err = mmc_send_app_op_cond(host, 0, &ocr);
776 if (err)
777 return err;
778
774 mmc_sd_attach_bus_ops(host); 779 mmc_sd_attach_bus_ops(host);
775 if (host->ocr_avail_sd) 780 if (host->ocr_avail_sd)
776 host->ocr_avail = host->ocr_avail_sd; 781 host->ocr_avail = host->ocr_avail_sd;
@@ -823,20 +828,20 @@ int mmc_attach_sd(struct mmc_host *host, u32 ocr)
823 goto err; 828 goto err;
824 829
825 mmc_release_host(host); 830 mmc_release_host(host);
826
827 err = mmc_add_card(host->card); 831 err = mmc_add_card(host->card);
832 mmc_claim_host(host);
828 if (err) 833 if (err)
829 goto remove_card; 834 goto remove_card;
830 835
831 return 0; 836 return 0;
832 837
833remove_card: 838remove_card:
839 mmc_release_host(host);
834 mmc_remove_card(host->card); 840 mmc_remove_card(host->card);
835 host->card = NULL; 841 host->card = NULL;
836 mmc_claim_host(host); 842 mmc_claim_host(host);
837err: 843err:
838 mmc_detach_bus(host); 844 mmc_detach_bus(host);
839 mmc_release_host(host);
840 845
841 printk(KERN_ERR "%s: error %d whilst initialising SD card\n", 846 printk(KERN_ERR "%s: error %d whilst initialising SD card\n",
842 mmc_hostname(host), err); 847 mmc_hostname(host), err);