ArmPkg/TimerDxe: Changed calculation to allow 1KHz granularity frequency

Prior to this change the frequency was rounded to 1Mhz.
This change rounds the timer frequency to 1KHz.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>



git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15921 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Olivier Martin 2014-08-27 10:12:00 +00:00 committed by oliviermartin
parent 8f1cbb011f
commit 33292af5f1
2 changed files with 10 additions and 7 deletions

View File

@ -141,12 +141,13 @@ TimerDriverSetTimerPeriod (
ArmArchTimerDisableTimer (); ArmArchTimerDisableTimer ();
if (TimerPeriod != 0) { if (TimerPeriod != 0) {
// Convert TimerPeriod to micro sec units // TimerTicks = TimerPeriod in 1ms unit x Frequency.10^-3
TimerTicks = DivU64x32 (TimerPeriod, 10); // = TimerPeriod.10^-4 x Frequency.10^-3
// = (TimerPeriod x Frequency) x 10^-7
TimerTicks = MultU64x32 (TimerPeriod, FixedPcdGet32 (PcdArmArchTimerFreqInHz));
TimerTicks = DivU64x32 (TimerTicks, 10000000U);
TimerTicks = MultU64x32 (TimerTicks, (PcdGet32(PcdArmArchTimerFreqInHz)/1000000)); ArmArchTimerSetTimerVal ((UINTN)TimerTicks);
ArmArchTimerSetTimerVal((UINTN)TimerTicks);
// Enable the timer // Enable the timer
ArmArchTimerEnableTimer (); ArmArchTimerEnableTimer ();

View File

@ -82,8 +82,10 @@ MicroSecondDelay (
UINT64 TimerTicks64; UINT64 TimerTicks64;
UINT64 SystemCounterVal; UINT64 SystemCounterVal;
// Calculate counter ticks that can represent requested delay // Calculate counter ticks that can represent requested delay:
TimerTicks64 = MultU64x32 (MicroSeconds, TICKS_PER_MICRO_SEC); // = MicroSeconds x TICKS_PER_MICRO_SEC
// = MicroSeconds x Frequency.10^-6
TimerTicks64 = (MicroSeconds * PcdGet32 (PcdArmArchTimerFreqInHz)) / 1000000U;
// Read System Counter value // Read System Counter value
SystemCounterVal = ArmArchTimerGetSystemCount (); SystemCounterVal = ArmArchTimerGetSystemCount ();