Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 149456
b: refs/heads/master
c: ae62890
h: refs/heads/master
v: v3
  • Loading branch information
Pierre Ossman committed Jun 13, 2009
1 parent 3018938 commit 82a6fa7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 27 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: 7ceeb6a40a4dcc9b9cded6127ad5cdddb79b40ad
refs/heads/master: ae628903ab6cc9a04fdf8d4ff3f0c5b2ffa6f939
53 changes: 28 additions & 25 deletions trunk/drivers/mmc/host/sdhci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1005,12 +1005,34 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
{
u8 pwr;

if (host->power == power)
if (power == (unsigned short)-1)
pwr = 0;
else {
switch (1 << power) {
case MMC_VDD_165_195:
pwr = SDHCI_POWER_180;
break;
case MMC_VDD_29_30:
case MMC_VDD_30_31:
pwr = SDHCI_POWER_300;
break;
case MMC_VDD_32_33:
case MMC_VDD_33_34:
pwr = SDHCI_POWER_330;
break;
default:
BUG();
}
}

if (host->pwr == pwr)
return;

if (power == (unsigned short)-1) {
host->pwr = pwr;

if (pwr == 0) {
sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);
goto out;
return;
}

/*
Expand All @@ -1020,35 +1042,16 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
if (!(host->quirks & SDHCI_QUIRK_SINGLE_POWER_WRITE))
sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);

pwr = SDHCI_POWER_ON;

switch (1 << power) {
case MMC_VDD_165_195:
pwr |= SDHCI_POWER_180;
break;
case MMC_VDD_29_30:
case MMC_VDD_30_31:
pwr |= SDHCI_POWER_300;
break;
case MMC_VDD_32_33:
case MMC_VDD_33_34:
pwr |= SDHCI_POWER_330;
break;
default:
BUG();
}

/*
* At least the Marvell CaFe chip gets confused if we set the voltage
* and set turn on power at the same time, so set the voltage first.
*/
if ((host->quirks & SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER))
sdhci_writeb(host, pwr & ~SDHCI_POWER_ON, SDHCI_POWER_CONTROL);
sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL);

sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL);
pwr |= SDHCI_POWER_ON;

out:
host->power = power;
sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL);
}

/*****************************************************************************\
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/mmc/host/sdhci.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ struct sdhci_host {
unsigned int timeout_clk; /* Timeout freq (KHz) */

unsigned int clock; /* Current clock (MHz) */
unsigned short power; /* Current voltage */
u8 pwr; /* Current voltage */

struct mmc_request *mrq; /* Current request */
struct mmc_command *cmd; /* Current command */
Expand Down

0 comments on commit 82a6fa7

Please sign in to comment.