aboutsummaryrefslogtreecommitdiff
path: root/drivers/mfd
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2009-10-10 17:48:21 +0200
committerLars-Peter Clausen <lars@metafoo.de>2009-12-06 08:46:43 +0100
commit0fd425a2d37c7d6f0dcd5403c0fde2b729026d61 (patch)
tree189bbd15f748ef209dca9628ad1ed4fde25751e2 /drivers/mfd
parent89738ae9c8a18326f88f020cfab78b982d6ddaef (diff)
glamo-mci: Wait for the mmc engine to become idle before signaling that a
request has been finished.
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/glamo/glamo-mci.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/drivers/mfd/glamo/glamo-mci.c b/drivers/mfd/glamo/glamo-mci.c
index 9404f540fe4..a173bbaaea3 100644
--- a/drivers/mfd/glamo/glamo-mci.c
+++ b/drivers/mfd/glamo/glamo-mci.c
@@ -221,6 +221,20 @@ static int glamo_mci_set_card_clock(struct glamo_mci_host *host, int freq)
return real_rate;
}
+static int glamo_mci_wait_idle(struct glamo_mci_host *host,
+ unsigned long timeout)
+{
+ uint16_t status;
+ do {
+ status = glamo_reg_read(host, GLAMO_REG_MMC_RB_STAT1);
+ } while (!(status & GLAMO_STAT1_MMC_IDLE) && jiffies < timeout);
+
+ if (jiffies >= timeout)
+ return -ETIMEDOUT;
+
+ return 0;
+}
+
static void glamo_mci_request_done(struct glamo_mci_host *host, struct
mmc_request *mrq)
{
@@ -233,12 +247,16 @@ static void glamo_mci_irq_worker(struct work_struct *work)
{
struct glamo_mci_host *host = container_of(work, struct glamo_mci_host,
irq_work);
+ struct mmc_request *mrq;
struct mmc_command *cmd;
uint16_t status;
+ int res;
+
if (!host->mrq || !host->mrq->cmd)
return;
- cmd = host->mrq->cmd;
+ mrq = host->mrq;
+ cmd = mrq->cmd;
#if 0
if (cmd->data->flags & MMC_DATA_READ)
@@ -263,12 +281,15 @@ static void glamo_mci_irq_worker(struct work_struct *work)
}
/* issue STOP if we have been given one to use */
- if (host->mrq->stop)
- glamo_mci_send_command(host, host->mrq->stop);
+ if (mrq->stop)
+ glamo_mci_send_command(host, mrq->stop);
if (cmd->data->flags & MMC_DATA_READ)
do_pio_read(host, cmd->data);
+ if (mrq->stop)
+ mrq->stop->error = glamo_mci_wait_idle(host, jiffies + HZ);
+
done:
host->mrq = NULL;
glamo_mci_request_done(host, cmd->mrq);
@@ -634,6 +655,8 @@ static void glamo_mci_send_request(struct mmc_host *mmc,
dev_dbg(&host->pdev->dev, "Waiting for payload data\n");
return;
done:
+ if (!cmd->error)
+ cmd->error = glamo_mci_wait_idle(host, jiffies + 2 * HZ);
glamo_mci_request_done(host, mrq);
}