From: Tony Lindgren <tony@atomide.com>
To: linux-kernel@vger.kernel.org,
Pierre Ossman <drzeus-list@drzeus.cx>,
Carlos Aguiar <carlos.aguiar@indt.org.br>,
Juha Yrjola <juha.yrjola@nokia.com>
Subject: Re: MMC: 2/2 Fix MMC_POWER_UP on some OMAP boards
Date: Thu, 4 May 2006 02:31:53 -0700 [thread overview]
Message-ID: <20060504093152.GJ8664@atomide.com> (raw)
In-Reply-To: <20060504075433.GA2839@flint.arm.linux.org.uk>
[-- Attachment #1: Type: text/plain, Size: 561 bytes --]
* Russell King <rmk+lkml@arm.linux.org.uk> [060504 00:54]:
> On Thu, May 04, 2006 at 12:26:30AM -0700, Tony Lindgren wrote:
> > MMC spec says that we must not enable clock prior to the power
> > stabilizing. But at least omap16xx needs clock divisor configured
> > during MMC_POWER_UP.
>
> In which case it's probably better to treat MMC_POWER_UP the same as
> MMC_POWER_OFF and just use MMC_POWER_ON and wait for your host to
> complete it's power stabilisation. No need for this additional
> complexity.
Nice, that makes things cleaner. Here's the patch:
[-- Attachment #2: patch-omap-mmc-powerup --]
[-- Type: text/plain, Size: 2555 bytes --]
Change OMAP MMC to use MMC_POWER_UP to power-up the card,
and set clock divisor with MMC_POWER_ON. Also separate
clock divisor calculation into a separate function.
Signed-off-by: Tony Lindgren <tony@atomide.com>
--- a/drivers/mmc/omap.c
+++ b/drivers/mmc/omap.c
@@ -893,48 +893,56 @@ static void mmc_omap_power(struct mmc_om
}
}
-static void mmc_omap_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
+static inline 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:
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);
- dsor |= 1<<11;
+ return;
+ case MMC_POWER_ON:
+ dsor |= 1 << 11;
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
@@ -943,11 +951,12 @@ 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->base, 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->base, IE, 0);
OMAP_MMC_WRITE(host->base, STAT, 0xffff);
- OMAP_MMC_WRITE(host->base, CMD, 1<<7);
+ OMAP_MMC_WRITE(host->base, CMD, 1 << 7);
while (0 == (OMAP_MMC_READ(host->base, STAT) & 1));
OMAP_MMC_WRITE(host->base, STAT, 1);
}
prev parent reply other threads:[~2006-05-04 9:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-04 7:24 MMC: 1/2 Make OMAP MMC work Tony Lindgren
2006-05-04 7:26 ` MMC: 2/2 Fix MMC_POWER_UP on some OMAP boards Tony Lindgren
2006-05-04 7:54 ` Russell King
2006-05-04 9:31 ` Tony Lindgren [this message]
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=20060504093152.GJ8664@atomide.com \
--to=tony@atomide.com \
--cc=carlos.aguiar@indt.org.br \
--cc=drzeus-list@drzeus.cx \
--cc=juha.yrjola@nokia.com \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome