From 80cd3fa707e54d391d64aed92857baebbb402f6d Mon Sep 17 00:00:00 2001 From: Hangfan Li Date: Wed, 4 Mar 2026 14:41:18 +0800 Subject: [PATCH] board: spacemit-k3: SPL entrypoint --- arch/riscv/cpu/k3/cache.c | 31 +++++++++++++++++++++++++++++++ arch/riscv/cpu/k3/spl.c | 21 +++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/arch/riscv/cpu/k3/cache.c b/arch/riscv/cpu/k3/cache.c index e69de29bb2d..303b78b44d3 100644 --- a/arch/riscv/cpu/k3/cache.c +++ b/arch/riscv/cpu/k3/cache.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2026 Hangfan Li + */ + +#include +#include +#include + +#if CONFIG_IS_ENABLED(RISCV_MMODE) +void icache_enable(void) +{ + csr_set(0x7c0, 0x2); +} + +void dcache_enable(void) +{ + csr_set(0x7c0, 0x1); + csr_set(0x7f0, 0x1); +} + +int icache_status(void) +{ + return (csr_read(0x7c0) & 0x2) != 0; +} + +int dcache_status(void) +{ + return (csr_read(0x7c0) & 0x1) != 0; +} +#endif /* CONFIG_IS_ENABLED(RISCV_MMODE) */ diff --git a/arch/riscv/cpu/k3/spl.c b/arch/riscv/cpu/k3/spl.c index f37ac3fdc91..5d057b57f08 100644 --- a/arch/riscv/cpu/k3/spl.c +++ b/arch/riscv/cpu/k3/spl.c @@ -1,6 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2026 Hangfan Li + */ + #include #include #include +#include +#include + + +void harts_early_init(void) +{ + icache_enable(); + dcache_enable(); +} void board_boot_order(u32 *spl_boot_list) { @@ -9,3 +23,10 @@ void board_boot_order(u32 *spl_boot_list) spl_boot_list[1] = BOOT_DEVICE_UART; spl_boot_list[2] = BOOT_DEVICE_NONE; } + +int spl_board_init_f(void) +{ + int ret; + + return 0; +}