diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2013-01-07 09:31:08 -0500 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2013-02-11 13:28:52 -0500 |
commit | 8213af3b7a4059f13ad8b5beb3e6d69d9301f27d (patch) | |
tree | fe90c6c43b359b0d9ff683f1a4f64e0472f6cea8 /drivers/mmc | |
parent | 740b7a44aedbe8d916ce21b636f78467f5da1c59 (diff) |
mmc: sdhci: introduce sdhci_update_clock helper to re-enable clock
There are three places where same piece of code is used. Let's split it
to a separate function.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/sdhci.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index b93076764ddd..336ab06aeb2f 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -1189,6 +1189,15 @@ out: | |||
1189 | host->clock = clock; | 1189 | host->clock = clock; |
1190 | } | 1190 | } |
1191 | 1191 | ||
1192 | static inline void sdhci_update_clock(struct sdhci_host *host) | ||
1193 | { | ||
1194 | unsigned int clock; | ||
1195 | |||
1196 | clock = host->clock; | ||
1197 | host->clock = 0; | ||
1198 | sdhci_set_clock(host, clock); | ||
1199 | } | ||
1200 | |||
1192 | static int sdhci_set_power(struct sdhci_host *host, unsigned short power) | 1201 | static int sdhci_set_power(struct sdhci_host *host, unsigned short power) |
1193 | { | 1202 | { |
1194 | u8 pwr = 0; | 1203 | u8 pwr = 0; |
@@ -1418,7 +1427,6 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) | |||
1418 | 1427 | ||
1419 | if (host->version >= SDHCI_SPEC_300) { | 1428 | if (host->version >= SDHCI_SPEC_300) { |
1420 | u16 clk, ctrl_2; | 1429 | u16 clk, ctrl_2; |
1421 | unsigned int clock; | ||
1422 | 1430 | ||
1423 | /* In case of UHS-I modes, set High Speed Enable */ | 1431 | /* In case of UHS-I modes, set High Speed Enable */ |
1424 | if ((ios->timing == MMC_TIMING_MMC_HS200) || | 1432 | if ((ios->timing == MMC_TIMING_MMC_HS200) || |
@@ -1458,9 +1466,7 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) | |||
1458 | sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); | 1466 | sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); |
1459 | 1467 | ||
1460 | /* Re-enable SD Clock */ | 1468 | /* Re-enable SD Clock */ |
1461 | clock = host->clock; | 1469 | sdhci_update_clock(host); |
1462 | host->clock = 0; | ||
1463 | sdhci_set_clock(host, clock); | ||
1464 | } | 1470 | } |
1465 | 1471 | ||
1466 | 1472 | ||
@@ -1491,9 +1497,7 @@ static void sdhci_do_set_ios(struct sdhci_host *host, struct mmc_ios *ios) | |||
1491 | } | 1497 | } |
1492 | 1498 | ||
1493 | /* Re-enable SD Clock */ | 1499 | /* Re-enable SD Clock */ |
1494 | clock = host->clock; | 1500 | sdhci_update_clock(host); |
1495 | host->clock = 0; | ||
1496 | sdhci_set_clock(host, clock); | ||
1497 | } else | 1501 | } else |
1498 | sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); | 1502 | sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); |
1499 | 1503 | ||
@@ -2083,14 +2087,9 @@ static void sdhci_tasklet_finish(unsigned long param) | |||
2083 | (host->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))) { | 2087 | (host->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))) { |
2084 | 2088 | ||
2085 | /* Some controllers need this kick or reset won't work here */ | 2089 | /* Some controllers need this kick or reset won't work here */ |
2086 | if (host->quirks & SDHCI_QUIRK_CLOCK_BEFORE_RESET) { | 2090 | if (host->quirks & SDHCI_QUIRK_CLOCK_BEFORE_RESET) |
2087 | unsigned int clock; | ||
2088 | |||
2089 | /* This is to force an update */ | 2091 | /* This is to force an update */ |
2090 | clock = host->clock; | 2092 | sdhci_update_clock(host); |
2091 | host->clock = 0; | ||
2092 | sdhci_set_clock(host, clock); | ||
2093 | } | ||
2094 | 2093 | ||
2095 | /* Spec says we should do both at the same time, but Ricoh | 2094 | /* Spec says we should do both at the same time, but Ricoh |
2096 | controllers do not like that. */ | 2095 | controllers do not like that. */ |