1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
/* SPDX-License-Identifier: GPL-2.0-only */
#include <arch/cpu.h>
#include <console/console.h>
#include <FspGuids.h>
#include <fsp/util.h>
#include <misc_data.h>
#include <soc/cpu.h>
#include <soc/soc_util.h>
#include <types.h>
#define SOCKET_TYPE_SHIFT 28
#define SOCKET_TYPSE_MASK (0xf << SOCKET_TYPE_SHIFT)
/* some Pollock engineering samples return the wrong socket type */
enum socket_type get_socket_type(void)
{
uint32_t ebx = cpuid_ebx(0x80000001);
ebx = (ebx & SOCKET_TYPSE_MASK) >> SOCKET_TYPE_SHIFT;
return (enum socket_type)ebx;
}
void print_socket_type(void)
{
enum socket_type socket = get_socket_type();
printk(BIOS_INFO, "Socket type: ");
switch (socket) {
case SOCKET_FP5:
printk(BIOS_INFO, "FP5\n");
break;
case SOCKET_AM4:
printk(BIOS_INFO, "AM4\n");
break;
case SOCKET_FT5:
printk(BIOS_INFO, "FT5\n");
break;
default:
printk(BIOS_INFO, "unknown\n");
}
}
/* returns 0 in case or errors */
static uint32_t get_internal_silicon_type(void)
{
static uint32_t silicon_type;
size_t hob_size = 0;
const struct picasso_misc_data *hob;
if (silicon_type)
return silicon_type;
hob = fsp_find_extension_hob_by_guid(PICASSO_MISC_DATA_HOB_GUID.b, &hob_size);
if (hob == NULL || hob_size == 0) {
printk(BIOS_ERR, "Couldn't find Picasso misc data HOB.\n");
return 0;
}
if (hob->version != PICASSO_MISC_DATA_VERSION) {
printk(BIOS_ERR, "Unexpected Picasso misc data HOB version.\n");
return 0;
}
silicon_type = hob->silicon_id;
printk(BIOS_DEBUG, "Silicon ID = 0x%x\n", silicon_type);
return silicon_type;
}
#define SILICON_IS_MYSTERY_MEAT (1 << 31)
#define SILICON_IS_RV2 (1 << 30)
static bool is_rv2_silicon(void)
{
return get_internal_silicon_type() & SILICON_IS_RV2;
}
static bool is_mystery_silicon(void)
{
return get_internal_silicon_type() & SILICON_IS_MYSTERY_MEAT;
}
static bool is_fam17_1x(void)
{
/* mask lower model number nibble and stepping */
return cpuid_eax(1) >> 8 == PICASSO_B1_CPUID >> 8;
}
static bool is_fam17_11(void)
{
/* only mask stepping */
return cpuid_eax(1) >> 4 == RAVEN1_B0_CPUID >> 4;
}
static bool is_fam17_18(void)
{
/* only mask stepping */
return cpuid_eax(1) >> 4 == PICASSO_B1_CPUID >> 4;
}
static bool is_fam17_2x(void)
{
/* mask lower model number nibble and stepping */
return cpuid_eax(1) >> 8 == RAVEN2_A1_CPUID >> 8;
}
static bool is_fam17_20(void)
{
/* only mask stepping */
return cpuid_eax(1) >> 4 == RAVEN2_A1_CPUID >> 4;
}
enum silicon_type get_silicon_type(void)
{
/*
* RV2 is fam17_20, but might return a fam17_1x CPUID in the is_mystery_silicon() case.
* is_rv2_silicon() has the correct information, but requires the HOB to be present.
*/
if (is_fam17_20() || is_rv2_silicon())
return SILICON_RV2;
if (is_fam17_18() && !is_rv2_silicon())
return SILICON_PCO;
if (is_fam17_11() && !is_rv2_silicon())
return SILICON_RV1;
/* some cases might still be missing */
return SILICON_UNKNOWN;
}
/* some Pollock engineering samples return the wrong socket type and get detected as Dali */
enum soc_type get_soc_type(void)
{
switch (get_socket_type()) {
case SOCKET_FP5:
if (is_fam17_1x() && !is_mystery_silicon())
return SOC_PICASSO;
if (is_fam17_2x() || (is_fam17_1x() && is_mystery_silicon()))
return SOC_DALI;
break;
case SOCKET_FT5:
/* add is_fam17_20() CPUID sanity check here? */
return SOC_POLLOCK;
break;
case SOCKET_AM4:
/* AM4 SoC type detection logic not implemented */
break;
}
return SOC_UNKNOWN;
}
void print_silicon_type(void)
{
const enum silicon_type silicon = get_silicon_type();
printk(BIOS_INFO, "Silicon type: ");
switch (silicon) {
case SILICON_RV1:
printk(BIOS_INFO, "RV1\n");
break;
case SILICON_PCO:
printk(BIOS_INFO, "PCO\n");
break;
case SILICON_RV2:
printk(BIOS_INFO, "RV2\n");
break;
default:
printk(BIOS_INFO, "unknown\n");
}
}
void print_soc_type(void)
{
const enum soc_type soc = get_soc_type();
printk(BIOS_INFO, "SoC type: ");
switch (soc) {
case SOC_PICASSO:
printk(BIOS_INFO, "Picasso\n");
break;
case SOC_DALI:
printk(BIOS_INFO, "Dali\n");
break;
case SOC_POLLOCK:
printk(BIOS_INFO, "Pollock\n");
break;
default:
printk(BIOS_INFO, "unknown\n");
}
}
bool soc_is_dali(void)
{
return get_soc_type() == SOC_DALI;
}
bool soc_is_raven2(void)
{
return get_silicon_type() == SILICON_RV2;
}
|