mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-30 09:56:33 +01:00
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:
@@ -172,9 +172,6 @@ const struct sbi_platform_operations platform_ops = {
|
||||
.ipi_clear = plicsw_ipi_clear,
|
||||
|
||||
.timer_init = ae350_timer_init,
|
||||
.timer_value = plmt_timer_value,
|
||||
.timer_event_start = plmt_timer_event_start,
|
||||
.timer_event_stop = plmt_timer_event_stop,
|
||||
|
||||
.vendor_ext_provider = ae350_vendor_ext_provider
|
||||
};
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -10,12 +10,6 @@
|
||||
#ifndef _AE350_PLMT_H_
|
||||
#define _AE350_PLMT_H_
|
||||
|
||||
u64 plmt_timer_value(void);
|
||||
|
||||
void plmt_timer_event_stop(void);
|
||||
|
||||
void plmt_timer_event_start(u64 next_event);
|
||||
|
||||
int plmt_warm_timer_init(void);
|
||||
|
||||
int plmt_cold_timer_init(unsigned long base, u32 hart_count);
|
||||
|
Reference in New Issue
Block a user