Yanhong Wang | 6a5a45d | 2023-03-29 11:42:17 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2022 StarFive Technology Co., Ltd. |
| 4 | * Author: Yanhong Wang<yanhong.wang@starfivetech.com> |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <asm/io.h> |
Yanhong Wang | 2b51743 | 2023-06-15 17:36:50 +0800 | [diff] [blame] | 9 | #include <asm/sections.h> |
Yanhong Wang | 6a5a45d | 2023-03-29 11:42:17 +0800 | [diff] [blame] | 10 | #include <cpu_func.h> |
Yanhong Wang | 2b51743 | 2023-06-15 17:36:50 +0800 | [diff] [blame] | 11 | #include <dm.h> |
Yanhong Wang | 6a5a45d | 2023-03-29 11:42:17 +0800 | [diff] [blame] | 12 | #include <linux/bitops.h> |
| 13 | |
| 14 | #define JH7110_L2_PREFETCHER_BASE_ADDR 0x2030000 |
| 15 | #define JH7110_L2_PREFETCHER_HART_OFFSET 0x2000 |
| 16 | |
| 17 | /* enable U74-mc hart1~hart4 prefetcher */ |
| 18 | static void enable_prefetcher(void) |
| 19 | { |
| 20 | u8 hart; |
| 21 | u32 *reg; |
| 22 | |
| 23 | /* JH7110 use U74MC CORE IP, it include five cores(one S7 and four U7), |
| 24 | * but only U7 cores support prefetcher configuration |
| 25 | */ |
| 26 | for (hart = 1; hart < 5; hart++) { |
| 27 | reg = (void *)(u64)(JH7110_L2_PREFETCHER_BASE_ADDR |
| 28 | + hart * JH7110_L2_PREFETCHER_HART_OFFSET); |
| 29 | |
| 30 | mb(); /* memory barrier */ |
| 31 | setbits_le32(reg, 0x1); |
| 32 | mb(); /* memory barrier */ |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | int board_init(void) |
| 37 | { |
| 38 | enable_caches(); |
| 39 | enable_prefetcher(); |
| 40 | |
| 41 | return 0; |
| 42 | } |
Yanhong Wang | 2b51743 | 2023-06-15 17:36:50 +0800 | [diff] [blame] | 43 | |
| 44 | void *board_fdt_blob_setup(int *err) |
| 45 | { |
| 46 | *err = 0; |
| 47 | if (IS_ENABLED(CONFIG_OF_SEPARATE) || IS_ENABLED(CONFIG_OF_BOARD)) { |
| 48 | if (gd->arch.firmware_fdt_addr) |
| 49 | return (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr; |
| 50 | } |
| 51 | |
| 52 | return (ulong *)&_end; |
| 53 | } |