]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg: MmcDxe: wait OCR busy bit free
authorHaojian Zhuang <haojian.zhuang@linaro.org>
Sun, 13 Nov 2016 06:47:50 +0000 (14:47 +0800)
committerLeif Lindholm <leif.lindholm@linaro.org>
Mon, 14 Nov 2016 15:45:08 +0000 (15:45 +0000)
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>
EmbeddedPkg/Universal/MmcDxe/MmcIdentification.c

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