1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2022 StarFive Technology Co., Ltd.
4 * Author: Yanhong Wang<yanhong.wang@starfivetech.com>
10 #include <fdt_support.h>
12 #include <asm/arch/eeprom.h>
14 #include <asm/sections.h>
15 #include <linux/bitops.h>
17 DECLARE_GLOBAL_DATA_PTR
;
18 #define JH7110_L2_PREFETCHER_BASE_ADDR 0x2030000
19 #define JH7110_L2_PREFETCHER_HART_OFFSET 0x2000
20 #define FDTFILE_VISIONFIVE2_1_2A \
21 "starfive/jh7110-starfive-visionfive-2-v1.2a.dtb"
22 #define FDTFILE_VISIONFIVE2_1_3B \
23 "starfive/jh7110-starfive-visionfive-2-v1.3b.dtb"
25 /* enable U74-mc hart1~hart4 prefetcher */
26 static void enable_prefetcher(void)
31 /* JH7110 use U74MC CORE IP, it include five cores(one S7 and four U7),
32 * but only U7 cores support prefetcher configuration
34 for (hart
= 1; hart
< 5; hart
++) {
35 reg
= (void *)(u64
)(JH7110_L2_PREFETCHER_BASE_ADDR
36 + hart
* JH7110_L2_PREFETCHER_HART_OFFSET
);
38 mb(); /* memory barrier */
39 setbits_le32(reg
, 0x1);
40 mb(); /* memory barrier */
45 * set_fdtfile() - set the $fdtfile variable based on the board revision
47 static void set_fdtfile(void)
52 version
= get_pcb_revision_from_eeprom();
56 fdtfile
= FDTFILE_VISIONFIVE2_1_2A
;
62 fdtfile
= FDTFILE_VISIONFIVE2_1_3B
;
66 env_set("fdtfile", fdtfile
);
77 int board_late_init(void)
79 if (CONFIG_IS_ENABLED(ID_EEPROM
))
85 void *board_fdt_blob_setup(int *err
)
88 if (IS_ENABLED(CONFIG_OF_SEPARATE
) || IS_ENABLED(CONFIG_OF_BOARD
)) {
89 if (gd
->arch
.firmware_fdt_addr
)
90 return (ulong
*)(uintptr_t)gd
->arch
.firmware_fdt_addr
;
93 return (ulong
*)&_end
;
96 int ft_board_setup(void *blob
, struct bd_info
*bd
)
98 return fdt_fixup_memory(blob
, 0x40000000, gd
->ram_size
);