Angel Pons | 32abdd6 | 2020-04-05 15:47:03 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 2 | |
| 3 | #include <arch/cpu.h> |
Kyösti Mälkki | f1b58b7 | 2019-03-01 13:43:02 +0200 | [diff] [blame] | 4 | #include <device/pci_ops.h> |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 5 | #include <console/console.h> |
Subrata Banik | 8993e67 | 2021-07-16 13:17:44 +0530 | [diff] [blame^] | 6 | #include <cpu/intel/cpu_ids.h> |
Subrata Banik | b7db12b | 2020-08-04 18:01:27 +0530 | [diff] [blame] | 7 | #include <cpu/intel/microcode.h> |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 8 | #include <cpu/x86/msr.h> |
| 9 | #include <device/pci.h> |
| 10 | #include <device/pci_ids.h> |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 11 | #include <soc/bootblock.h> |
| 12 | #include <soc/pch.h> |
| 13 | #include <soc/pci_devs.h> |
| 14 | #include <string.h> |
| 15 | |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 16 | static struct { |
| 17 | u32 cpuid; |
| 18 | const char *name; |
| 19 | } cpu_table[] = { |
Aamir Bohra | 9eac039 | 2018-06-30 12:07:04 +0530 | [diff] [blame] | 20 | { CPUID_ICELAKE_A0, "Icelake A0" }, |
| 21 | { CPUID_ICELAKE_B0, "Icelake B0" }, |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 22 | }; |
| 23 | |
| 24 | static struct { |
| 25 | u16 mchid; |
| 26 | const char *name; |
| 27 | } mch_table[] = { |
Aamir Bohra | 9eac039 | 2018-06-30 12:07:04 +0530 | [diff] [blame] | 28 | { PCI_DEVICE_ID_INTEL_ICL_ID_U, "Icelake-U" }, |
| 29 | { PCI_DEVICE_ID_INTEL_ICL_ID_U_2_2, "Icelake-U-2-2" }, |
| 30 | { PCI_DEVICE_ID_INTEL_ICL_ID_Y, "Icelake-Y" }, |
| 31 | { PCI_DEVICE_ID_INTEL_ICL_ID_Y_2, "Icelake-Y-2" }, |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | static struct { |
Subrata Banik | 3d152ac | 2018-10-31 23:08:14 +0530 | [diff] [blame] | 35 | u16 espiid; |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 36 | const char *name; |
| 37 | } pch_table[] = { |
Subrata Banik | 3d152ac | 2018-10-31 23:08:14 +0530 | [diff] [blame] | 38 | { PCI_DEVICE_ID_INTEL_ICL_BASE_U_ESPI, "Icelake-U Base" }, |
| 39 | { PCI_DEVICE_ID_INTEL_ICL_BASE_Y_ESPI, "Icelake-Y Base" }, |
| 40 | { PCI_DEVICE_ID_INTEL_ICL_U_PREMIUM_ESPI, "Icelake-U Premium" }, |
| 41 | { PCI_DEVICE_ID_INTEL_ICL_U_SUPER_U_ESPI, "Icelake-U Super" }, |
| 42 | { PCI_DEVICE_ID_INTEL_ICL_U_SUPER_U_ESPI_REV0, "Icelake-U Super REV0" }, |
| 43 | { PCI_DEVICE_ID_INTEL_ICL_SUPER_Y_ESPI, "Icelake-Y Super" }, |
| 44 | { PCI_DEVICE_ID_INTEL_ICL_Y_PREMIUM_ESPI, "Icelake-Y Premium" }, |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | static struct { |
| 48 | u16 igdid; |
| 49 | const char *name; |
| 50 | } igd_table[] = { |
Aamir Bohra | 9eac039 | 2018-06-30 12:07:04 +0530 | [diff] [blame] | 51 | { PCI_DEVICE_ID_INTEL_ICL_GT0_ULT, "Icelake ULT GT0" }, |
| 52 | { PCI_DEVICE_ID_INTEL_ICL_GT0_5_ULT, "Icelake ULT GT0.5" }, |
| 53 | { PCI_DEVICE_ID_INTEL_ICL_GT1_ULT, "Icelake U GT1" }, |
| 54 | { PCI_DEVICE_ID_INTEL_ICL_GT2_ULX_0, "Icelake Y GT2" }, |
| 55 | { PCI_DEVICE_ID_INTEL_ICL_GT2_ULX_1, "Icelake Y GT2_1" }, |
| 56 | { PCI_DEVICE_ID_INTEL_ICL_GT2_ULT_1, "Icelake U GT2_1" }, |
| 57 | { PCI_DEVICE_ID_INTEL_ICL_GT2_ULX_2, "Icelake Y GT2_2" }, |
| 58 | { PCI_DEVICE_ID_INTEL_ICL_GT2_ULT_2, "Icelake U GT2_2" }, |
| 59 | { PCI_DEVICE_ID_INTEL_ICL_GT2_ULX_3, "Icelake Y GT2_3" }, |
| 60 | { PCI_DEVICE_ID_INTEL_ICL_GT2_ULT_3, "Icelake U GT2_3" }, |
| 61 | { PCI_DEVICE_ID_INTEL_ICL_GT2_ULX_4, "Icelake Y GT2_4" }, |
| 62 | { PCI_DEVICE_ID_INTEL_ICL_GT2_ULT_4, "Icelake U GT2_4" }, |
| 63 | { PCI_DEVICE_ID_INTEL_ICL_GT2_ULX_5, "Icelake Y GT2_5" }, |
| 64 | { PCI_DEVICE_ID_INTEL_ICL_GT2_ULT_5, "Icelake U GT2_5" }, |
| 65 | { PCI_DEVICE_ID_INTEL_ICL_GT3_ULT, "Icelake U GT3" }, |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | static uint8_t get_dev_revision(pci_devfn_t dev) |
| 69 | { |
| 70 | return pci_read_config8(dev, PCI_REVISION_ID); |
| 71 | } |
| 72 | |
| 73 | static uint16_t get_dev_id(pci_devfn_t dev) |
| 74 | { |
| 75 | return pci_read_config16(dev, PCI_DEVICE_ID); |
| 76 | } |
| 77 | |
| 78 | static void report_cpu_info(void) |
| 79 | { |
| 80 | struct cpuid_result cpuidr; |
Subrata Banik | 53b08c3 | 2018-12-10 14:11:35 +0530 | [diff] [blame] | 81 | u32 i, index, cpu_id, cpu_feature_flag; |
Subrata Banik | 522b7c0 | 2019-11-01 13:55:39 +0530 | [diff] [blame] | 82 | const char cpu_not_found[] = "Platform info not available"; |
| 83 | const char *cpu_name = cpu_not_found; /* 48 bytes are reported */ |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 84 | int vt, txt, aes; |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 85 | static const char *const mode[] = {"NOT ", ""}; |
| 86 | const char *cpu_type = "Unknown"; |
| 87 | u32 p[13]; |
| 88 | |
| 89 | index = 0x80000000; |
| 90 | cpuidr = cpuid(index); |
Subrata Banik | 522b7c0 | 2019-11-01 13:55:39 +0530 | [diff] [blame] | 91 | if (cpuidr.eax >= 0x80000004) { |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 92 | int j = 0; |
| 93 | |
| 94 | for (i = 2; i <= 4; i++) { |
| 95 | cpuidr = cpuid(index + i); |
| 96 | p[j++] = cpuidr.eax; |
| 97 | p[j++] = cpuidr.ebx; |
| 98 | p[j++] = cpuidr.ecx; |
| 99 | p[j++] = cpuidr.edx; |
| 100 | } |
| 101 | p[12] = 0; |
| 102 | cpu_name = (char *)p; |
Subrata Banik | 522b7c0 | 2019-11-01 13:55:39 +0530 | [diff] [blame] | 103 | |
| 104 | /* Skip leading spaces in CPU name string */ |
| 105 | while (cpu_name[0] == ' ' && strlen(cpu_name) > 0) |
| 106 | cpu_name++; |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 107 | } |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 108 | |
Subrata Banik | 53b08c3 | 2018-12-10 14:11:35 +0530 | [diff] [blame] | 109 | cpu_id = cpu_get_cpuid(); |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 110 | |
| 111 | /* Look for string to match the name */ |
| 112 | for (i = 0; i < ARRAY_SIZE(cpu_table); i++) { |
Subrata Banik | 53b08c3 | 2018-12-10 14:11:35 +0530 | [diff] [blame] | 113 | if (cpu_table[i].cpuid == cpu_id) { |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 114 | cpu_type = cpu_table[i].name; |
| 115 | break; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | printk(BIOS_DEBUG, "CPU: %s\n", cpu_name); |
| 120 | printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n", |
Subrata Banik | b7db12b | 2020-08-04 18:01:27 +0530 | [diff] [blame] | 121 | cpu_id, cpu_type, get_current_microcode_rev()); |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 122 | |
Subrata Banik | 53b08c3 | 2018-12-10 14:11:35 +0530 | [diff] [blame] | 123 | cpu_feature_flag = cpu_get_feature_flags_ecx(); |
| 124 | aes = (cpu_feature_flag & CPUID_AES) ? 1 : 0; |
| 125 | txt = (cpu_feature_flag & CPUID_SMX) ? 1 : 0; |
| 126 | vt = (cpu_feature_flag & CPUID_VMX) ? 1 : 0; |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 127 | printk(BIOS_DEBUG, |
| 128 | "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n", |
| 129 | mode[aes], mode[txt], mode[vt]); |
| 130 | } |
| 131 | |
| 132 | static void report_mch_info(void) |
| 133 | { |
| 134 | int i; |
| 135 | pci_devfn_t dev = SA_DEV_ROOT; |
| 136 | uint16_t mchid = get_dev_id(dev); |
| 137 | uint8_t mch_revision = get_dev_revision(dev); |
| 138 | const char *mch_type = "Unknown"; |
| 139 | |
| 140 | for (i = 0; i < ARRAY_SIZE(mch_table); i++) { |
| 141 | if (mch_table[i].mchid == mchid) { |
| 142 | mch_type = mch_table[i].name; |
| 143 | break; |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n", |
| 148 | mchid, mch_revision, mch_type); |
| 149 | } |
| 150 | |
| 151 | static void report_pch_info(void) |
| 152 | { |
| 153 | int i; |
Subrata Banik | 3d152ac | 2018-10-31 23:08:14 +0530 | [diff] [blame] | 154 | pci_devfn_t dev = PCH_DEV_ESPI; |
| 155 | uint16_t espiid = get_dev_id(dev); |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 156 | const char *pch_type = "Unknown"; |
| 157 | |
| 158 | for (i = 0; i < ARRAY_SIZE(pch_table); i++) { |
Subrata Banik | 3d152ac | 2018-10-31 23:08:14 +0530 | [diff] [blame] | 159 | if (pch_table[i].espiid == espiid) { |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 160 | pch_type = pch_table[i].name; |
| 161 | break; |
| 162 | } |
| 163 | } |
| 164 | printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n", |
Subrata Banik | 3d152ac | 2018-10-31 23:08:14 +0530 | [diff] [blame] | 165 | espiid, get_dev_revision(dev), pch_type); |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | static void report_igd_info(void) |
| 169 | { |
| 170 | int i; |
| 171 | pci_devfn_t dev = SA_DEV_IGD; |
| 172 | uint16_t igdid = get_dev_id(dev); |
| 173 | const char *igd_type = "Unknown"; |
| 174 | |
| 175 | for (i = 0; i < ARRAY_SIZE(igd_table); i++) { |
| 176 | if (igd_table[i].igdid == igdid) { |
| 177 | igd_type = igd_table[i].name; |
| 178 | break; |
| 179 | } |
| 180 | } |
| 181 | printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n", |
| 182 | igdid, get_dev_revision(dev), igd_type); |
| 183 | } |
| 184 | |
| 185 | void report_platform_info(void) |
| 186 | { |
| 187 | report_cpu_info(); |
| 188 | report_mch_info(); |
| 189 | report_pch_info(); |
| 190 | report_igd_info(); |
| 191 | } |