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 <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
This commit is contained in:
Feng Tian 2016-04-29 14:39:30 +08:00
parent c25ddd0134
commit cb9cb9e2aa
3 changed files with 20 additions and 3 deletions

View File

@ -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.
//

View File

@ -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.
//

View File

@ -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.
//