blob: 41061ee03b62b732d9dbd322c7f54b6ae848141e [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" },
50};
51
52static struct {
53 u16 espiid;
54 const char *name;
55} pch_table[] = {
56 { PCI_DEVICE_ID_INTEL_TGP_ESPI_0, "Tigerlake-Base SKU" },
57 { PCI_DEVICE_ID_INTEL_TGP_SUPER_U_ESPI, "Tigerlake-U Super SKU" },
58 { PCI_DEVICE_ID_INTEL_TGP_PREMIUM_U_ESPI, "Tigerlake-U Premium SKU" },
59 { PCI_DEVICE_ID_INTEL_TGP_BASE_U_ESPI, "Tigerlake-U Base SKU" },
60 { PCI_DEVICE_ID_INTEL_TGP_ESPI_1, "Tigerlake-Base SKU" },
61 { PCI_DEVICE_ID_INTEL_TGP_ESPI_2, "Tigerlake-Base SKU" },
62 { PCI_DEVICE_ID_INTEL_TGP_SUPER_Y_ESPI, "Tigerlake-Y Super SKU" },
63 { PCI_DEVICE_ID_INTEL_TGP_PREMIUM_Y_ESPI, "Tigerlake-Y Premium SKU" },
64 { PCI_DEVICE_ID_INTEL_TGP_ESPI_3, "Tigerlake-Base SKU" },
65 { PCI_DEVICE_ID_INTEL_TGP_ESPI_4, "Tigerlake-Base SKU" },
66 { PCI_DEVICE_ID_INTEL_TGP_ESPI_5, "Tigerlake-Base SKU" },
67 { PCI_DEVICE_ID_INTEL_TGP_ESPI_6, "Tigerlake-Base SKU" },
68 { PCI_DEVICE_ID_INTEL_TGP_ESPI_7, "Tigerlake-Base SKU" },
69 { PCI_DEVICE_ID_INTEL_TGP_ESPI_8, "Tigerlake-Base SKU" },
70 { PCI_DEVICE_ID_INTEL_TGP_ESPI_9, "Tigerlake-Base SKU" },
71 { PCI_DEVICE_ID_INTEL_TGP_ESPI_10, "Tigerlake-Base SKU" },
72 { PCI_DEVICE_ID_INTEL_TGP_ESPI_11, "Tigerlake-Base SKU" },
73 { PCI_DEVICE_ID_INTEL_TGP_ESPI_12, "Tigerlake-Base SKU" },
74 { PCI_DEVICE_ID_INTEL_TGP_ESPI_13, "Tigerlake-Base SKU" },
75 { PCI_DEVICE_ID_INTEL_TGP_ESPI_14, "Tigerlake-Base SKU" },
76 { PCI_DEVICE_ID_INTEL_TGP_ESPI_15, "Tigerlake-Base SKU" },
77 { PCI_DEVICE_ID_INTEL_TGP_ESPI_16, "Tigerlake-Base SKU" },
78 { PCI_DEVICE_ID_INTEL_TGP_ESPI_17, "Tigerlake-Base SKU" },
79 { PCI_DEVICE_ID_INTEL_TGP_ESPI_18, "Tigerlake-Base SKU" },
80 { PCI_DEVICE_ID_INTEL_TGP_ESPI_19, "Tigerlake-Base SKU" },
81 { PCI_DEVICE_ID_INTEL_TGP_ESPI_20, "Tigerlake-Base SKU" },
82 { PCI_DEVICE_ID_INTEL_TGP_ESPI_21, "Tigerlake-Base SKU" },
83 { PCI_DEVICE_ID_INTEL_TGP_ESPI_22, "Tigerlake-Base SKU" },
84 { PCI_DEVICE_ID_INTEL_TGP_ESPI_23, "Tigerlake-Base SKU" },
85 { PCI_DEVICE_ID_INTEL_TGP_ESPI_24, "Tigerlake-Base SKU" },
86 { PCI_DEVICE_ID_INTEL_TGP_ESPI_25, "Tigerlake-Base SKU" },
87 { PCI_DEVICE_ID_INTEL_TGP_ESPI_26, "Tigerlake-Base SKU" },
88};
89
90static struct {
91 u16 igdid;
92 const char *name;
93} igd_table[] = {
94 { PCI_DEVICE_ID_INTEL_TGL_GT0, "Tigerlake U GT0" },
95 { PCI_DEVICE_ID_INTEL_TGL_GT2_ULT, "Tigerlake U GT2" },
96 { PCI_DEVICE_ID_INTEL_TGL_GT2_ULX, "Tigerlake Y GT2" },
97 { PCI_DEVICE_ID_INTEL_TGL_GT3_ULT, "Tigerlake U GT3" },
98};
Subrata Banik930c31c2019-11-01 18:12:58 +053099
100static inline uint8_t get_dev_revision(pci_devfn_t dev)
101{
102 return pci_read_config8(dev, PCI_REVISION_ID);
103}
104
105static inline uint16_t get_dev_id(pci_devfn_t dev)
106{
107 return pci_read_config16(dev, PCI_DEVICE_ID);
108}
109
110static void report_cpu_info(void)
111{
112 struct cpuid_result cpuidr;
113 u32 i, index, cpu_id, cpu_feature_flag;
114 const char cpu_not_found[] = "Platform info not available";
115 const char *cpu_name = cpu_not_found; /* 48 bytes are reported */
116 int vt, txt, aes;
117 msr_t microcode_ver;
118 static const char *const mode[] = {"NOT ", ""};
119 const char *cpu_type = "Unknown";
120 u32 p[13];
121
122 index = 0x80000000;
123 cpuidr = cpuid(index);
124 if (cpuidr.eax >= 0x80000004) {
125 int j = 0;
126
127 for (i = 2; i <= 4; i++) {
128 cpuidr = cpuid(index + i);
129 p[j++] = cpuidr.eax;
130 p[j++] = cpuidr.ebx;
131 p[j++] = cpuidr.ecx;
132 p[j++] = cpuidr.edx;
133 }
134 p[12] = 0;
135 cpu_name = (char *)p;
136
137 /* Skip leading spaces in CPU name string */
138 while (cpu_name[0] == ' ' && strlen(cpu_name) > 0)
139 cpu_name++;
140 }
141
142 microcode_ver.lo = 0;
143 microcode_ver.hi = 0;
144 wrmsr(BIOS_SIGN_ID, microcode_ver);
145 cpu_id = cpu_get_cpuid();
146 microcode_ver = rdmsr(BIOS_SIGN_ID);
147
148 /* Look for string to match the name */
149 for (i = 0; i < ARRAY_SIZE(cpu_table); i++) {
150 if (cpu_table[i].cpuid == cpu_id) {
151 cpu_type = cpu_table[i].name;
152 break;
153 }
154 }
155
156 printk(BIOS_DEBUG, "CPU: %s\n", cpu_name);
157 printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n",
158 cpu_id, cpu_type, microcode_ver.hi);
159
160 cpu_feature_flag = cpu_get_feature_flags_ecx();
161 aes = (cpu_feature_flag & CPUID_AES) ? 1 : 0;
162 txt = (cpu_feature_flag & CPUID_SMX) ? 1 : 0;
163 vt = (cpu_feature_flag & CPUID_VMX) ? 1 : 0;
164 printk(BIOS_DEBUG,
165 "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n",
166 mode[aes], mode[txt], mode[vt]);
167}
168
169static void report_mch_info(void)
170{
171 int i;
172 pci_devfn_t dev = SA_DEV_ROOT;
173 uint16_t mchid = get_dev_id(dev);
174 uint8_t mch_revision = get_dev_revision(dev);
175 const char *mch_type = "Unknown";
176
177 for (i = 0; i < ARRAY_SIZE(mch_table); i++) {
178 if (mch_table[i].mchid == mchid) {
179 mch_type = mch_table[i].name;
180 break;
181 }
182 }
183
184 printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n",
185 mchid, mch_revision, mch_type);
186}
187
188static void report_pch_info(void)
189{
190 int i;
191 pci_devfn_t dev = PCH_DEV_ESPI;
192 uint16_t espiid = get_dev_id(dev);
193 const char *pch_type = "Unknown";
194
195 for (i = 0; i < ARRAY_SIZE(pch_table); i++) {
196 if (pch_table[i].espiid == espiid) {
197 pch_type = pch_table[i].name;
198 break;
199 }
200 }
201 printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n",
202 espiid, get_dev_revision(dev), pch_type);
203}
204
205static void report_igd_info(void)
206{
207 int i;
208 pci_devfn_t dev = SA_DEV_IGD;
209 uint16_t igdid = get_dev_id(dev);
210 const char *igd_type = "Unknown";
211
212 for (i = 0; i < ARRAY_SIZE(igd_table); i++) {
213 if (igd_table[i].igdid == igdid) {
214 igd_type = igd_table[i].name;
215 break;
216 }
217 }
218 printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n",
219 igdid, get_dev_revision(dev), igd_type);
220}
221
222void report_platform_info(void)
223{
224 report_cpu_info();
225 report_mch_info();
226 report_pch_info();
227 report_igd_info();
228}