EmbeddedPkg: MmcDxe: wait OCR busy bit free

According to eMMC spec, OCR.PowerUp bit is also busy bit. If the busy
bit is '0', CMD1 should be sent and OCR should be fetched again. And add
a timeout counter on the repeated steps.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
Tested-by: Ryan Harkin <ryan.harkin@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
This commit is contained in:
Haojian Zhuang 2016-11-13 14:47:50 +08:00 committed by Leif Lindholm
parent bab82372a9
commit 3201075377
1 changed files with 8 additions and 3 deletions

View File

@ -222,14 +222,19 @@ MmcIdentificationMode (
// Send CMD1 to get OCR (MMC) // Send CMD1 to get OCR (MMC)
// This command only valid for MMC and eMMC // This command only valid for MMC and eMMC
Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, EMMC_CMD1_CAPACITY_GREATER_THAN_2GB); Timeout = MAX_RETRY_COUNT;
if (Status == EFI_SUCCESS) { do {
Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, EMMC_CMD1_CAPACITY_GREATER_THAN_2GB);
if (EFI_ERROR (Status))
break;
Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, (UINT32 *)&OcrResponse); Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, (UINT32 *)&OcrResponse);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Failed to receive OCR, Status=%r.\n", Status)); DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Failed to receive OCR, Status=%r.\n", Status));
return Status; return Status;
} }
Timeout--;
} while (!OcrResponse.Ocr.PowerUp && (Timeout > 0));
if (Status == EFI_SUCCESS) {
if (!OcrResponse.Ocr.PowerUp) { if (!OcrResponse.Ocr.PowerUp) {
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD1): Card initialisation failure, Status=%r.\n", Status)); DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD1): Card initialisation failure, Status=%r.\n", Status));
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;