Commit 6a51e93b authored by yong mao's avatar yong mao Committed by Greg Kroah-Hartman

mmc: mediatek: Fixed bug where clock frequency could be set wrong


[ Upstream commit 40ceda09 ]

This patch can fix two issues:

Issue 1:
In previous code, div may be overflow when setting clock frequency
as f_min. We can use DIV_ROUND_UP to fix this boundary related
issue.

Issue 2:
In previous code, we can not set the correct clock frequency when
div equals 0xff.
Signed-off-by: default avatarYong Mao <yong.mao@mediatek.com>
Signed-off-by: default avatarChaotian Jing <chaotian.jing@mediatek.com>
Reviewed-by: default avatarDaniel Kurtz <djkurtz@chromium.org>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 51b3eac3
...@@ -570,7 +570,7 @@ static void msdc_set_mclk(struct msdc_host *host, unsigned char timing, u32 hz) ...@@ -570,7 +570,7 @@ static void msdc_set_mclk(struct msdc_host *host, unsigned char timing, u32 hz)
} }
} }
sdr_set_field(host->base + MSDC_CFG, MSDC_CFG_CKMOD | MSDC_CFG_CKDIV, sdr_set_field(host->base + MSDC_CFG, MSDC_CFG_CKMOD | MSDC_CFG_CKDIV,
(mode << 8) | (div % 0xff)); (mode << 8) | div);
sdr_set_bits(host->base + MSDC_CFG, MSDC_CFG_CKPDN); sdr_set_bits(host->base + MSDC_CFG, MSDC_CFG_CKPDN);
while (!(readl(host->base + MSDC_CFG) & MSDC_CFG_CKSTB)) while (!(readl(host->base + MSDC_CFG) & MSDC_CFG_CKSTB))
cpu_relax(); cpu_relax();
...@@ -1540,7 +1540,7 @@ static int msdc_drv_probe(struct platform_device *pdev) ...@@ -1540,7 +1540,7 @@ static int msdc_drv_probe(struct platform_device *pdev)
host->src_clk_freq = clk_get_rate(host->src_clk); host->src_clk_freq = clk_get_rate(host->src_clk);
/* Set host parameters to mmc */ /* Set host parameters to mmc */
mmc->ops = &mt_msdc_ops; mmc->ops = &mt_msdc_ops;
mmc->f_min = host->src_clk_freq / (4 * 255); mmc->f_min = DIV_ROUND_UP(host->src_clk_freq, 4 * 255);
mmc->caps |= MMC_CAP_ERASE | MMC_CAP_CMD23; mmc->caps |= MMC_CAP_ERASE | MMC_CAP_CMD23;
mmc->caps |= MMC_CAP_RUNTIME_RESUME; mmc->caps |= MMC_CAP_RUNTIME_RESUME;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment