From: Feng Tian Date: Fri, 29 Apr 2016 06:39:30 +0000 (+0800) Subject: MdeModulePkg/SdMmcPciHcDxe: Use BaseClk if the target clock is larger X-Git-Tag: edk2-stable201903~7107 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=cb9cb9e2aaec95f89f3c0dfc411226aa6c42461a MdeModulePkg/SdMmcPciHcDxe: Use BaseClk if the target clock is larger The original code has a bug to calculate which clock freq should be used when the target clock freq is larger than the BaseClock Freq provided by the system. Cc: Wu, Hao A Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Feng Tian --- diff --git a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c index baa12f44ee..72af1e7a1b 100644 --- a/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c +++ b/MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c @@ -706,9 +706,14 @@ SdMmcHcClockSupply ( ASSERT (Capability.BaseClkFreq != 0); BaseClkFreq = Capability.BaseClkFreq; - if ((ClockFreq > (BaseClkFreq * 1000)) || (ClockFreq == 0)) { + if (ClockFreq == 0) { return EFI_INVALID_PARAMETER; } + + if (ClockFreq > (BaseClkFreq * 1000)) { + ClockFreq = BaseClkFreq * 1000; + } + // // Calculate the divisor of base frequency. // diff --git a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c b/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c index 050d843176..569a86a6e1 100644 --- a/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c +++ b/MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c @@ -535,9 +535,15 @@ EmmcPeimHcClockSupply ( ASSERT (Capability.BaseClkFreq != 0); BaseClkFreq = Capability.BaseClkFreq; - if ((ClockFreq > (BaseClkFreq * 1000)) || (ClockFreq == 0)) { + + if (ClockFreq == 0) { return EFI_INVALID_PARAMETER; } + + if (ClockFreq > (BaseClkFreq * 1000)) { + ClockFreq = BaseClkFreq * 1000; + } + // // Calculate the divisor of base frequency. // diff --git a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c index cbee947993..48e4ae68ca 100644 --- a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c +++ b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c @@ -535,9 +535,15 @@ SdPeimHcClockSupply ( ASSERT (Capability.BaseClkFreq != 0); BaseClkFreq = Capability.BaseClkFreq; - if ((ClockFreq > (BaseClkFreq * 1000)) || (ClockFreq == 0)) { + + if (ClockFreq == 0) { return EFI_INVALID_PARAMETER; } + + if (ClockFreq > (BaseClkFreq * 1000)) { + ClockFreq = BaseClkFreq * 1000; + } + // // Calculate the divisor of base frequency. //