From cb9cb9e2aaec95f89f3c0dfc411226aa6c42461a Mon Sep 17 00:00:00 2001 From: Feng Tian Date: Fri, 29 Apr 2016 14:39:30 +0800 Subject: 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 --- MdeModulePkg/Bus/Pci/SdMmcPciHcDxe/SdMmcPciHci.c | 7 ++++++- MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcHci.c | 8 +++++++- MdeModulePkg/Bus/Sd/SdBlockIoPei/SdHci.c | 8 +++++++- 3 files changed, 20 insertions(+), 3 deletions(-) (limited to 'MdeModulePkg') 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. // -- cgit v1.2.3