diff options
| -rw-r--r-- | MAINTAINERS | 6 | ||||
| -rw-r--r-- | drivers/mmc/core/mmc.c | 2 | ||||
| -rw-r--r-- | drivers/mmc/core/sd.c | 21 | ||||
| -rw-r--r-- | drivers/mmc/host/imxmmc.c | 19 | ||||
| -rw-r--r-- | drivers/mmc/host/mmc_spi.c | 188 | ||||
| -rw-r--r-- | drivers/mmc/host/omap_hsmmc.c | 7 | ||||
| -rw-r--r-- | drivers/mmc/host/sdhci-pci.c | 2 | ||||
| -rw-r--r-- | drivers/mmc/host/sdhci.c | 2 | ||||
| -rw-r--r-- | drivers/mmc/host/wbsd.c | 2 |
9 files changed, 164 insertions, 85 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index c3b215970f7b..d96e7451891f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -3057,7 +3057,7 @@ S: Supported | |||
| 3057 | 3057 | ||
| 3058 | MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND SDIO SUBSYSTEM | 3058 | MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND SDIO SUBSYSTEM |
| 3059 | P: Pierre Ossman | 3059 | P: Pierre Ossman |
| 3060 | M: drzeus-mmc@drzeus.cx | 3060 | M: pierre@ossman.eu |
| 3061 | L: linux-kernel@vger.kernel.org | 3061 | L: linux-kernel@vger.kernel.org |
| 3062 | S: Maintained | 3062 | S: Maintained |
| 3063 | 3063 | ||
| @@ -3939,7 +3939,7 @@ S: Maintained | |||
| 3939 | 3939 | ||
| 3940 | SECURE DIGITAL HOST CONTROLLER INTERFACE (SDHCI) DRIVER | 3940 | SECURE DIGITAL HOST CONTROLLER INTERFACE (SDHCI) DRIVER |
| 3941 | P: Pierre Ossman | 3941 | P: Pierre Ossman |
| 3942 | M: drzeus-sdhci@drzeus.cx | 3942 | M: pierre@ossman.eu |
| 3943 | L: sdhci-devel@lists.ossman.eu | 3943 | L: sdhci-devel@lists.ossman.eu |
| 3944 | S: Maintained | 3944 | S: Maintained |
| 3945 | 3945 | ||
| @@ -4926,7 +4926,7 @@ S: Maintained | |||
| 4926 | 4926 | ||
| 4927 | W83L51xD SD/MMC CARD INTERFACE DRIVER | 4927 | W83L51xD SD/MMC CARD INTERFACE DRIVER |
| 4928 | P: Pierre Ossman | 4928 | P: Pierre Ossman |
| 4929 | M: drzeus-wbsd@drzeus.cx | 4929 | M: pierre@ossman.eu |
| 4930 | L: linux-kernel@vger.kernel.org | 4930 | L: linux-kernel@vger.kernel.org |
| 4931 | S: Maintained | 4931 | S: Maintained |
| 4932 | 4932 | ||
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index c232d11a7ed4..06084dbf1277 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
| @@ -208,7 +208,7 @@ static int mmc_read_ext_csd(struct mmc_card *card) | |||
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | ext_csd_struct = ext_csd[EXT_CSD_REV]; | 210 | ext_csd_struct = ext_csd[EXT_CSD_REV]; |
| 211 | if (ext_csd_struct > 2) { | 211 | if (ext_csd_struct > 3) { |
| 212 | printk(KERN_ERR "%s: unrecognised EXT_CSD structure " | 212 | printk(KERN_ERR "%s: unrecognised EXT_CSD structure " |
| 213 | "version %d\n", mmc_hostname(card->host), | 213 | "version %d\n", mmc_hostname(card->host), |
| 214 | ext_csd_struct); | 214 | ext_csd_struct); |
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 26fc098d77cd..cd81c395e164 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c | |||
| @@ -363,15 +363,6 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, | |||
| 363 | goto err; | 363 | goto err; |
| 364 | 364 | ||
| 365 | /* | 365 | /* |
| 366 | * For SPI, enable CRC as appropriate. | ||
| 367 | */ | ||
| 368 | if (mmc_host_is_spi(host)) { | ||
| 369 | err = mmc_spi_set_crc(host, use_spi_crc); | ||
| 370 | if (err) | ||
| 371 | goto err; | ||
| 372 | } | ||
| 373 | |||
| 374 | /* | ||
| 375 | * Fetch CID from card. | 366 | * Fetch CID from card. |
| 376 | */ | 367 | */ |
| 377 | if (mmc_host_is_spi(host)) | 368 | if (mmc_host_is_spi(host)) |
| @@ -458,6 +449,18 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr, | |||
| 458 | } | 449 | } |
| 459 | 450 | ||
| 460 | /* | 451 | /* |
| 452 | * For SPI, enable CRC as appropriate. | ||
| 453 | * This CRC enable is located AFTER the reading of the | ||
| 454 | * card registers because some SDHC cards are not able | ||
| 455 | * to provide valid CRCs for non-512-byte blocks. | ||
| 456 | */ | ||
| 457 | if (mmc_host_is_spi(host)) { | ||
| 458 | err = mmc_spi_set_crc(host, use_spi_crc); | ||
| 459 | if (err) | ||
| 460 | goto free_card; | ||
| 461 | } | ||
| 462 | |||
| 463 | /* | ||
| 461 | * Attempt to change to high-speed (if supported) | 464 | * Attempt to change to high-speed (if supported) |
| 462 | */ | 465 | */ |
| 463 | err = mmc_switch_hs(card); | 466 | err = mmc_switch_hs(card); |
diff --git a/drivers/mmc/host/imxmmc.c b/drivers/mmc/host/imxmmc.c index eb29b1d933ac..e0be21a4a696 100644 --- a/drivers/mmc/host/imxmmc.c +++ b/drivers/mmc/host/imxmmc.c | |||
| @@ -307,13 +307,6 @@ static void imxmci_setup_data(struct imxmci_host *host, struct mmc_data *data) | |||
| 307 | 307 | ||
| 308 | wmb(); | 308 | wmb(); |
| 309 | 309 | ||
| 310 | if (host->actual_bus_width == MMC_BUS_WIDTH_4) | ||
| 311 | BLR(host->dma) = 0; /* burst 64 byte read / 64 bytes write */ | ||
| 312 | else | ||
| 313 | BLR(host->dma) = 16; /* burst 16 byte read / 16 bytes write */ | ||
| 314 | |||
| 315 | RSSR(host->dma) = DMA_REQ_SDHC; | ||
| 316 | |||
| 317 | set_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events); | 310 | set_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events); |
| 318 | clear_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events); | 311 | clear_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events); |
| 319 | 312 | ||
| @@ -818,9 +811,11 @@ static void imxmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
| 818 | if (ios->bus_width == MMC_BUS_WIDTH_4) { | 811 | if (ios->bus_width == MMC_BUS_WIDTH_4) { |
| 819 | host->actual_bus_width = MMC_BUS_WIDTH_4; | 812 | host->actual_bus_width = MMC_BUS_WIDTH_4; |
| 820 | imx_gpio_mode(PB11_PF_SD_DAT3); | 813 | imx_gpio_mode(PB11_PF_SD_DAT3); |
| 814 | BLR(host->dma) = 0; /* burst 64 byte read/write */ | ||
| 821 | } else { | 815 | } else { |
| 822 | host->actual_bus_width = MMC_BUS_WIDTH_1; | 816 | host->actual_bus_width = MMC_BUS_WIDTH_1; |
| 823 | imx_gpio_mode(GPIO_PORTB | GPIO_IN | GPIO_PUEN | 11); | 817 | imx_gpio_mode(GPIO_PORTB | GPIO_IN | GPIO_PUEN | 11); |
| 818 | BLR(host->dma) = 16; /* burst 16 byte read/write */ | ||
| 824 | } | 819 | } |
| 825 | 820 | ||
| 826 | if (host->power_mode != ios->power_mode) { | 821 | if (host->power_mode != ios->power_mode) { |
| @@ -938,7 +933,7 @@ static void imxmci_check_status(unsigned long data) | |||
| 938 | mod_timer(&host->timer, jiffies + (HZ>>1)); | 933 | mod_timer(&host->timer, jiffies + (HZ>>1)); |
| 939 | } | 934 | } |
| 940 | 935 | ||
| 941 | static int imxmci_probe(struct platform_device *pdev) | 936 | static int __init imxmci_probe(struct platform_device *pdev) |
| 942 | { | 937 | { |
| 943 | struct mmc_host *mmc; | 938 | struct mmc_host *mmc; |
| 944 | struct imxmci_host *host = NULL; | 939 | struct imxmci_host *host = NULL; |
| @@ -1034,6 +1029,7 @@ static int imxmci_probe(struct platform_device *pdev) | |||
| 1034 | } | 1029 | } |
| 1035 | host->dma_allocated = 1; | 1030 | host->dma_allocated = 1; |
| 1036 | imx_dma_setup_handlers(host->dma, imxmci_dma_irq, NULL, host); | 1031 | imx_dma_setup_handlers(host->dma, imxmci_dma_irq, NULL, host); |
| 1032 | RSSR(host->dma) = DMA_REQ_SDHC; | ||
| 1037 | 1033 | ||
| 1038 | tasklet_init(&host->tasklet, imxmci_tasklet_fnc, (unsigned long)host); | 1034 | tasklet_init(&host->tasklet, imxmci_tasklet_fnc, (unsigned long)host); |
| 1039 | host->status_reg=0; | 1035 | host->status_reg=0; |
| @@ -1079,7 +1075,7 @@ out: | |||
| 1079 | return ret; | 1075 | return ret; |
| 1080 | } | 1076 | } |
| 1081 | 1077 | ||
| 1082 | static int imxmci_remove(struct platform_device *pdev) | 1078 | static int __exit imxmci_remove(struct platform_device *pdev) |
| 1083 | { | 1079 | { |
| 1084 | struct mmc_host *mmc = platform_get_drvdata(pdev); | 1080 | struct mmc_host *mmc = platform_get_drvdata(pdev); |
| 1085 | 1081 | ||
| @@ -1145,8 +1141,7 @@ static int imxmci_resume(struct platform_device *dev) | |||
| 1145 | #endif /* CONFIG_PM */ | 1141 | #endif /* CONFIG_PM */ |
| 1146 | 1142 | ||
| 1147 | static struct platform_driver imxmci_driver = { | 1143 | static struct platform_driver imxmci_driver = { |
| 1148 | .probe = imxmci_probe, | 1144 | .remove = __exit_p(imxmci_remove), |
| 1149 | .remove = imxmci_remove, | ||
| 1150 | .suspend = imxmci_suspend, | 1145 | .suspend = imxmci_suspend, |
| 1151 | .resume = imxmci_resume, | 1146 | .resume = imxmci_resume, |
| 1152 | .driver = { | 1147 | .driver = { |
| @@ -1157,7 +1152,7 @@ static struct platform_driver imxmci_driver = { | |||
| 1157 | 1152 | ||
| 1158 | static int __init imxmci_init(void) | 1153 | static int __init imxmci_init(void) |
| 1159 | { | 1154 | { |
| 1160 | return platform_driver_register(&imxmci_driver); | 1155 | return platform_driver_probe(&imxmci_driver, imxmci_probe); |
| 1161 | } | 1156 | } |
| 1162 | 1157 | ||
| 1163 | static void __exit imxmci_exit(void) | 1158 | static void __exit imxmci_exit(void) |
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index 72f8bde4877a..f48349d18c92 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | * along with this program; if not, write to the Free Software | 24 | * along with this program; if not, write to the Free Software |
| 25 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 25 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 26 | */ | 26 | */ |
| 27 | #include <linux/hrtimer.h> | 27 | #include <linux/sched.h> |
| 28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
| 29 | #include <linux/bio.h> | 29 | #include <linux/bio.h> |
| 30 | #include <linux/dma-mapping.h> | 30 | #include <linux/dma-mapping.h> |
| @@ -95,7 +95,7 @@ | |||
| 95 | * reads which takes nowhere near that long. Older cards may be able to use | 95 | * reads which takes nowhere near that long. Older cards may be able to use |
| 96 | * shorter timeouts ... but why bother? | 96 | * shorter timeouts ... but why bother? |
| 97 | */ | 97 | */ |
| 98 | #define r1b_timeout ktime_set(3, 0) | 98 | #define r1b_timeout (HZ * 3) |
| 99 | 99 | ||
| 100 | 100 | ||
| 101 | /****************************************************************************/ | 101 | /****************************************************************************/ |
| @@ -183,12 +183,11 @@ mmc_spi_readbytes(struct mmc_spi_host *host, unsigned len) | |||
| 183 | return status; | 183 | return status; |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | static int | 186 | static int mmc_spi_skip(struct mmc_spi_host *host, unsigned long timeout, |
| 187 | mmc_spi_skip(struct mmc_spi_host *host, ktime_t timeout, unsigned n, u8 byte) | 187 | unsigned n, u8 byte) |
| 188 | { | 188 | { |
| 189 | u8 *cp = host->data->status; | 189 | u8 *cp = host->data->status; |
| 190 | 190 | unsigned long start = jiffies; | |
| 191 | timeout = ktime_add(timeout, ktime_get()); | ||
| 192 | 191 | ||
| 193 | while (1) { | 192 | while (1) { |
| 194 | int status; | 193 | int status; |
| @@ -203,22 +202,26 @@ mmc_spi_skip(struct mmc_spi_host *host, ktime_t timeout, unsigned n, u8 byte) | |||
| 203 | return cp[i]; | 202 | return cp[i]; |
| 204 | } | 203 | } |
| 205 | 204 | ||
| 206 | /* REVISIT investigate msleep() to avoid busy-wait I/O | 205 | if (time_is_before_jiffies(start + timeout)) |
| 207 | * in at least some cases. | ||
| 208 | */ | ||
| 209 | if (ktime_to_ns(ktime_sub(ktime_get(), timeout)) > 0) | ||
| 210 | break; | 206 | break; |
| 207 | |||
| 208 | /* If we need long timeouts, we may release the CPU. | ||
| 209 | * We use jiffies here because we want to have a relation | ||
| 210 | * between elapsed time and the blocking of the scheduler. | ||
| 211 | */ | ||
| 212 | if (time_is_before_jiffies(start+1)) | ||
| 213 | schedule(); | ||
| 211 | } | 214 | } |
| 212 | return -ETIMEDOUT; | 215 | return -ETIMEDOUT; |
| 213 | } | 216 | } |
| 214 | 217 | ||
| 215 | static inline int | 218 | static inline int |
| 216 | mmc_spi_wait_unbusy(struct mmc_spi_host *host, ktime_t timeout) | 219 | mmc_spi_wait_unbusy(struct mmc_spi_host *host, unsigned long timeout) |
| 217 | { | 220 | { |
| 218 | return mmc_spi_skip(host, timeout, sizeof(host->data->status), 0); | 221 | return mmc_spi_skip(host, timeout, sizeof(host->data->status), 0); |
| 219 | } | 222 | } |
| 220 | 223 | ||
| 221 | static int mmc_spi_readtoken(struct mmc_spi_host *host, ktime_t timeout) | 224 | static int mmc_spi_readtoken(struct mmc_spi_host *host, unsigned long timeout) |
| 222 | { | 225 | { |
| 223 | return mmc_spi_skip(host, timeout, 1, 0xff); | 226 | return mmc_spi_skip(host, timeout, 1, 0xff); |
| 224 | } | 227 | } |
| @@ -251,6 +254,10 @@ static int mmc_spi_response_get(struct mmc_spi_host *host, | |||
| 251 | u8 *cp = host->data->status; | 254 | u8 *cp = host->data->status; |
| 252 | u8 *end = cp + host->t.len; | 255 | u8 *end = cp + host->t.len; |
| 253 | int value = 0; | 256 | int value = 0; |
| 257 | int bitshift; | ||
| 258 | u8 leftover = 0; | ||
| 259 | unsigned short rotator; | ||
| 260 | int i; | ||
| 254 | char tag[32]; | 261 | char tag[32]; |
| 255 | 262 | ||
| 256 | snprintf(tag, sizeof(tag), " ... CMD%d response SPI_%s", | 263 | snprintf(tag, sizeof(tag), " ... CMD%d response SPI_%s", |
| @@ -268,9 +275,8 @@ static int mmc_spi_response_get(struct mmc_spi_host *host, | |||
| 268 | 275 | ||
| 269 | /* Data block reads (R1 response types) may need more data... */ | 276 | /* Data block reads (R1 response types) may need more data... */ |
| 270 | if (cp == end) { | 277 | if (cp == end) { |
| 271 | unsigned i; | ||
| 272 | |||
| 273 | cp = host->data->status; | 278 | cp = host->data->status; |
| 279 | end = cp+1; | ||
| 274 | 280 | ||
| 275 | /* Card sends N(CR) (== 1..8) bytes of all-ones then one | 281 | /* Card sends N(CR) (== 1..8) bytes of all-ones then one |
| 276 | * status byte ... and we already scanned 2 bytes. | 282 | * status byte ... and we already scanned 2 bytes. |
| @@ -295,20 +301,34 @@ static int mmc_spi_response_get(struct mmc_spi_host *host, | |||
| 295 | } | 301 | } |
| 296 | 302 | ||
| 297 | checkstatus: | 303 | checkstatus: |
| 298 | if (*cp & 0x80) { | 304 | bitshift = 0; |
| 299 | dev_dbg(&host->spi->dev, "%s: INVALID RESPONSE, %02x\n", | 305 | if (*cp & 0x80) { |
| 300 | tag, *cp); | 306 | /* Houston, we have an ugly card with a bit-shifted response */ |
| 301 | value = -EBADR; | 307 | rotator = *cp++ << 8; |
| 302 | goto done; | 308 | /* read the next byte */ |
| 309 | if (cp == end) { | ||
| 310 | value = mmc_spi_readbytes(host, 1); | ||
| 311 | if (value < 0) | ||
| 312 | goto done; | ||
| 313 | cp = host->data->status; | ||
| 314 | end = cp+1; | ||
| 315 | } | ||
| 316 | rotator |= *cp++; | ||
| 317 | while (rotator & 0x8000) { | ||
| 318 | bitshift++; | ||
| 319 | rotator <<= 1; | ||
| 320 | } | ||
| 321 | cmd->resp[0] = rotator >> 8; | ||
| 322 | leftover = rotator; | ||
| 323 | } else { | ||
| 324 | cmd->resp[0] = *cp++; | ||
| 303 | } | 325 | } |
| 304 | |||
| 305 | cmd->resp[0] = *cp++; | ||
| 306 | cmd->error = 0; | 326 | cmd->error = 0; |
| 307 | 327 | ||
| 308 | /* Status byte: the entire seven-bit R1 response. */ | 328 | /* Status byte: the entire seven-bit R1 response. */ |
| 309 | if (cmd->resp[0] != 0) { | 329 | if (cmd->resp[0] != 0) { |
| 310 | if ((R1_SPI_PARAMETER | R1_SPI_ADDRESS | 330 | if ((R1_SPI_PARAMETER | R1_SPI_ADDRESS |
| 311 | | R1_SPI_ILLEGAL_COMMAND) | 331 | | R1_SPI_ILLEGAL_COMMAND) |
| 312 | & cmd->resp[0]) | 332 | & cmd->resp[0]) |
| 313 | value = -EINVAL; | 333 | value = -EINVAL; |
| 314 | else if (R1_SPI_COM_CRC & cmd->resp[0]) | 334 | else if (R1_SPI_COM_CRC & cmd->resp[0]) |
| @@ -336,12 +356,45 @@ checkstatus: | |||
| 336 | * SPI R5 == R1 + data byte; IO_RW_DIRECT | 356 | * SPI R5 == R1 + data byte; IO_RW_DIRECT |
| 337 | */ | 357 | */ |
| 338 | case MMC_RSP_SPI_R2: | 358 | case MMC_RSP_SPI_R2: |
| 339 | cmd->resp[0] |= *cp << 8; | 359 | /* read the next byte */ |
| 360 | if (cp == end) { | ||
| 361 | value = mmc_spi_readbytes(host, 1); | ||
| 362 | if (value < 0) | ||
| 363 | goto done; | ||
| 364 | cp = host->data->status; | ||
| 365 | end = cp+1; | ||
| 366 | } | ||
| 367 | if (bitshift) { | ||
| 368 | rotator = leftover << 8; | ||
| 369 | rotator |= *cp << bitshift; | ||
| 370 | cmd->resp[0] |= (rotator & 0xFF00); | ||
| 371 | } else { | ||
| 372 | cmd->resp[0] |= *cp << 8; | ||
| 373 | } | ||
| 340 | break; | 374 | break; |
| 341 | 375 | ||
| 342 | /* SPI R3, R4, or R7 == R1 + 4 bytes */ | 376 | /* SPI R3, R4, or R7 == R1 + 4 bytes */ |
| 343 | case MMC_RSP_SPI_R3: | 377 | case MMC_RSP_SPI_R3: |
| 344 | cmd->resp[1] = get_unaligned_be32(cp); | 378 | rotator = leftover << 8; |
| 379 | cmd->resp[1] = 0; | ||
| 380 | for (i = 0; i < 4; i++) { | ||
| 381 | cmd->resp[1] <<= 8; | ||
| 382 | /* read the next byte */ | ||
| 383 | if (cp == end) { | ||
| 384 | value = mmc_spi_readbytes(host, 1); | ||
| 385 | if (value < 0) | ||
| 386 | goto done; | ||
| 387 | cp = host->data->status; | ||
| 388 | end = cp+1; | ||
| 389 | } | ||
| 390 | if (bitshift) { | ||
| 391 | rotator |= *cp++ << bitshift; | ||
| 392 | cmd->resp[1] |= (rotator >> 8); | ||
| 393 | rotator <<= 8; | ||
| 394 | } else { | ||
| 395 | cmd->resp[1] |= *cp++; | ||
| 396 | } | ||
| 397 | } | ||
| 345 | break; | 398 | break; |
| 346 | 399 | ||
| 347 | /* SPI R1 == just one status byte */ | 400 | /* SPI R1 == just one status byte */ |
| @@ -607,7 +660,7 @@ mmc_spi_setup_data_message( | |||
| 607 | */ | 660 | */ |
| 608 | static int | 661 | static int |
| 609 | mmc_spi_writeblock(struct mmc_spi_host *host, struct spi_transfer *t, | 662 | mmc_spi_writeblock(struct mmc_spi_host *host, struct spi_transfer *t, |
| 610 | ktime_t timeout) | 663 | unsigned long timeout) |
| 611 | { | 664 | { |
| 612 | struct spi_device *spi = host->spi; | 665 | struct spi_device *spi = host->spi; |
| 613 | int status, i; | 666 | int status, i; |
| @@ -717,11 +770,13 @@ mmc_spi_writeblock(struct mmc_spi_host *host, struct spi_transfer *t, | |||
| 717 | */ | 770 | */ |
| 718 | static int | 771 | static int |
| 719 | mmc_spi_readblock(struct mmc_spi_host *host, struct spi_transfer *t, | 772 | mmc_spi_readblock(struct mmc_spi_host *host, struct spi_transfer *t, |
| 720 | ktime_t timeout) | 773 | unsigned long timeout) |
| 721 | { | 774 | { |
| 722 | struct spi_device *spi = host->spi; | 775 | struct spi_device *spi = host->spi; |
| 723 | int status; | 776 | int status; |
| 724 | struct scratch *scratch = host->data; | 777 | struct scratch *scratch = host->data; |
| 778 | unsigned int bitshift; | ||
| 779 | u8 leftover; | ||
| 725 | 780 | ||
| 726 | /* At least one SD card sends an all-zeroes byte when N(CX) | 781 | /* At least one SD card sends an all-zeroes byte when N(CX) |
| 727 | * applies, before the all-ones bytes ... just cope with that. | 782 | * applies, before the all-ones bytes ... just cope with that. |
| @@ -733,38 +788,60 @@ mmc_spi_readblock(struct mmc_spi_host *host, struct spi_transfer *t, | |||
| 733 | if (status == 0xff || status == 0) | 788 | if (status == 0xff || status == 0) |
| 734 | status = mmc_spi_readtoken(host, timeout); | 789 | status = mmc_spi_readtoken(host, timeout); |
| 735 | 790 | ||
| 736 | if (status == SPI_TOKEN_SINGLE) { | 791 | if (status < 0) { |
| 737 | if (host->dma_dev) { | 792 | dev_dbg(&spi->dev, "read error %02x (%d)\n", status, status); |
| 738 | dma_sync_single_for_device(host->dma_dev, | 793 | return status; |
| 739 | host->data_dma, sizeof(*scratch), | 794 | } |
| 740 | DMA_BIDIRECTIONAL); | ||
| 741 | dma_sync_single_for_device(host->dma_dev, | ||
| 742 | t->rx_dma, t->len, | ||
| 743 | DMA_FROM_DEVICE); | ||
| 744 | } | ||
| 745 | 795 | ||
| 746 | status = spi_sync(spi, &host->m); | 796 | /* The token may be bit-shifted... |
| 797 | * the first 0-bit precedes the data stream. | ||
| 798 | */ | ||
| 799 | bitshift = 7; | ||
| 800 | while (status & 0x80) { | ||
| 801 | status <<= 1; | ||
| 802 | bitshift--; | ||
| 803 | } | ||
| 804 | leftover = status << 1; | ||
| 747 | 805 | ||
| 748 | if (host->dma_dev) { | 806 | if (host->dma_dev) { |
| 749 | dma_sync_single_for_cpu(host->dma_dev, | 807 | dma_sync_single_for_device(host->dma_dev, |
| 750 | host->data_dma, sizeof(*scratch), | 808 | host->data_dma, sizeof(*scratch), |
| 751 | DMA_BIDIRECTIONAL); | 809 | DMA_BIDIRECTIONAL); |
| 752 | dma_sync_single_for_cpu(host->dma_dev, | 810 | dma_sync_single_for_device(host->dma_dev, |
| 753 | t->rx_dma, t->len, | 811 | t->rx_dma, t->len, |
| 754 | DMA_FROM_DEVICE); | 812 | DMA_FROM_DEVICE); |
| 755 | } | 813 | } |
| 756 | 814 | ||
| 757 | } else { | 815 | status = spi_sync(spi, &host->m); |
| 758 | dev_dbg(&spi->dev, "read error %02x (%d)\n", status, status); | ||
| 759 | 816 | ||
| 760 | /* we've read extra garbage, timed out, etc */ | 817 | if (host->dma_dev) { |
| 761 | if (status < 0) | 818 | dma_sync_single_for_cpu(host->dma_dev, |
| 762 | return status; | 819 | host->data_dma, sizeof(*scratch), |
| 820 | DMA_BIDIRECTIONAL); | ||
| 821 | dma_sync_single_for_cpu(host->dma_dev, | ||
| 822 | t->rx_dma, t->len, | ||
| 823 | DMA_FROM_DEVICE); | ||
| 824 | } | ||
| 763 | 825 | ||
| 764 | /* low four bits are an R2 subset, fifth seems to be | 826 | if (bitshift) { |
| 765 | * vendor specific ... map them all to generic error.. | 827 | /* Walk through the data and the crc and do |
| 828 | * all the magic to get byte-aligned data. | ||
| 766 | */ | 829 | */ |
| 767 | return -EIO; | 830 | u8 *cp = t->rx_buf; |
| 831 | unsigned int len; | ||
| 832 | unsigned int bitright = 8 - bitshift; | ||
| 833 | u8 temp; | ||
| 834 | for (len = t->len; len; len--) { | ||
| 835 | temp = *cp; | ||
| 836 | *cp++ = leftover | (temp >> bitshift); | ||
| 837 | leftover = temp << bitright; | ||
| 838 | } | ||
| 839 | cp = (u8 *) &scratch->crc_val; | ||
| 840 | temp = *cp; | ||
| 841 | *cp++ = leftover | (temp >> bitshift); | ||
| 842 | leftover = temp << bitright; | ||
| 843 | temp = *cp; | ||
| 844 | *cp = leftover | (temp >> bitshift); | ||
| 768 | } | 845 | } |
| 769 | 846 | ||
| 770 | if (host->mmc->use_spi_crc) { | 847 | if (host->mmc->use_spi_crc) { |
| @@ -803,7 +880,7 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd, | |||
| 803 | unsigned n_sg; | 880 | unsigned n_sg; |
| 804 | int multiple = (data->blocks > 1); | 881 | int multiple = (data->blocks > 1); |
| 805 | u32 clock_rate; | 882 | u32 clock_rate; |
| 806 | ktime_t timeout; | 883 | unsigned long timeout; |
| 807 | 884 | ||
| 808 | if (data->flags & MMC_DATA_READ) | 885 | if (data->flags & MMC_DATA_READ) |
| 809 | direction = DMA_FROM_DEVICE; | 886 | direction = DMA_FROM_DEVICE; |
| @@ -817,8 +894,9 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd, | |||
| 817 | else | 894 | else |
| 818 | clock_rate = spi->max_speed_hz; | 895 | clock_rate = spi->max_speed_hz; |
| 819 | 896 | ||
| 820 | timeout = ktime_add_ns(ktime_set(0, 0), data->timeout_ns + | 897 | timeout = data->timeout_ns + |
| 821 | data->timeout_clks * 1000000 / clock_rate); | 898 | data->timeout_clks * 1000000 / clock_rate; |
| 899 | timeout = usecs_to_jiffies((unsigned int)(timeout / 1000)) + 1; | ||
| 822 | 900 | ||
| 823 | /* Handle scatterlist segments one at a time, with synch for | 901 | /* Handle scatterlist segments one at a time, with synch for |
| 824 | * each 512-byte block | 902 | * each 512-byte block |
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index d183be6f2a5f..e62a22a7f00c 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c | |||
| @@ -298,7 +298,6 @@ mmc_omap_xfer_done(struct mmc_omap_host *host, struct mmc_data *data) | |||
| 298 | struct mmc_request *mrq = host->mrq; | 298 | struct mmc_request *mrq = host->mrq; |
| 299 | 299 | ||
| 300 | host->mrq = NULL; | 300 | host->mrq = NULL; |
| 301 | mmc_omap_fclk_lazy_disable(host); | ||
| 302 | mmc_request_done(host->mmc, mrq); | 301 | mmc_request_done(host->mmc, mrq); |
| 303 | return; | 302 | return; |
| 304 | } | 303 | } |
| @@ -434,6 +433,8 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id) | |||
| 434 | if (host->mrq == NULL) { | 433 | if (host->mrq == NULL) { |
| 435 | OMAP_HSMMC_WRITE(host->base, STAT, | 434 | OMAP_HSMMC_WRITE(host->base, STAT, |
| 436 | OMAP_HSMMC_READ(host->base, STAT)); | 435 | OMAP_HSMMC_READ(host->base, STAT)); |
| 436 | /* Flush posted write */ | ||
| 437 | OMAP_HSMMC_READ(host->base, STAT); | ||
| 437 | return IRQ_HANDLED; | 438 | return IRQ_HANDLED; |
| 438 | } | 439 | } |
| 439 | 440 | ||
| @@ -489,8 +490,10 @@ static irqreturn_t mmc_omap_irq(int irq, void *dev_id) | |||
| 489 | } | 490 | } |
| 490 | 491 | ||
| 491 | OMAP_HSMMC_WRITE(host->base, STAT, status); | 492 | OMAP_HSMMC_WRITE(host->base, STAT, status); |
| 493 | /* Flush posted write */ | ||
| 494 | OMAP_HSMMC_READ(host->base, STAT); | ||
| 492 | 495 | ||
| 493 | if (end_cmd || (status & CC)) | 496 | if (end_cmd || ((status & CC) && host->cmd)) |
| 494 | mmc_omap_cmd_done(host, host->cmd); | 497 | mmc_omap_cmd_done(host, host->cmd); |
| 495 | if (end_trans || (status & TC)) | 498 | if (end_trans || (status & TC)) |
| 496 | mmc_omap_xfer_done(host, data); | 499 | mmc_omap_xfer_done(host, data); |
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c index c5b316e22371..cd37962ec44f 100644 --- a/drivers/mmc/host/sdhci-pci.c +++ b/drivers/mmc/host/sdhci-pci.c | |||
| @@ -729,6 +729,6 @@ static void __exit sdhci_drv_exit(void) | |||
| 729 | module_init(sdhci_drv_init); | 729 | module_init(sdhci_drv_init); |
| 730 | module_exit(sdhci_drv_exit); | 730 | module_exit(sdhci_drv_exit); |
| 731 | 731 | ||
| 732 | MODULE_AUTHOR("Pierre Ossman <drzeus@drzeus.cx>"); | 732 | MODULE_AUTHOR("Pierre Ossman <pierre@ossman.eu>"); |
| 733 | MODULE_DESCRIPTION("Secure Digital Host Controller Interface PCI driver"); | 733 | MODULE_DESCRIPTION("Secure Digital Host Controller Interface PCI driver"); |
| 734 | MODULE_LICENSE("GPL"); | 734 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 30d8e3d4e6fd..9234be2226e7 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
| @@ -1935,7 +1935,7 @@ module_exit(sdhci_drv_exit); | |||
| 1935 | 1935 | ||
| 1936 | module_param(debug_quirks, uint, 0444); | 1936 | module_param(debug_quirks, uint, 0444); |
| 1937 | 1937 | ||
| 1938 | MODULE_AUTHOR("Pierre Ossman <drzeus@drzeus.cx>"); | 1938 | MODULE_AUTHOR("Pierre Ossman <pierre@ossman.eu>"); |
| 1939 | MODULE_DESCRIPTION("Secure Digital Host Controller Interface core driver"); | 1939 | MODULE_DESCRIPTION("Secure Digital Host Controller Interface core driver"); |
| 1940 | MODULE_LICENSE("GPL"); | 1940 | MODULE_LICENSE("GPL"); |
| 1941 | 1941 | ||
diff --git a/drivers/mmc/host/wbsd.c b/drivers/mmc/host/wbsd.c index adda37952032..89bf8cd25cac 100644 --- a/drivers/mmc/host/wbsd.c +++ b/drivers/mmc/host/wbsd.c | |||
| @@ -2036,7 +2036,7 @@ module_param_named(irq, param_irq, uint, 0444); | |||
| 2036 | module_param_named(dma, param_dma, int, 0444); | 2036 | module_param_named(dma, param_dma, int, 0444); |
| 2037 | 2037 | ||
| 2038 | MODULE_LICENSE("GPL"); | 2038 | MODULE_LICENSE("GPL"); |
| 2039 | MODULE_AUTHOR("Pierre Ossman <drzeus@drzeus.cx>"); | 2039 | MODULE_AUTHOR("Pierre Ossman <pierre@ossman.eu>"); |
| 2040 | MODULE_DESCRIPTION("Winbond W83L51xD SD/MMC card interface driver"); | 2040 | MODULE_DESCRIPTION("Winbond W83L51xD SD/MMC card interface driver"); |
| 2041 | 2041 | ||
| 2042 | #ifdef CONFIG_PNP | 2042 | #ifdef CONFIG_PNP |
