From f594c15b57c690a1f079201baff3f53d6e497139 Mon Sep 17 00:00:00 2001 From: Sarthak Garg Date: Mon, 20 Jul 2020 14:17:13 +0530 Subject: [PATCH] host: sdhci-msm: implement get_current_limit() host op This is needed to get the current capabilities of vdd regulator that is not managed by SDHCI driver. Change-Id: I2a7f2981043185b51e268bf30c4ab9135991c6ee Signed-off-by: Sarthak Garg --- drivers/mmc/host/sdhci-msm.c | 18 ++++++++++++++++++ drivers/mmc/host/sdhci.c | 11 +++++++++-- drivers/mmc/host/sdhci.h | 3 +++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index 6ad5b6f9d1ac..7d79223ec3b5 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -512,6 +512,21 @@ static unsigned int msm_get_clock_rate_for_bus_mode(struct sdhci_host *host, return clock; } +#if defined(CONFIG_SDC_QTI) +static unsigned int sdhci_msm_get_current_limit(struct sdhci_host *host) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); + struct sdhci_msm_vreg_data *curr_slot = msm_host->vreg_data; + u32 max_curr = 0; + + if (curr_slot && curr_slot->vdd_data) + max_curr = curr_slot->vdd_data->hpm_uA; + + return max_curr; +} +#endif + static void msm_set_clock_rate_for_bus_mode(struct sdhci_host *host, unsigned int clock) { @@ -3060,6 +3075,9 @@ static const struct sdhci_ops sdhci_msm_ops = { .write_w = sdhci_msm_writew, .write_b = sdhci_msm_writeb, .irq = sdhci_msm_cqe_irq, +#if defined(CONFIG_SDC_QTI) + .get_current_limit = sdhci_msm_get_current_limit, +#endif }; static const struct sdhci_pltfm_data sdhci_msm_pdata = { diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 62995a6f2391..77458576ee21 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -4286,8 +4286,15 @@ int sdhci_setup_host(struct sdhci_host *host) * value. */ max_current_caps = sdhci_readl(host, SDHCI_MAX_CURRENT); - if (!max_current_caps && !IS_ERR(mmc->supply.vmmc)) { - int curr = regulator_get_current_limit(mmc->supply.vmmc); + if (!max_current_caps) { + u32 curr = 0; + + if (!IS_ERR(mmc->supply.vmmc)) + curr = regulator_get_current_limit(mmc->supply.vmmc); +#if defined(CONFIG_SDC_QTI) + else if (host->ops->get_current_limit) + curr = host->ops->get_current_limit(host); +#endif if (curr > 0) { /* convert to SDHCI_MAX_CURRENT format */ diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 3aed30a103ed..8a9840c0a6cd 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -658,6 +658,9 @@ struct sdhci_ops { dma_addr_t addr, int len, unsigned int cmd); void (*request_done)(struct sdhci_host *host, struct mmc_request *mrq); + #if defined(CONFIG_SDC_QTI) + unsigned int (*get_current_limit)(struct sdhci_host *host); + #endif }; #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS