b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * (C) Copyright 2000-2009 |
| 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 5 | * Copyright 2019 Google LLC |
| 6 | */ |
| 7 | |
| 8 | #ifndef __CPU_LEGACY_H |
| 9 | #define __CPU_LEGACY_H |
| 10 | |
| 11 | #include <linux/types.h> |
| 12 | |
| 13 | /* |
| 14 | * Multicore arch functions |
| 15 | * |
| 16 | * These should be moved to use the CPU uclass. |
| 17 | */ |
| 18 | int cpu_status(u32 nr); |
| 19 | int cpu_reset(u32 nr); |
| 20 | int cpu_disable(u32 nr); |
| 21 | int cpu_release(u32 nr, int argc, char *const argv[]); |
| 22 | |
| 23 | #if 0 |
| 24 | static inline int cpumask_next(int cpu, unsigned int mask) |
| 25 | { |
| 26 | for (cpu++; !((1 << cpu) & mask); cpu++) |
| 27 | ; |
| 28 | |
| 29 | return cpu; |
| 30 | } |
| 31 | #endif |
| 32 | |
| 33 | #define for_each_cpu(iter, cpu, num_cpus, mask) \ |
| 34 | for (iter = 0, cpu = cpumask_next(-1, mask); \ |
| 35 | iter < num_cpus; \ |
| 36 | iter++, cpu = cpumask_next(cpu, mask)) \ |
| 37 | |
| 38 | int cpu_numcores(void); |
| 39 | int cpu_num_dspcores(void); |
| 40 | u32 cpu_mask(void); |
| 41 | u32 cpu_dsp_mask(void); |
| 42 | int is_core_valid(unsigned int core); |
| 43 | |
| 44 | /** |
| 45 | * checkcpu() - perform an early check of the CPU |
| 46 | * |
| 47 | * This is used on PowerPC, SH and X86 machines as a CPU init mechanism. It is |
| 48 | * called during the pre-relocation init sequence in board_init_f(). |
| 49 | * |
| 50 | * @return 0 if oK, -ve on error |
| 51 | */ |
| 52 | int checkcpu(void); |
| 53 | |
| 54 | void smp_set_core_boot_addr(unsigned long addr, int corenr); |
| 55 | void smp_kick_all_cpus(void); |
| 56 | |
| 57 | int icache_status(void); |
| 58 | void icache_enable(void); |
| 59 | void icache_disable(void); |
| 60 | int dcache_status(void); |
| 61 | void dcache_enable(void); |
| 62 | void dcache_disable(void); |
| 63 | void mmu_disable(void); |
| 64 | |
| 65 | /* arch/$(ARCH)/lib/cache.c */ |
| 66 | void enable_caches(void); |
| 67 | void flush_cache(unsigned long addr, unsigned long size); |
| 68 | void flush_dcache_all(void); |
| 69 | void flush_dcache_range(unsigned long start, unsigned long stop); |
| 70 | void invalidate_dcache_range(unsigned long start, unsigned long stop); |
| 71 | void invalidate_dcache_all(void); |
| 72 | void invalidate_icache_all(void); |
| 73 | |
| 74 | enum { |
| 75 | /* Disable caches (else flush caches but leave them active) */ |
| 76 | CBL_DISABLE_CACHES = 1 << 0, |
| 77 | CBL_SHOW_BOOTSTAGE_REPORT = 1 << 1, |
| 78 | |
| 79 | CBL_ALL = 3, |
| 80 | }; |
| 81 | |
| 82 | /** |
| 83 | * Clean up ready for linux |
| 84 | * |
| 85 | * @param flags Flags to control what is done |
| 86 | */ |
| 87 | int cleanup_before_linux_select(int flags); |
| 88 | |
| 89 | void reset_cpu(ulong addr); |
| 90 | ; |
| 91 | #endif |