mmc: sdhci-of-arasan: refactor set_clock callback
authorShawn Lin <shawn.lin@rock-chips.com>
Mon, 25 Apr 2016 02:08:27 +0000 (10:08 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 25 Apr 2016 10:30:39 +0000 (18:30 +0800)
commit 61b914eb81f8 ("mmc: sdhci-of-arasan: add phy support for
sdhci-of-arasan") introduce phy support for arasan. According to
the vendor's databook, we should make sure the phy is in poweroff
stat before we configure the clk stuff. Otherwise it may cause
some IO sample timing issue from the test. But we don't need this
extra operation while running in non HS200/HS400 mode since phy
doesn't trigger sampling block.

Change-Id: I5506f99e5a3b4d9a4356ad485ceac900c6d754aa
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
drivers/mmc/host/sdhci-of-arasan.c

index 4724ca489b3f3be61b20d41d113298abf0240e7d..4cdb97c300ff6e578fb3f182ee8127e0f7e66a65 100644 (file)
@@ -55,8 +55,26 @@ static unsigned int sdhci_arasan_get_timeout_clock(struct sdhci_host *host)
        return freq;
 }
 
+static void sdhci_arasan_set_clock(struct sdhci_host *host, unsigned int clock)
+{
+       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+       struct sdhci_arasan_data *sdhci_arasan = pltfm_host->priv;
+       bool ctrl_phy = false;
+
+       if (clock > MMC_HIGH_52_MAX_DTR && (!IS_ERR(sdhci_arasan->phy)))
+               ctrl_phy = true;
+
+       if (ctrl_phy)
+               phy_power_off(sdhci_arasan->phy);
+
+       sdhci_set_clock(host, clock);
+
+       if (ctrl_phy)
+               phy_power_on(sdhci_arasan->phy);
+}
+
 static struct sdhci_ops sdhci_arasan_ops = {
-       .set_clock = sdhci_set_clock,
+       .set_clock = sdhci_arasan_set_clock,
        .get_max_clock = sdhci_pltfm_clk_get_max_clock,
        .get_timeout_clock = sdhci_arasan_get_timeout_clock,
        .set_bus_width = sdhci_set_bus_width,