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