summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZiyuan Xu <xzy.xu@rock-chips.com>2017-05-15 09:07:22 +0300
committerKever Yang <kever.yang@rock-chips.com>2017-07-18 17:08:31 +0300
commit85c817741d2d88fc8257587658ba323ccfa1ccb8 (patch)
tree051cfca339deb40f6e240c8f984ca5713f769b57
parent44346aa3d69a0ecc3ce0d6e6153e7b03ba6883be (diff)
downloadu-boot-85c817741d2d88fc8257587658ba323ccfa1ccb8.tar.xz
mmc: sdhci: export sdhci_set_clock()
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.xu@rock-chips.com>
-rw-r--r--drivers/mmc/sdhci.c16
-rw-r--r--include/sdhci.h5
2 files changed, 11 insertions, 10 deletions
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index a2d166040d..6cf43f1a34 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
@@ -364,7 +361,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);
@@ -386,12 +382,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;
}
@@ -489,8 +483,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 449ada12b4..da21194f48 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)