1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * Copyright (C) 2022, Ovidiu Panait <ovpanait@gmail.com> 4 */ 5 6 #ifndef __ASM_MICROBLAZE_CPUINFO_H 7 #define __ASM_MICROBLAZE_CPUINFO_H 8 9 /** 10 * struct microblaze_cpuinfo - CPU info for microblaze processor core. 11 * 12 * @icache_size: Size of instruction cache memory in bytes. 13 * @icache_line_length: Instruction cache line length in bytes. 14 * @dcache_size: Size of data cache memory in bytes. 15 * @dcache_line_length: Data cache line length in bytes. 16 * @use_mmu: MMU support flag. 17 * @cpu_freq: Cpu clock frequency in Hz. 18 * @addr_size: Address bus width in bits. 19 * @ver_code: Cpu version code. 20 * @fpga_code: FPGA family version code. 21 */ 22 struct microblaze_cpuinfo { 23 u32 icache_size; 24 u32 icache_line_length; 25 26 u32 dcache_size; 27 u32 dcache_line_length; 28 29 #if IS_ENABLED(CONFIG_CPU_MICROBLAZE) 30 u32 use_mmu; 31 u32 cpu_freq; 32 u32 addr_size; 33 34 u32 ver_code; 35 u32 fpga_code; 36 #endif /* CONFIG_CPU_MICROBLAZE */ 37 }; 38 39 /** 40 * struct microblaze_version_data - Maps a hex version code to a cpu/fpga name. 41 */ 42 struct microblaze_version_map { 43 const char *string; 44 const u32 code; 45 }; 46 47 /** 48 * microblaze_lookup_cpu_version_code() - Get hex version code for the 49 * specified cpu name string. 50 * 51 * This function searches the cpu_ver_lookup[] array for the hex version code 52 * associated with a specific CPU name. The version code is returned if a match 53 * is found, otherwise 0. 54 * 55 * @string: cpu name string 56 * 57 * Return: >0 if the entry is found, 0 otherwise. 58 */ 59 const u32 microblaze_lookup_cpu_version_code(const char *string); 60 61 /** 62 * microblaze_lookup_fpga_family_code() - Get hex version code for the 63 * specified fpga family name. 64 * 65 * This function searches the family_string_lookup[] array for the hex version 66 * code associated with a specific fpga family name. The version code is 67 * returned if a match is found, otherwise 0. 68 * 69 * @string: fpga family name string 70 * 71 * Return: >0 if the entry is found, 0 otherwise. 72 */ 73 const u32 microblaze_lookup_fpga_family_code(const char *string); 74 75 /** 76 * microblaze_lookup_cpu_version_string() - Get cpu name for the specified cpu 77 * version code. 78 * 79 * This function searches the cpu_ver_lookup[] array for the cpu name string 80 * associated with a specific version code. The cpu name is returned if a match 81 * is found, otherwise "(unknown)". 82 * 83 * @code: cpu version code 84 * 85 * Return: Pointer to the cpu name if the entry is found, otherwise "(unknown)". 86 */ 87 const char *microblaze_lookup_cpu_version_string(const u32 code); 88 89 /** 90 * microblaze_lookup_fpga_family_string() - Get fpga family name for the 91 * specified version code. 92 * 93 * This function searches the family_string_lookup[] array for the fpga family 94 * name string associated with a specific version code. The fpga family name is 95 * returned if a match is found, otherwise "(unknown)". 96 * 97 * @code: fpga family version code 98 * 99 * Return: Pointer to the fpga family name if the entry is found, otherwise 100 * "(unknown)". 101 */ 102 const char *microblaze_lookup_fpga_family_string(const u32 code); 103 104 /** 105 * microblaze_early_cpuinfo_init() - Initialize cpuinfo with default values. 106 * 107 * Initializes the global data cpuinfo structure with default values (cache 108 * size, cache line size, etc.). It is called very early in the boot process 109 * (start.S codepath right before the first cache flush call) to ensure that 110 * cache related operations are properly handled. 111 */ 112 void microblaze_early_cpuinfo_init(void); 113 114 #endif /* __ASM_MICROBLAZE_CPUINFO_H */ 115