cactus: ivy: Add sleep service
This service sleeps for a number of milliseconds.
Change-Id: Ib7f17142d22c8313dedc5f8037874bacbf8ed5f4
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
diff --git a/spm/common/sp_helpers.c b/spm/common/sp_helpers.c
index cccaf8b..5aec977 100644
--- a/spm/common/sp_helpers.c
+++ b/spm/common/sp_helpers.c
@@ -55,17 +55,15 @@
INFO("Test \"%s\" passed.\n", test_desc);
}
-void sp_sleep(uint32_t duration_sec)
+void sp_sleep(uint32_t ms)
{
- uint32_t timer_freq = mmio_read_32(SYS_CNT_CONTROL_BASE + CNTFID_OFF);
- VERBOSE("%s: Timer frequency = %u\n", __func__, timer_freq);
+ uint64_t timer_freq = mmio_read_32(SYS_CNT_CONTROL_BASE + CNTFID_OFF);
+ VERBOSE("%s: Timer frequency = %llu\n", __func__, timer_freq);
- INFO("%s: Sleeping for %u seconds...\n", __func__, duration_sec);
+ VERBOSE("%s: Sleeping for %u milliseconds...\n", __func__, ms);
uint64_t time1 = mmio_read_64(SYS_CNT_READ_BASE);
volatile uint64_t time2 = time1;
- while ((time2 - time1) < duration_sec * timer_freq) {
+ while ((time2 - time1) < ((ms * timer_freq) / 1000U)) {
time2 = mmio_read_64(SYS_CNT_READ_BASE);
}
-
- INFO("%s: Done\n", __func__);
}