do {\r
Status = EmmcSendTuningBlk (PassThru, Slot, BusWidth);\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR, "EmmcTuningClkForHs200: Send tuning block fails with %r\n", Status));\r
+ DEBUG ((DEBUG_ERROR, "EmmcTuningClkForHs200: Send tuning block fails with %r\n", Status));\r
return Status;\r
}\r
\r
}\r
} while (++Retry < 40);\r
\r
- DEBUG ((EFI_D_ERROR, "EmmcTuningClkForHs200: Send tuning block fails at %d times with HostCtrl2 %02x\n", Retry, HostCtrl2));\r
+ DEBUG ((DEBUG_ERROR, "EmmcTuningClkForHs200: Send tuning block fails at %d times with HostCtrl2 %02x\n", Retry, HostCtrl2));\r
//\r
// Abort the tuning procedure and reset the tuning circuit.\r
//\r
CmdSet = 0;\r
Status = EmmcSwitch (PassThru, Slot, Access, Index, Value, CmdSet);\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR, "EmmcSwitchBusWidth: Switch to bus width %d fails with %r\n", BusWidth, Status));\r
+ DEBUG ((DEBUG_ERROR, "EmmcSwitchBusWidth: Switch to bus width %d fails with %r\n", BusWidth, Status));\r
return Status;\r
}\r
\r
Status = EmmcSendStatus (PassThru, Slot, Rca, &DevStatus);\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR, "EmmcSwitchBusWidth: Send status fails with %r\n", Status));\r
+ DEBUG ((DEBUG_ERROR, "EmmcSwitchBusWidth: Send status fails with %r\n", Status));\r
return Status;\r
}\r
//\r
// Check the switch operation is really successful or not.\r
//\r
if ((DevStatus & BIT7) != 0) {\r
- DEBUG ((EFI_D_ERROR, "EmmcSwitchBusWidth: The switch operation fails as DevStatus is 0x%08x\n", DevStatus));\r
+ DEBUG ((DEBUG_ERROR, "EmmcSwitchBusWidth: The switch operation fails as DevStatus is 0x%08x\n", DevStatus));\r
return EFI_DEVICE_ERROR;\r
}\r
\r
\r
Status = EmmcSwitch (PassThru, Slot, Access, Index, Value, CmdSet);\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR, "EmmcSwitchClockFreq: Switch to hstiming %d fails with %r\n", HsTiming, Status));\r
+ DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: Switch to hstiming %d fails with %r\n", HsTiming, Status));\r
return Status;\r
}\r
\r
Status = EmmcSendStatus (PassThru, Slot, Rca, &DevStatus);\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR, "EmmcSwitchClockFreq: Send status fails with %r\n", Status));\r
+ DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: Send status fails with %r\n", Status));\r
return Status;\r
}\r
//\r
// Check the switch operation is really successful or not.\r
//\r
if ((DevStatus & BIT7) != 0) {\r
- DEBUG ((EFI_D_ERROR, "EmmcSwitchClockFreq: The switch operation fails as DevStatus is 0x%08x\n", DevStatus));\r
+ DEBUG ((DEBUG_ERROR, "EmmcSwitchClockFreq: The switch operation fails as DevStatus is 0x%08x\n", DevStatus));\r
return EFI_DEVICE_ERROR;\r
}\r
//\r
\r
HsTiming = 1;\r
Status = EmmcSwitchClockFreq (PciIo, PassThru, Slot, Rca, HsTiming, ClockFreq);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
\r
return Status;\r
}\r
\r
Status = EmmcGetCsd (PassThru, Slot, Rca, &Csd);\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR, "EmmcSetBusMode: GetCsd fails with %r\n", Status));\r
+ DEBUG ((DEBUG_ERROR, "EmmcSetBusMode: GetCsd fails with %r\n", Status));\r
return Status;\r
}\r
\r
Status = EmmcSelect (PassThru, Slot, Rca);\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR, "EmmcSetBusMode: Select fails with %r\n", Status));\r
+ DEBUG ((DEBUG_ERROR, "EmmcSetBusMode: Select fails with %r\n", Status));\r
return Status;\r
}\r
\r
//\r
Status = EmmcGetExtCsd (PassThru, Slot, &ExtCsd);\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR, "EmmcSetBusMode: GetExtCsd fails with %r\n", Status));\r
+ DEBUG ((DEBUG_ERROR, "EmmcSetBusMode: GetExtCsd fails with %r\n", Status));\r
return Status;\r
}\r
//\r
return EFI_SUCCESS;\r
}\r
\r
- DEBUG ((EFI_D_INFO, "EmmcSetBusMode: HsTiming %d ClockFreq %d BusWidth %d Ddr %a\n", HsTiming, ClockFreq, BusWidth, IsDdr ? "TRUE":"FALSE"));\r
+ DEBUG ((DEBUG_INFO, "EmmcSetBusMode: HsTiming %d ClockFreq %d BusWidth %d Ddr %a\n", HsTiming, ClockFreq, BusWidth, IsDdr ? "TRUE":"FALSE"));\r
\r
if (HsTiming == 3) {\r
//\r
Status = EmmcSwitchToHighSpeed (PciIo, PassThru, Slot, Rca, ClockFreq, IsDdr, BusWidth);\r
}\r
\r
- DEBUG ((EFI_D_INFO, "EmmcSetBusMode: Switch to %a %r\n", (HsTiming == 3) ? "HS400" : ((HsTiming == 2) ? "HS200" : "HighSpeed"), Status));\r
+ DEBUG ((DEBUG_INFO, "EmmcSetBusMode: Switch to %a %r\n", (HsTiming == 3) ? "HS400" : ((HsTiming == 2) ? "HS200" : "HighSpeed"), Status));\r
\r
return Status;\r
}\r
EFI_SD_MMC_PASS_THRU_PROTOCOL *PassThru;\r
UINT32 Ocr;\r
UINT16 Rca;\r
+ UINTN Retry;\r
\r
PciIo = Private->PciIo;\r
PassThru = &Private->PassThru;\r
\r
Status = EmmcReset (PassThru, Slot);\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_VERBOSE, "EmmcIdentification: Executing Cmd0 fails with %r\n", Status));\r
+ DEBUG ((DEBUG_VERBOSE, "EmmcIdentification: Executing Cmd0 fails with %r\n", Status));\r
return Status;\r
}\r
\r
- Ocr = 0;\r
+ Ocr = 0;\r
+ Retry = 0;\r
do {\r
Status = EmmcGetOcr (PassThru, Slot, &Ocr);\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_VERBOSE, "EmmcIdentification: Executing Cmd1 fails with %r\n", Status));\r
+ DEBUG ((DEBUG_VERBOSE, "EmmcIdentification: Executing Cmd1 fails with %r\n", Status));\r
return Status;\r
}\r
Ocr |= BIT30;\r
+\r
+ if (Retry++ == 100) {\r
+ DEBUG ((DEBUG_VERBOSE, "EmmcIdentification: Executing Cmd1 fails too many times\n"));\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+ gBS->Stall(10 * 1000);\r
} while ((Ocr & BIT31) == 0);\r
\r
Status = EmmcGetAllCid (PassThru, Slot);\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_VERBOSE, "EmmcIdentification: Executing Cmd2 fails with %r\n", Status));\r
+ DEBUG ((DEBUG_VERBOSE, "EmmcIdentification: Executing Cmd2 fails with %r\n", Status));\r
return Status;\r
}\r
//\r
Rca = Slot + 1;\r
Status = EmmcSetRca (PassThru, Slot, Rca);\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR, "EmmcIdentification: Executing Cmd3 fails with %r\n", Status));\r
+ DEBUG ((DEBUG_ERROR, "EmmcIdentification: Executing Cmd3 fails with %r\n", Status));\r
return Status;\r
}\r
//\r
// Enter Data Tranfer Mode.\r
//\r
- DEBUG ((EFI_D_INFO, "EmmcIdentification: Found a EMMC device at slot [%d], RCA [%d]\n", Slot, Rca));\r
+ DEBUG ((DEBUG_INFO, "EmmcIdentification: Found a EMMC device at slot [%d], RCA [%d]\n", Slot, Rca));\r
Private->Slot[Slot].CardType = EmmcCardType;\r
\r
Status = EmmcSetBusMode (PciIo, PassThru, Slot, Rca);\r