public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH/RFC] drivers/mmc/mmc.c: change the controller frequency before the card frequency
@ 2009-08-19 12:16 Albin Tonnerre
  2009-08-19 23:42 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 3+ messages in thread
From: Albin Tonnerre @ 2009-08-19 12:16 UTC (permalink / raw)
  To: u-boot

While rewriting the atmel_mci driver to use the new MMC_GENERIC API (and allow
the use of SD/MMC on AT91 in the process), it appeared that switching the card
frequency before the controller frequency resulted in the answer from the card
never being received. Changing the controller frequency before the controller
frequency fixes that.

Signed-off-by: Albin Tonnerre <albin.tonnerre@free-electrons.com>
---
I'm sending this as an RFC, as I only own AT91-based boards. Therefore, I don't
know whether doing so breaks the code for other cards or not. Andy, do you see
any obvious problem with such a change ? Haavard: I did not find evidence of
such a requirement in the AT91SAM9G20 datasheet, is it known behaviour, or do
you think I'm doing something wrong that might cause this ?

 drivers/mmc/mmc.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index b69ce15..6ff3624 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -717,14 +717,6 @@ int mmc_startup(struct mmc *mmc)
 	if (err)
 		return err;
 
-	if (IS_SD(mmc))
-		err = sd_change_freq(mmc);
-	else
-		err = mmc_change_freq(mmc);
-
-	if (err)
-		return err;
-
 	/* Restrict card's capabilities by what the host can do */
 	mmc->card_caps &= mmc->host_caps;
 
@@ -786,6 +778,14 @@ int mmc_startup(struct mmc *mmc)
 			mmc_set_clock(mmc, 20000000);
 	}
 
+	if (IS_SD(mmc))
+		err = sd_change_freq(mmc);
+	else
+		err = mmc_change_freq(mmc);
+
+	if (err)
+		return err;
+
 	/* fill in device description */
 	mmc->block_dev.lun = 0;
 	mmc->block_dev.type = 0;
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-08-20 11:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-19 12:16 [U-Boot] [PATCH/RFC] drivers/mmc/mmc.c: change the controller frequency before the card frequency Albin Tonnerre
2009-08-19 23:42 ` Jean-Christophe PLAGNIOL-VILLARD
2009-08-20 11:50   ` Albin Tonnerre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox