aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core/sd.c
diff options
context:
space:
mode:
authorArindam Nath <arindam.nath@amd.com>2011-05-05 02:48:57 -0400
committerChris Ball <cjb@laptop.org>2011-05-24 21:04:38 -0400
commitf2119df6b764609af4baceb68caf1e848c1c8aa7 (patch)
tree3c234b150d7add419cd07e15929b94b8c3baec63 /drivers/mmc/core/sd.c
parentcb87ea28ed9e75a41eb456bfcb547b4e6f10e750 (diff)
mmc: sd: add support for signal voltage switch procedure
Host Controller v3.00 adds another Capabilities register. Apart from other things, this new register indicates whether the Host Controller supports SDR50, SDR104, and DDR50 UHS-I modes. The spec doesn't mention about explicit support for SDR12 and SDR25 UHS-I modes, so the Host Controller v3.00 should support them by default. Also if the controller supports SDR104 mode, it will also support SDR50 mode as well. So depending on the host support, we set the corresponding MMC_CAP_* flags. One more new register. Host Control2 is added in v3.00, which is used during Signal Voltage Switch procedure described below. Since as per v3.00 spec, UHS-I supported hosts should set S18R to 1, we set S18R (bit 24) of OCR before sending ACMD41. We also need to set XPC (bit 28) of OCR in case the host can supply >150mA. This support is indicated by the Maximum Current Capabilities register of the Host Controller. If the response of ACMD41 has both CCS and S18A set, we start the signal voltage switch procedure, which if successfull, will switch the card from 3.3V signalling to 1.8V signalling. Signal voltage switch procedure adds support for a new command CMD11 in the Physical Layer Spec v3.01. As part of this procedure, we need to set 1.8V Signalling Enable (bit 3) of Host Control2 register, which if remains set after 5ms, means the switch to 1.8V signalling is successfull. Otherwise, we clear bit 24 of OCR and retry the initialization sequence. When we remove the card, and insert the same or another card, we need to make sure that we start with 3.3V signalling voltage. So we call mmc_set_signal_voltage() with MMC_SIGNAL_VOLTAGE_330 set so that we are back to 3.3V signalling voltage before we actually start initializing the card. Tested by Zhangfei Gao with a Toshiba uhs card and general hs card, on mmp2 in SDMA mode. Signed-off-by: Arindam Nath <arindam.nath@amd.com> Reviewed-by: Philip Rakity <prakity@marvell.com> Tested-by: Philip Rakity <prakity@marvell.com> Acked-by: Zhangfei Gao <zhangfei.gao@marvell.com> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc/core/sd.c')
-rw-r--r--drivers/mmc/core/sd.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 6dac89fe0535..b0cd285d272a 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -403,6 +403,7 @@ struct device_type sd_type = {
403int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid) 403int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid)
404{ 404{
405 int err; 405 int err;
406 u32 rocr;
406 407
407 /* 408 /*
408 * Since we're changing the OCR value, we seem to 409 * Since we're changing the OCR value, we seem to
@@ -420,12 +421,38 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid)
420 */ 421 */
421 err = mmc_send_if_cond(host, ocr); 422 err = mmc_send_if_cond(host, ocr);
422 if (!err) 423 if (!err)
423 ocr |= 1 << 30; 424 ocr |= SD_OCR_CCS;
424 425
425 err = mmc_send_app_op_cond(host, ocr, NULL); 426 /*
427 * If the host supports one of UHS-I modes, request the card
428 * to switch to 1.8V signaling level.
429 */
430 if (host->caps & (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 |
431 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_DDR50))
432 ocr |= SD_OCR_S18R;
433
434 /* If the host can supply more than 150mA, XPC should be set to 1. */
435 if (host->caps & (MMC_CAP_SET_XPC_330 | MMC_CAP_SET_XPC_300 |
436 MMC_CAP_SET_XPC_180))
437 ocr |= SD_OCR_XPC;
438
439try_again:
440 err = mmc_send_app_op_cond(host, ocr, &rocr);
426 if (err) 441 if (err)
427 return err; 442 return err;
428 443
444 /*
445 * In case CCS and S18A in the response is set, start Signal Voltage
446 * Switch procedure. SPI mode doesn't support CMD11.
447 */
448 if (!mmc_host_is_spi(host) && ((rocr & 0x41000000) == 0x41000000)) {
449 err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180);
450 if (err) {
451 ocr &= ~SD_OCR_S18R;
452 goto try_again;
453 }
454 }
455
429 if (mmc_host_is_spi(host)) 456 if (mmc_host_is_spi(host))
430 err = mmc_send_cid(host, cid); 457 err = mmc_send_cid(host, cid);
431 else 458 else
@@ -773,6 +800,11 @@ int mmc_attach_sd(struct mmc_host *host)
773 BUG_ON(!host); 800 BUG_ON(!host);
774 WARN_ON(!host->claimed); 801 WARN_ON(!host->claimed);
775 802
803 /* Make sure we are at 3.3V signalling voltage */
804 err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330);
805 if (err)
806 return err;
807
776 err = mmc_send_app_op_cond(host, 0, &ocr); 808 err = mmc_send_app_op_cond(host, 0, &ocr);
777 if (err) 809 if (err)
778 return err; 810 return err;