From 76e1e5631f1ad9b2275ff31fefe83258c0812b3d Mon Sep 17 00:00:00 2001 From: "Albecki, Mateusz" Date: Thu, 26 Sep 2019 22:27:44 +0800 Subject: [PATCH] MdeModulePkg/SdMmcPciHcDxe: Fix SdMmcMmcLegacy bus timing handling REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2218 There is a bug in current driver code that makes it impossible for it to work with devices that only work in legacy speed mode since the function EmmcSwitchToHighSpeed will return with EFI_INVALID_PARAMETER for such bus mode. Since the logic in that function will work well for SdMmcMmcLegacy this patch just allows to call this function with SdMmcMmcLegacy bus mode. Signed-off-by: Mateusz Albecki Reviewed-by: Hao A Wu Tested-by: Hao A Wu Tested-by: Marcin Wojtas --- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c index 3598a8538a..082904ccc5 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/EmmcDevice.c @@ -794,7 +794,7 @@ EmmcSwitchToHighSpeed ( EFI_STATUS Status; BOOLEAN IsDdr; - if ((BusMode->BusTiming != SdMmcMmcHsSdr && BusMode->BusTiming != SdMmcMmcHsDdr) || + if ((BusMode->BusTiming != SdMmcMmcHsSdr && BusMode->BusTiming != SdMmcMmcHsDdr && BusMode->BusTiming != SdMmcMmcLegacy) || BusMode->ClockFreq > 52) { return EFI_INVALID_PARAMETER; } @@ -1244,6 +1244,12 @@ EmmcSetBusMode ( } else if (BusMode.BusTiming == SdMmcMmcHs200) { Status = EmmcSwitchToHS200 (PciIo, PassThru, Slot, Rca, &BusMode); } else { + // + // Note that EmmcSwitchToHighSpeed is also called for SdMmcMmcLegacy + // bus timing. This is because even though we might not want to + // change the timing itself we still want to allow customization of + // bus parameters such as clock frequency and bus width. + // Status = EmmcSwitchToHighSpeed (PciIo, PassThru, Slot, Rca, &BusMode); } -- 2.39.2