From 6ab3e82f8151f8039d0b770f30007cb4bc58f1dd Mon Sep 17 00:00:00 2001 From: Sarthak Garg Date: Sun, 21 Jun 2020 11:26:35 +0530 Subject: [PATCH] mmc: sdhci-msm: Introduce timeout freq divider in sdhci host Some SD host controllers multiplies the timeout-clk internally while deriving the timeout value. So allow vendor driver to update the timeout-clock to get the correct data timeout counter value. Change-Id: Iacbd98f5251d5312c999478b0d0aac3abc339323 Suggested-by: Veerabhadrarao Badiganti Signed-off-by: Sarthak Garg --- drivers/mmc/host/sdhci.c | 13 +++++++++++++ drivers/mmc/host/sdhci.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 32137ba6a730..5c8934e3fee8 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2040,6 +2040,10 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) host->timeout_clk = host->mmc->actual_clock ? host->mmc->actual_clock / 1000 : host->clock / 1000; + +#if defined(CONFIG_SDC_QTI) + host->timeout_clk /= host->timeout_clk_div; +#endif host->mmc->max_busy_timeout = host->ops->get_max_timeout_count ? host->ops->get_max_timeout_count(host) : @@ -3891,6 +3895,11 @@ int sdhci_setup_host(struct sdhci_host *host) override_timeout_clk = host->timeout_clk; +#if defined(CONFIG_SDC_QTI) + if (!host->timeout_clk_div) + host->timeout_clk_div = 1; +#endif + if (host->version > SDHCI_SPEC_420) { pr_err("%s: Unknown controller version (%d). You may experience problems.\n", mmc_hostname(mmc), host->version); @@ -4088,6 +4097,10 @@ int sdhci_setup_host(struct sdhci_host *host) if (override_timeout_clk) host->timeout_clk = override_timeout_clk; +#if defined(CONFIG_SDC_QTI) + host->timeout_clk /= host->timeout_clk_div; +#endif + mmc->max_busy_timeout = host->ops->get_max_timeout_count ? host->ops->get_max_timeout_count(host) : 1 << 27; mmc->max_busy_timeout /= host->timeout_clk; diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 3d27205c5a6b..3aed30a103ed 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -524,6 +524,11 @@ struct sdhci_host { unsigned int max_clk; /* Max possible freq (MHz) */ unsigned int timeout_clk; /* Timeout freq (KHz) */ + +#if defined(CONFIG_SDC_QTI) + u8 timeout_clk_div; /* Timeout freq (KHz) divider */ +#endif + unsigned int clk_mul; /* Clock Muliplier value */ unsigned int clock; /* Current clock (MHz) */