aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/mxs-mmc.c39
1 files changed, 1 insertions, 38 deletions
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 7b85e035a4c..0813340fa29 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -501,43 +501,6 @@ static void mxs_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
501 mxs_mmc_start_cmd(host, mrq->cmd); 501 mxs_mmc_start_cmd(host, mrq->cmd);
502} 502}
503 503
504static void mxs_mmc_set_clk_rate(struct mxs_mmc_host *host, unsigned int rate)
505{
506 struct mxs_ssp *ssp = &host->ssp;
507 unsigned int ssp_clk, ssp_sck;
508 u32 clock_divide, clock_rate;
509 u32 val;
510
511 ssp_clk = clk_get_rate(ssp->clk);
512
513 for (clock_divide = 2; clock_divide <= 254; clock_divide += 2) {
514 clock_rate = DIV_ROUND_UP(ssp_clk, rate * clock_divide);
515 clock_rate = (clock_rate > 0) ? clock_rate - 1 : 0;
516 if (clock_rate <= 255)
517 break;
518 }
519
520 if (clock_divide > 254) {
521 dev_err(mmc_dev(host->mmc),
522 "%s: cannot set clock to %d\n", __func__, rate);
523 return;
524 }
525
526 ssp_sck = ssp_clk / clock_divide / (1 + clock_rate);
527
528 val = readl(ssp->base + HW_SSP_TIMING(ssp));
529 val &= ~(BM_SSP_TIMING_CLOCK_DIVIDE | BM_SSP_TIMING_CLOCK_RATE);
530 val |= BF_SSP(clock_divide, TIMING_CLOCK_DIVIDE);
531 val |= BF_SSP(clock_rate, TIMING_CLOCK_RATE);
532 writel(val, ssp->base + HW_SSP_TIMING(ssp));
533
534 ssp->clk_rate = ssp_sck;
535
536 dev_dbg(mmc_dev(host->mmc),
537 "%s: clock_divide %d, clock_rate %d, ssp_clk %d, rate_actual %d, rate_requested %d\n",
538 __func__, clock_divide, clock_rate, ssp_clk, ssp_sck, rate);
539}
540
541static void mxs_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) 504static void mxs_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
542{ 505{
543 struct mxs_mmc_host *host = mmc_priv(mmc); 506 struct mxs_mmc_host *host = mmc_priv(mmc);
@@ -550,7 +513,7 @@ static void mxs_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
550 host->bus_width = 0; 513 host->bus_width = 0;
551 514
552 if (ios->clock) 515 if (ios->clock)
553 mxs_mmc_set_clk_rate(host, ios->clock); 516 mxs_ssp_set_clk_rate(&host->ssp, ios->clock);
554} 517}
555 518
556static void mxs_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable) 519static void mxs_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)