diff options
author | Tony Lindgren <tony@atomide.com> | 2007-05-01 16:36:00 +0200 |
---|---|---|
committer | Pierre Ossman <drzeus@drzeus.cx> | 2007-05-01 16:36:00 +0200 |
commit | d3af5abe9a809becbe4b413144b607844560d445 (patch) | |
tree | 12c22ab6a438fa9eb7c51b06adcb67583ff1186b /drivers/mmc | |
parent | 46a6730e3ff9add5089ddd007f998b97fb4e8571 (diff) | |
download | linux-d3af5abe9a809becbe4b413144b607844560d445.tar.bz2 |
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>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/omap.c | 47 |
1 files changed, 26 insertions, 21 deletions
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c index fc044a5ed64e..1914e65d4db1 100644 --- a/drivers/mmc/host/omap.c +++ b/drivers/mmc/host/omap.c @@ -936,33 +936,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: @@ -977,9 +985,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 |