summaryrefslogtreecommitdiff
path: root/board/thead/th1520_lpi4a/spl.c
blob: d75fa6f3eff7ae1f72dba9d7d566ea879caf5d6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// 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);

	riscv_cpu_setup();
	th1520_kick_secondary_cores();

	spl_dram_init();

	icache_enable();
	dcache_enable();

	th1520_invalidate_pmp();
}