diff options
Diffstat (limited to 'drivers/mmc/mmc.c')
-rw-r--r-- | drivers/mmc/mmc.c | 63 |
1 files changed, 41 insertions, 22 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index da6ddd910fc5..6201f3086a02 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c | |||
@@ -59,21 +59,23 @@ static const unsigned int tacc_mant[] = { | |||
59 | 59 | ||
60 | 60 | ||
61 | /** | 61 | /** |
62 | * mmc_request_done - finish processing an MMC command | 62 | * mmc_request_done - finish processing an MMC request |
63 | * @host: MMC host which completed command | 63 | * @host: MMC host which completed request |
64 | * @mrq: MMC request which completed | 64 | * @mrq: MMC request which request |
65 | * | 65 | * |
66 | * MMC drivers should call this function when they have completed | 66 | * MMC drivers should call this function when they have completed |
67 | * their processing of a command. This should be called before the | 67 | * their processing of a request. |
68 | * data part of the command has completed. | ||
69 | */ | 68 | */ |
70 | void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) | 69 | void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) |
71 | { | 70 | { |
72 | struct mmc_command *cmd = mrq->cmd; | 71 | struct mmc_command *cmd = mrq->cmd; |
73 | int err = mrq->cmd->error; | 72 | int err = cmd->error; |
74 | pr_debug("MMC: req done (%02x): %d: %08x %08x %08x %08x\n", | 73 | |
75 | cmd->opcode, err, cmd->resp[0], cmd->resp[1], | 74 | pr_debug("%s: req done (CMD%u): %d/%d/%d: %08x %08x %08x %08x\n", |
76 | cmd->resp[2], cmd->resp[3]); | 75 | mmc_hostname(host), cmd->opcode, err, |
76 | mrq->data ? mrq->data->error : 0, | ||
77 | mrq->stop ? mrq->stop->error : 0, | ||
78 | cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]); | ||
77 | 79 | ||
78 | if (err && cmd->retries) { | 80 | if (err && cmd->retries) { |
79 | cmd->retries--; | 81 | cmd->retries--; |
@@ -97,8 +99,9 @@ EXPORT_SYMBOL(mmc_request_done); | |||
97 | void | 99 | void |
98 | mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) | 100 | mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) |
99 | { | 101 | { |
100 | pr_debug("MMC: starting cmd %02x arg %08x flags %08x\n", | 102 | pr_debug("%s: starting CMD%u arg %08x flags %08x\n", |
101 | mrq->cmd->opcode, mrq->cmd->arg, mrq->cmd->flags); | 103 | mmc_hostname(host), mrq->cmd->opcode, |
104 | mrq->cmd->arg, mrq->cmd->flags); | ||
102 | 105 | ||
103 | WARN_ON(host->card_busy == NULL); | 106 | WARN_ON(host->card_busy == NULL); |
104 | 107 | ||
@@ -312,6 +315,18 @@ void mmc_release_host(struct mmc_host *host) | |||
312 | 315 | ||
313 | EXPORT_SYMBOL(mmc_release_host); | 316 | EXPORT_SYMBOL(mmc_release_host); |
314 | 317 | ||
318 | static inline void mmc_set_ios(struct mmc_host *host) | ||
319 | { | ||
320 | struct mmc_ios *ios = &host->ios; | ||
321 | |||
322 | pr_debug("%s: clock %uHz busmode %u powermode %u cs %u Vdd %u width %u\n", | ||
323 | mmc_hostname(host), ios->clock, ios->bus_mode, | ||
324 | ios->power_mode, ios->chip_select, ios->vdd, | ||
325 | ios->bus_width); | ||
326 | |||
327 | host->ops->set_ios(host, ios); | ||
328 | } | ||
329 | |||
315 | static int mmc_select_card(struct mmc_host *host, struct mmc_card *card) | 330 | static int mmc_select_card(struct mmc_host *host, struct mmc_card *card) |
316 | { | 331 | { |
317 | int err; | 332 | int err; |
@@ -364,7 +379,7 @@ static int mmc_select_card(struct mmc_host *host, struct mmc_card *card) | |||
364 | } | 379 | } |
365 | } | 380 | } |
366 | 381 | ||
367 | host->ops->set_ios(host, &host->ios); | 382 | mmc_set_ios(host); |
368 | 383 | ||
369 | return MMC_ERR_NONE; | 384 | return MMC_ERR_NONE; |
370 | } | 385 | } |
@@ -415,7 +430,7 @@ static u32 mmc_select_voltage(struct mmc_host *host, u32 ocr) | |||
415 | ocr = 3 << bit; | 430 | ocr = 3 << bit; |
416 | 431 | ||
417 | host->ios.vdd = bit; | 432 | host->ios.vdd = bit; |
418 | host->ops->set_ios(host, &host->ios); | 433 | mmc_set_ios(host); |
419 | } else { | 434 | } else { |
420 | ocr = 0; | 435 | ocr = 0; |
421 | } | 436 | } |
@@ -549,6 +564,7 @@ static void mmc_decode_csd(struct mmc_card *card) | |||
549 | csd->read_partial = UNSTUFF_BITS(resp, 79, 1); | 564 | csd->read_partial = UNSTUFF_BITS(resp, 79, 1); |
550 | csd->write_misalign = UNSTUFF_BITS(resp, 78, 1); | 565 | csd->write_misalign = UNSTUFF_BITS(resp, 78, 1); |
551 | csd->read_misalign = UNSTUFF_BITS(resp, 77, 1); | 566 | csd->read_misalign = UNSTUFF_BITS(resp, 77, 1); |
567 | csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3); | ||
552 | csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4); | 568 | csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4); |
553 | csd->write_partial = UNSTUFF_BITS(resp, 21, 1); | 569 | csd->write_partial = UNSTUFF_BITS(resp, 21, 1); |
554 | } else { | 570 | } else { |
@@ -583,6 +599,7 @@ static void mmc_decode_csd(struct mmc_card *card) | |||
583 | csd->read_partial = UNSTUFF_BITS(resp, 79, 1); | 599 | csd->read_partial = UNSTUFF_BITS(resp, 79, 1); |
584 | csd->write_misalign = UNSTUFF_BITS(resp, 78, 1); | 600 | csd->write_misalign = UNSTUFF_BITS(resp, 78, 1); |
585 | csd->read_misalign = UNSTUFF_BITS(resp, 77, 1); | 601 | csd->read_misalign = UNSTUFF_BITS(resp, 77, 1); |
602 | csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3); | ||
586 | csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4); | 603 | csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4); |
587 | csd->write_partial = UNSTUFF_BITS(resp, 21, 1); | 604 | csd->write_partial = UNSTUFF_BITS(resp, 21, 1); |
588 | } | 605 | } |
@@ -666,7 +683,7 @@ static void mmc_idle_cards(struct mmc_host *host) | |||
666 | struct mmc_command cmd; | 683 | struct mmc_command cmd; |
667 | 684 | ||
668 | host->ios.chip_select = MMC_CS_HIGH; | 685 | host->ios.chip_select = MMC_CS_HIGH; |
669 | host->ops->set_ios(host, &host->ios); | 686 | mmc_set_ios(host); |
670 | 687 | ||
671 | mmc_delay(1); | 688 | mmc_delay(1); |
672 | 689 | ||
@@ -679,7 +696,7 @@ static void mmc_idle_cards(struct mmc_host *host) | |||
679 | mmc_delay(1); | 696 | mmc_delay(1); |
680 | 697 | ||
681 | host->ios.chip_select = MMC_CS_DONTCARE; | 698 | host->ios.chip_select = MMC_CS_DONTCARE; |
682 | host->ops->set_ios(host, &host->ios); | 699 | mmc_set_ios(host); |
683 | 700 | ||
684 | mmc_delay(1); | 701 | mmc_delay(1); |
685 | } | 702 | } |
@@ -704,13 +721,13 @@ static void mmc_power_up(struct mmc_host *host) | |||
704 | host->ios.chip_select = MMC_CS_DONTCARE; | 721 | host->ios.chip_select = MMC_CS_DONTCARE; |
705 | host->ios.power_mode = MMC_POWER_UP; | 722 | host->ios.power_mode = MMC_POWER_UP; |
706 | host->ios.bus_width = MMC_BUS_WIDTH_1; | 723 | host->ios.bus_width = MMC_BUS_WIDTH_1; |
707 | host->ops->set_ios(host, &host->ios); | 724 | mmc_set_ios(host); |
708 | 725 | ||
709 | mmc_delay(1); | 726 | mmc_delay(1); |
710 | 727 | ||
711 | host->ios.clock = host->f_min; | 728 | host->ios.clock = host->f_min; |
712 | host->ios.power_mode = MMC_POWER_ON; | 729 | host->ios.power_mode = MMC_POWER_ON; |
713 | host->ops->set_ios(host, &host->ios); | 730 | mmc_set_ios(host); |
714 | 731 | ||
715 | mmc_delay(2); | 732 | mmc_delay(2); |
716 | } | 733 | } |
@@ -723,7 +740,7 @@ static void mmc_power_off(struct mmc_host *host) | |||
723 | host->ios.chip_select = MMC_CS_DONTCARE; | 740 | host->ios.chip_select = MMC_CS_DONTCARE; |
724 | host->ios.power_mode = MMC_POWER_OFF; | 741 | host->ios.power_mode = MMC_POWER_OFF; |
725 | host->ios.bus_width = MMC_BUS_WIDTH_1; | 742 | host->ios.bus_width = MMC_BUS_WIDTH_1; |
726 | host->ops->set_ios(host, &host->ios); | 743 | mmc_set_ios(host); |
727 | } | 744 | } |
728 | 745 | ||
729 | static int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) | 746 | static int mmc_send_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr) |
@@ -934,6 +951,7 @@ static void mmc_read_scrs(struct mmc_host *host) | |||
934 | data.timeout_ns = card->csd.tacc_ns * 10; | 951 | data.timeout_ns = card->csd.tacc_ns * 10; |
935 | data.timeout_clks = card->csd.tacc_clks * 10; | 952 | data.timeout_clks = card->csd.tacc_clks * 10; |
936 | data.blksz_bits = 3; | 953 | data.blksz_bits = 3; |
954 | data.blksz = 1 << 3; | ||
937 | data.blocks = 1; | 955 | data.blocks = 1; |
938 | data.flags = MMC_DATA_READ; | 956 | data.flags = MMC_DATA_READ; |
939 | data.sg = &sg; | 957 | data.sg = &sg; |
@@ -971,7 +989,8 @@ static unsigned int mmc_calculate_clock(struct mmc_host *host) | |||
971 | if (!mmc_card_dead(card) && max_dtr > card->csd.max_dtr) | 989 | if (!mmc_card_dead(card) && max_dtr > card->csd.max_dtr) |
972 | max_dtr = card->csd.max_dtr; | 990 | max_dtr = card->csd.max_dtr; |
973 | 991 | ||
974 | pr_debug("MMC: selected %d.%03dMHz transfer rate\n", | 992 | pr_debug("%s: selected %d.%03dMHz transfer rate\n", |
993 | mmc_hostname(host), | ||
975 | max_dtr / 1000000, (max_dtr / 1000) % 1000); | 994 | max_dtr / 1000000, (max_dtr / 1000) % 1000); |
976 | 995 | ||
977 | return max_dtr; | 996 | return max_dtr; |
@@ -1046,7 +1065,7 @@ static void mmc_setup(struct mmc_host *host) | |||
1046 | } else { | 1065 | } else { |
1047 | host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; | 1066 | host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN; |
1048 | host->ios.clock = host->f_min; | 1067 | host->ios.clock = host->f_min; |
1049 | host->ops->set_ios(host, &host->ios); | 1068 | mmc_set_ios(host); |
1050 | 1069 | ||
1051 | /* | 1070 | /* |
1052 | * We should remember the OCR mask from the existing | 1071 | * We should remember the OCR mask from the existing |
@@ -1082,7 +1101,7 @@ static void mmc_setup(struct mmc_host *host) | |||
1082 | * Ok, now switch to push-pull mode. | 1101 | * Ok, now switch to push-pull mode. |
1083 | */ | 1102 | */ |
1084 | host->ios.bus_mode = MMC_BUSMODE_PUSHPULL; | 1103 | host->ios.bus_mode = MMC_BUSMODE_PUSHPULL; |
1085 | host->ops->set_ios(host, &host->ios); | 1104 | mmc_set_ios(host); |
1086 | 1105 | ||
1087 | mmc_read_csds(host); | 1106 | mmc_read_csds(host); |
1088 | 1107 | ||
@@ -1128,7 +1147,7 @@ static void mmc_rescan(void *data) | |||
1128 | * attached cards and the host support. | 1147 | * attached cards and the host support. |
1129 | */ | 1148 | */ |
1130 | host->ios.clock = mmc_calculate_clock(host); | 1149 | host->ios.clock = mmc_calculate_clock(host); |
1131 | host->ops->set_ios(host, &host->ios); | 1150 | mmc_set_ios(host); |
1132 | } | 1151 | } |
1133 | 1152 | ||
1134 | mmc_release_host(host); | 1153 | mmc_release_host(host); |