blob: 2610940859ab0a7c9ddf2aa77ce1b0c977e42d38 [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" },
Rizwan Qureshi5d419492016-08-03 19:16:18 +053035 { CPUID_KABYLAKE_G0, "Kabylake G0" },
36 { CPUID_KABYLAKE_H0, "Kabylake H0" },
Lee Leahyb0005132015-05-12 18:19:47 -070037};
38
39static struct {
Lee Leahy1d14b3e2015-05-12 18:23:27 -070040 u16 mchid;
Lee Leahyb0005132015-05-12 18:19:47 -070041 const char *name;
Lee Leahy1d14b3e2015-05-12 18:23:27 -070042} mch_table[] = {
43 { MCH_SKYLAKE_ID_U, "Skylake-U" },
44 { MCH_SKYLAKE_ID_Y, "Skylake-Y" },
45 { MCH_SKYLAKE_ID_ULX, "Skylake-ULX" },
Rizwan Qureshi5d419492016-08-03 19:16:18 +053046 { MCH_KABYLAKE_ID_U, "Kabylake-U" },
47 { MCH_KABYLAKE_ID_Y, "Kabylake-Y" },
Lee Leahyb0005132015-05-12 18:19:47 -070048};
49
50static struct {
51 u16 lpcid;
52 const char *name;
53} pch_table[] = {
Lee Leahy1d14b3e2015-05-12 18:23:27 -070054 { PCH_SPT_LP_SAMPLE, "Skylake LP Sample" },
55 { PCH_SPT_LP_U_BASE, "Skylake-U Base" },
56 { PCH_SPT_LP_U_PREMIUM, "Skylake-U Premium" },
57 { PCH_SPT_LP_Y_PREMIUM, "Skylake-Y Premium" },
Rizwan Qureshi5d419492016-08-03 19:16:18 +053058 { PCH_KBL_LP_U_PREMIUM, "Kabylake-U Premium" },
59 { PCH_KBL_LP_Y_PREMIUM, "Kabylake-Y Premium" },
Lee Leahyb0005132015-05-12 18:19:47 -070060};
61
62static struct {
63 u16 igdid;
64 const char *name;
65} igd_table[] = {
Lee Leahy1d14b3e2015-05-12 18:23:27 -070066 { IGD_SKYLAKE_GT1_SULTM, "Skylake ULT GT1"},
67 { IGD_SKYLAKE_GT2_SULXM, "Skylake ULX GT2" },
68 { IGD_SKYLAKE_GT2_SULTM, "Skylake ULT GT2" },
Lee Leahyb0005132015-05-12 18:19:47 -070069};
70
71static void report_cpu_info(void)
72{
73 struct cpuid_result cpuidr;
74 u32 i, index;
75 char cpu_string[50], *cpu_name = cpu_string; /* 48 bytes are reported */
76 int vt, txt, aes;
77 msr_t microcode_ver;
78 const char *mode[] = {"NOT ", ""};
79 const char *cpu_type = "Unknown";
80
81 index = 0x80000000;
82 cpuidr = cpuid(index);
83 if (cpuidr.eax < 0x80000004) {
84 strcpy(cpu_string, "Platform info not available");
85 } else {
Lee Leahy1d14b3e2015-05-12 18:23:27 -070086 u32 *p = (u32 *) cpu_string;
87 for (i = 2; i <= 4; i++) {
Lee Leahyb0005132015-05-12 18:19:47 -070088 cpuidr = cpuid(index + i);
89 *p++ = cpuidr.eax;
90 *p++ = cpuidr.ebx;
91 *p++ = cpuidr.ecx;
92 *p++ = cpuidr.edx;
93 }
94 }
95 /* Skip leading spaces in CPU name string */
96 while (cpu_name[0] == ' ')
97 cpu_name++;
98
99 microcode_ver.lo = 0;
100 microcode_ver.hi = 0;
101 wrmsr(0x8B, microcode_ver);
102 cpuidr = cpuid(1);
103 microcode_ver = rdmsr(0x8b);
104
105 /* Look for string to match the name */
106 for (i = 0; i < ARRAY_SIZE(cpu_table); i++) {
107 if (cpu_table[i].cpuid == cpuidr.eax) {
108 cpu_type = cpu_table[i].name;
109 break;
110 }
111 }
112
113 printk(BIOS_DEBUG, "CPU: %s\n", cpu_name);
114 printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n",
115 cpuidr.eax, cpu_type, microcode_ver.hi);
116
117 aes = (cpuidr.ecx & (1 << 25)) ? 1 : 0;
118 txt = (cpuidr.ecx & (1 << 6)) ? 1 : 0;
119 vt = (cpuidr.ecx & (1 << 5)) ? 1 : 0;
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700120 printk(BIOS_DEBUG,
121 "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n",
122 mode[aes], mode[txt], mode[vt]);
Lee Leahyb0005132015-05-12 18:19:47 -0700123}
124
125static void report_mch_info(void)
126{
127 int i;
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700128 u16 mchid = pci_read_config16(SA_DEV_ROOT, PCI_DEVICE_ID);
Lee Leahyb0005132015-05-12 18:19:47 -0700129 u8 mch_revision = pci_read_config8(SA_DEV_ROOT, PCI_REVISION_ID);
130 const char *mch_type = "Unknown";
131
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700132 for (i = 0; i < ARRAY_SIZE(mch_table); i++) {
133 if (mch_table[i].mchid == mchid) {
134 mch_type = mch_table[i].name;
135 break;
Lee Leahyb0005132015-05-12 18:19:47 -0700136 }
137 }
138
139 printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n",
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700140 mchid, mch_revision, mch_type);
Lee Leahyb0005132015-05-12 18:19:47 -0700141}
142
143static void report_pch_info(void)
144{
145 int i;
146 u16 lpcid = pch_type();
147 const char *pch_type = "Unknown";
148
149 for (i = 0; i < ARRAY_SIZE(pch_table); i++) {
150 if (pch_table[i].lpcid == lpcid) {
151 pch_type = pch_table[i].name;
152 break;
153 }
154 }
155 printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n",
156 lpcid, pch_revision(), pch_type);
157}
158
159static void report_igd_info(void)
160{
161 int i;
162 u16 igdid = pci_read_config16(SA_DEV_IGD, PCI_DEVICE_ID);
163 const char *igd_type = "Unknown";
164
165 for (i = 0; i < ARRAY_SIZE(igd_table); i++) {
166 if (igd_table[i].igdid == igdid) {
167 igd_type = igd_table[i].name;
168 break;
169 }
170 }
171 printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n",
172 igdid, pci_read_config8(SA_DEV_IGD, PCI_REVISION_ID), igd_type);
173}
174
175void report_platform_info(void)
176{
177 report_cpu_info();
178 report_mch_info();
179 report_pch_info();
180 report_igd_info();
181}
182
183/*
184 * Dump in the log memory controller configuration as read from the memory
185 * controller registers.
186 */
187void report_memory_config(void)
188{
189 u32 addr_decoder_common, addr_decode_ch[2];
190 int i;
191
192 addr_decoder_common = MCHBAR32(0x5000);
193 addr_decode_ch[0] = MCHBAR32(0x5004);
194 addr_decode_ch[1] = MCHBAR32(0x5008);
195
196 printk(BIOS_DEBUG, "memcfg DDR3 clock %d MHz\n",
197 (MCHBAR32(0x5e04) * 13333 * 2 + 50)/100);
198 printk(BIOS_DEBUG, "memcfg channel assignment: A: %d, B % d, C % d\n",
199 addr_decoder_common & 3,
200 (addr_decoder_common >> 2) & 3,
201 (addr_decoder_common >> 4) & 3);
202
203 for (i = 0; i < ARRAY_SIZE(addr_decode_ch); i++) {
204 u32 ch_conf = addr_decode_ch[i];
205 printk(BIOS_DEBUG, "memcfg channel[%d] config (%8.8x):\n",
206 i, ch_conf);
207 printk(BIOS_DEBUG, " enhanced interleave mode %s\n",
208 ((ch_conf >> 22) & 1) ? "on" : "off");
209 printk(BIOS_DEBUG, " rank interleave %s\n",
210 ((ch_conf >> 21) & 1) ? "on" : "off");
211 printk(BIOS_DEBUG, " DIMMA %d MB width %s %s rank%s\n",
212 ((ch_conf >> 0) & 0xff) * 256,
213 ((ch_conf >> 19) & 1) ? "x16" : "x8 or x32",
214 ((ch_conf >> 17) & 1) ? "dual" : "single",
215 ((ch_conf >> 16) & 1) ? "" : ", selected");
216 printk(BIOS_DEBUG, " DIMMB %d MB width %s %s rank%s\n",
217 ((ch_conf >> 8) & 0xff) * 256,
218 ((ch_conf >> 19) & 1) ? "x16" : "x8 or x32",
219 ((ch_conf >> 18) & 1) ? "dual" : "single",
220 ((ch_conf >> 16) & 1) ? ", selected" : "");
221 }
222}