blob: 69484fbb8eb74ab9f6afdb8d48f2a58ce4382d62 [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>
18#include <arch/io.h>
19#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" },
53 { PCI_DEVICE_ID_INTEL_SKL_ID_H, "Skylake-H" },
54 { PCI_DEVICE_ID_INTEL_SKL_ID_H_EM, "Skylake-H Embedded" },
55 { PCI_DEVICE_ID_INTEL_KBL_ID_U, "Kabylake-U" },
56 { PCI_DEVICE_ID_INTEL_KBL_U_R, "Kabylake-R ULT"},
57 { PCI_DEVICE_ID_INTEL_KBL_ID_Y, "Kabylake-Y" },
58 { PCI_DEVICE_ID_INTEL_KBL_ID_H, "Kabylake-H" },
Lee Leahyb0005132015-05-12 18:19:47 -070059};
60
61static struct {
62 u16 lpcid;
63 const char *name;
64} pch_table[] = {
Subrata Banikc2165672017-06-02 17:52:44 +053065 { PCI_DEVICE_ID_INTEL_SPT_LP_SAMPLE, "Skylake LP Sample" },
66 { PCI_DEVICE_ID_INTEL_SPT_LP_U_BASE, "Skylake-U Base" },
67 { PCI_DEVICE_ID_INTEL_SPT_LP_U_PREMIUM, "Skylake-U Premium" },
68 { PCI_DEVICE_ID_INTEL_SPT_LP_Y_PREMIUM, "Skylake-Y Premium" },
69 { PCI_DEVICE_ID_INTEL_KBP_H_PREMIUM, "Kabylake-H Premium" },
70 { PCI_DEVICE_ID_INTEL_KBP_H_C236, "Kabylake-H C236" },
71 { PCI_DEVICE_ID_INTEL_KBP_H_QM170, "Kabylake-H QM170" },
72 { PCI_DEVICE_ID_INTEL_KBP_LP_U_PREMIUM, "Kabylake-U Premium" },
73 { PCI_DEVICE_ID_INTEL_KBP_LP_Y_PREMIUM, "Kabylake-Y Premium" },
74 { PCI_DEVICE_ID_INTEL_KBP_LP_SUPER_SKU, "Kabylake Super Sku" },
75 { PCI_DEVICE_ID_INTEL_SPT_LP_Y_PREMIUM_HDCP22,
76 "Kabylake-Y iHDCP 2.2 Premium" },
77 { PCI_DEVICE_ID_INTEL_SPT_LP_U_PREMIUM_HDCP22,
78 "Kabylake-U iHDCP 2.2 Premium" },
Gaggery Tsaie2592be2017-09-20 22:46:39 +080079 { PCI_DEVICE_ID_INTEL_SPT_LP_U_BASE_HDCP22,
80 "Kabylake-U iHDCP 2.2 Base" },
Lee Leahyb0005132015-05-12 18:19:47 -070081};
82
83static struct {
84 u16 igdid;
85 const char *name;
86} igd_table[] = {
Subrata Banikc2165672017-06-02 17:52:44 +053087 { PCI_DEVICE_ID_INTEL_SKL_GT1_SULTM, "Skylake ULT GT1"},
88 { PCI_DEVICE_ID_INTEL_SKL_GT2_SULXM, "Skylake ULX GT2" },
89 { PCI_DEVICE_ID_INTEL_SKL_GT2_SULTM, "Skylake ULT GT2" },
90 { PCI_DEVICE_ID_INTEL_SKL_GT2_SHALM, "Skylake HALO GT2" },
91 { PCI_DEVICE_ID_INTEL_SKL_GT4_SHALM, "Skylake HALO GT4" },
92 { PCI_DEVICE_ID_INTEL_KBL_GT1_SULTM, "Kabylake ULT GT1"},
93 { PCI_DEVICE_ID_INTEL_KBL_GT2_SULXM, "Kabylake ULX GT2" },
94 { PCI_DEVICE_ID_INTEL_KBL_GT2_SULTM, "Kabylake ULT GT2" },
95 { PCI_DEVICE_ID_INTEL_KBL_GT2_SULTMR, "Kabylake-R ULT GT2"},
96 { PCI_DEVICE_ID_INTEL_KBL_GT2_SHALM, "Kabylake HALO GT2" },
Lee Leahyb0005132015-05-12 18:19:47 -070097};
98
99static void report_cpu_info(void)
100{
101 struct cpuid_result cpuidr;
102 u32 i, index;
103 char cpu_string[50], *cpu_name = cpu_string; /* 48 bytes are reported */
104 int vt, txt, aes;
105 msr_t microcode_ver;
Lee Leahyf4c4ab92017-03-16 17:08:03 -0700106 static const char * const mode[] = {"NOT ", ""};
Lee Leahyb0005132015-05-12 18:19:47 -0700107 const char *cpu_type = "Unknown";
108
109 index = 0x80000000;
110 cpuidr = cpuid(index);
111 if (cpuidr.eax < 0x80000004) {
112 strcpy(cpu_string, "Platform info not available");
113 } else {
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700114 u32 *p = (u32 *) cpu_string;
115 for (i = 2; i <= 4; i++) {
Lee Leahyb0005132015-05-12 18:19:47 -0700116 cpuidr = cpuid(index + i);
117 *p++ = cpuidr.eax;
118 *p++ = cpuidr.ebx;
119 *p++ = cpuidr.ecx;
120 *p++ = cpuidr.edx;
121 }
122 }
123 /* Skip leading spaces in CPU name string */
124 while (cpu_name[0] == ' ')
125 cpu_name++;
126
127 microcode_ver.lo = 0;
128 microcode_ver.hi = 0;
129 wrmsr(0x8B, microcode_ver);
130 cpuidr = cpuid(1);
131 microcode_ver = rdmsr(0x8b);
132
133 /* Look for string to match the name */
134 for (i = 0; i < ARRAY_SIZE(cpu_table); i++) {
135 if (cpu_table[i].cpuid == cpuidr.eax) {
136 cpu_type = cpu_table[i].name;
137 break;
138 }
139 }
140
141 printk(BIOS_DEBUG, "CPU: %s\n", cpu_name);
142 printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n",
143 cpuidr.eax, cpu_type, microcode_ver.hi);
144
145 aes = (cpuidr.ecx & (1 << 25)) ? 1 : 0;
146 txt = (cpuidr.ecx & (1 << 6)) ? 1 : 0;
147 vt = (cpuidr.ecx & (1 << 5)) ? 1 : 0;
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700148 printk(BIOS_DEBUG,
149 "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n",
150 mode[aes], mode[txt], mode[vt]);
Lee Leahyb0005132015-05-12 18:19:47 -0700151}
152
153static void report_mch_info(void)
154{
155 int i;
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700156 u16 mchid = pci_read_config16(SA_DEV_ROOT, PCI_DEVICE_ID);
Lee Leahyb0005132015-05-12 18:19:47 -0700157 u8 mch_revision = pci_read_config8(SA_DEV_ROOT, PCI_REVISION_ID);
158 const char *mch_type = "Unknown";
159
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700160 for (i = 0; i < ARRAY_SIZE(mch_table); i++) {
161 if (mch_table[i].mchid == mchid) {
162 mch_type = mch_table[i].name;
163 break;
Lee Leahyb0005132015-05-12 18:19:47 -0700164 }
165 }
166
167 printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n",
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700168 mchid, mch_revision, mch_type);
Lee Leahyb0005132015-05-12 18:19:47 -0700169}
170
171static void report_pch_info(void)
172{
173 int i;
174 u16 lpcid = pch_type();
175 const char *pch_type = "Unknown";
176
177 for (i = 0; i < ARRAY_SIZE(pch_table); i++) {
178 if (pch_table[i].lpcid == lpcid) {
179 pch_type = pch_table[i].name;
180 break;
181 }
182 }
183 printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n",
184 lpcid, pch_revision(), pch_type);
185}
186
187static void report_igd_info(void)
188{
189 int i;
190 u16 igdid = pci_read_config16(SA_DEV_IGD, PCI_DEVICE_ID);
191 const char *igd_type = "Unknown";
192
193 for (i = 0; i < ARRAY_SIZE(igd_table); i++) {
194 if (igd_table[i].igdid == igdid) {
195 igd_type = igd_table[i].name;
196 break;
197 }
198 }
199 printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n",
200 igdid, pci_read_config8(SA_DEV_IGD, PCI_REVISION_ID), igd_type);
201}
202
203void report_platform_info(void)
204{
205 report_cpu_info();
206 report_mch_info();
207 report_pch_info();
208 report_igd_info();
209}
210
211/*
212 * Dump in the log memory controller configuration as read from the memory
213 * controller registers.
214 */
215void report_memory_config(void)
216{
217 u32 addr_decoder_common, addr_decode_ch[2];
218 int i;
219
220 addr_decoder_common = MCHBAR32(0x5000);
221 addr_decode_ch[0] = MCHBAR32(0x5004);
222 addr_decode_ch[1] = MCHBAR32(0x5008);
223
224 printk(BIOS_DEBUG, "memcfg DDR3 clock %d MHz\n",
225 (MCHBAR32(0x5e04) * 13333 * 2 + 50)/100);
226 printk(BIOS_DEBUG, "memcfg channel assignment: A: %d, B % d, C % d\n",
227 addr_decoder_common & 3,
228 (addr_decoder_common >> 2) & 3,
229 (addr_decoder_common >> 4) & 3);
230
231 for (i = 0; i < ARRAY_SIZE(addr_decode_ch); i++) {
232 u32 ch_conf = addr_decode_ch[i];
233 printk(BIOS_DEBUG, "memcfg channel[%d] config (%8.8x):\n",
234 i, ch_conf);
235 printk(BIOS_DEBUG, " enhanced interleave mode %s\n",
236 ((ch_conf >> 22) & 1) ? "on" : "off");
237 printk(BIOS_DEBUG, " rank interleave %s\n",
238 ((ch_conf >> 21) & 1) ? "on" : "off");
239 printk(BIOS_DEBUG, " DIMMA %d MB width %s %s rank%s\n",
240 ((ch_conf >> 0) & 0xff) * 256,
241 ((ch_conf >> 19) & 1) ? "x16" : "x8 or x32",
242 ((ch_conf >> 17) & 1) ? "dual" : "single",
243 ((ch_conf >> 16) & 1) ? "" : ", selected");
244 printk(BIOS_DEBUG, " DIMMB %d MB width %s %s rank%s\n",
245 ((ch_conf >> 8) & 0xff) * 256,
246 ((ch_conf >> 19) & 1) ? "x16" : "x8 or x32",
247 ((ch_conf >> 18) & 1) ? "dual" : "single",
248 ((ch_conf >> 16) & 1) ? ", selected" : "");
249 }
250}