From nobody Fri May 3 04:32:22 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+85756+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+85756+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1642424166; cv=none; d=zohomail.com; s=zohoarc; b=djlNpzE3drXUIyrNaWRpjSbAQSiIBl3j2pXjQSN6qmyEob4DQkWRxO8YSSyLEFQoh7YZYO6Ynfvk+E1L6eHdVVDxsebcxprpABNoGJgWhhwI6wT82uhoWk053+dzKDyHSr1H9NgBGgnhkHABVmBwlOJ8dIoFZpMrX28jukXHDo4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642424166; 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=olyx1xuD7jUhdBkUNBeqjyxoWKkHiv9LKvvo80EWZ08=; b=VRLi/hpfGF1sDLBwNXxW4U7vPNQIx0i12BHQFr1SqvpThhEcYTIeqBwobNzTAkCNiI3s86fFANwmhGiAmp0qSJ7vN6pPjxly9ECmSansJTcqJZ7Un9nLkpDJu6pWR0Zvntz8m/SI2Auh11kd2BFtkOKG6qddqK/D2FWpb9j9CWc= 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+85756+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 1642424166144949.1064155851134; Mon, 17 Jan 2022 04:56:06 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id wMC8YY1788612x9u6iVGLajt; Mon, 17 Jan 2022 04:56:05 -0800 X-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 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" X-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" X-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: [edk2-devel] [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> 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: pUsULonZFTWxJYUaB0ctwMikx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1642424165; bh=H38flqNNhR1OmbTtDiMMBE0fMeTf6HF0Jpqidv11vVA=; h=Cc:Date:From:Reply-To:Subject:To; b=WR/EHHCxAuhLw/OMmZseHwd6+3OBMK0kZHt1NyBjXfXITIwc71Ch9zcargbWtmfGYHl hI2kKRppN5Na0iYOWE4jmi5fzrVFA1vr6TBSbMtKFbfNFzdGADGSshytti/fFYbvJ2mJP cvVNZJGFx1JmN7okccjUbRBnfY5fkbrO9Ls= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1642424167476100002 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 --- 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/B= us/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 =3D FALSE; =20 PciIo =3D Private->PciIo; PassThru =3D &Private->PassThru; + +Voltage33Retry: // // 1. Send Cmd0 to the device // @@ -1294,6 +1299,14 @@ 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; + ForceVoltage33 =3D 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; } =20 - gBS->Stall (1000); + // Workaround to add a delay of 50 ms in order for clock to stabiliz= e before turning on the SD card again. + gBS->Stall (50000); =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; + Status =3D SdMmcHcReset (Private, Slot); + Status =3D SdMmcHcInitHost (Private, Slot); + ForceVoltage33 =3D 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; } } =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 (#85756): https://edk2.groups.io/g/devel/message/85756 Mute This Topic: https://groups.io/mt/88482891/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-