All of lore.kernel.org
 help / color / mirror / Atom feed
From: tony@atomide.com
To: "Woodruff, Richard" <r-woodruff2@ti.com>
Cc: linux-omap-open-source@linux.omap.com
Subject: Re: [PATCH] - Fix MMC -- was  H4 boot with latest git kernel
Date: Sat, 10 Feb 2007 11:08:45 -0800	[thread overview]
Message-ID: <20070210190845.GA19642@atomide.com> (raw)
In-Reply-To: <20070210174121.GA5291@atomide.com>

[-- Attachment #1: Type: text/plain, Size: 1774 bytes --]

* Tony Lindgren <tony@atomide.com> [070210 09:42]:
> * Woodruff, Richard <r-woodruff2@ti.com> [070209 13:48]:
> > Hi,
> > 
> > So took a quick look with the emulator and see its hanging in MMC.  I'm
> > not an MMC expert but I don't see how you can send an init-stream
> > command with no clocks running and if you did it looks like it should be
> > 80clocks over 1ms.
> > 
> > The note in the upper layer in mmc.c says you power it first, then send
> > clocks out.  mmc.c calls MMC_POWER_UP twice.  The first time with
> > ios->clock = 0 and a second time with iso->clock=f_min.  To me that just
> > says set the power bit in the first pass and set the initstream command
> > in the second pass.
> > 
> > The below patch seems to work fine and would appear to be a long
> > standing bug.
> > 
> > Signed-off-by: Richard Woodruff <r-woodruff2.com>
> > 
> > diff --git a/drivers/mmc/omap.c b/drivers/mmc/omap.c
> > index 796172a..55075cc 100644
> > --- a/drivers/mmc/omap.c
> > +++ b/drivers/mmc/omap.c
> > @@ -990,7 +990,7 @@ static void mmc_omap_set_ios(struct mmc_
> >  	 * Writing to the CON register twice seems to do the trick. */
> >  	for (i = 0; i < 2; i++)
> >  		OMAP_MMC_WRITE(host, CON, dsor);
> > -	if (ios->power_mode == MMC_POWER_UP) {
> > +	if ((ios->power_mode == MMC_POWER_UP) && ios->clock) {
> >  		/* Send clock cycles, poll completion */
> >  		OMAP_MMC_WRITE(host, IE, 0);
> >  		OMAP_MMC_WRITE(host, STAT, 0xffff);
> > 
> 
> Thanks. Looks like we're still doing the MMC powerup wrong for omap
> though. I made a patch for that a while back but it got forgotten
> for some reason:
> 
> http://lkml.org/lkml/2006/5/4/44
> 
> I'll refresh that patch so we can make sure it works on all platforms.

Here are the refreshed patches to try.

Regards,

Tony

[-- Attachment #2: 0001-MMC-Fix-omap-to-use-MMC_POWER_ON.txt --]
[-- Type: text/plain, Size: 1280 bytes --]

>From fa6a7886da554980d7a250fc7232b8ed40168baf Mon Sep 17 00:00:00 2001
From: Tony Lindgren <tony@atomide.com>
Date: Sat, 10 Feb 2007 10:35:03 -0800
Subject: MMC: OMAP: Fix omap to use MMC_POWER_ON

As discussed earlier on LKML:

http://lkml.org/lkml/2006/5/4/44

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/mmc/omap.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/omap.c b/drivers/mmc/omap.c
index 796172a..7cc8972 100644
--- a/drivers/mmc/omap.c
+++ b/drivers/mmc/omap.c
@@ -973,8 +973,10 @@ static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		mmc_omap_power(host, 0);
 		break;
 	case MMC_POWER_UP:
-	case MMC_POWER_ON:
+		/* Cannot touch dsor yet, just power up MMC */
 		mmc_omap_power(host, 1);
+		return;
+	case MMC_POWER_ON:
 		dsor |= 1 << 11;
 		break;
 	}
@@ -990,7 +992,7 @@ static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	 * Writing to the CON register twice seems to do the trick. */
 	for (i = 0; i < 2; i++)
 		OMAP_MMC_WRITE(host, CON, dsor);
-	if (ios->power_mode == MMC_POWER_UP) {
+	if (ios->power_mode == MMC_POWER_ON) {
 		/* Send clock cycles, poll completion */
 		OMAP_MMC_WRITE(host, IE, 0);
 		OMAP_MMC_WRITE(host, STAT, 0xffff);
-- 
1.4.4.2


[-- Attachment #3: 0002-MMC-Clean-up-omap-set_ios.txt --]
[-- Type: text/plain, Size: 2224 bytes --]

>From 6e580793454d53e012e53581991dc54375c54143 Mon Sep 17 00:00:00 2001
From: Tony Lindgren <tony@atomide.com>
Date: Sat, 10 Feb 2007 10:40:31 -0800
Subject: MMC: OMAP: Clean up omap set_ios and make MMC_POWER_ON work

Move divisor calculation into a separate function and
re-arrange the init order to make MMC_POWER_ON work.

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/mmc/omap.c |   47 ++++++++++++++++++++++++++---------------------
 1 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/drivers/mmc/omap.c b/drivers/mmc/omap.c
index 7cc8972..2ae4c1b 100644
--- a/drivers/mmc/omap.c
+++ b/drivers/mmc/omap.c
@@ -940,33 +940,41 @@ static void mmc_omap_power(struct mmc_omap_host *host, int on)
 	}
 }
 
-static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
+static int mmc_omap_calc_divisor(struct mmc_host *mmc, struct mmc_ios *ios)
 {
 	struct mmc_omap_host *host = mmc_priv(mmc);
+	int func_clk_rate = clk_get_rate(host->fclk);
 	int dsor;
-	int realclock, i;
-
-	realclock = ios->clock;
 
 	if (ios->clock == 0)
-		dsor = 0;
-	else {
-		int func_clk_rate = clk_get_rate(host->fclk);
-
-		dsor = func_clk_rate / realclock;
-		if (dsor < 1)
-			dsor = 1;
+		return 0;
 
-		if (func_clk_rate / dsor > realclock)
-			dsor++;
+	dsor = func_clk_rate / ios->clock;
+	if (dsor < 1)
+		dsor = 1;
 
-		if (dsor > 250)
-			dsor = 250;
+	if (func_clk_rate / dsor > ios->clock)
 		dsor++;
 
-		if (ios->bus_width == MMC_BUS_WIDTH_4)
-			dsor |= 1 << 15;
-	}
+	if (dsor > 250)
+		dsor = 250;
+	dsor++;
+
+	if (ios->bus_width == MMC_BUS_WIDTH_4)
+		dsor |= 1 << 15;
+
+	return dsor;
+}
+
+static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+	struct mmc_omap_host *host = mmc_priv(mmc);
+	int dsor;
+	int i;
+
+	dsor = mmc_omap_calc_divisor(mmc, ios);
+	host->bus_mode = ios->bus_mode;
+	host->hw_bus_mode = host->bus_mode;
 
 	switch (ios->power_mode) {
 	case MMC_POWER_OFF:
@@ -981,9 +989,6 @@ static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		break;
 	}
 
-	host->bus_mode = ios->bus_mode;
-	host->hw_bus_mode = host->bus_mode;
-
 	clk_enable(host->fclk);
 
 	/* On insanely high arm_per frequencies something sometimes
-- 
1.4.4.2


[-- Attachment #4: Type: text/plain, Size: 0 bytes --]



  reply	other threads:[~2007-02-10 19:08 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-09 11:24 H4 boot with latest git kernel Trilok Soni
2007-02-09 16:51 ` Tony Lindgren
2007-02-09 21:47   ` [PATCH] - Fix MMC -- was " Woodruff, Richard
2007-02-10 17:41     ` Tony Lindgren
2007-02-10 19:08       ` tony [this message]
2007-02-19 16:04         ` Woodruff, Richard
2007-02-20  9:23           ` Tony Lindgren
2007-02-26  5:13             ` Kyungmin Park
2007-02-26 15:12             ` Anderson Briglia
2007-02-27 18:45           ` Carlos Aguiar
2007-02-27 18:50             ` Woodruff, Richard
2007-02-27 19:21               ` Anderson Briglia
2007-02-27 19:24                 ` Woodruff, Richard
2007-02-28 15:04                   ` Carlos Aguiar
2007-03-02 12:28                     ` Tony Lindgren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070210190845.GA19642@atomide.com \
    --to=tony@atomide.com \
    --cc=linux-omap-open-source@linux.omap.com \
    --cc=r-woodruff2@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.