blob: 2bfdf767f3a5aca641934f935b73cff1d1c153da [file] [log] [blame]
Ovidiu Panait87a739e2022-05-31 21:14:31 +03001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2022, Ovidiu Panait <ovpanait@gmail.com>
4 */
Ovidiu Panait87a739e2022-05-31 21:14:31 +03005#include <asm/cpuinfo.h>
6#include <asm/global_data.h>
7
8DECLARE_GLOBAL_DATA_PTR;
9
Simon Glassefe13ba2023-02-05 15:39:31 -070010#if IS_ENABLED(CONFIG_CPU_MICROBLAZE)
Ovidiu Panait64be9782022-05-31 21:14:35 +030011/* These key value are as per MBV field in PVR0 */
12static const struct microblaze_version_map cpu_ver_lookup[] = {
13 {"5.00.a", 0x01},
14 {"5.00.b", 0x02},
15 {"5.00.c", 0x03},
16 {"6.00.a", 0x04},
17 {"6.00.b", 0x06},
18 {"7.00.a", 0x05},
19 {"7.00.b", 0x07},
20 {"7.10.a", 0x08},
21 {"7.10.b", 0x09},
22 {"7.10.c", 0x0a},
23 {"7.10.d", 0x0b},
24 {"7.20.a", 0x0c},
25 {"7.20.b", 0x0d},
26 {"7.20.c", 0x0e},
27 {"7.20.d", 0x0f},
28 {"7.30.a", 0x10},
29 {"7.30.b", 0x11},
30 {"8.00.a", 0x12},
31 {"8.00.b", 0x13},
32 {"8.10.a", 0x14},
33 {"8.20.a", 0x15},
34 {"8.20.b", 0x16},
35 {"8.30.a", 0x17},
36 {"8.40.a", 0x18},
37 {"8.40.b", 0x19},
38 {"8.50.a", 0x1a},
39 {"8.50.b", 0x1c},
40 {"8.50.c", 0x1e},
41 {"9.0", 0x1b},
42 {"9.1", 0x1d},
43 {"9.2", 0x1f},
44 {"9.3", 0x20},
45 {"9.4", 0x21},
46 {"9.5", 0x22},
47 {"9.6", 0x23},
48 {"10.0", 0x24},
49 {"11.0", 0x25},
50 {NULL, 0},
51};
52
53static const struct microblaze_version_map family_string_lookup[] = {
54 {"virtex2", 0x4},
55 {"virtex2pro", 0x5},
56 {"spartan3", 0x6},
57 {"virtex4", 0x7},
58 {"virtex5", 0x8},
59 {"spartan3e", 0x9},
60 {"spartan3a", 0xa},
61 {"spartan3an", 0xb},
62 {"spartan3adsp", 0xc},
63 {"spartan6", 0xd},
64 {"virtex6", 0xe},
65 {"virtex7", 0xf},
66 /* FIXME There is no key code defined for spartan2 */
67 {"spartan2", 0xf0},
68 {"kintex7", 0x10},
69 {"artix7", 0x11},
70 {"zynq7000", 0x12},
71 {"UltraScale Virtex", 0x13},
72 {"UltraScale Kintex", 0x14},
73 {"UltraScale+ Zynq", 0x15},
74 {"UltraScale+ Virtex", 0x16},
75 {"UltraScale+ Kintex", 0x17},
76 {"Spartan7", 0x18},
77 {NULL, 0},
78};
79
80static const char *lookup_string(u32 code,
81 const struct microblaze_version_map *entry)
82{
83 for (; entry->string; ++entry)
84 if (entry->code == code)
85 return entry->string;
86
87 return "(unknown)";
88}
89
90static const u32 lookup_code(const char *string,
91 const struct microblaze_version_map *entry)
92{
93 for (; entry->string; ++entry)
94 if (!strcmp(entry->string, string))
95 return entry->code;
96
97 return 0;
98}
99
100const char *microblaze_lookup_fpga_family_string(const u32 code)
101{
102 return lookup_string(code, family_string_lookup);
103}
104
105const char *microblaze_lookup_cpu_version_string(const u32 code)
106{
107 return lookup_string(code, cpu_ver_lookup);
108}
109
110const u32 microblaze_lookup_fpga_family_code(const char *string)
111{
112 return lookup_code(string, family_string_lookup);
113}
114
115const u32 microblaze_lookup_cpu_version_code(const char *string)
116{
117 return lookup_code(string, cpu_ver_lookup);
118}
119#endif /* CONFIG_CPU_MICROBLAZE */
120
Ovidiu Panait87a739e2022-05-31 21:14:31 +0300121void microblaze_early_cpuinfo_init(void)
122{
123 struct microblaze_cpuinfo *ci = gd_cpuinfo();
124
125 ci->icache_size = CONFIG_XILINX_MICROBLAZE0_ICACHE_SIZE;
126 ci->icache_line_length = 4;
127
128 ci->dcache_size = CONFIG_XILINX_MICROBLAZE0_DCACHE_SIZE;
129 ci->dcache_line_length = 4;
130}