From nobody Mon May 6 15:33:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+85880+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+85880+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1642704826; cv=none; d=zohomail.com; s=zohoarc; b=nmMDv7aD1LYzZQoXwquW/ZNATjWacY11z9QlPEPOTcFnN63UQnFKocxgvgL/fORR66xxffZ07XSTcJ8N5qDjglW9rchM9STnYnioOpMZMNLeIJESYP7bF4WiFD7IIFPTzyH68hW4I5tPkCG8EYZIBSxGGBp0NqXzzUfet1rtN2k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642704826; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=8w7GPawYgEcfYnEeYl31V21V4j5rnmKXBrMu673pthI=; b=QPfiNWDVNXdVeBKDGykIfZCd1y13X1bi3NkDeIuDCWnsIm6jh1xaR/7EDQVcYNWvV0592VDp73+PcSwHn0kL5NW/4Q+6ozQcBsTQ2zwis6//cAVlaLVQtUx1wrWFZMNKwolhe15fOASSjWSn14/T5+ubObLMYzERPmHABQipEEU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+85880+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1642704826253525.6559678453898; Thu, 20 Jan 2022 10:53:46 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id lRSiYY1788612xexxIwYUNAN; Thu, 20 Jan 2022 10:53:45 -0800 X-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 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" X-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" X-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: [edk2-devel] [PATCH v3] MdeModulePkg: Enabling OS boot from SD card through UEFI payload Date: Fri, 21 Jan 2022 02:53:24 +0800 Message-Id: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,muhammad.aiman.rosli@intel.com X-Gm-Message-State: 36kG4pBy7fgs5Ep0ohNF8XQRx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1642704825; bh=CgbWu4r2g1ZY3Q8asMUtqrXAYAGkdiuf9oyJc6IZrGk=; h=Cc:Date:From:Reply-To:Subject:To; b=FEHSJDU1s/cBUvWzsu+WqDibd8M68m7S7fg8Pk3RCrwPM7CSIRkSzAXU5rTRrEqk/3X 3C0rnQuiIm1SZ8PIhTaNAy1jaPKpZWUCbstn+liuojZVnVFB/GSMdxxuuk7wFFn/rT5v+ trq2jGl7RAd8bTRFJERfzU8w6lOLvhKBz08= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1642704827031100002 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Hao A Wu --- 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/B= us/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 =3D FALSE; =20 PciIo =3D Private->PciIo; PassThru =3D &Private->PassThru; + +Voltage33Retry: // // 1. Send Cmd0 to the device // @@ -1294,6 +1299,13 @@ SdCardIdentification ( return EFI_UNSUPPORTED; } =20 + // + // 1.8V had failed in the previous run, forcing a retry with 3.3V instead + // + if (ForceVoltage33 =3D=3D TRUE) { + S18r =3D 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 ( =20 SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE, sizeof (P= resentState), &PresentState); if (((PresentState >> 20) & 0xF) !=3D 0xF) { - DEBUG ((DEBUG_ERROR, "SdCardIdentification: SwitchVoltage fails wi= th PresentState =3D 0x%x, It should be 0xF\n", PresentState)); - Status =3D EFI_DEVICE_ERROR; - goto Error; + // + // Delay 50 milliseconds in order for clock to stabilize, retry re= ading 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) !=3D 0xF) { + DEBUG ((DEBUG_ERROR, "SdCardIdentification: SwitchVoltage fails = with PresentState =3D 0x%x, It should be 0xF\n", PresentState)); + // + // Reset and reinitialize the slot before the 3.3V retry. + // + Status =3D SdMmcHcReset (Private, Slot); + if (EFI_ERROR (Status)) { + goto Error; + } + + Status =3D SdMmcHcInitHost (Private, Slot); + if (EFI_ERROR (Status)) { + goto Error; + } + + DEBUG ((DEBUG_ERROR, "SdCardIdentification: Switching to 1.8V fa= iled, forcing a retry with 3.3V instead\n")); + ForceVoltage33 =3D TRUE; + goto Voltage33Retry; + } } } =20 --=20 2.34.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#85880): https://edk2.groups.io/g/devel/message/85880 Mute This Topic: https://groups.io/mt/88566229/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-