For arasan-rk3399-sdhci controller, we should make sure the phy is in
poweroff status before we configure the clock stuff. So that we need to
export it for phy configuration.

Signed-off-by: Ziyuan Xu <xzy...@rock-chips.com>
---

 drivers/mmc/sdhci.c | 16 +++++++---------
 include/sdhci.h     |  5 ++++-
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index 5c6dbdc..b9cd13a 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -301,9 +301,8 @@ static int sdhci_send_command(struct mmc *mmc, struct 
mmc_cmd *cmd,
                return -ECOMM;
 }
 
-static int sdhci_set_clock(struct mmc *mmc, unsigned int clock)
+int sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
 {
-       struct sdhci_host *host = mmc->priv;
        unsigned int div, clk = 0, timeout;
 
        /* Wait max 20 ms */
@@ -319,12 +318,10 @@ static int sdhci_set_clock(struct mmc *mmc, unsigned int 
clock)
                timeout--;
                udelay(100);
        }
-
        sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
 
        if (clock == 0)
                return 0;
-
        if (SDHCI_GET_VERSION(host) >= SDHCI_SPEC_300) {
                /*
                 * Check if the Host Controller supports Programmable Clock
@@ -365,7 +362,6 @@ static int sdhci_set_clock(struct mmc *mmc, unsigned int 
clock)
                }
                div >>= 1;
        }
-
        if (host->ops && host->ops->set_clock_ext)
                host->ops->set_clock_ext(host, div);
 
@@ -387,12 +383,10 @@ static int sdhci_set_clock(struct mmc *mmc, unsigned int 
clock)
                timeout--;
                udelay(1000);
        }
-
        clk |= SDHCI_CLOCK_CARD_EN;
        sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
 
        host->clock = clock;
-
        return 0;
 }
 
@@ -490,8 +484,12 @@ static int sdhci_set_ios(struct mmc *mmc)
        if (host->ops && host->ops->set_control_reg)
                host->ops->set_control_reg(host);
 
-       if (mmc->clock != host->clock)
-               sdhci_set_clock(mmc, mmc->clock);
+       if (mmc->clock != host->clock) {
+               if (host->ops && host->ops->set_clock)
+                       host->ops->set_clock(host, mmc->clock);
+               else
+                       sdhci_set_clock(host, mmc->clock);
+       }
 
        /* Set bus width */
        ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
diff --git a/include/sdhci.h b/include/sdhci.h
index 449ada1..da21194 100644
--- a/include/sdhci.h
+++ b/include/sdhci.h
@@ -254,7 +254,8 @@ struct sdhci_ops {
        int     (*get_cd)(struct sdhci_host *host);
        void    (*set_control_reg)(struct sdhci_host *host);
        void    (*set_ios_post)(struct sdhci_host *host);
-       void    (*set_clock)(struct sdhci_host *host, u32 div);
+       int     (*set_clock)(struct sdhci_host *host, unsigned int clock);
+       void    (*set_clock_ext)(struct sdhci_host *host, u32 div);
 };
 
 struct sdhci_host {
@@ -279,6 +280,8 @@ struct sdhci_host {
        struct mmc_config cfg;
 };
 
+int sdhci_set_clock(struct sdhci_host *host, unsigned int clock);
+
 #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS
 
 static inline void sdhci_writel(struct sdhci_host *host, u32 val, int reg)
-- 
2.7.4


_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to