summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Behl <cap2k4@rivosinc.com>2025-06-08 23:09:04 +0530
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-07-08 18:35:46 +0000
commit34d609402bfec75c51a02deac7733c9a0128f55d (patch)
tree86044314b94f062dd7dcde3ffc14cd6314baac9c
parent484930e0c6b7991758a098b6e0fd31dec38e7d85 (diff)
downloadedk2-34d609402bfec75c51a02deac7733c9a0128f55d.zip
edk2-34d609402bfec75c51a02deac7733c9a0128f55d.tar.gz
edk2-34d609402bfec75c51a02deac7733c9a0128f55d.tar.bz2
UefiCpuPkg/CpuTimerDxeRiscV64: Use DT based timer frequency in Timer driver
There is GetPerformanceCounterProperties() that relies on Device Tree to fetch timer frequency and removes the dependency from the PCDs, use that instead. Signed-off-by: Akshay Behl <cap2k4@rivosinc.com> Co-authored-by: Dhaval Sharma <dhaval@rivosinc.com>
-rw-r--r--UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf2
-rw-r--r--UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c7
2 files changed, 5 insertions, 4 deletions
diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf b/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf
index f2a2cf1..812b674 100644
--- a/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf
+++ b/UefiCpuPkg/CpuTimerDxeRiscV64/CpuTimerDxeRiscV64.inf
@@ -32,6 +32,7 @@
CpuLib
UefiBootServicesTableLib
UefiDriverEntryPoint
+ TimerLib
[LibraryClasses.RISCV64]
RiscVSbiLib
@@ -42,7 +43,6 @@
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdRiscVFeatureOverride ## CONSUMES
- gUefiCpuPkgTokenSpaceGuid.PcdCpuCoreCrystalClockFrequency ## CONSUMES
[Protocols]
gEfiCpuArchProtocolGuid ## CONSUMES
diff --git a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c
index 216f48a..14780e4 100644
--- a/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c
+++ b/UefiCpuPkg/CpuTimerDxeRiscV64/Timer.c
@@ -10,6 +10,7 @@
#include <Library/BaseLib.h>
#include <Library/BaseRiscVSbiLib.h>
#include <Library/UefiLib.h>
+#include <Library/TimerLib.h>
#include "Timer.h"
//
@@ -114,7 +115,7 @@ TimerInterruptHandler (
mTimerNotifyFunction (
DivU64x32 (
EFI_TIMER_PERIOD_SECONDS (PeriodStart - mLastPeriodStart),
- PcdGet64 (PcdCpuCoreCrystalClockFrequency)
+ GetPerformanceCounterProperties (NULL, NULL)
)
);
}
@@ -129,7 +130,7 @@ TimerInterruptHandler (
PeriodStart += DivU64x32 (
MultU64x32 (
mTimerPeriod,
- PcdGet64 (PcdCpuCoreCrystalClockFrequency)
+ GetPerformanceCounterProperties (NULL, NULL)
),
1000000u
); // convert to tick
@@ -232,7 +233,7 @@ TimerDriverSetTimerPeriod (
PeriodStart += DivU64x32 (
MultU64x32 (
mTimerPeriod,
- PcdGet64 (PcdCpuCoreCrystalClockFrequency)
+ GetPerformanceCounterProperties (NULL, NULL)
),
1000000u
); // convert to tick