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> |
Subrata Banik | c216567 | 2017-06-02 17:52:44 +0530 | [diff] [blame] | 22 | #include <device/pci_ids.h> |
Barnali Sarkar | 7327386 | 2017-06-13 20:22:33 +0530 | [diff] [blame] | 23 | #include <intelblocks/mp_init.h> |
Naresh G Solanki | ecd9a94 | 2016-08-11 14:56:28 +0530 | [diff] [blame] | 24 | #include <soc/bootblock.h> |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 25 | #include <soc/cpu.h> |
| 26 | #include <soc/pch.h> |
| 27 | #include <soc/pci_devs.h> |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 28 | #include <soc/systemagent.h> |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 29 | #include <string.h> |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 30 | |
| 31 | static struct { |
| 32 | u32 cpuid; |
| 33 | const char *name; |
| 34 | } cpu_table[] = { |
Subrata Banik | c216567 | 2017-06-02 17:52:44 +0530 | [diff] [blame] | 35 | { CPUID_SKYLAKE_C0, "Skylake C0" }, |
| 36 | { CPUID_SKYLAKE_D0, "Skylake D0" }, |
| 37 | { CPUID_SKYLAKE_HQ0, "Skylake H Q0" }, |
| 38 | { CPUID_SKYLAKE_HR0, "Skylake H R0" }, |
| 39 | { CPUID_KABYLAKE_G0, "Kabylake G0" }, |
| 40 | { CPUID_KABYLAKE_H0, "Kabylake H0" }, |
| 41 | { CPUID_KABYLAKE_Y0, "Kabylake Y0" }, |
| 42 | { CPUID_KABYLAKE_HA0, "Kabylake H A0" }, |
| 43 | { CPUID_KABYLAKE_HB0, "Kabylake H B0" }, |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | static struct { |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 47 | u16 mchid; |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 48 | const char *name; |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 49 | } mch_table[] = { |
Subrata Banik | c216567 | 2017-06-02 17:52:44 +0530 | [diff] [blame] | 50 | { PCI_DEVICE_ID_INTEL_SKL_ID_U, "Skylake-U" }, |
| 51 | { PCI_DEVICE_ID_INTEL_SKL_ID_Y, "Skylake-Y" }, |
| 52 | { PCI_DEVICE_ID_INTEL_SKL_ID_ULX, "Skylake-ULX" }, |
| 53 | { PCI_DEVICE_ID_INTEL_SKL_ID_H, "Skylake-H" }, |
| 54 | { PCI_DEVICE_ID_INTEL_SKL_ID_H_EM, "Skylake-H Embedded" }, |
| 55 | { PCI_DEVICE_ID_INTEL_KBL_ID_U, "Kabylake-U" }, |
| 56 | { PCI_DEVICE_ID_INTEL_KBL_U_R, "Kabylake-R ULT"}, |
| 57 | { PCI_DEVICE_ID_INTEL_KBL_ID_Y, "Kabylake-Y" }, |
| 58 | { PCI_DEVICE_ID_INTEL_KBL_ID_H, "Kabylake-H" }, |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | static struct { |
| 62 | u16 lpcid; |
| 63 | const char *name; |
| 64 | } pch_table[] = { |
Subrata Banik | c216567 | 2017-06-02 17:52:44 +0530 | [diff] [blame] | 65 | { PCI_DEVICE_ID_INTEL_SPT_LP_SAMPLE, "Skylake LP Sample" }, |
| 66 | { PCI_DEVICE_ID_INTEL_SPT_LP_U_BASE, "Skylake-U Base" }, |
| 67 | { PCI_DEVICE_ID_INTEL_SPT_LP_U_PREMIUM, "Skylake-U Premium" }, |
| 68 | { PCI_DEVICE_ID_INTEL_SPT_LP_Y_PREMIUM, "Skylake-Y Premium" }, |
V Sowmya | 7c15047 | 2018-01-23 14:44:45 +0530 | [diff] [blame^] | 69 | { PCI_DEVICE_ID_INTEL_SPT_H_PREMIUM, "Skylake PCH-H Premium" }, |
| 70 | { PCI_DEVICE_ID_INTEL_SPT_H_C236, "Skylake PCH-H C236" }, |
| 71 | { PCI_DEVICE_ID_INTEL_SPT_H_QM170, "Skylake PCH-H QM170" }, |
Subrata Banik | c216567 | 2017-06-02 17:52:44 +0530 | [diff] [blame] | 72 | { PCI_DEVICE_ID_INTEL_KBP_LP_U_PREMIUM, "Kabylake-U Premium" }, |
| 73 | { PCI_DEVICE_ID_INTEL_KBP_LP_Y_PREMIUM, "Kabylake-Y Premium" }, |
| 74 | { PCI_DEVICE_ID_INTEL_KBP_LP_SUPER_SKU, "Kabylake Super Sku" }, |
| 75 | { PCI_DEVICE_ID_INTEL_SPT_LP_Y_PREMIUM_HDCP22, |
| 76 | "Kabylake-Y iHDCP 2.2 Premium" }, |
| 77 | { PCI_DEVICE_ID_INTEL_SPT_LP_U_PREMIUM_HDCP22, |
| 78 | "Kabylake-U iHDCP 2.2 Premium" }, |
Gaggery Tsai | e2592be | 2017-09-20 22:46:39 +0800 | [diff] [blame] | 79 | { PCI_DEVICE_ID_INTEL_SPT_LP_U_BASE_HDCP22, |
| 80 | "Kabylake-U iHDCP 2.2 Base" }, |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | static struct { |
| 84 | u16 igdid; |
| 85 | const char *name; |
| 86 | } igd_table[] = { |
Subrata Banik | c216567 | 2017-06-02 17:52:44 +0530 | [diff] [blame] | 87 | { PCI_DEVICE_ID_INTEL_SKL_GT1_SULTM, "Skylake ULT GT1"}, |
| 88 | { PCI_DEVICE_ID_INTEL_SKL_GT2_SULXM, "Skylake ULX GT2" }, |
| 89 | { PCI_DEVICE_ID_INTEL_SKL_GT2_SULTM, "Skylake ULT GT2" }, |
| 90 | { PCI_DEVICE_ID_INTEL_SKL_GT2_SHALM, "Skylake HALO GT2" }, |
| 91 | { PCI_DEVICE_ID_INTEL_SKL_GT4_SHALM, "Skylake HALO GT4" }, |
| 92 | { PCI_DEVICE_ID_INTEL_KBL_GT1_SULTM, "Kabylake ULT GT1"}, |
| 93 | { PCI_DEVICE_ID_INTEL_KBL_GT2_SULXM, "Kabylake ULX GT2" }, |
| 94 | { PCI_DEVICE_ID_INTEL_KBL_GT2_SULTM, "Kabylake ULT GT2" }, |
| 95 | { PCI_DEVICE_ID_INTEL_KBL_GT2_SULTMR, "Kabylake-R ULT GT2"}, |
| 96 | { PCI_DEVICE_ID_INTEL_KBL_GT2_SHALM, "Kabylake HALO GT2" }, |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 97 | }; |
| 98 | |
Subrata Banik | df5ae9c | 2017-12-06 19:10:15 +0530 | [diff] [blame] | 99 | static uint8_t get_dev_revision(device_t dev) |
| 100 | { |
| 101 | return pci_read_config8(dev, PCI_REVISION_ID); |
| 102 | } |
| 103 | |
| 104 | static uint16_t get_dev_id(device_t dev) |
| 105 | { |
| 106 | return pci_read_config16(dev, PCI_DEVICE_ID); |
| 107 | } |
| 108 | |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 109 | static void report_cpu_info(void) |
| 110 | { |
| 111 | struct cpuid_result cpuidr; |
| 112 | u32 i, index; |
| 113 | char cpu_string[50], *cpu_name = cpu_string; /* 48 bytes are reported */ |
| 114 | int vt, txt, aes; |
| 115 | msr_t microcode_ver; |
Lee Leahy | f4c4ab9 | 2017-03-16 17:08:03 -0700 | [diff] [blame] | 116 | static const char * const mode[] = {"NOT ", ""}; |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 117 | const char *cpu_type = "Unknown"; |
| 118 | |
| 119 | index = 0x80000000; |
| 120 | cpuidr = cpuid(index); |
| 121 | if (cpuidr.eax < 0x80000004) { |
| 122 | strcpy(cpu_string, "Platform info not available"); |
| 123 | } else { |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 124 | u32 *p = (u32 *) cpu_string; |
| 125 | for (i = 2; i <= 4; i++) { |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 126 | cpuidr = cpuid(index + i); |
| 127 | *p++ = cpuidr.eax; |
| 128 | *p++ = cpuidr.ebx; |
| 129 | *p++ = cpuidr.ecx; |
| 130 | *p++ = cpuidr.edx; |
| 131 | } |
| 132 | } |
| 133 | /* Skip leading spaces in CPU name string */ |
| 134 | while (cpu_name[0] == ' ') |
| 135 | cpu_name++; |
| 136 | |
| 137 | microcode_ver.lo = 0; |
| 138 | microcode_ver.hi = 0; |
| 139 | wrmsr(0x8B, microcode_ver); |
| 140 | cpuidr = cpuid(1); |
| 141 | microcode_ver = rdmsr(0x8b); |
| 142 | |
| 143 | /* Look for string to match the name */ |
| 144 | for (i = 0; i < ARRAY_SIZE(cpu_table); i++) { |
| 145 | if (cpu_table[i].cpuid == cpuidr.eax) { |
| 146 | cpu_type = cpu_table[i].name; |
| 147 | break; |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | printk(BIOS_DEBUG, "CPU: %s\n", cpu_name); |
| 152 | printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n", |
| 153 | cpuidr.eax, cpu_type, microcode_ver.hi); |
| 154 | |
| 155 | aes = (cpuidr.ecx & (1 << 25)) ? 1 : 0; |
| 156 | txt = (cpuidr.ecx & (1 << 6)) ? 1 : 0; |
| 157 | vt = (cpuidr.ecx & (1 << 5)) ? 1 : 0; |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 158 | printk(BIOS_DEBUG, |
| 159 | "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n", |
| 160 | mode[aes], mode[txt], mode[vt]); |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | static void report_mch_info(void) |
| 164 | { |
| 165 | int i; |
Subrata Banik | df5ae9c | 2017-12-06 19:10:15 +0530 | [diff] [blame] | 166 | device_t dev = SA_DEV_ROOT; |
| 167 | uint16_t mchid = get_dev_id(dev); |
| 168 | uint8_t mch_revision = get_dev_revision(dev); |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 169 | const char *mch_type = "Unknown"; |
| 170 | |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 171 | for (i = 0; i < ARRAY_SIZE(mch_table); i++) { |
| 172 | if (mch_table[i].mchid == mchid) { |
| 173 | mch_type = mch_table[i].name; |
| 174 | break; |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 175 | } |
| 176 | } |
| 177 | |
| 178 | printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n", |
Lee Leahy | 1d14b3e | 2015-05-12 18:23:27 -0700 | [diff] [blame] | 179 | mchid, mch_revision, mch_type); |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | static void report_pch_info(void) |
| 183 | { |
| 184 | int i; |
Subrata Banik | df5ae9c | 2017-12-06 19:10:15 +0530 | [diff] [blame] | 185 | device_t dev = PCH_DEV_LPC; |
| 186 | uint16_t lpcid = get_dev_id(dev); |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 187 | const char *pch_type = "Unknown"; |
| 188 | |
| 189 | for (i = 0; i < ARRAY_SIZE(pch_table); i++) { |
| 190 | if (pch_table[i].lpcid == lpcid) { |
| 191 | pch_type = pch_table[i].name; |
| 192 | break; |
| 193 | } |
| 194 | } |
| 195 | printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n", |
Subrata Banik | df5ae9c | 2017-12-06 19:10:15 +0530 | [diff] [blame] | 196 | lpcid, get_dev_revision(dev), pch_type); |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | static void report_igd_info(void) |
| 200 | { |
| 201 | int i; |
Subrata Banik | df5ae9c | 2017-12-06 19:10:15 +0530 | [diff] [blame] | 202 | device_t dev = SA_DEV_IGD; |
| 203 | uint16_t igdid = get_dev_id(dev); |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 204 | const char *igd_type = "Unknown"; |
| 205 | |
| 206 | for (i = 0; i < ARRAY_SIZE(igd_table); i++) { |
| 207 | if (igd_table[i].igdid == igdid) { |
| 208 | igd_type = igd_table[i].name; |
| 209 | break; |
| 210 | } |
| 211 | } |
| 212 | printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n", |
Subrata Banik | df5ae9c | 2017-12-06 19:10:15 +0530 | [diff] [blame] | 213 | igdid, get_dev_revision(dev), igd_type); |
Lee Leahy | b000513 | 2015-05-12 18:19:47 -0700 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | void report_platform_info(void) |
| 217 | { |
| 218 | report_cpu_info(); |
| 219 | report_mch_info(); |
| 220 | report_pch_info(); |
| 221 | report_igd_info(); |
| 222 | } |
| 223 | |
| 224 | /* |
| 225 | * Dump in the log memory controller configuration as read from the memory |
| 226 | * controller registers. |
| 227 | */ |
| 228 | void report_memory_config(void) |
| 229 | { |
| 230 | u32 addr_decoder_common, addr_decode_ch[2]; |
| 231 | int i; |
| 232 | |
| 233 | addr_decoder_common = MCHBAR32(0x5000); |
| 234 | addr_decode_ch[0] = MCHBAR32(0x5004); |
| 235 | addr_decode_ch[1] = MCHBAR32(0x5008); |
| 236 | |
| 237 | printk(BIOS_DEBUG, "memcfg DDR3 clock %d MHz\n", |
| 238 | (MCHBAR32(0x5e04) * 13333 * 2 + 50)/100); |
| 239 | printk(BIOS_DEBUG, "memcfg channel assignment: A: %d, B % d, C % d\n", |
| 240 | addr_decoder_common & 3, |
| 241 | (addr_decoder_common >> 2) & 3, |
| 242 | (addr_decoder_common >> 4) & 3); |
| 243 | |
| 244 | for (i = 0; i < ARRAY_SIZE(addr_decode_ch); i++) { |
| 245 | u32 ch_conf = addr_decode_ch[i]; |
| 246 | printk(BIOS_DEBUG, "memcfg channel[%d] config (%8.8x):\n", |
| 247 | i, ch_conf); |
| 248 | printk(BIOS_DEBUG, " enhanced interleave mode %s\n", |
| 249 | ((ch_conf >> 22) & 1) ? "on" : "off"); |
| 250 | printk(BIOS_DEBUG, " rank interleave %s\n", |
| 251 | ((ch_conf >> 21) & 1) ? "on" : "off"); |
| 252 | printk(BIOS_DEBUG, " DIMMA %d MB width %s %s rank%s\n", |
| 253 | ((ch_conf >> 0) & 0xff) * 256, |
| 254 | ((ch_conf >> 19) & 1) ? "x16" : "x8 or x32", |
| 255 | ((ch_conf >> 17) & 1) ? "dual" : "single", |
| 256 | ((ch_conf >> 16) & 1) ? "" : ", selected"); |
| 257 | printk(BIOS_DEBUG, " DIMMB %d MB width %s %s rank%s\n", |
| 258 | ((ch_conf >> 8) & 0xff) * 256, |
| 259 | ((ch_conf >> 19) & 1) ? "x16" : "x8 or x32", |
| 260 | ((ch_conf >> 18) & 1) ? "dual" : "single", |
| 261 | ((ch_conf >> 16) & 1) ? ", selected" : ""); |
| 262 | } |
| 263 | } |