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

@@ -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
};

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;
}

View File

@@ -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);

View File

@@ -159,9 +159,6 @@ const struct sbi_platform_operations platform_ops = {
.ipi_send = clint_ipi_send,
.ipi_clear = clint_ipi_clear,
.timer_init = ariane_timer_init,
.timer_value = clint_timer_value,
.timer_event_start = clint_timer_event_start,
.timer_event_stop = clint_timer_event_stop,
};
const struct sbi_platform platform = {

View File

@@ -185,9 +185,6 @@ const struct sbi_platform_operations platform_ops = {
.ipi_send = clint_ipi_send,
.ipi_clear = clint_ipi_clear,
.timer_init = openpiton_timer_init,
.timer_value = clint_timer_value,
.timer_event_start = clint_timer_event_start,
.timer_event_stop = clint_timer_event_stop,
};
const struct sbi_platform platform = {

View File

@@ -218,9 +218,6 @@ const struct sbi_platform_operations platform_ops = {
.ipi_init = fdt_ipi_init,
.ipi_exit = fdt_ipi_exit,
.get_tlbr_flush_limit = generic_tlbr_flush_limit,
.timer_value = fdt_timer_value,
.timer_event_stop = fdt_timer_event_stop,
.timer_event_start = fdt_timer_event_start,
.timer_init = fdt_timer_init,
.timer_exit = fdt_timer_exit,
.system_reset_check = generic_system_reset_check,

View File

@@ -160,16 +160,13 @@ const struct sbi_platform_operations platform_ops = {
.system_reset = k210_system_reset,
.timer_init = k210_timer_init,
.timer_value = clint_timer_value,
.timer_event_stop = clint_timer_event_stop,
.timer_event_start = clint_timer_event_start,
};
const struct sbi_platform platform = {
.opensbi_version = OPENSBI_VERSION,
.platform_version = SBI_PLATFORM_VERSION(0x0, 0x01),
.name = "Kendryte K210",
.features = SBI_PLATFORM_HAS_TIMER_VALUE,
.features = 0,
.hart_count = K210_HART_COUNT,
.hart_stack_size = SBI_PLATFORM_DEFAULT_HART_STACK_SIZE,
.platform_ops_addr = (unsigned long)&platform_ops

View File

@@ -207,9 +207,6 @@ const struct sbi_platform_operations platform_ops = {
.ipi_send = clint_ipi_send,
.ipi_clear = clint_ipi_clear,
.ipi_init = ux600_ipi_init,
.timer_value = clint_timer_value,
.timer_event_stop = clint_timer_event_stop,
.timer_event_start = clint_timer_event_start,
.timer_init = ux600_timer_init,
.system_reset_check = ux600_system_reset_check,
.system_reset = ux600_system_reset

View File

@@ -162,9 +162,6 @@ const struct sbi_platform_operations platform_ops = {
.ipi_clear = clint_ipi_clear,
.ipi_init = fu540_ipi_init,
.get_tlbr_flush_limit = fu540_get_tlbr_flush_limit,
.timer_value = clint_timer_value,
.timer_event_stop = clint_timer_event_stop,
.timer_event_start = clint_timer_event_start,
.timer_init = fu540_timer_init,
};

View File

@@ -133,33 +133,6 @@ static int platform_timer_init(bool cold_boot)
return clint_warm_timer_init();
}
/*
* Get platform timer value.
*/
static u64 platform_timer_value(void)
{
/* Example if the generic CLINT driver is used */
return clint_timer_value();
}
/*
* Start platform timer event for current HART.
*/
static void platform_timer_event_start(u64 next_event)
{
/* Example if the generic CLINT driver is used */
clint_timer_event_start(next_event);
}
/*
* Stop platform timer event for current HART.
*/
static void platform_timer_event_stop(void)
{
/* Example if the generic CLINT driver is used */
clint_timer_event_stop();
}
/*
* Check reset type and reason supported by the platform.
*/
@@ -186,9 +159,6 @@ const struct sbi_platform_operations platform_ops = {
.ipi_send = platform_ipi_send,
.ipi_clear = platform_ipi_clear,
.ipi_init = platform_ipi_init,
.timer_value = platform_timer_value,
.timer_event_stop = platform_timer_event_stop,
.timer_event_start = platform_timer_event_start,
.timer_init = platform_timer_init,
.system_reset_check = platform_system_reset_check,
.system_reset = platform_system_reset