lib: sbi: Simplify timer platform operations

Instead of having timer_value(), timer_event_start(), and
timer_event_stop() callbacks in platform operations, it will
be much simpler for timer driver to directly register these
operations as device to the sbi_timer implementation.

Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
Anup Patel
2021-04-21 22:04:17 +05:30
committed by Anup Patel
parent 068ca086af
commit 559a8f1d3b
19 changed files with 92 additions and 191 deletions

View File

@@ -10,13 +10,14 @@
#include <sbi/riscv_asm.h>
#include <sbi/riscv_io.h>
#include <sbi/sbi_timer.h>
static u32 plmt_time_hart_count;
static volatile void *plmt_time_base;
static volatile u64 *plmt_time_val;
static volatile u64 *plmt_time_cmp;
u64 plmt_timer_value(void)
static u64 plmt_timer_value(void)
{
#if __riscv_xlen == 64
return readq_relaxed(plmt_time_val);
@@ -32,7 +33,7 @@ u64 plmt_timer_value(void)
#endif
}
void plmt_timer_event_stop(void)
static void plmt_timer_event_stop(void)
{
u32 target_hart = current_hartid();
@@ -48,7 +49,7 @@ void plmt_timer_event_stop(void)
#endif
}
void plmt_timer_event_start(u64 next_event)
static void plmt_timer_event_start(u64 next_event)
{
u32 target_hart = current_hartid();
@@ -68,6 +69,13 @@ void plmt_timer_event_start(u64 next_event)
}
static struct sbi_timer_device plmt_timer = {
.name = "ae350_plmt",
.timer_value = plmt_timer_value,
.timer_event_start = plmt_timer_event_start,
.timer_event_stop = plmt_timer_event_stop
};
int plmt_warm_timer_init(void)
{
u32 target_hart = current_hartid();
@@ -93,5 +101,7 @@ int plmt_cold_timer_init(unsigned long base, u32 hart_count)
plmt_time_val = (u64 *)(plmt_time_base);
plmt_time_cmp = (u64 *)(plmt_time_base + 0x8);
sbi_timer_set_device(&plmt_timer);
return 0;
}