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