blob: 59091c112fdb5f19abb8f6aeda5af24d67f03116 [file] [log] [blame]
Subrata Banik930c31c2019-11-01 18:12:58 +05301/*
2 * This file is part of the coreboot project.
3 *
Subrata Banik930c31c2019-11-01 18:12:58 +05304 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15/*
16 * This file is created based on Intel Tiger Lake Platform Stepping and IDs
17 * Document number: 605534
18 * Chapter number: 2, 4, 5, 6
19 */
20
21#include <arch/cpu.h>
22#include <device/pci_ops.h>
23#include <console/console.h>
24#include <cpu/x86/msr.h>
25#include <device/pci.h>
26#include <device/pci_ids.h>
27#include <intelblocks/mp_init.h>
28#include <soc/bootblock.h>
29#include <soc/pch.h>
30#include <soc/pci_devs.h>
31#include <string.h>
32
33#define BIOS_SIGN_ID 0x8B
34
Subrata Banikae695752019-11-12 12:47:43 +053035static struct {
36 u32 cpuid;
37 const char *name;
38} cpu_table[] = {
39 { CPUID_TIGERLAKE_A0, "Tigerlake A0" },
40};
41
42static struct {
43 u16 mchid;
44 const char *name;
45} mch_table[] = {
46 { PCI_DEVICE_ID_INTEL_TGL_ID_U, "Tigerlake-U-4-2" },
47 { PCI_DEVICE_ID_INTEL_TGL_ID_U_1, "Tigerlake-U-4-3e" },
Srinidhi N Kaushik1d812e82020-02-07 15:51:09 -080048 { PCI_DEVICE_ID_INTEL_TGL_ID_U_2_2, "Tigerlake-U-2-2" },
Subrata Banikae695752019-11-12 12:47:43 +053049 { PCI_DEVICE_ID_INTEL_TGL_ID_Y, "Tigerlake-Y-4-2" },
Tan, Lean Sheng26136092020-01-20 19:13:56 -080050 { PCI_DEVICE_ID_INTEL_JSL_EHL, "Jasperlake Elkhartlake" },
51 { PCI_DEVICE_ID_INTEL_EHL_ID_1, "Elkhartlake-1" },
Subrata Banikae695752019-11-12 12:47:43 +053052};
53
54static struct {
55 u16 espiid;
56 const char *name;
57} pch_table[] = {
58 { PCI_DEVICE_ID_INTEL_TGP_ESPI_0, "Tigerlake-Base SKU" },
59 { PCI_DEVICE_ID_INTEL_TGP_SUPER_U_ESPI, "Tigerlake-U Super SKU" },
60 { PCI_DEVICE_ID_INTEL_TGP_PREMIUM_U_ESPI, "Tigerlake-U Premium SKU" },
61 { PCI_DEVICE_ID_INTEL_TGP_BASE_U_ESPI, "Tigerlake-U Base SKU" },
62 { PCI_DEVICE_ID_INTEL_TGP_ESPI_1, "Tigerlake-Base SKU" },
63 { PCI_DEVICE_ID_INTEL_TGP_ESPI_2, "Tigerlake-Base SKU" },
64 { PCI_DEVICE_ID_INTEL_TGP_SUPER_Y_ESPI, "Tigerlake-Y Super SKU" },
65 { PCI_DEVICE_ID_INTEL_TGP_PREMIUM_Y_ESPI, "Tigerlake-Y Premium SKU" },
66 { PCI_DEVICE_ID_INTEL_TGP_ESPI_3, "Tigerlake-Base SKU" },
67 { PCI_DEVICE_ID_INTEL_TGP_ESPI_4, "Tigerlake-Base SKU" },
68 { PCI_DEVICE_ID_INTEL_TGP_ESPI_5, "Tigerlake-Base SKU" },
69 { PCI_DEVICE_ID_INTEL_TGP_ESPI_6, "Tigerlake-Base SKU" },
70 { PCI_DEVICE_ID_INTEL_TGP_ESPI_7, "Tigerlake-Base SKU" },
71 { PCI_DEVICE_ID_INTEL_TGP_ESPI_8, "Tigerlake-Base SKU" },
72 { PCI_DEVICE_ID_INTEL_TGP_ESPI_9, "Tigerlake-Base SKU" },
73 { PCI_DEVICE_ID_INTEL_TGP_ESPI_10, "Tigerlake-Base SKU" },
74 { PCI_DEVICE_ID_INTEL_TGP_ESPI_11, "Tigerlake-Base SKU" },
75 { PCI_DEVICE_ID_INTEL_TGP_ESPI_12, "Tigerlake-Base SKU" },
76 { PCI_DEVICE_ID_INTEL_TGP_ESPI_13, "Tigerlake-Base SKU" },
77 { PCI_DEVICE_ID_INTEL_TGP_ESPI_14, "Tigerlake-Base SKU" },
78 { PCI_DEVICE_ID_INTEL_TGP_ESPI_15, "Tigerlake-Base SKU" },
79 { PCI_DEVICE_ID_INTEL_TGP_ESPI_16, "Tigerlake-Base SKU" },
80 { PCI_DEVICE_ID_INTEL_TGP_ESPI_17, "Tigerlake-Base SKU" },
81 { PCI_DEVICE_ID_INTEL_TGP_ESPI_18, "Tigerlake-Base SKU" },
82 { PCI_DEVICE_ID_INTEL_TGP_ESPI_19, "Tigerlake-Base SKU" },
83 { PCI_DEVICE_ID_INTEL_TGP_ESPI_20, "Tigerlake-Base SKU" },
84 { PCI_DEVICE_ID_INTEL_TGP_ESPI_21, "Tigerlake-Base SKU" },
85 { PCI_DEVICE_ID_INTEL_TGP_ESPI_22, "Tigerlake-Base SKU" },
86 { PCI_DEVICE_ID_INTEL_TGP_ESPI_23, "Tigerlake-Base SKU" },
87 { PCI_DEVICE_ID_INTEL_TGP_ESPI_24, "Tigerlake-Base SKU" },
88 { PCI_DEVICE_ID_INTEL_TGP_ESPI_25, "Tigerlake-Base SKU" },
89 { PCI_DEVICE_ID_INTEL_TGP_ESPI_26, "Tigerlake-Base SKU" },
Tan, Lean Sheng26136092020-01-20 19:13:56 -080090 { PCI_DEVICE_ID_INTEL_MCC_ESPI_0, "Elkhartlake-0" },
91 { PCI_DEVICE_ID_INTEL_MCC_ESPI_1, "Elkhartlake-1" },
92 { PCI_DEVICE_ID_INTEL_MCC_BASE_ESPI, "Elkhartlake Base" },
93 { PCI_DEVICE_ID_INTEL_MCC_PREMIUM_ESPI, "Elkhartlake Premium" },
94 { PCI_DEVICE_ID_INTEL_MCC_SUPER_ESPI, "Elkhartlake Super" },
Subrata Banikae695752019-11-12 12:47:43 +053095};
96
97static struct {
98 u16 igdid;
99 const char *name;
100} igd_table[] = {
101 { PCI_DEVICE_ID_INTEL_TGL_GT0, "Tigerlake U GT0" },
102 { PCI_DEVICE_ID_INTEL_TGL_GT2_ULT, "Tigerlake U GT2" },
103 { PCI_DEVICE_ID_INTEL_TGL_GT2_ULX, "Tigerlake Y GT2" },
104 { PCI_DEVICE_ID_INTEL_TGL_GT3_ULT, "Tigerlake U GT3" },
Tan, Lean Sheng26136092020-01-20 19:13:56 -0800105 { PCI_DEVICE_ID_INTEL_EHL_GT1_1, "Elkhartlake GT1 1" },
106 { PCI_DEVICE_ID_INTEL_EHL_GT2_1, "Elkhartlake GT2 1" },
107 { PCI_DEVICE_ID_INTEL_EHL_GT1_2, "Elkhartlake GT1 2" },
108 { PCI_DEVICE_ID_INTEL_EHL_GT2_2, "Elkhartlake GT2 2" },
109 { PCI_DEVICE_ID_INTEL_EHL_GT1_3, "Elkhartlake GT1 3" },
110 { PCI_DEVICE_ID_INTEL_EHL_GT2_3, "Elkhartlake GT2 3" },
Subrata Banikae695752019-11-12 12:47:43 +0530111};
Subrata Banik930c31c2019-11-01 18:12:58 +0530112
113static inline uint8_t get_dev_revision(pci_devfn_t dev)
114{
115 return pci_read_config8(dev, PCI_REVISION_ID);
116}
117
118static inline uint16_t get_dev_id(pci_devfn_t dev)
119{
120 return pci_read_config16(dev, PCI_DEVICE_ID);
121}
122
123static void report_cpu_info(void)
124{
125 struct cpuid_result cpuidr;
126 u32 i, index, cpu_id, cpu_feature_flag;
127 const char cpu_not_found[] = "Platform info not available";
128 const char *cpu_name = cpu_not_found; /* 48 bytes are reported */
129 int vt, txt, aes;
130 msr_t microcode_ver;
131 static const char *const mode[] = {"NOT ", ""};
132 const char *cpu_type = "Unknown";
133 u32 p[13];
134
135 index = 0x80000000;
136 cpuidr = cpuid(index);
137 if (cpuidr.eax >= 0x80000004) {
138 int j = 0;
139
140 for (i = 2; i <= 4; i++) {
141 cpuidr = cpuid(index + i);
142 p[j++] = cpuidr.eax;
143 p[j++] = cpuidr.ebx;
144 p[j++] = cpuidr.ecx;
145 p[j++] = cpuidr.edx;
146 }
147 p[12] = 0;
148 cpu_name = (char *)p;
149
150 /* Skip leading spaces in CPU name string */
151 while (cpu_name[0] == ' ' && strlen(cpu_name) > 0)
152 cpu_name++;
153 }
154
155 microcode_ver.lo = 0;
156 microcode_ver.hi = 0;
157 wrmsr(BIOS_SIGN_ID, microcode_ver);
158 cpu_id = cpu_get_cpuid();
159 microcode_ver = rdmsr(BIOS_SIGN_ID);
160
161 /* Look for string to match the name */
162 for (i = 0; i < ARRAY_SIZE(cpu_table); i++) {
163 if (cpu_table[i].cpuid == cpu_id) {
164 cpu_type = cpu_table[i].name;
165 break;
166 }
167 }
168
169 printk(BIOS_DEBUG, "CPU: %s\n", cpu_name);
170 printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n",
171 cpu_id, cpu_type, microcode_ver.hi);
172
173 cpu_feature_flag = cpu_get_feature_flags_ecx();
174 aes = (cpu_feature_flag & CPUID_AES) ? 1 : 0;
175 txt = (cpu_feature_flag & CPUID_SMX) ? 1 : 0;
176 vt = (cpu_feature_flag & CPUID_VMX) ? 1 : 0;
177 printk(BIOS_DEBUG,
178 "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n",
179 mode[aes], mode[txt], mode[vt]);
180}
181
182static void report_mch_info(void)
183{
184 int i;
185 pci_devfn_t dev = SA_DEV_ROOT;
186 uint16_t mchid = get_dev_id(dev);
187 uint8_t mch_revision = get_dev_revision(dev);
188 const char *mch_type = "Unknown";
189
190 for (i = 0; i < ARRAY_SIZE(mch_table); i++) {
191 if (mch_table[i].mchid == mchid) {
192 mch_type = mch_table[i].name;
193 break;
194 }
195 }
196
197 printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n",
198 mchid, mch_revision, mch_type);
199}
200
201static void report_pch_info(void)
202{
203 int i;
204 pci_devfn_t dev = PCH_DEV_ESPI;
205 uint16_t espiid = get_dev_id(dev);
206 const char *pch_type = "Unknown";
207
208 for (i = 0; i < ARRAY_SIZE(pch_table); i++) {
209 if (pch_table[i].espiid == espiid) {
210 pch_type = pch_table[i].name;
211 break;
212 }
213 }
214 printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n",
215 espiid, get_dev_revision(dev), pch_type);
216}
217
218static void report_igd_info(void)
219{
220 int i;
221 pci_devfn_t dev = SA_DEV_IGD;
222 uint16_t igdid = get_dev_id(dev);
223 const char *igd_type = "Unknown";
224
225 for (i = 0; i < ARRAY_SIZE(igd_table); i++) {
226 if (igd_table[i].igdid == igdid) {
227 igd_type = igd_table[i].name;
228 break;
229 }
230 }
231 printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n",
232 igdid, get_dev_revision(dev), igd_type);
233}
234
235void report_platform_info(void)
236{
237 report_cpu_info();
238 report_mch_info();
239 report_pch_info();
240 report_igd_info();
241}