diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-04-25 08:00:01 -0400 |
---|---|---|
committer | Chris Ball <chris@printf.net> | 2014-05-22 08:33:29 -0400 |
commit | e921a8b6c47012bef94fe778f6e00df4207d5ed9 (patch) | |
tree | 77dabaaadb2d298b89a1d2e7acd630d5d64ee26e | |
parent | b4f3b7c8b13c6f0f84781a5d07fa553b3df4dfe6 (diff) |
mmc: sdhci: move regulator handling into sdhci_set_power()
Move the regulator handling into sdhci_set_power() rather than being in
sdhci_do_set_ios(). This wraps all power control up into this function.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Tested-by: Markus Pargmann <mpa@pengutronix.de>
Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>
-rw-r--r-- | drivers/mmc/host/sdhci.c | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 7368d3992ad4..2724e6fe6ca9 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -1216,7 +1216,7 @@ clock_set: | |||
1216 | } | 1216 | } |
1217 | EXPORT_SYMBOL_GPL(sdhci_set_clock); | 1217 | EXPORT_SYMBOL_GPL(sdhci_set_clock); |
1218 | 1218 | ||
1219 | static int sdhci_set_power(struct sdhci_host *host, unsigned short power) | 1219 | static void sdhci_set_power(struct sdhci_host *host, unsigned short power) |
1220 | { | 1220 | { |
1221 | u8 pwr = 0; | 1221 | u8 pwr = 0; |
1222 | 1222 | ||
@@ -1239,7 +1239,7 @@ static int sdhci_set_power(struct sdhci_host *host, unsigned short power) | |||
1239 | } | 1239 | } |
1240 | 1240 | ||
1241 | if (host->pwr == pwr) | 1241 | if (host->pwr == pwr) |
1242 | return -1; | 1242 | return; |
1243 | 1243 | ||
1244 | host->pwr = pwr; | 1244 | host->pwr = pwr; |
1245 | 1245 | ||
@@ -1247,38 +1247,43 @@ static int sdhci_set_power(struct sdhci_host *host, unsigned short power) | |||
1247 | sdhci_writeb(host, 0, SDHCI_POWER_CONTROL); | 1247 | sdhci_writeb(host, 0, SDHCI_POWER_CONTROL); |
1248 | if (host->quirks2 & SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON) | 1248 | if (host->quirks2 & SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON) |
1249 | sdhci_runtime_pm_bus_off(host); | 1249 | sdhci_runtime_pm_bus_off(host); |
1250 | return 0; | 1250 | power = 0; |
1251 | } | 1251 | } else { |
1252 | 1252 | /* | |
1253 | /* | 1253 | * Spec says that we should clear the power reg before setting |
1254 | * Spec says that we should clear the power reg before setting | 1254 | * a new value. Some controllers don't seem to like this though. |
1255 | * a new value. Some controllers don't seem to like this though. | 1255 | */ |
1256 | */ | 1256 | if (!(host->quirks & SDHCI_QUIRK_SINGLE_POWER_WRITE)) |
1257 | if (!(host->quirks & SDHCI_QUIRK_SINGLE_POWER_WRITE)) | 1257 | sdhci_writeb(host, 0, SDHCI_POWER_CONTROL); |
1258 | sdhci_writeb(host, 0, SDHCI_POWER_CONTROL); | ||
1259 | 1258 | ||
1260 | /* | 1259 | /* |
1261 | * At least the Marvell CaFe chip gets confused if we set the voltage | 1260 | * At least the Marvell CaFe chip gets confused if we set the |
1262 | * and set turn on power at the same time, so set the voltage first. | 1261 | * voltage and set turn on power at the same time, so set the |
1263 | */ | 1262 | * voltage first. |
1264 | if (host->quirks & SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER) | 1263 | */ |
1265 | sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL); | 1264 | if (host->quirks & SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER) |
1265 | sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL); | ||
1266 | 1266 | ||
1267 | pwr |= SDHCI_POWER_ON; | 1267 | pwr |= SDHCI_POWER_ON; |
1268 | 1268 | ||
1269 | sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL); | 1269 | sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL); |
1270 | 1270 | ||
1271 | if (host->quirks2 & SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON) | 1271 | if (host->quirks2 & SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON) |
1272 | sdhci_runtime_pm_bus_on(host); | 1272 | sdhci_runtime_pm_bus_on(host); |
1273 | 1273 | ||
1274 | /* | 1274 | /* |
1275 | * Some controllers need an extra 10ms delay of 10ms before they | 1275 | * Some controllers need an extra 10ms delay of 10ms before |
1276 | * can apply clock after applying power | 1276 | * they can apply clock after applying power |
1277 | */ | 1277 | */ |
1278 | if (host->quirks & SDHCI_QUIRK_DELAY_AFTER_POWER) | 1278 | if (host->quirks & SDHCI_QUIRK_DELAY_AFTER_POWER) |
1279 | mdelay(10); | 1279 | mdelay(10); |
1280 | } | ||
1280 | 1281 | ||
1281 | return power; | 1282 | if (host->vmmc) { |
1283 | spin_unlock_irq(&host->lock); | ||
1284 | mmc_regulator_set_ocr(host->mmc, host->vmmc, power); | ||
1285 | spin_lock_irq(&host->lock); | ||
1286 | } | ||
1282 | } | 1287 | } |
1283 | 1288 | ||
1284 | /*****************************************************************************\ | 1289 | /*****************************************************************************\ |
@@ -1429,7 +1434,6 @@ EXPORT_SYMBOL_GPL(sdhci_set_uhs_signaling); | |||
1429 | static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) | 1434 | static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) |
1430 | { | 1435 | { |
1431 | unsigned long flags; | 1436 | unsigned long flags; |
1432 | int vdd_bit = -1; | ||
1433 | u8 ctrl; | 1437 | u8 ctrl; |
1434 | 1438 | ||
1435 | spin_lock_irqsave(&host->lock, flags); | 1439 | spin_lock_irqsave(&host->lock, flags); |
@@ -1461,15 +1465,9 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) | |||
1461 | } | 1465 | } |
1462 | 1466 | ||
1463 | if (ios->power_mode == MMC_POWER_OFF) | 1467 | if (ios->power_mode == MMC_POWER_OFF) |
1464 | vdd_bit = sdhci_set_power(host, -1); | 1468 | sdhci_set_power(host, -1); |
1465 | else | 1469 | else |
1466 | vdd_bit = sdhci_set_power(host, ios->vdd); | 1470 | sdhci_set_power(host, ios->vdd); |
1467 | |||
1468 | if (host->vmmc && vdd_bit != -1) { | ||
1469 | spin_unlock_irqrestore(&host->lock, flags); | ||
1470 | mmc_regulator_set_ocr(host->mmc, host->vmmc, vdd_bit); | ||
1471 | spin_lock_irqsave(&host->lock, flags); | ||
1472 | } | ||
1473 | 1471 | ||
1474 | if (host->ops->platform_send_init_74_clocks) | 1472 | if (host->ops->platform_send_init_74_clocks) |
1475 | host->ops->platform_send_init_74_clocks(host, ios->power_mode); | 1473 | host->ops->platform_send_init_74_clocks(host, ios->power_mode); |