summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2021-09-14 19:21:48 +0300
committerAnup Patel <anup@brainfault.org>2021-09-26 17:22:10 +0300
commit12e7af9ab7ef9adf61b9138e2c38e3aeef3c140b (patch)
tree67d388a1d7a4435060beace5dbaba32679adef41 /lib
parent72154f4708de79816f0178b16223afa352b20e30 (diff)
downloadopensbi-12e7af9ab7ef9adf61b9138e2c38e3aeef3c140b.tar.xz
lib: sbi: Add timer frequency to struct sbi_timer_device
Generic mdelay() and udelay() functions can be provided by the sbi_timer framework if timer frequency is available in the timer instance provided by the platform support or timer driver. This patch adds timer frequency (timer_freq) member in the struct sbi_timer_device for above purpose. Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Xiang W <wxjstz@126.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/utils/timer/aclint_mtimer.c3
-rw-r--r--lib/utils/timer/fdt_timer_mtimer.c4
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/utils/timer/aclint_mtimer.c b/lib/utils/timer/aclint_mtimer.c
index d612b12..62e87f7 100644
--- a/lib/utils/timer/aclint_mtimer.c
+++ b/lib/utils/timer/aclint_mtimer.c
@@ -186,6 +186,8 @@ int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt,
(mt->first_hartid >= SBI_HARTMASK_MAX_BITS) ||
(mt->hart_count > ACLINT_MTIMER_MAX_HARTS))
return SBI_EINVAL;
+ if (reference && mt->mtime_freq != reference->mtime_freq)
+ return SBI_EINVAL;
/* Initialize private data */
aclint_mtimer_set_reference(mt, reference);
@@ -227,6 +229,7 @@ int aclint_mtimer_cold_init(struct aclint_mtimer_data *mt,
return rc;
}
+ mtimer.timer_freq = mt->mtime_freq;
sbi_timer_set_device(&mtimer);
return 0;
diff --git a/lib/utils/timer/fdt_timer_mtimer.c b/lib/utils/timer/fdt_timer_mtimer.c
index 4eafffa..1ad8508 100644
--- a/lib/utils/timer/fdt_timer_mtimer.c
+++ b/lib/utils/timer/fdt_timer_mtimer.c
@@ -38,6 +38,10 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,
mt->has_64bit_mmio = true;
mt->has_shared_mtime = false;
+ rc = fdt_parse_timebase_frequency(fdt, &mt->mtime_freq);
+ if (rc)
+ return rc;
+
if (match->data) { /* SiFive CLINT */
/* Set CLINT addresses */
mt->mtimecmp_addr = addr[0] + ACLINT_DEFAULT_MTIMECMP_OFFSET;