From: Yao Zi Date: Thu, 23 Jan 2025 09:11:33 +0000 (+0000) Subject: riscv: add a generic implementation for cleanup_before_linux() X-Git-Tag: v2025.04-rc2~35^2~2 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f88e3b77395255ad001b9237a8e57b932330d673;p=pandora-u-boot.git riscv: add a generic implementation for cleanup_before_linux() Most RISC-V SoCs have similar cleanup_before_linux() functions. Let's provide a weak symbol as fallback to reduce duplicated code. Signed-off-by: Yao Zi Reviewed-by: Leo Yu-Chi Liang --- diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c index 06ecd92b9bc..5b31da64cbd 100644 --- a/arch/riscv/cpu/cpu.c +++ b/arch/riscv/cpu/cpu.c @@ -11,11 +11,13 @@ #include #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -729,3 +731,18 @@ void reset_cpu(void) hang(); } #endif + +/* + * cleanup_before_linux() is called just before we call linux, which prepares + * the processor for linux. + * this weak implementation is used by default. we disable interrupts and flush + * the cache. + */ +__weak int cleanup_before_linux(void) +{ + disable_interrupts(); + + cache_flush(); + + return 0; +}