aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/pxamci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/pxamci.c')
-rw-r--r--drivers/mmc/pxamci.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c
index eb9a8826e9b5..f97b472085cb 100644
--- a/drivers/mmc/pxamci.c
+++ b/drivers/mmc/pxamci.c
@@ -65,11 +65,6 @@ struct pxamci_host {
65 unsigned int dma_dir; 65 unsigned int dma_dir;
66}; 66};
67 67
68static inline unsigned int ns_to_clocks(unsigned int ns)
69{
70 return (ns * (CLOCKRATE / 1000000) + 999) / 1000;
71}
72
73static void pxamci_stop_clock(struct pxamci_host *host) 68static void pxamci_stop_clock(struct pxamci_host *host)
74{ 69{
75 if (readl(host->base + MMC_STAT) & STAT_CLK_EN) { 70 if (readl(host->base + MMC_STAT) & STAT_CLK_EN) {
@@ -113,6 +108,7 @@ static void pxamci_disable_irq(struct pxamci_host *host, unsigned int mask)
113static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data) 108static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data)
114{ 109{
115 unsigned int nob = data->blocks; 110 unsigned int nob = data->blocks;
111 unsigned long long clks;
116 unsigned int timeout; 112 unsigned int timeout;
117 u32 dcmd; 113 u32 dcmd;
118 int i; 114 int i;
@@ -125,7 +121,9 @@ static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data)
125 writel(nob, host->base + MMC_NOB); 121 writel(nob, host->base + MMC_NOB);
126 writel(1 << data->blksz_bits, host->base + MMC_BLKLEN); 122 writel(1 << data->blksz_bits, host->base + MMC_BLKLEN);
127 123
128 timeout = ns_to_clocks(data->timeout_ns) + data->timeout_clks; 124 clks = (unsigned long long)data->timeout_ns * CLOCKRATE;
125 do_div(clks, 1000000000UL);
126 timeout = (unsigned int)clks + (data->timeout_clks << host->clkrt);
129 writel((timeout + 255) / 256, host->base + MMC_RDTO); 127 writel((timeout + 255) / 256, host->base + MMC_RDTO);
130 128
131 if (data->flags & MMC_DATA_READ) { 129 if (data->flags & MMC_DATA_READ) {
@@ -200,7 +198,6 @@ static void pxamci_start_cmd(struct pxamci_host *host, struct mmc_command *cmd,
200 198
201static void pxamci_finish_request(struct pxamci_host *host, struct mmc_request *mrq) 199static void pxamci_finish_request(struct pxamci_host *host, struct mmc_request *mrq)
202{ 200{
203 pr_debug("PXAMCI: request done\n");
204 host->mrq = NULL; 201 host->mrq = NULL;
205 host->cmd = NULL; 202 host->cmd = NULL;
206 host->data = NULL; 203 host->data = NULL;
@@ -293,7 +290,7 @@ static int pxamci_data_done(struct pxamci_host *host, unsigned int stat)
293 pxamci_disable_irq(host, DATA_TRAN_DONE); 290 pxamci_disable_irq(host, DATA_TRAN_DONE);
294 291
295 host->data = NULL; 292 host->data = NULL;
296 if (host->mrq->stop && data->error == MMC_ERR_NONE) { 293 if (host->mrq->stop) {
297 pxamci_stop_clock(host); 294 pxamci_stop_clock(host);
298 pxamci_start_cmd(host, host->mrq->stop, 0); 295 pxamci_start_cmd(host, host->mrq->stop, 0);
299 } else { 296 } else {
@@ -311,12 +308,10 @@ static irqreturn_t pxamci_irq(int irq, void *devid, struct pt_regs *regs)
311 308
312 ireg = readl(host->base + MMC_I_REG); 309 ireg = readl(host->base + MMC_I_REG);
313 310
314 pr_debug("PXAMCI: irq %08x\n", ireg);
315
316 if (ireg) { 311 if (ireg) {
317 unsigned stat = readl(host->base + MMC_STAT); 312 unsigned stat = readl(host->base + MMC_STAT);
318 313
319 pr_debug("PXAMCI: stat %08x\n", stat); 314 pr_debug("PXAMCI: irq %08x stat %08x\n", ireg, stat);
320 315
321 if (ireg & END_CMD_RES) 316 if (ireg & END_CMD_RES)
322 handled |= pxamci_cmd_done(host, stat); 317 handled |= pxamci_cmd_done(host, stat);
@@ -370,10 +365,6 @@ static void pxamci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
370{ 365{
371 struct pxamci_host *host = mmc_priv(mmc); 366 struct pxamci_host *host = mmc_priv(mmc);
372 367
373 pr_debug("pxamci_set_ios: clock %u power %u vdd %u.%02u\n",
374 ios->clock, ios->power_mode, ios->vdd / 100,
375 ios->vdd % 100);
376
377 if (ios->clock) { 368 if (ios->clock) {
378 unsigned int clk = CLOCKRATE / ios->clock; 369 unsigned int clk = CLOCKRATE / ios->clock;
379 if (CLOCKRATE / clk > ios->clock) 370 if (CLOCKRATE / clk > ios->clock)
@@ -399,7 +390,7 @@ static void pxamci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
399 host->cmdat |= CMDAT_INIT; 390 host->cmdat |= CMDAT_INIT;
400 } 391 }
401 392
402 pr_debug("pxamci_set_ios: clkrt = %x cmdat = %x\n", 393 pr_debug("PXAMCI: clkrt = %x cmdat = %x\n",
403 host->clkrt, host->cmdat); 394 host->clkrt, host->cmdat);
404} 395}
405 396