From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.10796.1642424164071612969 for ; Mon, 17 Jan 2022 04:56:05 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=cGdXFU6U; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: muhammad.aiman.rosli@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1642424164; x=1673960164; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=S8lPstMw3ZtfdXaNVXr/LQjnV13Mx3E1TzyfIrcNHVY=; b=cGdXFU6UY4nt8/WLUYiSpprTG551IZqNdNNVtgCPpyTEAFhDx5ODZeO5 Z/2wp+VcAmOVStIu24JlX0ta9bTcz5BmroAcABaA5+O7S5Tn50xMyWxhK EUjaXO+MSOPT1PGFRkgIIjHTmZbsV8BKsZ4AMseqBaU7enVqBjx37+mLD kCOWTMK1ubKVRxttEUisgZjbZVgw77mTb+q8/ZaE8ueLStZMQbXBrf7xh /tqihmwmtI5yR43AXcFTGTzBXDvT3zfe0+clzrE6rdR9t4+pZ/tOyR2gr MUd9qpFj10rX0jbKzBqKheFXTzSAT5q34u4gyoeTdpoW/oD1pX54PiL2v g==; X-IronPort-AV: E=McAfee;i="6200,9189,10229"; a="244575004" X-IronPort-AV: E=Sophos;i="5.88,295,1635231600"; d="scan'208";a="244575004" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2022 04:56:03 -0800 X-IronPort-AV: E=Sophos;i="5.88,295,1635231600"; d="scan'208";a="476642090" Received: from roslim1-mobl1.gar.corp.intel.com ([10.214.166.63]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2022 04:56:01 -0800 From: "Aiman Rosli" To: devel@edk2.groups.io Cc: Aiman Rosli Subject: [PATCH v2] MdeModulePkg: Enabling OS boot from SD card through UEFI payload Date: Mon, 17 Jan 2022 20:55:35 +0800 Message-Id: <7fbe9337faa69eaacc20f225a5e97d163d97a4c9.1642423955.git.muhammad.aiman.rosli@intel.com> X-Mailer: git-send-email 2.34.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This changes is by adding 50ms delay during voltage switching from 3.3V to 1.8V, plus adding a goto Voltage33Retry for 3.3V checking and retrying. Signed-off-by: Aiman Rosli --- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c index 662f9f483c..527fe7dc20 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c @@ -1213,9 +1213,14 @@ SdCardIdentification ( UINT32 PresentState; UINT8 HostCtrl2; UINTN Retry; + BOOLEAN ForceVoltage33; + + ForceVoltage33 = FALSE; PciIo = Private->PciIo; PassThru = &Private->PassThru; + +Voltage33Retry: // // 1. Send Cmd0 to the device // @@ -1294,6 +1299,14 @@ SdCardIdentification ( return EFI_UNSUPPORTED; } + // + // 1.8V had failed in the previous run, forcing a retry with 3.3V instead + // + if (ForceVoltage33 == TRUE) { + S18r = FALSE; + ForceVoltage33 = FALSE; + } + // // 5. Repeatly send Acmd41 with supply voltage window to the device. // Note here we only support the cards complied with SD physical @@ -1362,13 +1375,17 @@ SdCardIdentification ( goto Error; } - gBS->Stall (1000); + // Workaround to add a delay of 50 ms in order for clock to stabilize before turning on the SD card again. + gBS->Stall (50000); SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE, sizeof (PresentState), &PresentState); if (((PresentState >> 20) & 0xF) != 0xF) { DEBUG ((DEBUG_ERROR, "SdCardIdentification: SwitchVoltage fails with PresentState = 0x%x, It should be 0xF\n", PresentState)); - Status = EFI_DEVICE_ERROR; - goto Error; + Status = SdMmcHcReset (Private, Slot); + Status = SdMmcHcInitHost (Private, Slot); + ForceVoltage33 = TRUE; + DEBUG ((DEBUG_ERROR, "SdCardIdentification: Switching to 1.8V had failed in the previous run, forcing a retry with 3.3V instead\n")); + goto Voltage33Retry; } } -- 2.34.1.windows.1