summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/lib/aarch64/arch_helpers.h1
-rw-r--r--spm/common/sp_helpers.c7
2 files changed, 5 insertions, 3 deletions
diff --git a/include/lib/aarch64/arch_helpers.h b/include/lib/aarch64/arch_helpers.h
index 9bcd0bb..6a96ea2 100644
--- a/include/lib/aarch64/arch_helpers.h
+++ b/include/lib/aarch64/arch_helpers.h
@@ -367,6 +367,7 @@ DEFINE_SYSREG_RW_FUNCS(cntp_ctl_el0)
DEFINE_SYSREG_RW_FUNCS(cntp_tval_el0)
DEFINE_SYSREG_RW_FUNCS(cntp_cval_el0)
DEFINE_SYSREG_READ_FUNC(cntpct_el0)
+DEFINE_SYSREG_READ_FUNC(cntvct_el0)
DEFINE_SYSREG_RW_FUNCS(cnthctl_el2)
#define get_cntp_ctl_enable(x) (((x) >> CNTP_CTL_ENABLE_SHIFT) & \
diff --git a/spm/common/sp_helpers.c b/spm/common/sp_helpers.c
index 1b650d3..5d76dc8 100644
--- a/spm/common/sp_helpers.c
+++ b/spm/common/sp_helpers.c
@@ -60,14 +60,15 @@ void announce_test_end(const char *test_desc)
void sp_sleep(uint32_t ms)
{
- uint64_t timer_freq = mmio_read_32(SYS_CNT_CONTROL_BASE + CNTFID_OFF);
+ uint64_t timer_freq = read_cntfrq_el0();
+
VERBOSE("%s: Timer frequency = %llu\n", __func__, timer_freq);
VERBOSE("%s: Sleeping for %u milliseconds...\n", __func__, ms);
- uint64_t time1 = mmio_read_64(SYS_CNT_READ_BASE);
+ uint64_t time1 = read_cntvct_el0();
volatile uint64_t time2 = time1;
while ((time2 - time1) < ((ms * timer_freq) / 1000U)) {
- time2 = mmio_read_64(SYS_CNT_READ_BASE);
+ time2 = read_cntvct_el0();
}
}