Skip to content

Commit 6c92ae1

Browse files
Nicolas Saenz Juliennestorulf
Nicolas Saenz Julienne
authored andcommitted
mmc: sdhci: Introduce sdhci_set_power_and_bus_voltage()
Some controllers diverge from the standard way of setting power and need their bus voltage register to be configured regardless of the whether they use regulators. As this is a common pattern across sdhci hosts, create a helper function. Signed-off-by: Nicolas Saenz Julienne <[email protected]> Acked-by: Adrian Hunter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 6bbcf74 commit 6c92ae1

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

drivers/mmc/host/sdhci.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,6 +2010,25 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
20102010
}
20112011
EXPORT_SYMBOL_GPL(sdhci_set_power);
20122012

2013+
/*
2014+
* Some controllers need to configure a valid bus voltage on their power
2015+
* register regardless of whether an external regulator is taking care of power
2016+
* supply. This helper function takes care of it if set as the controller's
2017+
* sdhci_ops.set_power callback.
2018+
*/
2019+
void sdhci_set_power_and_bus_voltage(struct sdhci_host *host,
2020+
unsigned char mode,
2021+
unsigned short vdd)
2022+
{
2023+
if (!IS_ERR(host->mmc->supply.vmmc)) {
2024+
struct mmc_host *mmc = host->mmc;
2025+
2026+
mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
2027+
}
2028+
sdhci_set_power_noreg(host, mode, vdd);
2029+
}
2030+
EXPORT_SYMBOL_GPL(sdhci_set_power_and_bus_voltage);
2031+
20132032
/*****************************************************************************\
20142033
* *
20152034
* MMC callbacks *

drivers/mmc/host/sdhci.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,9 @@ void sdhci_set_clock(struct sdhci_host *host, unsigned int clock);
772772
void sdhci_enable_clk(struct sdhci_host *host, u16 clk);
773773
void sdhci_set_power(struct sdhci_host *host, unsigned char mode,
774774
unsigned short vdd);
775+
void sdhci_set_power_and_bus_voltage(struct sdhci_host *host,
776+
unsigned char mode,
777+
unsigned short vdd);
775778
void sdhci_set_power_noreg(struct sdhci_host *host, unsigned char mode,
776779
unsigned short vdd);
777780
void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq);

0 commit comments

Comments
 (0)