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