blob: fe1a785d2252529931216f112d8f34d4ccb9a6c0 [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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
Lee Leahy1d14b3e2015-05-12 18:23:27 -070018 * Foundation, Inc.
Lee Leahyb0005132015-05-12 18:19:47 -070019 */
20
21#include <arch/cpu.h>
22#include <arch/io.h>
23#include <console/console.h>
Lee Leahyb0005132015-05-12 18:19:47 -070024#include <cpu/x86/msr.h>
Lee Leahy1d14b3e2015-05-12 18:23:27 -070025#include <device/pci.h>
Lee Leahyb0005132015-05-12 18:19:47 -070026#include <soc/cpu.h>
27#include <soc/pch.h>
28#include <soc/pci_devs.h>
29#include <soc/romstage.h>
30#include <soc/systemagent.h>
Lee Leahy1d14b3e2015-05-12 18:23:27 -070031#include <string.h>
Lee Leahyb0005132015-05-12 18:19:47 -070032
33static struct {
34 u32 cpuid;
35 const char *name;
36} cpu_table[] = {
Lee Leahy1d14b3e2015-05-12 18:23:27 -070037 { CPUID_SKYLAKE_C0, "Skylake C0" },
38 { CPUID_SKYLAKE_D0, "Skylake D0" },
Lee Leahyb0005132015-05-12 18:19:47 -070039};
40
41static struct {
Lee Leahy1d14b3e2015-05-12 18:23:27 -070042 u16 mchid;
Lee Leahyb0005132015-05-12 18:19:47 -070043 const char *name;
Lee Leahy1d14b3e2015-05-12 18:23:27 -070044} mch_table[] = {
45 { MCH_SKYLAKE_ID_U, "Skylake-U" },
46 { MCH_SKYLAKE_ID_Y, "Skylake-Y" },
47 { MCH_SKYLAKE_ID_ULX, "Skylake-ULX" },
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" },
Lee Leahyb0005132015-05-12 18:19:47 -070058};
59
60static struct {
61 u16 igdid;
62 const char *name;
63} igd_table[] = {
Lee Leahy1d14b3e2015-05-12 18:23:27 -070064 { IGD_SKYLAKE_GT1_SULTM, "Skylake ULT GT1"},
65 { IGD_SKYLAKE_GT2_SULXM, "Skylake ULX GT2" },
66 { IGD_SKYLAKE_GT2_SULTM, "Skylake ULT GT2" },
Lee Leahyb0005132015-05-12 18:19:47 -070067};
68
69static void report_cpu_info(void)
70{
71 struct cpuid_result cpuidr;
72 u32 i, index;
73 char cpu_string[50], *cpu_name = cpu_string; /* 48 bytes are reported */
74 int vt, txt, aes;
75 msr_t microcode_ver;
76 const char *mode[] = {"NOT ", ""};
77 const char *cpu_type = "Unknown";
78
79 index = 0x80000000;
80 cpuidr = cpuid(index);
81 if (cpuidr.eax < 0x80000004) {
82 strcpy(cpu_string, "Platform info not available");
83 } else {
Lee Leahy1d14b3e2015-05-12 18:23:27 -070084 u32 *p = (u32 *) cpu_string;
85 for (i = 2; i <= 4; i++) {
Lee Leahyb0005132015-05-12 18:19:47 -070086 cpuidr = cpuid(index + i);
87 *p++ = cpuidr.eax;
88 *p++ = cpuidr.ebx;
89 *p++ = cpuidr.ecx;
90 *p++ = cpuidr.edx;
91 }
92 }
93 /* Skip leading spaces in CPU name string */
94 while (cpu_name[0] == ' ')
95 cpu_name++;
96
97 microcode_ver.lo = 0;
98 microcode_ver.hi = 0;
99 wrmsr(0x8B, microcode_ver);
100 cpuidr = cpuid(1);
101 microcode_ver = rdmsr(0x8b);
102
103 /* Look for string to match the name */
104 for (i = 0; i < ARRAY_SIZE(cpu_table); i++) {
105 if (cpu_table[i].cpuid == cpuidr.eax) {
106 cpu_type = cpu_table[i].name;
107 break;
108 }
109 }
110
111 printk(BIOS_DEBUG, "CPU: %s\n", cpu_name);
112 printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n",
113 cpuidr.eax, cpu_type, microcode_ver.hi);
114
115 aes = (cpuidr.ecx & (1 << 25)) ? 1 : 0;
116 txt = (cpuidr.ecx & (1 << 6)) ? 1 : 0;
117 vt = (cpuidr.ecx & (1 << 5)) ? 1 : 0;
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700118 printk(BIOS_DEBUG,
119 "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n",
120 mode[aes], mode[txt], mode[vt]);
Lee Leahyb0005132015-05-12 18:19:47 -0700121}
122
123static void report_mch_info(void)
124{
125 int i;
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700126 u16 mchid = pci_read_config16(SA_DEV_ROOT, PCI_DEVICE_ID);
Lee Leahyb0005132015-05-12 18:19:47 -0700127 u8 mch_revision = pci_read_config8(SA_DEV_ROOT, PCI_REVISION_ID);
128 const char *mch_type = "Unknown";
129
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700130 for (i = 0; i < ARRAY_SIZE(mch_table); i++) {
131 if (mch_table[i].mchid == mchid) {
132 mch_type = mch_table[i].name;
133 break;
Lee Leahyb0005132015-05-12 18:19:47 -0700134 }
135 }
136
137 printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n",
Lee Leahy1d14b3e2015-05-12 18:23:27 -0700138 mchid, mch_revision, mch_type);
Lee Leahyb0005132015-05-12 18:19:47 -0700139}
140
141static void report_pch_info(void)
142{
143 int i;
144 u16 lpcid = pch_type();
145 const char *pch_type = "Unknown";
146
147 for (i = 0; i < ARRAY_SIZE(pch_table); i++) {
148 if (pch_table[i].lpcid == lpcid) {
149 pch_type = pch_table[i].name;
150 break;
151 }
152 }
153 printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n",
154 lpcid, pch_revision(), pch_type);
155}
156
157static void report_igd_info(void)
158{
159 int i;
160 u16 igdid = pci_read_config16(SA_DEV_IGD, PCI_DEVICE_ID);
161 const char *igd_type = "Unknown";
162
163 for (i = 0; i < ARRAY_SIZE(igd_table); i++) {
164 if (igd_table[i].igdid == igdid) {
165 igd_type = igd_table[i].name;
166 break;
167 }
168 }
169 printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n",
170 igdid, pci_read_config8(SA_DEV_IGD, PCI_REVISION_ID), igd_type);
171}
172
173void report_platform_info(void)
174{
175 report_cpu_info();
176 report_mch_info();
177 report_pch_info();
178 report_igd_info();
179}
180
181/*
182 * Dump in the log memory controller configuration as read from the memory
183 * controller registers.
184 */
185void report_memory_config(void)
186{
187 u32 addr_decoder_common, addr_decode_ch[2];
188 int i;
189
190 addr_decoder_common = MCHBAR32(0x5000);
191 addr_decode_ch[0] = MCHBAR32(0x5004);
192 addr_decode_ch[1] = MCHBAR32(0x5008);
193
194 printk(BIOS_DEBUG, "memcfg DDR3 clock %d MHz\n",
195 (MCHBAR32(0x5e04) * 13333 * 2 + 50)/100);
196 printk(BIOS_DEBUG, "memcfg channel assignment: A: %d, B % d, C % d\n",
197 addr_decoder_common & 3,
198 (addr_decoder_common >> 2) & 3,
199 (addr_decoder_common >> 4) & 3);
200
201 for (i = 0; i < ARRAY_SIZE(addr_decode_ch); i++) {
202 u32 ch_conf = addr_decode_ch[i];
203 printk(BIOS_DEBUG, "memcfg channel[%d] config (%8.8x):\n",
204 i, ch_conf);
205 printk(BIOS_DEBUG, " enhanced interleave mode %s\n",
206 ((ch_conf >> 22) & 1) ? "on" : "off");
207 printk(BIOS_DEBUG, " rank interleave %s\n",
208 ((ch_conf >> 21) & 1) ? "on" : "off");
209 printk(BIOS_DEBUG, " DIMMA %d MB width %s %s rank%s\n",
210 ((ch_conf >> 0) & 0xff) * 256,
211 ((ch_conf >> 19) & 1) ? "x16" : "x8 or x32",
212 ((ch_conf >> 17) & 1) ? "dual" : "single",
213 ((ch_conf >> 16) & 1) ? "" : ", selected");
214 printk(BIOS_DEBUG, " DIMMB %d MB width %s %s rank%s\n",
215 ((ch_conf >> 8) & 0xff) * 256,
216 ((ch_conf >> 19) & 1) ? "x16" : "x8 or x32",
217 ((ch_conf >> 18) & 1) ? "dual" : "single",
218 ((ch_conf >> 16) & 1) ? ", selected" : "");
219 }
220}