summaryrefslogtreecommitdiffstats
path: root/EmbeddedPkg/Universal
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@linaro.org>2016-11-13 14:47:50 +0800
committerLeif Lindholm <leif.lindholm@linaro.org>2016-11-14 15:45:08 +0000
commit3201075377f80af632465361155f7498c177bad1 (patch)
tree968d2e1ce868c0bae24656dd9b05d3c1c4dda142 /EmbeddedPkg/Universal
parentbab82372a9e6ce066fa725a792e71d07191046ca (diff)
downloadedk2-3201075377f80af632465361155f7498c177bad1.tar.gz
edk2-3201075377f80af632465361155f7498c177bad1.tar.bz2
edk2-3201075377f80af632465361155f7498c177bad1.zip
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>
Diffstat (limited to 'EmbeddedPkg/Universal')
-rw-r--r--EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c
index 2d8038ffe0..0b0a044540 100644
--- a/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c
+++ b/EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c
@@ -222,14 +222,19 @@ MmcIdentificationMode (
// Send CMD1 to get OCR (MMC)
// This command only valid for MMC and eMMC
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, EMMC_CMD1_CAPACITY_GREATER_THAN_2GB);
- if (Status == EFI_SUCCESS) {
+ Timeout = MAX_RETRY_COUNT;
+ 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);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode() : Failed to receive OCR, Status=%r.\n", Status));
return Status;
}
-
+ Timeout--;
+ } while (!OcrResponse.Ocr.PowerUp && (Timeout > 0));
+ if (Status == EFI_SUCCESS) {
if (!OcrResponse.Ocr.PowerUp) {
DEBUG ((EFI_D_ERROR, "MmcIdentificationMode(MMC_CMD1): Card initialisation failure, Status=%r.\n", Status));
return EFI_DEVICE_ERROR;