* [PATCH v3] MdeModulePkg: Enabling OS boot from SD card through UEFI payload
@ 2022-01-20 18:53 Aiman Rosli
2022-01-21 0:57 ` [edk2-devel] " Wu, Hao A
0 siblings, 1 reply; 3+ messages in thread
From: Aiman Rosli @ 2022-01-20 18:53 UTC (permalink / raw)
To: devel; +Cc: Aiman Rosli
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 <muhammad.aiman.rosli@intel.com>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [edk2-devel] [PATCH v3] MdeModulePkg: Enabling OS boot from SD card through UEFI payload
2022-01-20 18:53 [PATCH v3] MdeModulePkg: Enabling OS boot from SD card through UEFI payload Aiman Rosli
@ 2022-01-21 0:57 ` Wu, Hao A
2022-01-24 2:02 ` Wu, Hao A
0 siblings, 1 reply; 3+ messages in thread
From: Wu, Hao A @ 2022-01-21 0:57 UTC (permalink / raw)
To: devel@edk2.groups.io, Rosli, Muhammad Aiman, Wang, Jian J,
Gao, Liming, Ni, Ray
(Add missing maintainers/reviewers)
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Will wait until early next week for the merging to see if any comment from other reviewers.
Best Regards,
Hao Wu
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Aiman
> Rosli
> Sent: Friday, January 21, 2022 2:53 AM
> To: devel@edk2.groups.io
> Cc: Rosli, Muhammad Aiman <muhammad.aiman.rosli@intel.com>
> Subject: [edk2-devel] [PATCH v3] MdeModulePkg: Enabling OS boot from SD
> card through UEFI payload
>
> 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 <muhammad.aiman.rosli@intel.com>
> ---
> 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
>
>
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [edk2-devel] [PATCH v3] MdeModulePkg: Enabling OS boot from SD card through UEFI payload
2022-01-21 0:57 ` [edk2-devel] " Wu, Hao A
@ 2022-01-24 2:02 ` Wu, Hao A
0 siblings, 0 replies; 3+ messages in thread
From: Wu, Hao A @ 2022-01-24 2:02 UTC (permalink / raw)
To: devel@edk2.groups.io, Wu, Hao A, Rosli, Muhammad Aiman,
Wang, Jian J, Gao, Liming, Ni, Ray
Change the subject of the commit to "MdeModulePkg/SdMmcPciHcDxe: Robust improvements for SD card 1.8V switch" in order to better reflect the purpose of the change.
Patch merged via:
PR - https://github.com/tianocore/edk2/pull/2438
Commit - https://github.com/tianocore/edk2/commit/7e5c603cba0823fd97456984f4cfc21c4c831b52
Best Regards,
Hao Wu
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Wu, Hao
> A
> Sent: Friday, January 21, 2022 8:57 AM
> To: devel@edk2.groups.io; Rosli, Muhammad Aiman
> <muhammad.aiman.rosli@intel.com>; Wang, Jian J <jian.j.wang@intel.com>;
> Gao, Liming <gaoliming@byosoft.com.cn>; Ni, Ray <ray.ni@intel.com>
> Subject: Re: [edk2-devel] [PATCH v3] MdeModulePkg: Enabling OS boot
> from SD card through UEFI payload
>
> (Add missing maintainers/reviewers)
>
> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Will wait until early next
> week for the merging to see if any comment from other reviewers.
>
> Best Regards,
> Hao Wu
>
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Aiman
> > Rosli
> > Sent: Friday, January 21, 2022 2:53 AM
> > To: devel@edk2.groups.io
> > Cc: Rosli, Muhammad Aiman <muhammad.aiman.rosli@intel.com>
> > Subject: [edk2-devel] [PATCH v3] MdeModulePkg: Enabling OS boot from
> > SD card through UEFI payload
> >
> > 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 <muhammad.aiman.rosli@intel.com>
> > ---
> > 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
> >
> >
> >
> >
> >
>
>
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-24 2:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-20 18:53 [PATCH v3] MdeModulePkg: Enabling OS boot from SD card through UEFI payload Aiman Rosli
2022-01-21 0:57 ` [edk2-devel] " Wu, Hao A
2022-01-24 2:02 ` Wu, Hao A
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox