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

* [U-Boot] [PATCH/RFC] drivers/mmc/mmc.c: change the controller frequency before the card frequency
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-08-19 23:42 UTC (permalink / raw)
  To: u-boot

On 14:16 Wed 19 Aug     , Albin Tonnerre wrote:
> 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.
IIRC it's not correct you are supposed to switch the card to higherfreq and
then the bus speed

could show the patch of the atmel_mci to help

Best Regards,
J.

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

* [U-Boot] [PATCH/RFC] drivers/mmc/mmc.c: change the controller frequency before the card frequency
  2009-08-19 23:42 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-08-20 11:50   ` Albin Tonnerre
  0 siblings, 0 replies; 3+ messages in thread
From: Albin Tonnerre @ 2009-08-20 11:50 UTC (permalink / raw)
  To: u-boot

On Thu, Aug 20, 2009 at 01:42:04AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote :
> On 14:16 Wed 19 Aug     , Albin Tonnerre wrote:
> > 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.
> IIRC it's not correct you are supposed to switch the card to higherfreq and
> then the bus speed

This was an error on my side, sorry for the noise.

> could show the patch of the atmel_mci to help

It's not complete yet, but I'll be sure to post it for comments as soon as i'm
done.

> Best Regards,
> J.

Regards,
-- 
Albin Tonnerre, Free Electrons
Kernel, drivers and embedded Linux development,
consulting, training and support.
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: Digital signature
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090820/8522f424/attachment.pgp 

^ permalink raw reply	[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