aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChaotian Jing <chaotian.jing@mediatek.com>2015-10-27 02:24:24 -0400
committerUlf Hansson <ulf.hansson@linaro.org>2015-10-27 05:21:16 -0400
commit6e622947e149fa9fd62e3609aab010935c8e10bd (patch)
tree4c4363022b54c0ac3e29605c160af7b6a325d42a
parent726a9aac31a89d5a02614ca8f2b3f644df621c27 (diff)
mmc: mediatek: change the argument "ddr" to "timing"
use the ios->timing directly is better It can reflect current timing and do settings by timing Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/host/mtk-sd.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index 8b3e15d0f1f0..c877dedf23d2 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -297,7 +297,7 @@ struct msdc_host {
297 u32 mclk; /* mmc subsystem clock frequency */ 297 u32 mclk; /* mmc subsystem clock frequency */
298 u32 src_clk_freq; /* source clock frequency */ 298 u32 src_clk_freq; /* source clock frequency */
299 u32 sclk; /* SD/MS bus clock frequency */ 299 u32 sclk; /* SD/MS bus clock frequency */
300 bool ddr; 300 unsigned char timing;
301 bool vqmmc_enabled; 301 bool vqmmc_enabled;
302 struct msdc_save_para save_para; /* used when gate HCLK */ 302 struct msdc_save_para save_para; /* used when gate HCLK */
303}; 303};
@@ -488,7 +488,7 @@ static void msdc_ungate_clock(struct msdc_host *host)
488 cpu_relax(); 488 cpu_relax();
489} 489}
490 490
491static void msdc_set_mclk(struct msdc_host *host, int ddr, u32 hz) 491static void msdc_set_mclk(struct msdc_host *host, unsigned char timing, u32 hz)
492{ 492{
493 u32 mode; 493 u32 mode;
494 u32 flags; 494 u32 flags;
@@ -504,7 +504,8 @@ static void msdc_set_mclk(struct msdc_host *host, int ddr, u32 hz)
504 504
505 flags = readl(host->base + MSDC_INTEN); 505 flags = readl(host->base + MSDC_INTEN);
506 sdr_clr_bits(host->base + MSDC_INTEN, flags); 506 sdr_clr_bits(host->base + MSDC_INTEN, flags);
507 if (ddr) { /* may need to modify later */ 507 if (timing == MMC_TIMING_UHS_DDR50 ||
508 timing == MMC_TIMING_MMC_DDR52) {
508 mode = 0x2; /* ddr mode and use divisor */ 509 mode = 0x2; /* ddr mode and use divisor */
509 if (hz >= (host->src_clk_freq >> 2)) { 510 if (hz >= (host->src_clk_freq >> 2)) {
510 div = 0; /* mean div = 1/4 */ 511 div = 0; /* mean div = 1/4 */
@@ -535,12 +536,12 @@ static void msdc_set_mclk(struct msdc_host *host, int ddr, u32 hz)
535 cpu_relax(); 536 cpu_relax();
536 host->sclk = sclk; 537 host->sclk = sclk;
537 host->mclk = hz; 538 host->mclk = hz;
538 host->ddr = ddr; 539 host->timing = timing;
539 /* need because clk changed. */ 540 /* need because clk changed. */
540 msdc_set_timeout(host, host->timeout_ns, host->timeout_clks); 541 msdc_set_timeout(host, host->timeout_ns, host->timeout_clks);
541 sdr_set_bits(host->base + MSDC_INTEN, flags); 542 sdr_set_bits(host->base + MSDC_INTEN, flags);
542 543
543 dev_dbg(host->dev, "sclk: %d, ddr: %d\n", host->sclk, ddr); 544 dev_dbg(host->dev, "sclk: %d, timing: %d\n", host->sclk, timing);
544} 545}
545 546
546static inline u32 msdc_cmd_find_resp(struct msdc_host *host, 547static inline u32 msdc_cmd_find_resp(struct msdc_host *host,
@@ -1158,14 +1159,9 @@ static void msdc_ops_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1158{ 1159{
1159 struct msdc_host *host = mmc_priv(mmc); 1160 struct msdc_host *host = mmc_priv(mmc);
1160 int ret; 1161 int ret;
1161 u32 ddr = 0;
1162 1162
1163 pm_runtime_get_sync(host->dev); 1163 pm_runtime_get_sync(host->dev);
1164 1164
1165 if (ios->timing == MMC_TIMING_UHS_DDR50 ||
1166 ios->timing == MMC_TIMING_MMC_DDR52)
1167 ddr = 1;
1168
1169 msdc_set_buswidth(host, ios->bus_width); 1165 msdc_set_buswidth(host, ios->bus_width);
1170 1166
1171 /* Suspend/Resume will do power off/on */ 1167 /* Suspend/Resume will do power off/on */
@@ -1202,8 +1198,8 @@ static void msdc_ops_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1202 break; 1198 break;
1203 } 1199 }
1204 1200
1205 if (host->mclk != ios->clock || host->ddr != ddr) 1201 if (host->mclk != ios->clock || host->timing != ios->timing)
1206 msdc_set_mclk(host, ddr, ios->clock); 1202 msdc_set_mclk(host, ios->timing, ios->clock);
1207 1203
1208end: 1204end:
1209 pm_runtime_mark_last_busy(host->dev); 1205 pm_runtime_mark_last_busy(host->dev);