Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2014 Google Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <arch/cpu.h> |
| 17 | #include <arch/io.h> |
| 18 | #include <console/console.h> |
| 19 | #include <device/pci.h> |
| 20 | #include <string.h> |
| 21 | #include <cpu/x86/msr.h> |
Julius Werner | 4ee4bd5 | 2014-10-20 13:46:39 -0700 | [diff] [blame] | 22 | #include <soc/cpu.h> |
| 23 | #include <soc/pch.h> |
| 24 | #include <soc/pci_devs.h> |
| 25 | #include <soc/romstage.h> |
| 26 | #include <soc/systemagent.h> |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 27 | |
| 28 | static struct { |
| 29 | u32 cpuid; |
| 30 | const char *name; |
Duncan Laurie | 2af67c9 | 2014-10-14 08:37:18 -0700 | [diff] [blame] | 31 | } cpu_table[] = { |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 32 | { CPUID_HASWELL_A0, "Haswell A0" }, |
| 33 | { CPUID_HASWELL_B0, "Haswell B0" }, |
| 34 | { CPUID_HASWELL_C0, "Haswell C0" }, |
| 35 | { CPUID_HASWELL_ULT_B0, "Haswell ULT B0" }, |
| 36 | { CPUID_HASWELL_ULT, "Haswell ULT C0 or D0" }, |
| 37 | { CPUID_HASWELL_HALO, "Haswell Perf Halo" }, |
| 38 | { CPUID_BROADWELL_C0, "Broadwell C0" }, |
| 39 | { CPUID_BROADWELL_D0, "Broadwell D0" }, |
Duncan Laurie | 4b2adb1 | 2014-10-13 13:14:22 -0700 | [diff] [blame] | 40 | { CPUID_BROADWELL_E0, "Broadwell E0 or F0" }, |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | static struct { |
Duncan Laurie | 2af67c9 | 2014-10-14 08:37:18 -0700 | [diff] [blame] | 44 | u8 revid; |
| 45 | const char *name; |
| 46 | } mch_rev_table[] = { |
| 47 | { MCH_BROADWELL_REV_D0, "Broadwell D0" }, |
| 48 | { MCH_BROADWELL_REV_E0, "Broadwell E0" }, |
| 49 | { MCH_BROADWELL_REV_F0, "Broadwell F0" }, |
| 50 | }; |
| 51 | |
| 52 | static struct { |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 53 | u16 lpcid; |
| 54 | const char *name; |
Duncan Laurie | 2af67c9 | 2014-10-14 08:37:18 -0700 | [diff] [blame] | 55 | } pch_table[] = { |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 56 | { PCH_LPT_LP_SAMPLE, "LynxPoint LP Sample" }, |
| 57 | { PCH_LPT_LP_PREMIUM, "LynxPoint LP Premium" }, |
| 58 | { PCH_LPT_LP_MAINSTREAM, "LynxPoint LP Mainstream" }, |
| 59 | { PCH_LPT_LP_VALUE, "LynxPoint LP Value" }, |
| 60 | { PCH_WPT_HSW_U_SAMPLE, "Haswell U Sample" }, |
| 61 | { PCH_WPT_BDW_U_SAMPLE, "Broadwell U Sample" }, |
| 62 | { PCH_WPT_BDW_U_PREMIUM, "Broadwell U Premium" }, |
| 63 | { PCH_WPT_BDW_U_BASE, "Broadwell U Base" }, |
| 64 | { PCH_WPT_BDW_Y_SAMPLE, "Broadwell Y Sample" }, |
| 65 | { PCH_WPT_BDW_Y_PREMIUM, "Broadwell Y Premium" }, |
| 66 | { PCH_WPT_BDW_Y_BASE, "Broadwell Y Base" }, |
| 67 | { PCH_WPT_BDW_H, "Broadwell H" }, |
| 68 | }; |
| 69 | |
| 70 | static struct { |
| 71 | u16 igdid; |
| 72 | const char *name; |
Duncan Laurie | 2af67c9 | 2014-10-14 08:37:18 -0700 | [diff] [blame] | 73 | } igd_table[] = { |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 74 | { IGD_HASWELL_ULT_GT1, "Haswell ULT GT1" }, |
| 75 | { IGD_HASWELL_ULT_GT2, "Haswell ULT GT2" }, |
| 76 | { IGD_HASWELL_ULT_GT3, "Haswell ULT GT3" }, |
| 77 | { IGD_BROADWELL_U_GT1, "Broadwell U GT1" }, |
| 78 | { IGD_BROADWELL_U_GT2, "Broadwell U GT2" }, |
| 79 | { IGD_BROADWELL_U_GT3_15W, "Broadwell U GT3 (15W)" }, |
| 80 | { IGD_BROADWELL_U_GT3_28W, "Broadwell U GT3 (28W)" }, |
| 81 | { IGD_BROADWELL_Y_GT2, "Broadwell Y GT2" }, |
| 82 | { IGD_BROADWELL_H_GT2, "Broadwell U GT2" }, |
| 83 | { IGD_BROADWELL_H_GT3, "Broadwell U GT3" }, |
| 84 | }; |
| 85 | |
| 86 | static void report_cpu_info(void) |
| 87 | { |
| 88 | struct cpuid_result cpuidr; |
Subrata Banik | 53b08c3 | 2018-12-10 14:11:35 +0530 | [diff] [blame] | 89 | u32 i, index, cpu_id, cpu_feature_flag; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 90 | char cpu_string[50], *cpu_name = cpu_string; /* 48 bytes are reported */ |
| 91 | int vt, txt, aes; |
| 92 | msr_t microcode_ver; |
| 93 | const char *mode[] = {"NOT ", ""}; |
| 94 | const char *cpu_type = "Unknown"; |
| 95 | |
| 96 | index = 0x80000000; |
| 97 | cpuidr = cpuid(index); |
| 98 | if (cpuidr.eax < 0x80000004) { |
| 99 | strcpy(cpu_string, "Platform info not available"); |
| 100 | } else { |
Lee Leahy | 26b7cd0 | 2017-03-16 18:47:55 -0700 | [diff] [blame] | 101 | u32 *p = (u32 *)cpu_string; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 102 | for (i = 2; i <= 4 ; i++) { |
| 103 | cpuidr = cpuid(index + i); |
| 104 | *p++ = cpuidr.eax; |
| 105 | *p++ = cpuidr.ebx; |
| 106 | *p++ = cpuidr.ecx; |
| 107 | *p++ = cpuidr.edx; |
| 108 | } |
| 109 | } |
| 110 | /* Skip leading spaces in CPU name string */ |
| 111 | while (cpu_name[0] == ' ') |
| 112 | cpu_name++; |
| 113 | |
| 114 | microcode_ver.lo = 0; |
| 115 | microcode_ver.hi = 0; |
Elyes HAOUAS | 603963e | 2018-09-28 09:06:43 +0200 | [diff] [blame] | 116 | wrmsr(IA32_BIOS_SIGN_ID, microcode_ver); |
Subrata Banik | 53b08c3 | 2018-12-10 14:11:35 +0530 | [diff] [blame] | 117 | cpu_id = cpu_get_cpuid(); |
Elyes HAOUAS | 603963e | 2018-09-28 09:06:43 +0200 | [diff] [blame] | 118 | microcode_ver = rdmsr(IA32_BIOS_SIGN_ID); |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 119 | |
| 120 | /* Look for string to match the name */ |
| 121 | for (i = 0; i < ARRAY_SIZE(cpu_table); i++) { |
Subrata Banik | 53b08c3 | 2018-12-10 14:11:35 +0530 | [diff] [blame] | 122 | if (cpu_table[i].cpuid == cpu_id) { |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 123 | cpu_type = cpu_table[i].name; |
| 124 | break; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | printk(BIOS_DEBUG, "CPU: %s\n", cpu_name); |
| 129 | printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n", |
Subrata Banik | 53b08c3 | 2018-12-10 14:11:35 +0530 | [diff] [blame] | 130 | cpu_id, cpu_type, microcode_ver.hi); |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 131 | |
Subrata Banik | 53b08c3 | 2018-12-10 14:11:35 +0530 | [diff] [blame] | 132 | cpu_feature_flag = cpu_get_feature_flags_ecx(); |
| 133 | aes = (cpu_feature_flag & CPUID_AES) ? 1 : 0; |
| 134 | txt = (cpu_feature_flag & CPUID_SMX) ? 1 : 0; |
| 135 | vt = (cpu_feature_flag & CPUID_VMX) ? 1 : 0; |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 136 | printk(BIOS_DEBUG, "CPU: AES %ssupported, TXT %ssupported, " |
| 137 | "VT %ssupported\n", mode[aes], mode[txt], mode[vt]); |
| 138 | } |
| 139 | |
Duncan Laurie | 2af67c9 | 2014-10-14 08:37:18 -0700 | [diff] [blame] | 140 | static void report_mch_info(void) |
| 141 | { |
| 142 | int i; |
| 143 | u16 mch_device = pci_read_config16(SA_DEV_ROOT, PCI_DEVICE_ID); |
| 144 | u8 mch_revision = pci_read_config8(SA_DEV_ROOT, PCI_REVISION_ID); |
| 145 | const char *mch_type = "Unknown"; |
| 146 | |
| 147 | /* Look for string to match the revision for Broadwell U/Y */ |
| 148 | if (mch_device == MCH_BROADWELL_ID_U_Y) { |
| 149 | for (i = 0; i < ARRAY_SIZE(mch_rev_table); i++) { |
| 150 | if (mch_rev_table[i].revid == mch_revision) { |
| 151 | mch_type = mch_rev_table[i].name; |
| 152 | break; |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n", |
| 158 | mch_device, mch_revision, mch_type); |
| 159 | } |
| 160 | |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 161 | static void report_pch_info(void) |
| 162 | { |
| 163 | int i; |
| 164 | u16 lpcid = pch_type(); |
| 165 | const char *pch_type = "Unknown"; |
| 166 | |
| 167 | for (i = 0; i < ARRAY_SIZE(pch_table); i++) { |
| 168 | if (pch_table[i].lpcid == lpcid) { |
| 169 | pch_type = pch_table[i].name; |
| 170 | break; |
| 171 | } |
| 172 | } |
| 173 | printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n", |
| 174 | lpcid, pch_revision(), pch_type); |
| 175 | } |
| 176 | |
| 177 | static void report_igd_info(void) |
| 178 | { |
| 179 | int i; |
| 180 | u16 igdid = pci_read_config16(SA_DEV_IGD, PCI_DEVICE_ID); |
| 181 | const char *igd_type = "Unknown"; |
| 182 | |
| 183 | for (i = 0; i < ARRAY_SIZE(igd_table); i++) { |
| 184 | if (igd_table[i].igdid == igdid) { |
| 185 | igd_type = igd_table[i].name; |
| 186 | break; |
| 187 | } |
| 188 | } |
| 189 | printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n", |
| 190 | igdid, pci_read_config8(SA_DEV_IGD, PCI_REVISION_ID), igd_type); |
| 191 | } |
| 192 | |
| 193 | void report_platform_info(void) |
| 194 | { |
| 195 | report_cpu_info(); |
Duncan Laurie | 2af67c9 | 2014-10-14 08:37:18 -0700 | [diff] [blame] | 196 | report_mch_info(); |
Duncan Laurie | c88c54c | 2014-04-30 16:36:13 -0700 | [diff] [blame] | 197 | report_pch_info(); |
| 198 | report_igd_info(); |
| 199 | } |
| 200 | |
| 201 | /* |
| 202 | * Dump in the log memory controller configuration as read from the memory |
| 203 | * controller registers. |
| 204 | */ |
| 205 | void report_memory_config(void) |
| 206 | { |
| 207 | u32 addr_decoder_common, addr_decode_ch[2]; |
| 208 | int i; |
| 209 | |
| 210 | addr_decoder_common = MCHBAR32(0x5000); |
| 211 | addr_decode_ch[0] = MCHBAR32(0x5004); |
| 212 | addr_decode_ch[1] = MCHBAR32(0x5008); |
| 213 | |
| 214 | printk(BIOS_DEBUG, "memcfg DDR3 clock %d MHz\n", |
| 215 | (MCHBAR32(0x5e04) * 13333 * 2 + 50)/100); |
| 216 | printk(BIOS_DEBUG, "memcfg channel assignment: A: %d, B % d, C % d\n", |
| 217 | addr_decoder_common & 3, |
| 218 | (addr_decoder_common >> 2) & 3, |
| 219 | (addr_decoder_common >> 4) & 3); |
| 220 | |
| 221 | for (i = 0; i < ARRAY_SIZE(addr_decode_ch); i++) { |
| 222 | u32 ch_conf = addr_decode_ch[i]; |
| 223 | printk(BIOS_DEBUG, "memcfg channel[%d] config (%8.8x):\n", |
| 224 | i, ch_conf); |
| 225 | printk(BIOS_DEBUG, " enhanced interleave mode %s\n", |
| 226 | ((ch_conf >> 22) & 1) ? "on" : "off"); |
| 227 | printk(BIOS_DEBUG, " rank interleave %s\n", |
| 228 | ((ch_conf >> 21) & 1) ? "on" : "off"); |
| 229 | printk(BIOS_DEBUG, " DIMMA %d MB width %s %s rank%s\n", |
| 230 | ((ch_conf >> 0) & 0xff) * 256, |
| 231 | ((ch_conf >> 19) & 1) ? "x16" : "x8 or x32", |
| 232 | ((ch_conf >> 17) & 1) ? "dual" : "single", |
| 233 | ((ch_conf >> 16) & 1) ? "" : ", selected"); |
| 234 | printk(BIOS_DEBUG, " DIMMB %d MB width %s %s rank%s\n", |
| 235 | ((ch_conf >> 8) & 0xff) * 256, |
| 236 | ((ch_conf >> 19) & 1) ? "x16" : "x8 or x32", |
| 237 | ((ch_conf >> 18) & 1) ? "dual" : "single", |
| 238 | ((ch_conf >> 16) & 1) ? ", selected" : ""); |
| 239 | } |
| 240 | } |