From: Simon Glass Date: Sat, 16 Dec 2023 03:14:09 +0000 (-0700) Subject: riscv: Add a reset_cpu() function X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=c35bfd07ecdf683b6a80132f5ac6201d6d24c734;p=u-boot.git riscv: Add a reset_cpu() function The current do_reset() is called from a command context. Add a function which can be used from anywhere, as is done on ARM. Adjust do_reset() to call it. Note that reset_cpu() is normally provided by SYSRESET so make this declaration conditional on that being disabled. Signed-off-by: Simon Glass Reviewed-by: Chanho Park Tested-by: Chanho Park --- diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c index ebd39cb41a..8445c5823e 100644 --- a/arch/riscv/cpu/cpu.c +++ b/arch/riscv/cpu/cpu.c @@ -3,10 +3,13 @@ * Copyright (C) 2018, Bin Meng */ +#include #include +#include #include #include #include +#include #include #include #include @@ -162,3 +165,13 @@ int arch_early_init_r(void) __weak void harts_early_init(void) { } + +#if !CONFIG_IS_ENABLED(SYSRESET) +void reset_cpu(void) +{ + printf("resetting ...\n"); + + printf("reset not supported yet\n"); + hang(); +} +#endif diff --git a/arch/riscv/lib/reset.c b/arch/riscv/lib/reset.c index 712e1bdb8e..c4153c9e6e 100644 --- a/arch/riscv/lib/reset.c +++ b/arch/riscv/lib/reset.c @@ -4,14 +4,11 @@ */ #include -#include +#include int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { - printf("resetting ...\n"); - - printf("reset not supported yet\n"); - hang(); + reset_cpu(); return 0; }