blob: 314afbf9faeef95c47b2b9bb2aaf4eeae707d9c3 [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>
Naresh G Solankiecd9a942016-08-11 14:56:28 +053023#include <soc/bootblock.h>
Lee Leahyb0005132015-05-12 18:19:47 -070024#include <soc/cpu.h>
25#include <soc/pch.h>
26#include <soc/pci_devs.h>
Lee Leahyb0005132015-05-12 18:19:47 -070027#include <soc/systemagent.h>
Lee Leahy1d14b3e2015-05-12 18:23:27 -070028#include <string.h>
Lee Leahyb0005132015-05-12 18:19:47 -070029
30static struct {
31 u32 cpuid;
32 const char *name;
33} cpu_table[] = {
Subrata Banikc2165672017-06-02 17:52:44 +053034 { CPUID_SKYLAKE_C0, "Skylake C0" },
35 { CPUID_SKYLAKE_D0, "Skylake D0" },
36 { CPUID_SKYLAKE_HQ0, "Skylake H Q0" },
37 { CPUID_SKYLAKE_HR0, "Skylake H R0" },
38 { CPUID_KABYLAKE_G0, "Kabylake G0" },
39 { CPUID_KABYLAKE_H0, "Kabylake H0" },
40 { CPUID_KABYLAKE_Y0, "Kabylake Y0" },
41 { CPUID_KABYLAKE_HA0, "Kabylake H A0" },
42 { CPUID_KABYLAKE_HB0, "Kabylake H B0" },
Lee Leahyb0005132015-05-12 18:19:47 -070043};
44
45static struct {
Lee Leahy1d14b3e2015-05-12 18:23:27 -070046 u16 mchid;
Lee Leahyb0005132015-05-12 18:19:47 -070047 const char *name;
Lee Leahy1d14b3e2015-05-12 18:23:27 -070048} mch_table[] = {
Subrata Banikc2165672017-06-02 17:52:44 +053049 { PCI_DEVICE_ID_INTEL_SKL_ID_U, "Skylake-U" },
50 { PCI_DEVICE_ID_INTEL_SKL_ID_Y, "Skylake-Y" },
51 { PCI_DEVICE_ID_INTEL_SKL_ID_ULX, "Skylake-ULX" },
52 { PCI_DEVICE_ID_INTEL_SKL_ID_H, "Skylake-H" },
53 { PCI_DEVICE_ID_INTEL_SKL_ID_H_EM, "Skylake-H Embedded" },
54 { PCI_DEVICE_ID_INTEL_KBL_ID_U, "Kabylake-U" },
55 { PCI_DEVICE_ID_INTEL_KBL_U_R, "Kabylake-R ULT"},
56 { PCI_DEVICE_ID_INTEL_KBL_ID_Y, "Kabylake-Y" },
57 { PCI_DEVICE_ID_INTEL_KBL_ID_H, "Kabylake-H" },
Lee Leahyb0005132015-05-12 18:19:47 -070058};
59
60static struct {
61 u16 lpcid;
62 const char *name;
63} pch_table[] = {
Subrata Banikc2165672017-06-02 17:52:44 +053064 { PCI_DEVICE_ID_INTEL_SPT_LP_SAMPLE, "Skylake LP Sample" },
65 { PCI_DEVICE_ID_INTEL_SPT_LP_U_BASE, "Skylake-U Base" },
66 { PCI_DEVICE_ID_INTEL_SPT_LP_U_PREMIUM, "Skylake-U Premium" },
67 { PCI_DEVICE_ID_INTEL_SPT_LP_Y_PREMIUM, "Skylake-Y Premium" },
68 { PCI_DEVICE_ID_INTEL_KBP_H_PREMIUM, "Kabylake-H Premium" },
69 { PCI_DEVICE_ID_INTEL_KBP_H_C236, "Kabylake-H C236" },
70 { PCI_DEVICE_ID_INTEL_KBP_H_QM170, "Kabylake-H QM170" },
71 { PCI_DEVICE_ID_INTEL_KBP_LP_U_PREMIUM, "Kabylake-U Premium" },
72 { PCI_DEVICE_ID_INTEL_KBP_LP_Y_PREMIUM, "Kabylake-Y Premium" },
73 { PCI_DEVICE_ID_INTEL_KBP_LP_SUPER_SKU, "Kabylake Super Sku" },
74 { PCI_DEVICE_ID_INTEL_SPT_LP_Y_PREMIUM_HDCP22,
75 "Kabylake-Y iHDCP 2.2 Premium" },
76 { PCI_DEVICE_ID_INTEL_SPT_LP_U_PREMIUM_HDCP22,
77 "Kabylake-U iHDCP 2.2 Premium" },
Lee Leahyb0005132015-05-12 18:19:47 -070078};
79
80static struct {
81 u16 igdid;
82 const char *name;
83} igd_table[] = {
Subrata Banikc2165672017-06-02 17:52:44 +053084 { PCI_DEVICE_ID_INTEL_SKL_GT1_SULTM, "Skylake ULT GT1"},
85 { PCI_DEVICE_ID_INTEL_SKL_GT2_SULXM, "Skylake ULX GT2" },
86 { PCI_DEVICE_ID_INTEL_SKL_GT2_SULTM, "Skylake ULT GT2" },
87 { PCI_DEVICE_ID_INTEL_SKL_GT2_SHALM, "Skylake HALO GT2" },
88 { PCI_DEVICE_ID_INTEL_SKL_GT4_SHALM, "Skylake HALO GT4" },
89 { PCI_DEVICE_ID_INTEL_KBL_GT1_SULTM, "Kabylake ULT GT1"},
90 { PCI_DEVICE_ID_INTEL_KBL_GT2_SULXM, "Kabylake ULX GT2" },
91 { PCI_DEVICE_ID_INTEL_KBL_GT2_SULTM, "Kabylake ULT GT2" },
92 { PCI_DEVICE_ID_INTEL_KBL_GT2_SULTMR, "Kabylake-R ULT GT2"},
93 { PCI_DEVICE_ID_INTEL_KBL_GT2_SHALM, "Kabylake HALO GT2" },
Lee Leahyb0005132015-05-12 18:19:47 -070094};
95
96static void report_cpu_info(void)
97{
98 struct cpuid_result cpuidr;
99 u32 i, index;
100 char cpu_string[50], *cpu_name = cpu_string; /* 48 bytes are reported */
101 int vt, txt, aes;
102 msr_t microcode_ver;
Lee Leahyf4c4ab92017-03-16 17:08:03 -0700103 static const char * const mode[] = {"NOT ", ""};
Lee Leahyb0005132015-05-12 18:19:47 -0700104 const char *cpu_type = "Unknown";
105
106 index = 0x80000000;
107 cpuidr = cpuid(index);
108 if (cpuidr.eax < 0x80000004) {
109 strcpy(cpu_string, "Platform info not available");
110 } else {
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700111 u32 *p = (u32 *) cpu_string;
112 for (i = 2; i <= 4; i++) {
Lee Leahyb0005132015-05-12 18:19:47 -0700113 cpuidr = cpuid(index + i);
114 *p++ = cpuidr.eax;
115 *p++ = cpuidr.ebx;
116 *p++ = cpuidr.ecx;
117 *p++ = cpuidr.edx;
118 }
119 }
120 /* Skip leading spaces in CPU name string */
121 while (cpu_name[0] == ' ')
122 cpu_name++;
123
124 microcode_ver.lo = 0;
125 microcode_ver.hi = 0;
126 wrmsr(0x8B, microcode_ver);
127 cpuidr = cpuid(1);
128 microcode_ver = rdmsr(0x8b);
129
130 /* Look for string to match the name */
131 for (i = 0; i < ARRAY_SIZE(cpu_table); i++) {
132 if (cpu_table[i].cpuid == cpuidr.eax) {
133 cpu_type = cpu_table[i].name;
134 break;
135 }
136 }
137
138 printk(BIOS_DEBUG, "CPU: %s\n", cpu_name);
139 printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n",
140 cpuidr.eax, cpu_type, microcode_ver.hi);
141
142 aes = (cpuidr.ecx & (1 << 25)) ? 1 : 0;
143 txt = (cpuidr.ecx & (1 << 6)) ? 1 : 0;
144 vt = (cpuidr.ecx & (1 << 5)) ? 1 : 0;
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700145 printk(BIOS_DEBUG,
146 "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n",
147 mode[aes], mode[txt], mode[vt]);
Lee Leahyb0005132015-05-12 18:19:47 -0700148}
149
150static void report_mch_info(void)
151{
152 int i;
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700153 u16 mchid = pci_read_config16(SA_DEV_ROOT, PCI_DEVICE_ID);
Lee Leahyb0005132015-05-12 18:19:47 -0700154 u8 mch_revision = pci_read_config8(SA_DEV_ROOT, PCI_REVISION_ID);
155 const char *mch_type = "Unknown";
156
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700157 for (i = 0; i < ARRAY_SIZE(mch_table); i++) {
158 if (mch_table[i].mchid == mchid) {
159 mch_type = mch_table[i].name;
160 break;
Lee Leahyb0005132015-05-12 18:19:47 -0700161 }
162 }
163
164 printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n",
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700165 mchid, mch_revision, mch_type);
Lee Leahyb0005132015-05-12 18:19:47 -0700166}
167
168static void report_pch_info(void)
169{
170 int i;
171 u16 lpcid = pch_type();
172 const char *pch_type = "Unknown";
173
174 for (i = 0; i < ARRAY_SIZE(pch_table); i++) {
175 if (pch_table[i].lpcid == lpcid) {
176 pch_type = pch_table[i].name;
177 break;
178 }
179 }
180 printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n",
181 lpcid, pch_revision(), pch_type);
182}
183
184static void report_igd_info(void)
185{
186 int i;
187 u16 igdid = pci_read_config16(SA_DEV_IGD, PCI_DEVICE_ID);
188 const char *igd_type = "Unknown";
189
190 for (i = 0; i < ARRAY_SIZE(igd_table); i++) {
191 if (igd_table[i].igdid == igdid) {
192 igd_type = igd_table[i].name;
193 break;
194 }
195 }
196 printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n",
197 igdid, pci_read_config8(SA_DEV_IGD, PCI_REVISION_ID), igd_type);
198}
199
200void report_platform_info(void)
201{
202 report_cpu_info();
203 report_mch_info();
204 report_pch_info();
205 report_igd_info();
206}
207
208/*
209 * Dump in the log memory controller configuration as read from the memory
210 * controller registers.
211 */
212void report_memory_config(void)
213{
214 u32 addr_decoder_common, addr_decode_ch[2];
215 int i;
216
217 addr_decoder_common = MCHBAR32(0x5000);
218 addr_decode_ch[0] = MCHBAR32(0x5004);
219 addr_decode_ch[1] = MCHBAR32(0x5008);
220
221 printk(BIOS_DEBUG, "memcfg DDR3 clock %d MHz\n",
222 (MCHBAR32(0x5e04) * 13333 * 2 + 50)/100);
223 printk(BIOS_DEBUG, "memcfg channel assignment: A: %d, B % d, C % d\n",
224 addr_decoder_common & 3,
225 (addr_decoder_common >> 2) & 3,
226 (addr_decoder_common >> 4) & 3);
227
228 for (i = 0; i < ARRAY_SIZE(addr_decode_ch); i++) {
229 u32 ch_conf = addr_decode_ch[i];
230 printk(BIOS_DEBUG, "memcfg channel[%d] config (%8.8x):\n",
231 i, ch_conf);
232 printk(BIOS_DEBUG, " enhanced interleave mode %s\n",
233 ((ch_conf >> 22) & 1) ? "on" : "off");
234 printk(BIOS_DEBUG, " rank interleave %s\n",
235 ((ch_conf >> 21) & 1) ? "on" : "off");
236 printk(BIOS_DEBUG, " DIMMA %d MB width %s %s rank%s\n",
237 ((ch_conf >> 0) & 0xff) * 256,
238 ((ch_conf >> 19) & 1) ? "x16" : "x8 or x32",
239 ((ch_conf >> 17) & 1) ? "dual" : "single",
240 ((ch_conf >> 16) & 1) ? "" : ", selected");
241 printk(BIOS_DEBUG, " DIMMB %d MB width %s %s rank%s\n",
242 ((ch_conf >> 8) & 0xff) * 256,
243 ((ch_conf >> 19) & 1) ? "x16" : "x8 or x32",
244 ((ch_conf >> 18) & 1) ? "dual" : "single",
245 ((ch_conf >> 16) & 1) ? ", selected" : "");
246 }
247}