Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 164745
b: refs/heads/master
c: ad1e597
h: refs/heads/master
i:
  164743: 39a3ecf
v: v3
  • Loading branch information
Anton Vorontsov authored and Linus Torvalds committed Sep 23, 2009
1 parent f8078d6 commit 3bb2cc7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8226a219254bbcd20492df185f191a11a7a81dcd
refs/heads/master: ad1e597d4199ffcdee04b9fb402e45c5be6a5052
19 changes: 8 additions & 11 deletions trunk/drivers/mmc/host/sdhci-of.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,23 @@ static void esdhc_writeb(struct sdhci_host *host, u8 val, int reg)

static void esdhc_set_clock(struct sdhci_host *host, unsigned int clock)
{
int div;
int pre_div = 2;
int div = 1;

clrbits32(host->ioaddr + ESDHC_SYSTEM_CONTROL, ESDHC_CLOCK_IPGEN |
ESDHC_CLOCK_HCKEN | ESDHC_CLOCK_PEREN | ESDHC_CLOCK_MASK);

if (clock == 0)
goto out;

if (host->max_clk / 16 > clock) {
for (; pre_div < 256; pre_div *= 2) {
if (host->max_clk / pre_div < clock * 16)
break;
}
}
while (host->max_clk / pre_div / 16 > clock && pre_div < 256)
pre_div *= 2;

for (div = 1; div <= 16; div++) {
if (host->max_clk / (div * pre_div) <= clock)
break;
}
while (host->max_clk / pre_div / div > clock && div < 16)
div++;

dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n",
clock, host->max_clk / pre_div / div);

pre_div >>= 1;
div--;
Expand Down

0 comments on commit 3bb2cc7

Please sign in to comment.