From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web08.270.1642704824276317271 for ; Thu, 20 Jan 2022 10:53:45 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=jBMvTWqs; spf=pass (domain: intel.com, ip: 134.134.136.24, 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=1642704824; x=1674240824; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=rs/IS3WUFyLuYyj6HN5HehfOoxe7GPvnxwxyDcRcC3A=; b=jBMvTWqstsQDRM9PcQu8fdWNeLvcbZKpLSyjmG7Du+EV8Wartx41aYJd 8SqYi5K2OQbfOfzNw5sH2c6NAz/NjgqLpIRctPgjUdPJmiMh2gaRWSVrE PvqyNIwxa97U1+AOqHph6GE4yxvfiVzjUZ36IJ2nGAQoy+dl14t5Dz8r1 yrhU8eMS/TzoYTNmI2m65LsQpAgOEdy2er8MJXOPlhvPYwwRVn/VfkdFR Gilm8EDaRuROS+DsSlPypRvCZyfUFV1fHsLHnxM2Vcv6tRmHbod60lRTo GfgiqT0clmmwBv2pKgQfL1gFtqJdH8SLYhvSKUNh+LpZw1FaXAQYqyafz g==; X-IronPort-AV: E=McAfee;i="6200,9189,10233"; a="245224451" X-IronPort-AV: E=Sophos;i="5.88,303,1635231600"; d="scan'208";a="245224451" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2022 10:53:43 -0800 X-IronPort-AV: E=Sophos;i="5.88,303,1635231600"; d="scan'208";a="626420813" Received: from roslim1-mobl1.gar.corp.intel.com ([10.213.147.236]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2022 10:53:42 -0800 From: "Aiman Rosli" To: devel@edk2.groups.io Cc: Aiman Rosli Subject: [PATCH v3] MdeModulePkg: Enabling OS boot from SD card through UEFI payload Date: Fri, 21 Jan 2022 02:53:24 +0800 Message-Id: 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 | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdDevice.c index 662f9f483c..f5a3607e47 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,13 @@ SdCardIdentification ( return EFI_UNSUPPORTED; } + // + // 1.8V had failed in the previous run, forcing a retry with 3.3V instead + // + if (ForceVoltage33 == TRUE) { + S18r = FALSE; + } + // // 5. Repeatly send Acmd41 with supply voltage window to the device. // Note here we only support the cards complied with SD physical @@ -1366,9 +1378,30 @@ SdCardIdentification ( 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; + // + // Delay 50 milliseconds in order for clock to stabilize, retry reading the SD_MMC_HC_PRESENT_STATE + // + 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)); + // + // Reset and reinitialize the slot before the 3.3V retry. + // + Status = SdMmcHcReset (Private, Slot); + if (EFI_ERROR (Status)) { + goto Error; + } + + Status = SdMmcHcInitHost (Private, Slot); + if (EFI_ERROR (Status)) { + goto Error; + } + + DEBUG ((DEBUG_ERROR, "SdCardIdentification: Switching to 1.8V failed, forcing a retry with 3.3V instead\n")); + ForceVoltage33 = TRUE; + goto Voltage33Retry; + } } } -- 2.34.1.windows.1