Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 140487
b: refs/heads/master
c: 7260cf5
h: refs/heads/master
i:
  140485: a52fcda
  140483: 9874511
  140479: 91a9e13
v: v3
  • Loading branch information
Anton Vorontsov authored and Pierre Ossman committed Mar 24, 2009
1 parent 055bf7a commit 276f0e0
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 18 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: 4e4141a526dd7f5ac3ce1458ae79ea6e5a515b06
refs/heads/master: 7260cf5e12393536ce61d184c3fc750fb2ba635a
78 changes: 61 additions & 17 deletions trunk/drivers/mmc/host/sdhci.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,47 @@ static void sdhci_dumpregs(struct sdhci_host *host)
* *
\*****************************************************************************/

static void sdhci_clear_set_irqs(struct sdhci_host *host, u32 clear, u32 set)
{
u32 ier;

ier = sdhci_readl(host, SDHCI_INT_ENABLE);
ier &= ~clear;
ier |= set;
sdhci_writel(host, ier, SDHCI_INT_ENABLE);
sdhci_writel(host, ier, SDHCI_SIGNAL_ENABLE);
}

static void sdhci_unmask_irqs(struct sdhci_host *host, u32 irqs)
{
sdhci_clear_set_irqs(host, 0, irqs);
}

static void sdhci_mask_irqs(struct sdhci_host *host, u32 irqs)
{
sdhci_clear_set_irqs(host, irqs, 0);
}

static void sdhci_set_card_detection(struct sdhci_host *host, bool enable)
{
u32 irqs = SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT;

if (enable)
sdhci_unmask_irqs(host, irqs);
else
sdhci_mask_irqs(host, irqs);
}

static void sdhci_enable_card_detection(struct sdhci_host *host)
{
sdhci_set_card_detection(host, true);
}

static void sdhci_disable_card_detection(struct sdhci_host *host)
{
sdhci_set_card_detection(host, false);
}

static void sdhci_reset(struct sdhci_host *host, u8 mask)
{
unsigned long timeout;
Expand Down Expand Up @@ -120,20 +161,21 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask)

static void sdhci_init(struct sdhci_host *host)
{
u32 intmask;

sdhci_reset(host, SDHCI_RESET_ALL);

intmask = SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT |
sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK,
SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT |
SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_INDEX |
SDHCI_INT_END_BIT | SDHCI_INT_CRC | SDHCI_INT_TIMEOUT |
SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT |
SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL |
SDHCI_INT_DMA_END | SDHCI_INT_DATA_END | SDHCI_INT_RESPONSE |
SDHCI_INT_ADMA_ERROR;
SDHCI_INT_ADMA_ERROR);
}

sdhci_writel(host, intmask, SDHCI_INT_ENABLE);
sdhci_writel(host, intmask, SDHCI_SIGNAL_ENABLE);
static void sdhci_reinit(struct sdhci_host *host)
{
sdhci_init(host);
sdhci_enable_card_detection(host);
}

static void sdhci_activate_led(struct sdhci_host *host)
Expand Down Expand Up @@ -1032,7 +1074,7 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
*/
if (ios->power_mode == MMC_POWER_OFF) {
sdhci_writel(host, 0, SDHCI_SIGNAL_ENABLE);
sdhci_init(host);
sdhci_reinit(host);
}

sdhci_set_clock(host, ios->clock);
Expand Down Expand Up @@ -1093,7 +1135,6 @@ static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable)
{
struct sdhci_host *host;
unsigned long flags;
u32 ier;

host = mmc_priv(mmc);

Expand All @@ -1102,15 +1143,10 @@ static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable)
if (host->flags & SDHCI_DEVICE_DEAD)
goto out;

ier = sdhci_readl(host, SDHCI_INT_ENABLE);

ier &= ~SDHCI_INT_CARD_INT;
if (enable)
ier |= SDHCI_INT_CARD_INT;

sdhci_writel(host, ier, SDHCI_INT_ENABLE);
sdhci_writel(host, ier, SDHCI_SIGNAL_ENABLE);

sdhci_unmask_irqs(host, SDHCI_INT_CARD_INT);
else
sdhci_mask_irqs(host, SDHCI_INT_CARD_INT);
out:
mmiowb();

Expand Down Expand Up @@ -1452,6 +1488,8 @@ int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state)
{
int ret;

sdhci_disable_card_detection(host);

ret = mmc_suspend_host(host->mmc, state);
if (ret)
return ret;
Expand Down Expand Up @@ -1484,6 +1522,8 @@ int sdhci_resume_host(struct sdhci_host *host)
if (ret)
return ret;

sdhci_enable_card_detection(host);

return 0;
}

Expand Down Expand Up @@ -1743,6 +1783,8 @@ int sdhci_add_host(struct sdhci_host *host)
(host->flags & SDHCI_USE_ADMA)?"A":"",
(host->flags & SDHCI_USE_DMA)?"DMA":"PIO");

sdhci_enable_card_detection(host);

return 0;

#ifdef SDHCI_USE_LEDS_CLASS
Expand Down Expand Up @@ -1779,6 +1821,8 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)
spin_unlock_irqrestore(&host->lock, flags);
}

sdhci_disable_card_detection(host);

mmc_remove_host(host->mmc);

#ifdef SDHCI_USE_LEDS_CLASS
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/mmc/host/sdhci.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL | \
SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_DATA_CRC | \
SDHCI_INT_DATA_END_BIT)
#define SDHCI_INT_ALL_MASK ((unsigned int)-1)

#define SDHCI_ACMD12_ERR 0x3C

Expand Down

0 comments on commit 276f0e0

Please sign in to comment.