aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/host
diff options
context:
space:
mode:
authorIan Molton <ian@mnementh.co.uk>2009-06-12 16:53:05 -0400
committerPierre Ossman <pierre@ossman.eu>2009-06-13 16:43:00 -0400
commitda46a0bd42c81a473618e94871500fb792c98727 (patch)
tree5c2f750e8cc1e2821bb3c62d6b53cebc3937c6b0 /drivers/mmc/host
parent544f277bb849da0ba86cfc4203a4c9139e2cd927 (diff)
tmio_mmc: fix clock setup
This patch fixes the clock setup in tmio_mmc. * Incorrect divider setting * Cruft written to the clock registers (seemingly harmless but Not Good (tm)) It also eliminates some unnecessary ifs and tidies the loop syntax. Thanks to Philipp Zabel who discovered the divider issue, commenting "Except for the SDCLK = HCLK (divider bypassed) case, the clock setting resulted in double the requested frequency. The smallest possible frequency (f_max/512) is configured with a divider setting 0x80, not 0x40." Signed-off-by: Ian Molton <ian@mnementh.co.uk> Signed-off-by: Pierre Ossman <pierre@ossman.eu>
Diffstat (limited to 'drivers/mmc/host')
-rw-r--r--drivers/mmc/host/tmio_mmc.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c
index fe6d2b6c0161..10951b7131d6 100644
--- a/drivers/mmc/host/tmio_mmc.c
+++ b/drivers/mmc/host/tmio_mmc.c
@@ -37,22 +37,17 @@
37 37
38static void tmio_mmc_set_clock(struct tmio_mmc_host *host, int new_clock) 38static void tmio_mmc_set_clock(struct tmio_mmc_host *host, int new_clock)
39{ 39{
40 u32 clk = 0, clock, f_min = host->mmc->f_min; 40 u32 clk = 0, clock;
41 41
42 if (new_clock) { 42 if (new_clock) {
43 for (clock = f_min, clk = 0x100; new_clock >= (clock<<1); ) { 43 for (clock = host->mmc->f_min, clk = 0x80000080;
44 new_clock >= (clock<<1); clk >>= 1)
44 clock <<= 1; 45 clock <<= 1;
45 clk >>= 1;
46 }
47 if (clk & 0x1)
48 clk = 0x20000;
49
50 clk >>= 2;
51 sd_config_write8(host, CNF_SD_CLK_MODE, (clk & 0x8000) ? 0 : 1);
52 clk |= 0x100; 46 clk |= 0x100;
53 } 47 }
54 48
55 sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, clk); 49 sd_config_write8(host, CNF_SD_CLK_MODE, clk >> 22);
50 sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, clk & 0x1ff);
56} 51}
57 52
58static void tmio_mmc_clk_stop(struct tmio_mmc_host *host) 53static void tmio_mmc_clk_stop(struct tmio_mmc_host *host)