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