mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-09-08 18:21:29 +01:00
lib/sbi/sbi_timer: Add sbi_timer_frequency() function
Drivers and other library code sometimes need the timer frequency outside of lib/sbi/sbi_timer.c, but there is currently no accessor for it. Add sbi_timer_frequency() to expose the frequency of the registered timer device. Signed-off-by: Sunil V L <sunilvl@oss.qualcomm.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20260703050530.2460037-2-sunilvl@oss.qualcomm.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -104,6 +104,18 @@ bool sbi_timer_waitms_until(bool (*predicate)(void *), void *arg,
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned long sbi_timer_frequency(void)
|
||||
{
|
||||
const struct sbi_timer_device *timer_dev = sbi_timer_get_device();
|
||||
|
||||
if (!timer_dev) {
|
||||
sbi_printf("%s: called without timer device\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return timer_dev->timer_freq;
|
||||
}
|
||||
|
||||
u64 sbi_timer_value(void)
|
||||
{
|
||||
if (get_time_val)
|
||||
|
||||
Reference in New Issue
Block a user