blob: 89dd1547c0f83f12d4bd09337f5c9df91b60f05c [file] [log] [blame]
Lee Leahyb0005132015-05-12 18:19:47 -07001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 Google Inc.
Lee Leahy1d14b3e2015-05-12 18:23:27 -07005 * Copyright (C) 2015 Intel Corporation.
Lee Leahyb0005132015-05-12 18:19:47 -07006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Lee Leahyb0005132015-05-12 18:19:47 -070015 */
16
17#include <arch/cpu.h>
Kyösti Mälkkif1b58b72019-03-01 13:43:02 +020018#include <device/pci_ops.h>
Lee Leahyb0005132015-05-12 18:19:47 -070019#include <console/console.h>
Lee Leahyb0005132015-05-12 18:19:47 -070020#include <cpu/x86/msr.h>
Lee Leahy1d14b3e2015-05-12 18:23:27 -070021#include <device/pci.h>
Subrata Banikc2165672017-06-02 17:52:44 +053022#include <device/pci_ids.h>
Barnali Sarkar73273862017-06-13 20:22:33 +053023#include <intelblocks/mp_init.h>
Naresh G Solankiecd9a942016-08-11 14:56:28 +053024#include <soc/bootblock.h>
Lee Leahyb0005132015-05-12 18:19:47 -070025#include <soc/cpu.h>
26#include <soc/pch.h>
27#include <soc/pci_devs.h>
Lee Leahyb0005132015-05-12 18:19:47 -070028#include <soc/systemagent.h>
Lee Leahy1d14b3e2015-05-12 18:23:27 -070029#include <string.h>
Lee Leahyb0005132015-05-12 18:19:47 -070030
31static struct {
32 u32 cpuid;
33 const char *name;
34} cpu_table[] = {
Subrata Banikc2165672017-06-02 17:52:44 +053035 { CPUID_SKYLAKE_C0, "Skylake C0" },
36 { CPUID_SKYLAKE_D0, "Skylake D0" },
37 { CPUID_SKYLAKE_HQ0, "Skylake H Q0" },
38 { CPUID_SKYLAKE_HR0, "Skylake H R0" },
39 { CPUID_KABYLAKE_G0, "Kabylake G0" },
40 { CPUID_KABYLAKE_H0, "Kabylake H0" },
41 { CPUID_KABYLAKE_Y0, "Kabylake Y0" },
42 { CPUID_KABYLAKE_HA0, "Kabylake H A0" },
43 { CPUID_KABYLAKE_HB0, "Kabylake H B0" },
Lee Leahyb0005132015-05-12 18:19:47 -070044};
45
46static struct {
Lee Leahy1d14b3e2015-05-12 18:23:27 -070047 u16 mchid;
Lee Leahyb0005132015-05-12 18:19:47 -070048 const char *name;
Lee Leahy1d14b3e2015-05-12 18:23:27 -070049} mch_table[] = {
Subrata Banikc2165672017-06-02 17:52:44 +053050 { PCI_DEVICE_ID_INTEL_SKL_ID_U, "Skylake-U" },
51 { PCI_DEVICE_ID_INTEL_SKL_ID_Y, "Skylake-Y" },
52 { PCI_DEVICE_ID_INTEL_SKL_ID_ULX, "Skylake-ULX" },
Maxim Polyakovdde937c2019-09-09 15:50:03 +030053 { PCI_DEVICE_ID_INTEL_SKL_ID_H_4, "Skylake-H (4 Core)" },
Subrata Banikc2165672017-06-02 17:52:44 +053054 { PCI_DEVICE_ID_INTEL_SKL_ID_H_EM, "Skylake-H Embedded" },
Keno Fischer1044eba2019-06-07 01:55:56 -040055 { PCI_DEVICE_ID_INTEL_SKL_ID_H_2, "Skylake-H (2 Core)" },
56 { PCI_DEVICE_ID_INTEL_SKL_ID_S_2, "Skylake-S (2 Core)" },
Maxim Polyakova0cd4b12019-08-27 15:58:04 +030057 { PCI_DEVICE_ID_INTEL_SKL_ID_S_4, "Skylake-S (4 Core) / Skylake-DT" },
Subrata Banikc2165672017-06-02 17:52:44 +053058 { PCI_DEVICE_ID_INTEL_KBL_ID_U, "Kabylake-U" },
59 { PCI_DEVICE_ID_INTEL_KBL_U_R, "Kabylake-R ULT"},
60 { PCI_DEVICE_ID_INTEL_KBL_ID_Y, "Kabylake-Y" },
61 { PCI_DEVICE_ID_INTEL_KBL_ID_H, "Kabylake-H" },
Gaggery Tsaie415a4c2018-03-21 22:36:18 +080062 { PCI_DEVICE_ID_INTEL_KBL_ID_S, "Kabylake-S" },
V Sowmyaacc2a482018-01-23 15:27:23 +053063 { PCI_DEVICE_ID_INTEL_KBL_ID_DT, "Kabylake DT" },
Christian Walter3d840382019-05-17 19:37:16 +020064 { PCI_DEVICE_ID_INTEL_KBL_ID_DT_2, "Kabylake DT 2" },
Lee Leahyb0005132015-05-12 18:19:47 -070065};
66
67static struct {
68 u16 lpcid;
69 const char *name;
70} pch_table[] = {
Subrata Banikc2165672017-06-02 17:52:44 +053071 { PCI_DEVICE_ID_INTEL_SPT_LP_SAMPLE, "Skylake LP Sample" },
72 { PCI_DEVICE_ID_INTEL_SPT_LP_U_BASE, "Skylake-U Base" },
73 { PCI_DEVICE_ID_INTEL_SPT_LP_U_PREMIUM, "Skylake-U Premium" },
74 { PCI_DEVICE_ID_INTEL_SPT_LP_Y_PREMIUM, "Skylake-Y Premium" },
Maxim Polyakov7a732b42019-02-25 10:48:39 +030075 { PCI_DEVICE_ID_INTEL_SPT_H_H110, "Skylake PCH-H H110" },
Marius Genheimer4998bec2019-04-30 00:04:32 +020076 { PCI_DEVICE_ID_INTEL_SPT_H_H170, "Skylake PCH-H H170" },
77 { PCI_DEVICE_ID_INTEL_SPT_H_Z170, "Skylake PCH-H Z170" },
78 { PCI_DEVICE_ID_INTEL_SPT_H_Q170, "Skylake PCH-H Q170" },
79 { PCI_DEVICE_ID_INTEL_SPT_H_Q150, "Skylake PCH-H Q150" },
80 { PCI_DEVICE_ID_INTEL_SPT_H_B150, "Skylake PCH-H B150" },
V Sowmya7c150472018-01-23 14:44:45 +053081 { PCI_DEVICE_ID_INTEL_SPT_H_C236, "Skylake PCH-H C236" },
Felix Singerc3244cc2019-07-29 22:54:09 +020082 { PCI_DEVICE_ID_INTEL_SPT_H_C232, "Skylake PCH-H C232" },
V Sowmya7c150472018-01-23 14:44:45 +053083 { PCI_DEVICE_ID_INTEL_SPT_H_QM170, "Skylake PCH-H QM170" },
Felix Singerc3244cc2019-07-29 22:54:09 +020084 { PCI_DEVICE_ID_INTEL_SPT_H_HM170, "Skylake PCH-H HM170" },
85 { PCI_DEVICE_ID_INTEL_SPT_H_CM236, "Skylake PCH-H CM236" },
Praveen hodagatta pranesh523d6692018-11-03 01:21:14 +080086 { PCI_DEVICE_ID_INTEL_SPT_H_HM175, "Skylake PCH-H HM175" },
87 { PCI_DEVICE_ID_INTEL_SPT_H_QM175, "Skylake PCH-H QM175" },
88 { PCI_DEVICE_ID_INTEL_SPT_H_CM238, "Skylake PCH-H CM238" },
Maxim Polyakov571d07d2019-08-22 13:11:32 +030089 { PCI_DEVICE_ID_INTEL_LWB_C621, "Lewisburg PCH C621" },
90 { PCI_DEVICE_ID_INTEL_LWB_C622, "Lewisburg PCH C622" },
91 { PCI_DEVICE_ID_INTEL_LWB_C624, "Lewisburg PCH C624" },
92 { PCI_DEVICE_ID_INTEL_LWB_C625, "Lewisburg PCH C625" },
93 { PCI_DEVICE_ID_INTEL_LWB_C626, "Lewisburg PCH C626" },
94 { PCI_DEVICE_ID_INTEL_LWB_C627, "Lewisburg PCH C627" },
95 { PCI_DEVICE_ID_INTEL_LWB_C628, "Lewisburg PCH C628" },
96 { PCI_DEVICE_ID_INTEL_LWB_C629, "Lewisburg PCH C629" },
97 { PCI_DEVICE_ID_INTEL_LWB_C624_SUPER, "Lewisburg PCH C624 Super SKU" },
98 { PCI_DEVICE_ID_INTEL_LWB_C627_SUPER_1, "Lewisburg PCH C627 Super SKU" },
99 { PCI_DEVICE_ID_INTEL_LWB_C621_SUPER, "Lewisburg PCH C621 Super SKU" },
100 { PCI_DEVICE_ID_INTEL_LWB_C627_SUPER_2, "Lewisburg PCH C627 Super SKU" },
101 { PCI_DEVICE_ID_INTEL_LWB_C628_SUPER, "Lewisburg PCH C628 Super SKU" },
V Sowmyaacc2a482018-01-23 15:27:23 +0530102 { PCI_DEVICE_ID_INTEL_KBP_H_Q270, "Kabylake-H Q270" },
Gaggery Tsaie415a4c2018-03-21 22:36:18 +0800103 { PCI_DEVICE_ID_INTEL_KBP_H_H270, "Kabylake-H H270" },
104 { PCI_DEVICE_ID_INTEL_KBP_H_Z270, "Kabylake-H Z270" },
105 { PCI_DEVICE_ID_INTEL_KBP_H_B250, "Kabylake-H B250" },
106 { PCI_DEVICE_ID_INTEL_KBP_H_Q250, "Kabylake-H Q250" },
Subrata Banikc2165672017-06-02 17:52:44 +0530107 { PCI_DEVICE_ID_INTEL_KBP_LP_U_PREMIUM, "Kabylake-U Premium" },
108 { PCI_DEVICE_ID_INTEL_KBP_LP_Y_PREMIUM, "Kabylake-Y Premium" },
109 { PCI_DEVICE_ID_INTEL_KBP_LP_SUPER_SKU, "Kabylake Super Sku" },
110 { PCI_DEVICE_ID_INTEL_SPT_LP_Y_PREMIUM_HDCP22,
111 "Kabylake-Y iHDCP 2.2 Premium" },
112 { PCI_DEVICE_ID_INTEL_SPT_LP_U_PREMIUM_HDCP22,
113 "Kabylake-U iHDCP 2.2 Premium" },
Gaggery Tsaie2592be2017-09-20 22:46:39 +0800114 { PCI_DEVICE_ID_INTEL_SPT_LP_U_BASE_HDCP22,
115 "Kabylake-U iHDCP 2.2 Base" },
Lee Leahyb0005132015-05-12 18:19:47 -0700116};
117
118static struct {
119 u16 igdid;
120 const char *name;
121} igd_table[] = {
Subrata Banikc2165672017-06-02 17:52:44 +0530122 { PCI_DEVICE_ID_INTEL_SKL_GT1_SULTM, "Skylake ULT GT1"},
Maxim Polyakov46e68522019-02-25 10:46:18 +0300123 { PCI_DEVICE_ID_INTEL_SKL_GT2_DT2P1, "Skylake DT GT2" },
Subrata Banikc2165672017-06-02 17:52:44 +0530124 { PCI_DEVICE_ID_INTEL_SKL_GT2_SULXM, "Skylake ULX GT2" },
125 { PCI_DEVICE_ID_INTEL_SKL_GT2_SULTM, "Skylake ULT GT2" },
126 { PCI_DEVICE_ID_INTEL_SKL_GT2_SHALM, "Skylake HALO GT2" },
127 { PCI_DEVICE_ID_INTEL_SKL_GT4_SHALM, "Skylake HALO GT4" },
128 { PCI_DEVICE_ID_INTEL_KBL_GT1_SULTM, "Kabylake ULT GT1"},
129 { PCI_DEVICE_ID_INTEL_KBL_GT2_SULXM, "Kabylake ULX GT2" },
130 { PCI_DEVICE_ID_INTEL_KBL_GT2_SULTM, "Kabylake ULT GT2" },
131 { PCI_DEVICE_ID_INTEL_KBL_GT2_SULTMR, "Kabylake-R ULT GT2"},
132 { PCI_DEVICE_ID_INTEL_KBL_GT2_SHALM, "Kabylake HALO GT2" },
V Sowmyaacc2a482018-01-23 15:27:23 +0530133 { PCI_DEVICE_ID_INTEL_KBL_GT2_DT2P2, "Kabylake DT GT2" },
Gaggery Tsai8aee7f72018-08-03 11:40:55 -0700134 { PCI_DEVICE_ID_INTEL_AML_GT2_ULX, "Amberlake ULX GT2" },
Lee Leahyb0005132015-05-12 18:19:47 -0700135};
136
Elyes HAOUAS68c851b2018-06-12 22:06:09 +0200137static uint8_t get_dev_revision(pci_devfn_t dev)
Subrata Banikdf5ae9c2017-12-06 19:10:15 +0530138{
139 return pci_read_config8(dev, PCI_REVISION_ID);
140}
141
Elyes HAOUAS68c851b2018-06-12 22:06:09 +0200142static uint16_t get_dev_id(pci_devfn_t dev)
Subrata Banikdf5ae9c2017-12-06 19:10:15 +0530143{
144 return pci_read_config16(dev, PCI_DEVICE_ID);
145}
146
Lee Leahyb0005132015-05-12 18:19:47 -0700147static void report_cpu_info(void)
148{
149 struct cpuid_result cpuidr;
Subrata Banik53b08c32018-12-10 14:11:35 +0530150 u32 i, index, cpu_id, cpu_feature_flag;
Lee Leahyb0005132015-05-12 18:19:47 -0700151 char cpu_string[50], *cpu_name = cpu_string; /* 48 bytes are reported */
152 int vt, txt, aes;
153 msr_t microcode_ver;
Elyes HAOUAS39303d52018-07-08 12:40:45 +0200154 static const char *const mode[] = {"NOT ", ""};
Lee Leahyb0005132015-05-12 18:19:47 -0700155 const char *cpu_type = "Unknown";
156
157 index = 0x80000000;
158 cpuidr = cpuid(index);
159 if (cpuidr.eax < 0x80000004) {
160 strcpy(cpu_string, "Platform info not available");
161 } else {
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700162 u32 *p = (u32 *) cpu_string;
163 for (i = 2; i <= 4; i++) {
Lee Leahyb0005132015-05-12 18:19:47 -0700164 cpuidr = cpuid(index + i);
165 *p++ = cpuidr.eax;
166 *p++ = cpuidr.ebx;
167 *p++ = cpuidr.ecx;
168 *p++ = cpuidr.edx;
169 }
170 }
171 /* Skip leading spaces in CPU name string */
172 while (cpu_name[0] == ' ')
173 cpu_name++;
174
175 microcode_ver.lo = 0;
176 microcode_ver.hi = 0;
Elyes HAOUAS603963e2018-09-28 09:06:43 +0200177 wrmsr(IA32_BIOS_SIGN_ID, microcode_ver);
Subrata Banik53b08c32018-12-10 14:11:35 +0530178 cpu_id = cpu_get_cpuid();
Elyes HAOUAS603963e2018-09-28 09:06:43 +0200179 microcode_ver = rdmsr(IA32_BIOS_SIGN_ID);
Lee Leahyb0005132015-05-12 18:19:47 -0700180
181 /* Look for string to match the name */
182 for (i = 0; i < ARRAY_SIZE(cpu_table); i++) {
Subrata Banik53b08c32018-12-10 14:11:35 +0530183 if (cpu_table[i].cpuid == cpu_id) {
Lee Leahyb0005132015-05-12 18:19:47 -0700184 cpu_type = cpu_table[i].name;
185 break;
186 }
187 }
188
189 printk(BIOS_DEBUG, "CPU: %s\n", cpu_name);
190 printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n",
Subrata Banik53b08c32018-12-10 14:11:35 +0530191 cpu_id, cpu_type, microcode_ver.hi);
Lee Leahyb0005132015-05-12 18:19:47 -0700192
Subrata Banik53b08c32018-12-10 14:11:35 +0530193 cpu_feature_flag = cpu_get_feature_flags_ecx();
194 aes = (cpu_feature_flag & CPUID_AES) ? 1 : 0;
195 txt = (cpu_feature_flag & CPUID_SMX) ? 1 : 0;
196 vt = (cpu_feature_flag & CPUID_VMX) ? 1 : 0;
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700197 printk(BIOS_DEBUG,
198 "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n",
199 mode[aes], mode[txt], mode[vt]);
Lee Leahyb0005132015-05-12 18:19:47 -0700200}
201
202static void report_mch_info(void)
203{
204 int i;
Elyes HAOUAS68c851b2018-06-12 22:06:09 +0200205 pci_devfn_t dev = SA_DEV_ROOT;
Subrata Banikdf5ae9c2017-12-06 19:10:15 +0530206 uint16_t mchid = get_dev_id(dev);
207 uint8_t mch_revision = get_dev_revision(dev);
Lee Leahyb0005132015-05-12 18:19:47 -0700208 const char *mch_type = "Unknown";
209
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700210 for (i = 0; i < ARRAY_SIZE(mch_table); i++) {
211 if (mch_table[i].mchid == mchid) {
212 mch_type = mch_table[i].name;
213 break;
Lee Leahyb0005132015-05-12 18:19:47 -0700214 }
215 }
216
217 printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n",
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700218 mchid, mch_revision, mch_type);
Lee Leahyb0005132015-05-12 18:19:47 -0700219}
220
221static void report_pch_info(void)
222{
223 int i;
Elyes HAOUAS68c851b2018-06-12 22:06:09 +0200224 pci_devfn_t dev = PCH_DEV_LPC;
Subrata Banikdf5ae9c2017-12-06 19:10:15 +0530225 uint16_t lpcid = get_dev_id(dev);
Lee Leahyb0005132015-05-12 18:19:47 -0700226 const char *pch_type = "Unknown";
227
228 for (i = 0; i < ARRAY_SIZE(pch_table); i++) {
229 if (pch_table[i].lpcid == lpcid) {
230 pch_type = pch_table[i].name;
231 break;
232 }
233 }
234 printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n",
Subrata Banikdf5ae9c2017-12-06 19:10:15 +0530235 lpcid, get_dev_revision(dev), pch_type);
Lee Leahyb0005132015-05-12 18:19:47 -0700236}
237
238static void report_igd_info(void)
239{
240 int i;
Elyes HAOUAS68c851b2018-06-12 22:06:09 +0200241 pci_devfn_t dev = SA_DEV_IGD;
Subrata Banikdf5ae9c2017-12-06 19:10:15 +0530242 uint16_t igdid = get_dev_id(dev);
Lee Leahyb0005132015-05-12 18:19:47 -0700243 const char *igd_type = "Unknown";
244
245 for (i = 0; i < ARRAY_SIZE(igd_table); i++) {
246 if (igd_table[i].igdid == igdid) {
247 igd_type = igd_table[i].name;
248 break;
249 }
250 }
251 printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n",
Subrata Banikdf5ae9c2017-12-06 19:10:15 +0530252 igdid, get_dev_revision(dev), igd_type);
Lee Leahyb0005132015-05-12 18:19:47 -0700253}
254
255void report_platform_info(void)
256{
257 report_cpu_info();
258 report_mch_info();
259 report_pch_info();
260 report_igd_info();
261}
262
263/*
264 * Dump in the log memory controller configuration as read from the memory
265 * controller registers.
266 */
267void report_memory_config(void)
268{
269 u32 addr_decoder_common, addr_decode_ch[2];
270 int i;
271
272 addr_decoder_common = MCHBAR32(0x5000);
273 addr_decode_ch[0] = MCHBAR32(0x5004);
274 addr_decode_ch[1] = MCHBAR32(0x5008);
275
276 printk(BIOS_DEBUG, "memcfg DDR3 clock %d MHz\n",
277 (MCHBAR32(0x5e04) * 13333 * 2 + 50)/100);
278 printk(BIOS_DEBUG, "memcfg channel assignment: A: %d, B % d, C % d\n",
279 addr_decoder_common & 3,
280 (addr_decoder_common >> 2) & 3,
281 (addr_decoder_common >> 4) & 3);
282
283 for (i = 0; i < ARRAY_SIZE(addr_decode_ch); i++) {
284 u32 ch_conf = addr_decode_ch[i];
285 printk(BIOS_DEBUG, "memcfg channel[%d] config (%8.8x):\n",
286 i, ch_conf);
287 printk(BIOS_DEBUG, " enhanced interleave mode %s\n",
288 ((ch_conf >> 22) & 1) ? "on" : "off");
289 printk(BIOS_DEBUG, " rank interleave %s\n",
290 ((ch_conf >> 21) & 1) ? "on" : "off");
291 printk(BIOS_DEBUG, " DIMMA %d MB width %s %s rank%s\n",
292 ((ch_conf >> 0) & 0xff) * 256,
293 ((ch_conf >> 19) & 1) ? "x16" : "x8 or x32",
294 ((ch_conf >> 17) & 1) ? "dual" : "single",
295 ((ch_conf >> 16) & 1) ? "" : ", selected");
296 printk(BIOS_DEBUG, " DIMMB %d MB width %s %s rank%s\n",
297 ((ch_conf >> 8) & 0xff) * 256,
298 ((ch_conf >> 19) & 1) ? "x16" : "x8 or x32",
299 ((ch_conf >> 18) & 1) ? "dual" : "single",
300 ((ch_conf >> 16) & 1) ? ", selected" : "");
301 }
302}