aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/host/imxmmc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/host/imxmmc.c')
-rw-r--r--drivers/mmc/host/imxmmc.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/drivers/mmc/host/imxmmc.c b/drivers/mmc/host/imxmmc.c
index 54bfc9f25596..6ebc41e7592c 100644
--- a/drivers/mmc/host/imxmmc.c
+++ b/drivers/mmc/host/imxmmc.c
@@ -428,11 +428,11 @@ static int imxmci_finish_data(struct imxmci_host *host, unsigned int stat)
428 if ( stat & STATUS_ERR_MASK ) { 428 if ( stat & STATUS_ERR_MASK ) {
429 dev_dbg(mmc_dev(host->mmc), "request failed. status: 0x%08x\n",stat); 429 dev_dbg(mmc_dev(host->mmc), "request failed. status: 0x%08x\n",stat);
430 if(stat & (STATUS_CRC_READ_ERR | STATUS_CRC_WRITE_ERR)) 430 if(stat & (STATUS_CRC_READ_ERR | STATUS_CRC_WRITE_ERR))
431 data->error = MMC_ERR_BADCRC; 431 data->error = -EILSEQ;
432 else if(stat & STATUS_TIME_OUT_READ) 432 else if(stat & STATUS_TIME_OUT_READ)
433 data->error = MMC_ERR_TIMEOUT; 433 data->error = -ETIMEDOUT;
434 else 434 else
435 data->error = MMC_ERR_FAILED; 435 data->error = -EIO;
436 } else { 436 } else {
437 data->bytes_xfered = host->dma_size; 437 data->bytes_xfered = host->dma_size;
438 } 438 }
@@ -458,10 +458,10 @@ static int imxmci_cmd_done(struct imxmci_host *host, unsigned int stat)
458 458
459 if (stat & STATUS_TIME_OUT_RESP) { 459 if (stat & STATUS_TIME_OUT_RESP) {
460 dev_dbg(mmc_dev(host->mmc), "CMD TIMEOUT\n"); 460 dev_dbg(mmc_dev(host->mmc), "CMD TIMEOUT\n");
461 cmd->error = MMC_ERR_TIMEOUT; 461 cmd->error = -ETIMEDOUT;
462 } else if (stat & STATUS_RESP_CRC_ERR && cmd->flags & MMC_RSP_CRC) { 462 } else if (stat & STATUS_RESP_CRC_ERR && cmd->flags & MMC_RSP_CRC) {
463 dev_dbg(mmc_dev(host->mmc), "cmd crc error\n"); 463 dev_dbg(mmc_dev(host->mmc), "cmd crc error\n");
464 cmd->error = MMC_ERR_BADCRC; 464 cmd->error = -EILSEQ;
465 } 465 }
466 466
467 if(cmd->flags & MMC_RSP_PRESENT) { 467 if(cmd->flags & MMC_RSP_PRESENT) {
@@ -482,7 +482,7 @@ static int imxmci_cmd_done(struct imxmci_host *host, unsigned int stat)
482 dev_dbg(mmc_dev(host->mmc), "RESP 0x%08x, 0x%08x, 0x%08x, 0x%08x, error %d\n", 482 dev_dbg(mmc_dev(host->mmc), "RESP 0x%08x, 0x%08x, 0x%08x, 0x%08x, error %d\n",
483 cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3], cmd->error); 483 cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3], cmd->error);
484 484
485 if (data && (cmd->error == MMC_ERR_NONE) && !(stat & STATUS_ERR_MASK)) { 485 if (data && !cmd->error && !(stat & STATUS_ERR_MASK)) {
486 if (host->req->data->flags & MMC_DATA_WRITE) { 486 if (host->req->data->flags & MMC_DATA_WRITE) {
487 487
488 /* Wait for FIFO to be empty before starting DMA write */ 488 /* Wait for FIFO to be empty before starting DMA write */
@@ -491,7 +491,7 @@ static int imxmci_cmd_done(struct imxmci_host *host, unsigned int stat)
491 if(imxmci_busy_wait_for_status(host, &stat, 491 if(imxmci_busy_wait_for_status(host, &stat,
492 STATUS_APPL_BUFF_FE, 492 STATUS_APPL_BUFF_FE,
493 40, "imxmci_cmd_done DMA WR") < 0) { 493 40, "imxmci_cmd_done DMA WR") < 0) {
494 cmd->error = MMC_ERR_FIFO; 494 cmd->error = -EIO;
495 imxmci_finish_data(host, stat); 495 imxmci_finish_data(host, stat);
496 if(host->req) 496 if(host->req)
497 imxmci_finish_request(host, host->req); 497 imxmci_finish_request(host, host->req);
@@ -884,9 +884,21 @@ static void imxmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
884 } 884 }
885} 885}
886 886
887static int imxmci_get_ro(struct mmc_host *mmc)
888{
889 struct imxmci_host *host = mmc_priv(mmc);
890
891 if (host->pdata && host->pdata->get_ro)
892 return host->pdata->get_ro(mmc_dev(mmc));
893 /* Host doesn't support read only detection so assume writeable */
894 return 0;
895}
896
897
887static const struct mmc_host_ops imxmci_ops = { 898static const struct mmc_host_ops imxmci_ops = {
888 .request = imxmci_request, 899 .request = imxmci_request,
889 .set_ios = imxmci_set_ios, 900 .set_ios = imxmci_set_ios,
901 .get_ro = imxmci_get_ro,
890}; 902};
891 903
892static struct resource *platform_device_resource(struct platform_device *dev, unsigned int mask, int nr) 904static struct resource *platform_device_resource(struct platform_device *dev, unsigned int mask, int nr)
@@ -913,7 +925,7 @@ static void imxmci_check_status(unsigned long data)
913{ 925{
914 struct imxmci_host *host = (struct imxmci_host *)data; 926 struct imxmci_host *host = (struct imxmci_host *)data;
915 927
916 if( host->pdata->card_present() != host->present ) { 928 if( host->pdata->card_present(mmc_dev(host->mmc)) != host->present ) {
917 host->present ^= 1; 929 host->present ^= 1;
918 dev_info(mmc_dev(host->mmc), "card %s\n", 930 dev_info(mmc_dev(host->mmc), "card %s\n",
919 host->present ? "inserted" : "removed"); 931 host->present ? "inserted" : "removed");
@@ -963,7 +975,7 @@ static int imxmci_probe(struct platform_device *pdev)
963 mmc->f_min = 150000; 975 mmc->f_min = 150000;
964 mmc->f_max = CLK_RATE/2; 976 mmc->f_max = CLK_RATE/2;
965 mmc->ocr_avail = MMC_VDD_32_33; 977 mmc->ocr_avail = MMC_VDD_32_33;
966 mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_BYTEBLOCK; 978 mmc->caps = MMC_CAP_4_BIT_DATA;
967 979
968 /* MMC core transfer sizes tunable parameters */ 980 /* MMC core transfer sizes tunable parameters */
969 mmc->max_hw_segs = 64; 981 mmc->max_hw_segs = 64;
@@ -1022,7 +1034,7 @@ static int imxmci_probe(struct platform_device *pdev)
1022 if (ret) 1034 if (ret)
1023 goto out; 1035 goto out;
1024 1036
1025 host->present = host->pdata->card_present(); 1037 host->present = host->pdata->card_present(mmc_dev(mmc));
1026 init_timer(&host->timer); 1038 init_timer(&host->timer);
1027 host->timer.data = (unsigned long)host; 1039 host->timer.data = (unsigned long)host;
1028 host->timer.function = imxmci_check_status; 1040 host->timer.function = imxmci_check_status;