diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-12-12 23:06:13 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-12-12 23:06:13 -0500 |
| commit | 71fe5ccac7ede00526de490a2df10ebcd39c4c11 (patch) | |
| tree | f327328400e51b47d47f6957d010496ff7e308aa | |
| parent | dc47ce90c3a822cd7c9e9339fe4d5f61dcb26b50 (diff) | |
| parent | 49df78074963c97e25debc3c67b72f059111607d (diff) | |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc:
mmc: core: Fix deadlock when the CONFIG_MMC_UNSAFE_RESUME is not defined
mmc: sdhci-s3c: Remove old and misprototyped suspend operations
mmc: tmio: fix clock gating on platforms with a .set_pwr() method
mmc: sh_mmcif: fix clock gating on platforms with a .down_pwr() method
mmc: core: Fix typo at mmc_card_sleep
mmc: core: Fix power_off_notify during suspend
mmc: core: Fix setting power notify state variable for non-eMMC
mmc: core: Add quirk for long data read time
mmc: Add module.h include to sdhci-cns3xxx.c
mmc: mxcmmc: fix falling back to PIO
mmc: omap_hsmmc: DMA unmap only once in case of MMC error
| -rw-r--r-- | drivers/mmc/card/block.c | 8 | ||||
| -rw-r--r-- | drivers/mmc/core/core.c | 98 | ||||
| -rw-r--r-- | drivers/mmc/core/mmc.c | 12 | ||||
| -rw-r--r-- | drivers/mmc/host/mxcmmc.c | 1 | ||||
| -rw-r--r-- | drivers/mmc/host/omap_hsmmc.c | 7 | ||||
| -rw-r--r-- | drivers/mmc/host/sdhci-cns3xxx.c | 1 | ||||
| -rw-r--r-- | drivers/mmc/host/sdhci-s3c.c | 2 | ||||
| -rw-r--r-- | drivers/mmc/host/sh_mmcif.c | 2 | ||||
| -rw-r--r-- | drivers/mmc/host/tmio_mmc_pio.c | 2 | ||||
| -rw-r--r-- | include/linux/mmc/card.h | 6 |
10 files changed, 95 insertions, 44 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index a1cb21f9530..1e0e27cbe98 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
| @@ -1606,6 +1606,14 @@ static const struct mmc_fixup blk_fixups[] = | |||
| 1606 | MMC_QUIRK_BLK_NO_CMD23), | 1606 | MMC_QUIRK_BLK_NO_CMD23), |
| 1607 | MMC_FIXUP("MMC32G", 0x11, CID_OEMID_ANY, add_quirk_mmc, | 1607 | MMC_FIXUP("MMC32G", 0x11, CID_OEMID_ANY, add_quirk_mmc, |
| 1608 | MMC_QUIRK_BLK_NO_CMD23), | 1608 | MMC_QUIRK_BLK_NO_CMD23), |
| 1609 | |||
| 1610 | /* | ||
| 1611 | * Some Micron MMC cards needs longer data read timeout than | ||
| 1612 | * indicated in CSD. | ||
| 1613 | */ | ||
| 1614 | MMC_FIXUP(CID_NAME_ANY, 0x13, 0x200, add_quirk_mmc, | ||
| 1615 | MMC_QUIRK_LONG_READ_TIME), | ||
| 1616 | |||
| 1609 | END_FIXUP | 1617 | END_FIXUP |
| 1610 | }; | 1618 | }; |
| 1611 | 1619 | ||
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 5278ffb20e7..950b97d7412 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
| @@ -529,6 +529,18 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card) | |||
| 529 | data->timeout_clks = 0; | 529 | data->timeout_clks = 0; |
| 530 | } | 530 | } |
| 531 | } | 531 | } |
| 532 | |||
| 533 | /* | ||
| 534 | * Some cards require longer data read timeout than indicated in CSD. | ||
| 535 | * Address this by setting the read timeout to a "reasonably high" | ||
| 536 | * value. For the cards tested, 300ms has proven enough. If necessary, | ||
| 537 | * this value can be increased if other problematic cards require this. | ||
| 538 | */ | ||
| 539 | if (mmc_card_long_read_time(card) && data->flags & MMC_DATA_READ) { | ||
| 540 | data->timeout_ns = 300000000; | ||
| 541 | data->timeout_clks = 0; | ||
| 542 | } | ||
| 543 | |||
| 532 | /* | 544 | /* |
| 533 | * Some cards need very high timeouts if driven in SPI mode. | 545 | * Some cards need very high timeouts if driven in SPI mode. |
| 534 | * The worst observed timeout was 900ms after writing a | 546 | * The worst observed timeout was 900ms after writing a |
| @@ -1213,6 +1225,46 @@ void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type) | |||
| 1213 | mmc_host_clk_release(host); | 1225 | mmc_host_clk_release(host); |
| 1214 | } | 1226 | } |
| 1215 | 1227 | ||
| 1228 | static void mmc_poweroff_notify(struct mmc_host *host) | ||
| 1229 | { | ||
| 1230 | struct mmc_card *card; | ||
| 1231 | unsigned int timeout; | ||
| 1232 | unsigned int notify_type = EXT_CSD_NO_POWER_NOTIFICATION; | ||
| 1233 | int err = 0; | ||
| 1234 | |||
| 1235 | card = host->card; | ||
| 1236 | |||
| 1237 | /* | ||
| 1238 | * Send power notify command only if card | ||
| 1239 | * is mmc and notify state is powered ON | ||
| 1240 | */ | ||
| 1241 | if (card && mmc_card_mmc(card) && | ||
| 1242 | (card->poweroff_notify_state == MMC_POWERED_ON)) { | ||
| 1243 | |||
| 1244 | if (host->power_notify_type == MMC_HOST_PW_NOTIFY_SHORT) { | ||
| 1245 | notify_type = EXT_CSD_POWER_OFF_SHORT; | ||
| 1246 | timeout = card->ext_csd.generic_cmd6_time; | ||
| 1247 | card->poweroff_notify_state = MMC_POWEROFF_SHORT; | ||
| 1248 | } else { | ||
| 1249 | notify_type = EXT_CSD_POWER_OFF_LONG; | ||
| 1250 | timeout = card->ext_csd.power_off_longtime; | ||
| 1251 | card->poweroff_notify_state = MMC_POWEROFF_LONG; | ||
| 1252 | } | ||
| 1253 | |||
| 1254 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | ||
| 1255 | EXT_CSD_POWER_OFF_NOTIFICATION, | ||
| 1256 | notify_type, timeout); | ||
| 1257 | |||
| 1258 | if (err && err != -EBADMSG) | ||
| 1259 | pr_err("Device failed to respond within %d poweroff " | ||
| 1260 | "time. Forcefully powering down the device\n", | ||
| 1261 | timeout); | ||
| 1262 | |||
| 1263 | /* Set the card state to no notification after the poweroff */ | ||
| 1264 | card->poweroff_notify_state = MMC_NO_POWER_NOTIFICATION; | ||
| 1265 | } | ||
| 1266 | } | ||
| 1267 | |||
| 1216 | /* | 1268 | /* |
| 1217 | * Apply power to the MMC stack. This is a two-stage process. | 1269 | * Apply power to the MMC stack. This is a two-stage process. |
| 1218 | * First, we enable power to the card without the clock running. | 1270 | * First, we enable power to the card without the clock running. |
| @@ -1269,42 +1321,12 @@ static void mmc_power_up(struct mmc_host *host) | |||
| 1269 | 1321 | ||
| 1270 | void mmc_power_off(struct mmc_host *host) | 1322 | void mmc_power_off(struct mmc_host *host) |
| 1271 | { | 1323 | { |
| 1272 | struct mmc_card *card; | ||
| 1273 | unsigned int notify_type; | ||
| 1274 | unsigned int timeout; | ||
| 1275 | int err; | ||
| 1276 | |||
| 1277 | mmc_host_clk_hold(host); | 1324 | mmc_host_clk_hold(host); |
| 1278 | 1325 | ||
| 1279 | card = host->card; | ||
| 1280 | host->ios.clock = 0; | 1326 | host->ios.clock = 0; |
| 1281 | host->ios.vdd = 0; | 1327 | host->ios.vdd = 0; |
| 1282 | 1328 | ||
| 1283 | if (card && mmc_card_mmc(card) && | 1329 | mmc_poweroff_notify(host); |
| 1284 | (card->poweroff_notify_state == MMC_POWERED_ON)) { | ||
| 1285 | |||
| 1286 | if (host->power_notify_type == MMC_HOST_PW_NOTIFY_SHORT) { | ||
| 1287 | notify_type = EXT_CSD_POWER_OFF_SHORT; | ||
| 1288 | timeout = card->ext_csd.generic_cmd6_time; | ||
| 1289 | card->poweroff_notify_state = MMC_POWEROFF_SHORT; | ||
| 1290 | } else { | ||
| 1291 | notify_type = EXT_CSD_POWER_OFF_LONG; | ||
| 1292 | timeout = card->ext_csd.power_off_longtime; | ||
| 1293 | card->poweroff_notify_state = MMC_POWEROFF_LONG; | ||
| 1294 | } | ||
| 1295 | |||
| 1296 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | ||
| 1297 | EXT_CSD_POWER_OFF_NOTIFICATION, | ||
| 1298 | notify_type, timeout); | ||
| 1299 | |||
| 1300 | if (err && err != -EBADMSG) | ||
| 1301 | pr_err("Device failed to respond within %d poweroff " | ||
| 1302 | "time. Forcefully powering down the device\n", | ||
| 1303 | timeout); | ||
| 1304 | |||
| 1305 | /* Set the card state to no notification after the poweroff */ | ||
| 1306 | card->poweroff_notify_state = MMC_NO_POWER_NOTIFICATION; | ||
| 1307 | } | ||
| 1308 | 1330 | ||
| 1309 | /* | 1331 | /* |
| 1310 | * Reset ocr mask to be the highest possible voltage supported for | 1332 | * Reset ocr mask to be the highest possible voltage supported for |
| @@ -2196,7 +2218,7 @@ int mmc_card_sleep(struct mmc_host *host) | |||
| 2196 | 2218 | ||
| 2197 | mmc_bus_get(host); | 2219 | mmc_bus_get(host); |
| 2198 | 2220 | ||
| 2199 | if (host->bus_ops && !host->bus_dead && host->bus_ops->awake) | 2221 | if (host->bus_ops && !host->bus_dead && host->bus_ops->sleep) |
| 2200 | err = host->bus_ops->sleep(host); | 2222 | err = host->bus_ops->sleep(host); |
| 2201 | 2223 | ||
| 2202 | mmc_bus_put(host); | 2224 | mmc_bus_put(host); |
| @@ -2302,8 +2324,17 @@ int mmc_suspend_host(struct mmc_host *host) | |||
| 2302 | * pre-claim the host. | 2324 | * pre-claim the host. |
| 2303 | */ | 2325 | */ |
| 2304 | if (mmc_try_claim_host(host)) { | 2326 | if (mmc_try_claim_host(host)) { |
| 2305 | if (host->bus_ops->suspend) | 2327 | if (host->bus_ops->suspend) { |
| 2328 | /* | ||
| 2329 | * For eMMC 4.5 device send notify command | ||
| 2330 | * before sleep, because in sleep state eMMC 4.5 | ||
| 2331 | * devices respond to only RESET and AWAKE cmd | ||
| 2332 | */ | ||
| 2333 | mmc_poweroff_notify(host); | ||
| 2306 | err = host->bus_ops->suspend(host); | 2334 | err = host->bus_ops->suspend(host); |
| 2335 | } | ||
| 2336 | mmc_do_release_host(host); | ||
| 2337 | |||
| 2307 | if (err == -ENOSYS || !host->bus_ops->resume) { | 2338 | if (err == -ENOSYS || !host->bus_ops->resume) { |
| 2308 | /* | 2339 | /* |
| 2309 | * We simply "remove" the card in this case. | 2340 | * We simply "remove" the card in this case. |
| @@ -2318,7 +2349,6 @@ int mmc_suspend_host(struct mmc_host *host) | |||
| 2318 | host->pm_flags = 0; | 2349 | host->pm_flags = 0; |
| 2319 | err = 0; | 2350 | err = 0; |
| 2320 | } | 2351 | } |
| 2321 | mmc_do_release_host(host); | ||
| 2322 | } else { | 2352 | } else { |
| 2323 | err = -EBUSY; | 2353 | err = -EBUSY; |
| 2324 | } | 2354 | } |
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index dbf421a6279..d240427c124 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
| @@ -876,17 +876,21 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
| 876 | * set the notification byte in the ext_csd register of device | 876 | * set the notification byte in the ext_csd register of device |
| 877 | */ | 877 | */ |
| 878 | if ((host->caps2 & MMC_CAP2_POWEROFF_NOTIFY) && | ||
