diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index 2b2db9b299f0..53e98136c522 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -519,6 +519,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) { @@ -3128,6 +3143,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