diff options
author | Anup Patel <anup.patel@wdc.com> | 2021-04-21 22:04:17 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2021-04-28 17:00:49 +0530 |
commit | 559a8f1d3be3210d4903c0db54c2d36e2f8d6ad4 (patch) | |
tree | 5a646e54241cfef96ccca4a5a8cc29ee68d77acf /platform | |
parent | 068ca086af2312d56efe51a724d78d84e1339ab4 (diff) |
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>
Diffstat (limited to 'platform')
-rw-r--r-- | platform/andes/ae350/platform.c | 3 | ||||
-rw-r--r-- | platform/andes/ae350/plmt.c | 16 | ||||
-rw-r--r-- | platform/andes/ae350/plmt.h | 6 | ||||
-rw-r--r-- | platform/fpga/ariane/platform.c | 3 | ||||
-rw-r--r-- | platform/fpga/openpiton/platform.c | 3 | ||||
-rw-r--r-- | platform/generic/platform.c | 3 | ||||
-rw-r--r-- | platform/kendryte/k210/platform.c | 5 | ||||
-rw-r--r-- | platform/nuclei/ux600/platform.c | 3 | ||||
-rw-r--r-- | platform/sifive/fu540/platform.c | 3 | ||||
-rw-r--r-- | platform/template/platform.c | 30 |
10 files changed, 14 insertions, 61 deletions
diff --git a/platform/andes/ae350/platform.c b/platform/andes/ae350/platform.c index 338159d..17a4e48 100644 --- a/platform/andes/ae350/platform.c +++ b/platform/andes/ae350/platform.c @@ -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 }; diff --git a/platform/andes/ae350/plmt.c b/platform/andes/ae350/plmt.c index 3848e15..54dcb94 100644 --- a/platform/andes/ae350/plmt.c +++ b/platform/andes/ae350/plmt.c @@ -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; } diff --git a/platform/andes/ae350/plmt.h b/platform/andes/ae350/plmt.h index 129fcf8..db093e0 100644 --- a/platform/andes/ae350/plmt.h +++ b/platform/andes/ae350/plmt.h @@ -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); diff --git a/platform/fpga/ariane/platform.c b/platform/fpga/ariane/platform.c index 4f32c42..73c8b9c 100644 --- a/platform/fpga/ariane/platform.c +++ b/platform/fpga/ariane/platform.c @@ -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 = { diff --git a/platform/fpga/openpiton/platform.c b/platform/fpga/openpiton/platform.c index 77403c9..4d876c9 100644 --- a/platform/fpga/openpiton/platform.c +++ b/platform/fpga/openpiton/platform.c @@ -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 = { diff --git a/platform/generic/platform.c b/platform/generic/platform.c index 445cbcf..cf18a1b 100644 --- a/platform/generic/platform.c +++ b/platform/generic/platform.c @@ -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, diff --git a/platform/kendryte/k210/platform.c b/platform/kendryte/k210/platform.c index 495d214..c8fd45e 100644 --- a/platform/kendryte/k210/platform.c +++ b/platform/kendryte/k210/platform.c @@ -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 diff --git a/platform/nuclei/ux600/platform.c b/platform/nuclei/ux600/platform.c index 4f4f884..86130c8 100644 --- a/platform/nuclei/ux600/platform.c +++ b/platform/nuclei/ux600/platform.c @@ -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 diff --git a/platform/sifive/fu540/platform.c b/platform/sifive/fu540/platform.c index 82f6f75..78de30d 100644 --- a/platform/sifive/fu540/platform.c +++ b/platform/sifive/fu540/platform.c @@ -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, }; diff --git a/platform/template/platform.c b/platform/template/platform.c index fbbac30..1691652 100644 --- a/platform/template/platform.c +++ b/platform/template/platform.c @@ -134,33 +134,6 @@ static int platform_timer_init(bool cold_boot) } /* - * 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. */ static int platform_system_reset_check(u32 type, u32 reason) @@ -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 |