Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2014 Google Inc. |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 5 | * Copyright (C) 2015 Intel Corporation. |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 6 | * |
| 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 Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <arch/cpu.h> |
| 18 | #include <arch/io.h> |
| 19 | #include <console/console.h> |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 20 | #include <cpu/x86/msr.h> |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 21 | #include <device/pci.h> |
Naresh G Solanki | ecd9a94 | 2016-08-11 14:56:28 +0530 | [diff] [blame] | 22 | #include <soc/bootblock.h> |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 23 | #include <soc/cpu.h> |
| 24 | #include <soc/pch.h> |
| 25 | #include <soc/pci_devs.h> |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 26 | #include <soc/systemagent.h> |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 27 | #include <string.h> |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 28 | |
| 29 | static struct { |
| 30 | u32 cpuid; |
| 31 | const char *name; |
| 32 | } cpu_table[] = { |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 33 | { CPUID_SKYLAKE_C0, "Skylake C0" }, |
| 34 | { CPUID_SKYLAKE_D0, "Skylake D0" }, |
Sooi, Li Cheng | c76e998 | 2017-01-04 13:36:06 +0800 | [diff] [blame] | 35 | { CPUID_SKYLAKE_HQ0, "Skylake H Q0" }, |
| 36 | { CPUID_SKYLAKE_HR0, "Skylake H R0" }, |
Rizwan Qureshi | 5d41949 | 2016-08-03 19:16:18 +0530 | [diff] [blame] | 37 | { CPUID_KABYLAKE_G0, "Kabylake G0" }, |
| 38 | { CPUID_KABYLAKE_H0, "Kabylake H0" }, |
Sooi, Li Cheng | c76e998 | 2017-01-04 13:36:06 +0800 | [diff] [blame] | 39 | { CPUID_KABYLAKE_HA0, "Kabylake H A0" }, |
| 40 | { CPUID_KABYLAKE_HB0, "Kabylake H B0" }, |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | static struct { |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 44 | u16 mchid; |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 45 | const char *name; |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 46 | } 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 Cheng | c76e998 | 2017-01-04 13:36:06 +0800 | [diff] [blame] | 50 | { MCH_SKYLAKE_ID_H, "Skylake-H" }, |
| 51 | { MCH_SKYLAKE_ID_H_EM, "Skylake-H Embedded" }, |
Rizwan Qureshi | 5d41949 | 2016-08-03 19:16:18 +0530 | [diff] [blame] | 52 | { MCH_KABYLAKE_ID_U, "Kabylake-U" }, |
| 53 | { MCH_KABYLAKE_ID_Y, "Kabylake-Y" }, |
Sooi, Li Cheng | c76e998 | 2017-01-04 13:36:06 +0800 | [diff] [blame] | 54 | { MCH_KABYLAKE_ID_H, "Kabylake-H" }, |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | static struct { |
| 58 | u16 lpcid; |
| 59 | const char *name; |
| 60 | } pch_table[] = { |
Naresh G Solanki | 50bb67e | 2016-11-06 12:36:31 +0530 | [diff] [blame] | 61 | { 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 Cheng | c76e998 | 2017-01-04 13:36:06 +0800 | [diff] [blame] | 65 | { 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 Solanki | 50bb67e | 2016-11-06 12:36:31 +0530 | [diff] [blame] | 68 | { 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 Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | static struct { |
| 74 | u16 igdid; |
| 75 | const char *name; |
| 76 | } igd_table[] = { |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 77 | { 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 Cheng | c76e998 | 2017-01-04 13:36:06 +0800 | [diff] [blame] | 80 | { IGD_SKYLAKE_GT2_SHALM, "Skylake HALO GT2" }, |
| 81 | { IGD_SKYLAKE_GT4_SHALM, "Skylake HALO GT4" }, |
Barnali Sarkar | 9912310 | 2016-08-26 14:48:46 +0530 | [diff] [blame] | 82 | { 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 Cheng | c76e998 | 2017-01-04 13:36:06 +0800 | [diff] [blame] | 85 | { IGD_KABYLAKE_GT2_SHALM, "Kabylake HALO GT2" }, |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | static 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 Leahy | f4c4ab9 | 2017-03-16 17:08:03 -0700 | [diff] [blame^] | 95 | static const char * const mode[] = {"NOT ", ""}; |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 96 | 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 Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 103 | u32 *p = (u32 *) cpu_string; |
| 104 | for (i = 2; i <= 4; i++) { |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 105 | 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 Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 137 | printk(BIOS_DEBUG, |
| 138 | "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n", |
| 139 | mode[aes], mode[txt], mode[vt]); |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | static void report_mch_info(void) |
| 143 | { |
| 144 | int i; |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 145 | u16 mchid = pci_read_config16(SA_DEV_ROOT, PCI_DEVICE_ID); |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 146 | u8 mch_revision = pci_read_config8(SA_DEV_ROOT, PCI_REVISION_ID); |
| 147 | const char *mch_type = "Unknown"; |
| 148 | |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 149 | 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 Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 153 | } |
| 154 | } |
| 155 | |
| 156 | printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n", |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 157 | mchid, mch_revision, mch_type); |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | static 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 | |
| 176 | static 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 | |
| 192 | void 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 | */ |
| 204 | void 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 | } |