summaryrefslogtreecommitdiff
path: root/board
diff options
context:
space:
mode:
authorYao Zi <[email protected]>2025-05-13 09:05:02 +0000
committerLeo Yu-Chi Liang <[email protected]>2025-05-21 16:49:52 +0800
commit38ed760bc90722207060ff16e370e4ea3f7f3db3 (patch)
treeab4abac2f8be2e45cfc82ef1f6f818ed3aab8c76 /board
parent19ec61b3e6c9c9b027d50eda9f03929bdd00b4a9 (diff)
board: thead: licheepi4a: Enable SPL support
Adjust Kconfig and defconfig and add SPL initialization code for Lichee Pi 4A. Then enable SPL support which we've added for TH1520 SoC earlier. The board devicetree is changed to use TH1520 binman configuration to generate bootable images. Signed-off-by: Yao Zi <[email protected]> Reviewed-by: Leo Yu-Chi Liang <[email protected]>
Diffstat (limited to 'board')
-rw-r--r--board/thead/th1520_lpi4a/Kconfig5
-rw-r--r--board/thead/th1520_lpi4a/Makefile1
-rw-r--r--board/thead/th1520_lpi4a/spl.c48
3 files changed, 52 insertions, 2 deletions
diff --git a/board/thead/th1520_lpi4a/Kconfig b/board/thead/th1520_lpi4a/Kconfig
index 622246127c1..f139d5ff2bb 100644
--- a/board/thead/th1520_lpi4a/Kconfig
+++ b/board/thead/th1520_lpi4a/Kconfig
@@ -11,7 +11,7 @@ config SYS_VENDOR
default "thead"
config SYS_CPU
- default "generic"
+ default "th1520"
config SYS_CONFIG_NAME
default "th1520_lpi4a"
@@ -22,7 +22,7 @@ config TEXT_BASE
default 0x01c00000 if RISCV_SMODE
config SPL_TEXT_BASE
- default 0x08000000
+ default 0xffe0000000
config SPL_OPENSBI_LOAD_ADDR
default 0x80000000
@@ -30,6 +30,7 @@ config SPL_OPENSBI_LOAD_ADDR
config BOARD_SPECIFIC_OPTIONS
def_bool y
select ARCH_EARLY_INIT_R
+ select THEAD_TH1520
imply CPU
imply CPU_RISCV
imply RISCV_TIMER if RISCV_SMODE
diff --git a/board/thead/th1520_lpi4a/Makefile b/board/thead/th1520_lpi4a/Makefile
index 9671b3bbb0b..a7ddfc48d40 100644
--- a/board/thead/th1520_lpi4a/Makefile
+++ b/board/thead/th1520_lpi4a/Makefile
@@ -3,3 +3,4 @@
# Copyright (c) 2023, Yixun Lan <[email protected]>
obj-y += board.o
+obj-$(CONFIG_XPL_BUILD) += spl.o
diff --git a/board/thead/th1520_lpi4a/spl.c b/board/thead/th1520_lpi4a/spl.c
new file mode 100644
index 00000000000..25dfa387c36
--- /dev/null
+++ b/board/thead/th1520_lpi4a/spl.c
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2025, Yao Zi <[email protected]>
+ */
+
+#include <asm/io.h>
+#include <asm/spl.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/spl.h>
+#include <cpu_func.h>
+#include <dm.h>
+#include <hang.h>
+#include <spl.h>
+
+u32 spl_boot_device(void)
+{
+ /*
+ * We don't bother to load proper U-Boot from an external device as
+ * it fits in the integrated SRAM nicely.
+ */
+ return BOOT_DEVICE_RAM;
+}
+
+void board_init_f(ulong dummy)
+{
+ int ret = spl_early_init();
+ struct udevice *dev;
+
+ if (ret)
+ panic("spl_early_init() failed %d\n", ret);
+
+ preloader_console_init();
+
+ /*
+ * Manually bind CPU ahead of time to make sure in-core timers are
+ * available in SPL.
+ */
+ ret = uclass_get_device(UCLASS_CPU, 0, &dev);
+ if (ret)
+ panic("failed to bind CPU: %d\n", ret);
+
+ spl_dram_init();
+
+ icache_enable();
+ dcache_enable();
+
+ th1520_invalidate_pmp();
+}