Subrata Banik | 930c31c | 2019-11-01 18:12:58 +0530 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2019 Intel Corp. |
| 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. |
| 14 | */ |
| 15 | |
| 16 | /* |
| 17 | * This file is created based on Intel Tiger Lake Platform Stepping and IDs |
| 18 | * Document number: 605534 |
| 19 | * Chapter number: 2, 4, 5, 6 |
| 20 | */ |
| 21 | |
| 22 | #include <arch/cpu.h> |
| 23 | #include <device/pci_ops.h> |
| 24 | #include <console/console.h> |
| 25 | #include <cpu/x86/msr.h> |
| 26 | #include <device/pci.h> |
| 27 | #include <device/pci_ids.h> |
| 28 | #include <intelblocks/mp_init.h> |
| 29 | #include <soc/bootblock.h> |
| 30 | #include <soc/pch.h> |
| 31 | #include <soc/pci_devs.h> |
| 32 | #include <string.h> |
| 33 | |
| 34 | #define BIOS_SIGN_ID 0x8B |
| 35 | |
Subrata Banik | ae69575 | 2019-11-12 12:47:43 +0530 | [diff] [blame] | 36 | static struct { |
| 37 | u32 cpuid; |
| 38 | const char *name; |
| 39 | } cpu_table[] = { |
| 40 | { CPUID_TIGERLAKE_A0, "Tigerlake A0" }, |
| 41 | }; |
| 42 | |
| 43 | static struct { |
| 44 | u16 mchid; |
| 45 | const char *name; |
| 46 | } mch_table[] = { |
| 47 | { PCI_DEVICE_ID_INTEL_TGL_ID_U, "Tigerlake-U-4-2" }, |
| 48 | { PCI_DEVICE_ID_INTEL_TGL_ID_U_1, "Tigerlake-U-4-3e" }, |
Srinidhi N Kaushik | 1d812e8 | 2020-02-07 15:51:09 -0800 | [diff] [blame^] | 49 | { PCI_DEVICE_ID_INTEL_TGL_ID_U_2_2, "Tigerlake-U-2-2" }, |
Subrata Banik | ae69575 | 2019-11-12 12:47:43 +0530 | [diff] [blame] | 50 | { PCI_DEVICE_ID_INTEL_TGL_ID_Y, "Tigerlake-Y-4-2" }, |
rkanabar | 263f129 | 2019-11-28 10:41:45 +0530 | [diff] [blame] | 51 | { PCI_DEVICE_ID_INTEL_JSL_PRE_PROD, "Jasperlake Pre Prod" }, |
Tan, Lean Sheng | 2613609 | 2020-01-20 19:13:56 -0800 | [diff] [blame] | 52 | { PCI_DEVICE_ID_INTEL_JSL_EHL, "Jasperlake Elkhartlake" }, |
| 53 | { PCI_DEVICE_ID_INTEL_EHL_ID_1, "Elkhartlake-1" }, |
Subrata Banik | ae69575 | 2019-11-12 12:47:43 +0530 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | static struct { |
| 57 | u16 espiid; |
| 58 | const char *name; |
| 59 | } pch_table[] = { |
| 60 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_0, "Tigerlake-Base SKU" }, |
| 61 | { PCI_DEVICE_ID_INTEL_TGP_SUPER_U_ESPI, "Tigerlake-U Super SKU" }, |
| 62 | { PCI_DEVICE_ID_INTEL_TGP_PREMIUM_U_ESPI, "Tigerlake-U Premium SKU" }, |
| 63 | { PCI_DEVICE_ID_INTEL_TGP_BASE_U_ESPI, "Tigerlake-U Base SKU" }, |
| 64 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_1, "Tigerlake-Base SKU" }, |
| 65 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_2, "Tigerlake-Base SKU" }, |
| 66 | { PCI_DEVICE_ID_INTEL_TGP_SUPER_Y_ESPI, "Tigerlake-Y Super SKU" }, |
| 67 | { PCI_DEVICE_ID_INTEL_TGP_PREMIUM_Y_ESPI, "Tigerlake-Y Premium SKU" }, |
| 68 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_3, "Tigerlake-Base SKU" }, |
| 69 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_4, "Tigerlake-Base SKU" }, |
| 70 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_5, "Tigerlake-Base SKU" }, |
| 71 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_6, "Tigerlake-Base SKU" }, |
| 72 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_7, "Tigerlake-Base SKU" }, |
| 73 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_8, "Tigerlake-Base SKU" }, |
| 74 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_9, "Tigerlake-Base SKU" }, |
| 75 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_10, "Tigerlake-Base SKU" }, |
| 76 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_11, "Tigerlake-Base SKU" }, |
| 77 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_12, "Tigerlake-Base SKU" }, |
| 78 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_13, "Tigerlake-Base SKU" }, |
| 79 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_14, "Tigerlake-Base SKU" }, |
| 80 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_15, "Tigerlake-Base SKU" }, |
| 81 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_16, "Tigerlake-Base SKU" }, |
| 82 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_17, "Tigerlake-Base SKU" }, |
| 83 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_18, "Tigerlake-Base SKU" }, |
| 84 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_19, "Tigerlake-Base SKU" }, |
| 85 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_20, "Tigerlake-Base SKU" }, |
| 86 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_21, "Tigerlake-Base SKU" }, |
| 87 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_22, "Tigerlake-Base SKU" }, |
| 88 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_23, "Tigerlake-Base SKU" }, |
| 89 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_24, "Tigerlake-Base SKU" }, |
| 90 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_25, "Tigerlake-Base SKU" }, |
| 91 | { PCI_DEVICE_ID_INTEL_TGP_ESPI_26, "Tigerlake-Base SKU" }, |
rkanabar | 263f129 | 2019-11-28 10:41:45 +0530 | [diff] [blame] | 92 | { PCI_DEVICE_ID_INTEL_JSP_PRE_PROD_ESPI_1, "Jasperlake Pre Prod" }, |
| 93 | { PCI_DEVICE_ID_INTEL_JSP_PRE_PROD_ESPI_2, "Jasperlake Pre Prod" }, |
Tan, Lean Sheng | 2613609 | 2020-01-20 19:13:56 -0800 | [diff] [blame] | 94 | { PCI_DEVICE_ID_INTEL_MCC_ESPI_0, "Elkhartlake-0" }, |
| 95 | { PCI_DEVICE_ID_INTEL_MCC_ESPI_1, "Elkhartlake-1" }, |
| 96 | { PCI_DEVICE_ID_INTEL_MCC_BASE_ESPI, "Elkhartlake Base" }, |
| 97 | { PCI_DEVICE_ID_INTEL_MCC_PREMIUM_ESPI, "Elkhartlake Premium" }, |
| 98 | { PCI_DEVICE_ID_INTEL_MCC_SUPER_ESPI, "Elkhartlake Super" }, |
Subrata Banik | ae69575 | 2019-11-12 12:47:43 +0530 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | static struct { |
| 102 | u16 igdid; |
| 103 | const char *name; |
| 104 | } igd_table[] = { |
| 105 | { PCI_DEVICE_ID_INTEL_TGL_GT0, "Tigerlake U GT0" }, |
| 106 | { PCI_DEVICE_ID_INTEL_TGL_GT2_ULT, "Tigerlake U GT2" }, |
| 107 | { PCI_DEVICE_ID_INTEL_TGL_GT2_ULX, "Tigerlake Y GT2" }, |
| 108 | { PCI_DEVICE_ID_INTEL_TGL_GT3_ULT, "Tigerlake U GT3" }, |
rkanabar | 263f129 | 2019-11-28 10:41:45 +0530 | [diff] [blame] | 109 | { PCI_DEVICE_ID_INTEL_JSL_PRE_PROD_GT0, "Jasperlake Pre Prod GT0" }, |
Tan, Lean Sheng | 2613609 | 2020-01-20 19:13:56 -0800 | [diff] [blame] | 110 | { PCI_DEVICE_ID_INTEL_EHL_GT1_1, "Elkhartlake GT1 1" }, |
| 111 | { PCI_DEVICE_ID_INTEL_EHL_GT2_1, "Elkhartlake GT2 1" }, |
| 112 | { PCI_DEVICE_ID_INTEL_EHL_GT1_2, "Elkhartlake GT1 2" }, |
| 113 | { PCI_DEVICE_ID_INTEL_EHL_GT2_2, "Elkhartlake GT2 2" }, |
| 114 | { PCI_DEVICE_ID_INTEL_EHL_GT1_3, "Elkhartlake GT1 3" }, |
| 115 | { PCI_DEVICE_ID_INTEL_EHL_GT2_3, "Elkhartlake GT2 3" }, |
Subrata Banik | ae69575 | 2019-11-12 12:47:43 +0530 | [diff] [blame] | 116 | }; |
Subrata Banik | 930c31c | 2019-11-01 18:12:58 +0530 | [diff] [blame] | 117 | |
| 118 | static inline uint8_t get_dev_revision(pci_devfn_t dev) |
| 119 | { |
| 120 | return pci_read_config8(dev, PCI_REVISION_ID); |
| 121 | } |
| 122 | |
| 123 | static inline uint16_t get_dev_id(pci_devfn_t dev) |
| 124 | { |
| 125 | return pci_read_config16(dev, PCI_DEVICE_ID); |
| 126 | } |
| 127 | |
| 128 | static void report_cpu_info(void) |
| 129 | { |
| 130 | struct cpuid_result cpuidr; |
| 131 | u32 i, index, cpu_id, cpu_feature_flag; |
| 132 | const char cpu_not_found[] = "Platform info not available"; |
| 133 | const char *cpu_name = cpu_not_found; /* 48 bytes are reported */ |
| 134 | int vt, txt, aes; |
| 135 | msr_t microcode_ver; |
| 136 | static const char *const mode[] = {"NOT ", ""}; |
| 137 | const char *cpu_type = "Unknown"; |
| 138 | u32 p[13]; |
| 139 | |
| 140 | index = 0x80000000; |
| 141 | cpuidr = cpuid(index); |
| 142 | if (cpuidr.eax >= 0x80000004) { |
| 143 | int j = 0; |
| 144 | |
| 145 | for (i = 2; i <= 4; i++) { |
| 146 | cpuidr = cpuid(index + i); |
| 147 | p[j++] = cpuidr.eax; |
| 148 | p[j++] = cpuidr.ebx; |
| 149 | p[j++] = cpuidr.ecx; |
| 150 | p[j++] = cpuidr.edx; |
| 151 | } |
| 152 | p[12] = 0; |
| 153 | cpu_name = (char *)p; |
| 154 | |
| 155 | /* Skip leading spaces in CPU name string */ |
| 156 | while (cpu_name[0] == ' ' && strlen(cpu_name) > 0) |
| 157 | cpu_name++; |
| 158 | } |
| 159 | |
| 160 | microcode_ver.lo = 0; |
| 161 | microcode_ver.hi = 0; |
| 162 | wrmsr(BIOS_SIGN_ID, microcode_ver); |
| 163 | cpu_id = cpu_get_cpuid(); |
| 164 | microcode_ver = rdmsr(BIOS_SIGN_ID); |
| 165 | |
| 166 | /* Look for string to match the name */ |
| 167 | for (i = 0; i < ARRAY_SIZE(cpu_table); i++) { |
| 168 | if (cpu_table[i].cpuid == cpu_id) { |
| 169 | cpu_type = cpu_table[i].name; |
| 170 | break; |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | printk(BIOS_DEBUG, "CPU: %s\n", cpu_name); |
| 175 | printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n", |
| 176 | cpu_id, cpu_type, microcode_ver.hi); |
| 177 | |
| 178 | cpu_feature_flag = cpu_get_feature_flags_ecx(); |
| 179 | aes = (cpu_feature_flag & CPUID_AES) ? 1 : 0; |
| 180 | txt = (cpu_feature_flag & CPUID_SMX) ? 1 : 0; |
| 181 | vt = (cpu_feature_flag & CPUID_VMX) ? 1 : 0; |
| 182 | printk(BIOS_DEBUG, |
| 183 | "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n", |
| 184 | mode[aes], mode[txt], mode[vt]); |
| 185 | } |
| 186 | |
| 187 | static void report_mch_info(void) |
| 188 | { |
| 189 | int i; |
| 190 | pci_devfn_t dev = SA_DEV_ROOT; |
| 191 | uint16_t mchid = get_dev_id(dev); |
| 192 | uint8_t mch_revision = get_dev_revision(dev); |
| 193 | const char *mch_type = "Unknown"; |
| 194 | |
| 195 | for (i = 0; i < ARRAY_SIZE(mch_table); i++) { |
| 196 | if (mch_table[i].mchid == mchid) { |
| 197 | mch_type = mch_table[i].name; |
| 198 | break; |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n", |
| 203 | mchid, mch_revision, mch_type); |
| 204 | } |
| 205 | |
| 206 | static void report_pch_info(void) |
| 207 | { |
| 208 | int i; |
| 209 | pci_devfn_t dev = PCH_DEV_ESPI; |
| 210 | uint16_t espiid = get_dev_id(dev); |
| 211 | const char *pch_type = "Unknown"; |
| 212 | |
| 213 | for (i = 0; i < ARRAY_SIZE(pch_table); i++) { |
| 214 | if (pch_table[i].espiid == espiid) { |
| 215 | pch_type = pch_table[i].name; |
| 216 | break; |
| 217 | } |
| 218 | } |
| 219 | printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n", |
| 220 | espiid, get_dev_revision(dev), pch_type); |
| 221 | } |
| 222 | |
| 223 | static void report_igd_info(void) |
| 224 | { |
| 225 | int i; |
| 226 | pci_devfn_t dev = SA_DEV_IGD; |
| 227 | uint16_t igdid = get_dev_id(dev); |
| 228 | const char *igd_type = "Unknown"; |
| 229 | |
| 230 | for (i = 0; i < ARRAY_SIZE(igd_table); i++) { |
| 231 | if (igd_table[i].igdid == igdid) { |
| 232 | igd_type = igd_table[i].name; |
| 233 | break; |
| 234 | } |
| 235 | } |
| 236 | printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n", |
| 237 | igdid, get_dev_revision(dev), igd_type); |
| 238 | } |
| 239 | |
| 240 | void report_platform_info(void) |
| 241 | { |
| 242 | report_cpu_info(); |
| 243 | report_mch_info(); |
| 244 | report_pch_info(); |
| 245 | report_igd_info(); |
| 246 | } |