blob: 63cd6367ab2b1e770b4daedab98524a45b2e356f [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>
Naresh G Solankiecd9a942016-08-11 14:56:28 +053022#include <soc/bootblock.h>
Lee Leahyb0005132015-05-12 18:19:47 -070023#include <soc/cpu.h>
24#include <soc/pch.h>
25#include <soc/pci_devs.h>
Lee Leahyb0005132015-05-12 18:19:47 -070026#include <soc/systemagent.h>
Lee Leahy1d14b3e2015-05-12 18:23:27 -070027#include <string.h>
Lee Leahyb0005132015-05-12 18:19:47 -070028
29static struct {
30 u32 cpuid;
31 const char *name;
32} cpu_table[] = {
Lee Leahy1d14b3e2015-05-12 18:23:27 -070033 { CPUID_SKYLAKE_C0, "Skylake C0" },
34 { CPUID_SKYLAKE_D0, "Skylake D0" },
Sooi, Li Chengc76e9982017-01-04 13:36:06 +080035 { CPUID_SKYLAKE_HQ0, "Skylake H Q0" },
36 { CPUID_SKYLAKE_HR0, "Skylake H R0" },
Rizwan Qureshi5d419492016-08-03 19:16:18 +053037 { CPUID_KABYLAKE_G0, "Kabylake G0" },
38 { CPUID_KABYLAKE_H0, "Kabylake H0" },
Sooi, Li Chengc76e9982017-01-04 13:36:06 +080039 { CPUID_KABYLAKE_HA0, "Kabylake H A0" },
40 { CPUID_KABYLAKE_HB0, "Kabylake H B0" },
Lee Leahyb0005132015-05-12 18:19:47 -070041};
42
43static struct {
Lee Leahy1d14b3e2015-05-12 18:23:27 -070044 u16 mchid;
Lee Leahyb0005132015-05-12 18:19:47 -070045 const char *name;
Lee Leahy1d14b3e2015-05-12 18:23:27 -070046} mch_table[] = {
47 { MCH_SKYLAKE_ID_U, "Skylake-U" },
48 { MCH_SKYLAKE_ID_Y, "Skylake-Y" },
49 { MCH_SKYLAKE_ID_ULX, "Skylake-ULX" },
Sooi, Li Chengc76e9982017-01-04 13:36:06 +080050 { MCH_SKYLAKE_ID_H, "Skylake-H" },
51 { MCH_SKYLAKE_ID_H_EM, "Skylake-H Embedded" },
Rizwan Qureshi5d419492016-08-03 19:16:18 +053052 { MCH_KABYLAKE_ID_U, "Kabylake-U" },
53 { MCH_KABYLAKE_ID_Y, "Kabylake-Y" },
Sooi, Li Chengc76e9982017-01-04 13:36:06 +080054 { MCH_KABYLAKE_ID_H, "Kabylake-H" },
Lee Leahyb0005132015-05-12 18:19:47 -070055};
56
57static struct {
58 u16 lpcid;
59 const char *name;
60} pch_table[] = {
Naresh G Solanki50bb67e2016-11-06 12:36:31 +053061 { PCH_SPT_LP_SAMPLE, "Skylake LP Sample" },
62 { PCH_SPT_LP_U_BASE, "Skylake-U Base" },
63 { PCH_SPT_LP_U_PREMIUM, "Skylake-U Premium" },
64 { PCH_SPT_LP_Y_PREMIUM, "Skylake-Y Premium" },
Sooi, Li Chengc76e9982017-01-04 13:36:06 +080065 { PCH_SPT_H_PREMIUM, "Skylake-H Premium" },
66 { PCH_SPT_H_C236, "Skylake-H C236" },
67 { PCH_SPT_H_QM170, "Skylake-H QM170" },
Naresh G Solanki50bb67e2016-11-06 12:36:31 +053068 { PCH_KBL_LP_U_PREMIUM, "Kabylake-U Premium" },
69 { PCH_KBL_LP_Y_PREMIUM, "Kabylake-Y Premium" },
70 { PCH_KBL_LP_Y_PREMIUM_HDCP22, "Kabylake-Y iHDCP 2.2 Premium" },
Lee Leahyb0005132015-05-12 18:19:47 -070071};
72
73static struct {
74 u16 igdid;
75 const char *name;
76} igd_table[] = {
Lee Leahy1d14b3e2015-05-12 18:23:27 -070077 { IGD_SKYLAKE_GT1_SULTM, "Skylake ULT GT1"},
78 { IGD_SKYLAKE_GT2_SULXM, "Skylake ULX GT2" },
79 { IGD_SKYLAKE_GT2_SULTM, "Skylake ULT GT2" },
Sooi, Li Chengc76e9982017-01-04 13:36:06 +080080 { IGD_SKYLAKE_GT2_SHALM, "Skylake HALO GT2" },
81 { IGD_SKYLAKE_GT4_SHALM, "Skylake HALO GT4" },
Barnali Sarkar99123102016-08-26 14:48:46 +053082 { IGD_KABYLAKE_GT1_SULTM, "Kabylake ULT GT1"},
83 { IGD_KABYLAKE_GT2_SULXM, "Kabylake ULX GT2" },
84 { IGD_KABYLAKE_GT2_SULTM, "Kabylake ULT GT2" },
Sooi, Li Chengc76e9982017-01-04 13:36:06 +080085 { IGD_KABYLAKE_GT2_SHALM, "Kabylake HALO GT2" },
Lee Leahyb0005132015-05-12 18:19:47 -070086};
87
88static void report_cpu_info(void)
89{
90 struct cpuid_result cpuidr;
91 u32 i, index;
92 char cpu_string[50], *cpu_name = cpu_string; /* 48 bytes are reported */
93 int vt, txt, aes;
94 msr_t microcode_ver;
Lee Leahyf4c4ab92017-03-16 17:08:03 -070095 static const char * const mode[] = {"NOT ", ""};
Lee Leahyb0005132015-05-12 18:19:47 -070096 const char *cpu_type = "Unknown";
97
98 index = 0x80000000;
99 cpuidr = cpuid(index);
100 if (cpuidr.eax < 0x80000004) {
101 strcpy(cpu_string, "Platform info not available");
102 } else {
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700103 u32 *p = (u32 *) cpu_string;
104 for (i = 2; i <= 4; i++) {
Lee Leahyb0005132015-05-12 18:19:47 -0700105 cpuidr = cpuid(index + i);
106 *p++ = cpuidr.eax;
107 *p++ = cpuidr.ebx;
108 *p++ = cpuidr.ecx;
109 *p++ = cpuidr.edx;
110 }
111 }
112 /* Skip leading spaces in CPU name string */
113 while (cpu_name[0] == ' ')
114 cpu_name++;
115
116 microcode_ver.lo = 0;
117 microcode_ver.hi = 0;
118 wrmsr(0x8B, microcode_ver);
119 cpuidr = cpuid(1);
120 microcode_ver = rdmsr(0x8b);
121
122 /* Look for string to match the name */
123 for (i = 0; i < ARRAY_SIZE(cpu_table); i++) {
124 if (cpu_table[i].cpuid == cpuidr.eax) {
125 cpu_type = cpu_table[i].name;
126 break;
127 }
128 }
129
130 printk(BIOS_DEBUG, "CPU: %s\n", cpu_name);
131 printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n",
132 cpuidr.eax, cpu_type, microcode_ver.hi);
133
134 aes = (cpuidr.ecx & (1 << 25)) ? 1 : 0;
135 txt = (cpuidr.ecx & (1 << 6)) ? 1 : 0;
136 vt = (cpuidr.ecx & (1 << 5)) ? 1 : 0;
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700137 printk(BIOS_DEBUG,
138 "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n",
139 mode[aes], mode[txt], mode[vt]);
Lee Leahyb0005132015-05-12 18:19:47 -0700140}
141
142static void report_mch_info(void)
143{
144 int i;
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700145 u16 mchid = pci_read_config16(SA_DEV_ROOT, PCI_DEVICE_ID);
Lee Leahyb0005132015-05-12 18:19:47 -0700146 u8 mch_revision = pci_read_config8(SA_DEV_ROOT, PCI_REVISION_ID);
147 const char *mch_type = "Unknown";
148
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700149 for (i = 0; i < ARRAY_SIZE(mch_table); i++) {
150 if (mch_table[i].mchid == mchid) {
151 mch_type = mch_table[i].name;
152 break;
Lee Leahyb0005132015-05-12 18:19:47 -0700153 }
154 }
155
156 printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n",
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700157 mchid, mch_revision, mch_type);
Lee Leahyb0005132015-05-12 18:19:47 -0700158}
159
160static void report_pch_info(void)
161{
162 int i;
163 u16 lpcid = pch_type();
164 const char *pch_type = "Unknown";
165
166 for (i = 0; i < ARRAY_SIZE(pch_table); i++) {
167 if (pch_table[i].lpcid == lpcid) {
168 pch_type = pch_table[i].name;
169 break;
170 }
171 }
172 printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n",
173 lpcid, pch_revision(), pch_type);
174}
175
176static void report_igd_info(void)
177{
178 int i;
179 u16 igdid = pci_read_config16(SA_DEV_IGD, PCI_DEVICE_ID);
180 const char *igd_type = "Unknown";
181
182 for (i = 0; i < ARRAY_SIZE(igd_table); i++) {
183 if (igd_table[i].igdid == igdid) {
184 igd_type = igd_table[i].name;
185 break;
186 }
187 }
188 printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n",
189 igdid, pci_read_config8(SA_DEV_IGD, PCI_REVISION_ID), igd_type);
190}
191
192void report_platform_info(void)
193{
194 report_cpu_info();
195 report_mch_info();
196 report_pch_info();
197 report_igd_info();
198}
199
200/*
201 * Dump in the log memory controller configuration as read from the memory
202 * controller registers.
203 */
204void report_memory_config(void)
205{
206 u32 addr_decoder_common, addr_decode_ch[2];
207 int i;
208
209 addr_decoder_common = MCHBAR32(0x5000);
210 addr_decode_ch[0] = MCHBAR32(0x5004);
211 addr_decode_ch[1] = MCHBAR32(0x5008);
212
213 printk(BIOS_DEBUG, "memcfg DDR3 clock %d MHz\n",
214 (MCHBAR32(0x5e04) * 13333 * 2 + 50)/100);
215 printk(BIOS_DEBUG, "memcfg channel assignment: A: %d, B % d, C % d\n",
216 addr_decoder_common & 3,
217 (addr_decoder_common >> 2) & 3,
218 (addr_decoder_common >> 4) & 3);
219
220 for (i = 0; i < ARRAY_SIZE(addr_decode_ch); i++) {
221 u32 ch_conf = addr_decode_ch[i];
222 printk(BIOS_DEBUG, "memcfg channel[%d] config (%8.8x):\n",
223 i, ch_conf);
224 printk(BIOS_DEBUG, " enhanced interleave mode %s\n",
225 ((ch_conf >> 22) & 1) ? "on" : "off");
226 printk(BIOS_DEBUG, " rank interleave %s\n",
227 ((ch_conf >> 21) & 1) ? "on" : "off");
228 printk(BIOS_DEBUG, " DIMMA %d MB width %s %s rank%s\n",
229 ((ch_conf >> 0) & 0xff) * 256,
230 ((ch_conf >> 19) & 1) ? "x16" : "x8 or x32",
231 ((ch_conf >> 17) & 1) ? "dual" : "single",
232 ((ch_conf >> 16) & 1) ? "" : ", selected");
233 printk(BIOS_DEBUG, " DIMMB %d MB width %s %s rank%s\n",
234 ((ch_conf >> 8) & 0xff) * 256,
235 ((ch_conf >> 19) & 1) ? "x16" : "x8 or x32",
236 ((ch_conf >> 18) & 1) ? "dual" : "single",
237 ((ch_conf >> 16) & 1) ? ", selected" : "");
238 }
239}