Subrata Banik | b3ced6a | 2020-08-04 13:34:03 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | /* |
| 4 | * This file is created based on Intel Alder Lake Platform Stepping and IDs |
| 5 | * Document number: 619362, 619501 |
| 6 | * Chapter number: 2, 14 |
| 7 | */ |
| 8 | |
| 9 | #include <arch/cpu.h> |
| 10 | #include <device/pci_ops.h> |
Subrata Banik | 55f5410 | 2021-07-23 21:04:41 +0530 | [diff] [blame] | 11 | #include <commonlib/helpers.h> |
Subrata Banik | b3ced6a | 2020-08-04 13:34:03 +0530 | [diff] [blame] | 12 | #include <console/console.h> |
Subrata Banik | 87685c5 | 2021-07-15 16:31:30 +0530 | [diff] [blame] | 13 | #include <cpu/intel/cpu_ids.h> |
Subrata Banik | b3ced6a | 2020-08-04 13:34:03 +0530 | [diff] [blame] | 14 | #include <cpu/intel/microcode.h> |
| 15 | #include <cpu/x86/msr.h> |
| 16 | #include <cpu/x86/name.h> |
| 17 | #include <device/pci.h> |
| 18 | #include <device/pci_ids.h> |
Subrata Banik | b3ced6a | 2020-08-04 13:34:03 +0530 | [diff] [blame] | 19 | #include <soc/bootblock.h> |
Subrata Banik | b3ced6a | 2020-08-04 13:34:03 +0530 | [diff] [blame] | 20 | #include <soc/pci_devs.h> |
Subrata Banik | b3ced6a | 2020-08-04 13:34:03 +0530 | [diff] [blame] | 21 | |
| 22 | static struct { |
| 23 | u32 cpuid; |
| 24 | const char *name; |
| 25 | } cpu_table[] = { |
Sridhar Siricilla | f93aa04 | 2021-06-07 21:28:00 +0530 | [diff] [blame] | 26 | { CPUID_ALDERLAKE_A0, "Alderlake Platform" }, |
| 27 | { CPUID_ALDERLAKE_A1, "Alderlake Platform" }, |
| 28 | { CPUID_ALDERLAKE_A2, "Alderlake Platform" }, |
Meera Ravindranath | f3c4282 | 2021-09-13 13:35:34 +0530 | [diff] [blame] | 29 | { CPUID_ALDERLAKE_A3, "Alderlake Platform" }, |
Usha P | 5b94cd9 | 2021-11-15 18:40:00 +0530 | [diff] [blame^] | 30 | { CPUID_ALDERLAKE_N_A0, "Alderlake-N Platform" }, |
Subrata Banik | b3ced6a | 2020-08-04 13:34:03 +0530 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | static struct { |
| 34 | u16 mchid; |
| 35 | const char *name; |
| 36 | } mch_table[] = { |
| 37 | { PCI_DEVICE_ID_INTEL_ADL_P_ID_1, "Alderlake-P" }, |
Subrata Banik | b3ced6a | 2020-08-04 13:34:03 +0530 | [diff] [blame] | 38 | { PCI_DEVICE_ID_INTEL_ADL_P_ID_3, "Alderlake-P" }, |
| 39 | { PCI_DEVICE_ID_INTEL_ADL_P_ID_4, "Alderlake-P" }, |
| 40 | { PCI_DEVICE_ID_INTEL_ADL_P_ID_5, "Alderlake-P" }, |
| 41 | { PCI_DEVICE_ID_INTEL_ADL_P_ID_6, "Alderlake-P" }, |
| 42 | { PCI_DEVICE_ID_INTEL_ADL_P_ID_7, "Alderlake-P" }, |
| 43 | { PCI_DEVICE_ID_INTEL_ADL_P_ID_8, "Alderlake-P" }, |
| 44 | { PCI_DEVICE_ID_INTEL_ADL_P_ID_9, "Alderlake-P" }, |
Sumeet R Pawnikar | dd4861a | 2021-05-19 15:59:55 +0530 | [diff] [blame] | 45 | { PCI_DEVICE_ID_INTEL_ADL_M_ID_1, "Alderlake-M" }, |
Sumeet Pawnikar | 3888292 | 2021-07-29 22:09:14 +0530 | [diff] [blame] | 46 | { PCI_DEVICE_ID_INTEL_ADL_M_ID_2, "Alderlake-M" }, |
Usha P | 5b94cd9 | 2021-11-15 18:40:00 +0530 | [diff] [blame^] | 47 | { PCI_DEVICE_ID_INTEL_ADL_N_ID_1, "Alderlake-N" }, |
| 48 | { PCI_DEVICE_ID_INTEL_ADL_N_ID_2, "Alderlake-N" }, |
Subrata Banik | b3ced6a | 2020-08-04 13:34:03 +0530 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | static struct { |
| 52 | u16 espiid; |
| 53 | const char *name; |
| 54 | } pch_table[] = { |
| 55 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_0, "Alderlake-P SKU" }, |
| 56 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_1, "Alderlake-P SKU" }, |
| 57 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_2, "Alderlake-P SKU" }, |
| 58 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_3, "Alderlake-P SKU" }, |
| 59 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_4, "Alderlake-P SKU" }, |
| 60 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_5, "Alderlake-P SKU" }, |
| 61 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_6, "Alderlake-P SKU" }, |
| 62 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_7, "Alderlake-P SKU" }, |
| 63 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_8, "Alderlake-P SKU" }, |
| 64 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_9, "Alderlake-P SKU" }, |
| 65 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_10, "Alderlake-P SKU" }, |
| 66 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_11, "Alderlake-P SKU" }, |
| 67 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_12, "Alderlake-P SKU" }, |
| 68 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_13, "Alderlake-P SKU" }, |
| 69 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_14, "Alderlake-P SKU" }, |
| 70 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_15, "Alderlake-P SKU" }, |
| 71 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_16, "Alderlake-P SKU" }, |
| 72 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_17, "Alderlake-P SKU" }, |
| 73 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_18, "Alderlake-P SKU" }, |
| 74 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_19, "Alderlake-P SKU" }, |
| 75 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_20, "Alderlake-P SKU" }, |
| 76 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_21, "Alderlake-P SKU" }, |
| 77 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_22, "Alderlake-P SKU" }, |
| 78 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_23, "Alderlake-P SKU" }, |
| 79 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_24, "Alderlake-P SKU" }, |
| 80 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_25, "Alderlake-P SKU" }, |
| 81 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_26, "Alderlake-P SKU" }, |
| 82 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_27, "Alderlake-P SKU" }, |
| 83 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_28, "Alderlake-P SKU" }, |
| 84 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_29, "Alderlake-P SKU" }, |
| 85 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_30, "Alderlake-P SKU" }, |
| 86 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_31, "Alderlake-P SKU" }, |
Subrata Banik | 4e8a9c7 | 2020-11-11 23:07:18 +0530 | [diff] [blame] | 87 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_32, "Alderlake-P SKU" }, |
Subrata Banik | a19001b | 2021-01-11 15:04:11 +0530 | [diff] [blame] | 88 | { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_33, "Alderlake-P SKU" }, |
Maulik V Vaghela | afb143d | 2021-01-29 22:42:08 +0530 | [diff] [blame] | 89 | { PCI_DEVICE_ID_INTEL_ADP_M_ESPI_32, "Alderlake-M SKU" }, |
Subrata Banik | b3ced6a | 2020-08-04 13:34:03 +0530 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | static struct { |
| 93 | u16 igdid; |
| 94 | const char *name; |
| 95 | } igd_table[] = { |
| 96 | { PCI_DEVICE_ID_INTEL_ADL_GT0, "Alderlake GT0" }, |
| 97 | { PCI_DEVICE_ID_INTEL_ADL_GT1, "Alderlake GT1" }, |
| 98 | { PCI_DEVICE_ID_INTEL_ADL_GT1_1, "Alderlake GT1" }, |
| 99 | { PCI_DEVICE_ID_INTEL_ADL_GT1_2, "Alderlake GT1" }, |
| 100 | { PCI_DEVICE_ID_INTEL_ADL_GT1_3, "Alderlake GT1" }, |
| 101 | { PCI_DEVICE_ID_INTEL_ADL_GT1_4, "Alderlake GT1" }, |
| 102 | { PCI_DEVICE_ID_INTEL_ADL_GT1_5, "Alderlake GT1" }, |
| 103 | { PCI_DEVICE_ID_INTEL_ADL_GT1_6, "Alderlake GT1" }, |
| 104 | { PCI_DEVICE_ID_INTEL_ADL_GT1_7, "Alderlake GT1" }, |
| 105 | { PCI_DEVICE_ID_INTEL_ADL_GT1_8, "Alderlake GT1" }, |
| 106 | { PCI_DEVICE_ID_INTEL_ADL_GT1_9, "Alderlake GT1" }, |
| 107 | { PCI_DEVICE_ID_INTEL_ADL_P_GT2, "Alderlake P GT2" }, |
Maulik V Vaghela | 351f1e6 | 2021-05-13 11:34:14 +0530 | [diff] [blame] | 108 | { PCI_DEVICE_ID_INTEL_ADL_P_GT2_1, "Alderlake P GT2" }, |
Sumeet R Pawnikar | dd4861a | 2021-05-19 15:59:55 +0530 | [diff] [blame] | 109 | { PCI_DEVICE_ID_INTEL_ADL_P_GT2_2, "Alderlake P GT2" }, |
| 110 | { PCI_DEVICE_ID_INTEL_ADL_P_GT2_3, "Alderlake P GT2" }, |
Sridhar Siricilla | 3102fd0 | 2021-06-07 23:38:17 +0530 | [diff] [blame] | 111 | { PCI_DEVICE_ID_INTEL_ADL_P_GT2_4, "Alderlake P GT2" }, |
Meera Ravindranath | 8b60afe | 2021-06-18 11:02:45 +0530 | [diff] [blame] | 112 | { PCI_DEVICE_ID_INTEL_ADL_P_GT2_5, "Alderlake P GT2" }, |
Maulik V Vaghela | b3d24d3 | 2021-07-02 14:42:03 +0530 | [diff] [blame] | 113 | { PCI_DEVICE_ID_INTEL_ADL_P_GT2_6, "Alderlake P GT2" }, |
Maulik V Vaghela | afb143d | 2021-01-29 22:42:08 +0530 | [diff] [blame] | 114 | { PCI_DEVICE_ID_INTEL_ADL_M_GT1, "Alderlake M GT1" }, |
Bora Guvendik | 3198848 | 2021-07-23 14:12:57 -0700 | [diff] [blame] | 115 | { PCI_DEVICE_ID_INTEL_ADL_M_GT2, "Alderlake M GT2" }, |
Selma Bensaid | 326a2c4 | 2021-09-23 18:45:14 -0700 | [diff] [blame] | 116 | { PCI_DEVICE_ID_INTEL_ADL_M_GT3, "Alderlake M GT3" }, |
Usha P | 5b94cd9 | 2021-11-15 18:40:00 +0530 | [diff] [blame^] | 117 | { PCI_DEVICE_ID_INTEL_ADL_N_GT1, "Alderlake N GT1" }, |
| 118 | { PCI_DEVICE_ID_INTEL_ADL_N_GT2, "Alderlake N GT2" }, |
| 119 | { PCI_DEVICE_ID_INTEL_ADL_N_GT3, "Alderlake N GT3" }, |
Subrata Banik | b3ced6a | 2020-08-04 13:34:03 +0530 | [diff] [blame] | 120 | }; |
| 121 | |
| 122 | static inline uint8_t get_dev_revision(pci_devfn_t dev) |
| 123 | { |
| 124 | return pci_read_config8(dev, PCI_REVISION_ID); |
| 125 | } |
| 126 | |
| 127 | static inline uint16_t get_dev_id(pci_devfn_t dev) |
| 128 | { |
| 129 | return pci_read_config16(dev, PCI_DEVICE_ID); |
| 130 | } |
| 131 | |
Subrata Banik | 55f5410 | 2021-07-23 21:04:41 +0530 | [diff] [blame] | 132 | static void report_cache_info(void) |
| 133 | { |
| 134 | int cache_level = CACHE_L3; |
| 135 | struct cpu_cache_info info; |
| 136 | |
| 137 | if (!fill_cpu_cache_info(cache_level, &info)) |
| 138 | return; |
| 139 | |
| 140 | printk(BIOS_INFO, "Cache: Level %d: ", cache_level); |
| 141 | printk(BIOS_INFO, "Associativity = %zd Partitions = %zd Line Size = %zd Sets = %zd\n", |
| 142 | info.num_ways, info.physical_partitions, info.line_size, info.num_sets); |
| 143 | |
| 144 | printk(BIOS_INFO, "Cache size = %ld MiB\n", get_cache_size(&info)/MiB); |
| 145 | } |
| 146 | |
Subrata Banik | b3ced6a | 2020-08-04 13:34:03 +0530 | [diff] [blame] | 147 | static void report_cpu_info(void) |
| 148 | { |
| 149 | u32 i, cpu_id, cpu_feature_flag; |
| 150 | char cpu_name[49]; |
| 151 | int vt, txt, aes; |
| 152 | static const char *const mode[] = {"NOT ", ""}; |
| 153 | const char *cpu_type = "Unknown"; |
| 154 | |
| 155 | fill_processor_name(cpu_name); |
| 156 | cpu_id = cpu_get_cpuid(); |
| 157 | |
| 158 | /* Look for string to match the name */ |
| 159 | for (i = 0; i < ARRAY_SIZE(cpu_table); i++) { |
| 160 | if (cpu_table[i].cpuid == cpu_id) { |
| 161 | cpu_type = cpu_table[i].name; |
| 162 | break; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | printk(BIOS_DEBUG, "CPU: %s\n", cpu_name); |
| 167 | printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n", |
| 168 | cpu_id, cpu_type, get_current_microcode_rev()); |
| 169 | |
| 170 | cpu_feature_flag = cpu_get_feature_flags_ecx(); |
| 171 | aes = !!(cpu_feature_flag & CPUID_AES); |
| 172 | txt = !!(cpu_feature_flag & CPUID_SMX); |
| 173 | vt = !!(cpu_feature_flag & CPUID_VMX); |
| 174 | printk(BIOS_DEBUG, |
| 175 | "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n", |
| 176 | mode[aes], mode[txt], mode[vt]); |
Subrata Banik | 55f5410 | 2021-07-23 21:04:41 +0530 | [diff] [blame] | 177 | |
| 178 | report_cache_info(); |
Subrata Banik | b3ced6a | 2020-08-04 13:34:03 +0530 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | static void report_mch_info(void) |
| 182 | { |
| 183 | int i; |
| 184 | uint16_t mchid = get_dev_id(SA_DEV_ROOT); |
| 185 | const char *mch_type = "Unknown"; |
| 186 | |
| 187 | for (i = 0; i < ARRAY_SIZE(mch_table); i++) { |
| 188 | if (mch_table[i].mchid == mchid) { |
| 189 | mch_type = mch_table[i].name; |
| 190 | break; |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n", |
| 195 | mchid, get_dev_revision(SA_DEV_ROOT), mch_type); |
| 196 | } |
| 197 | |
| 198 | static void report_pch_info(void) |
| 199 | { |
| 200 | int i; |
| 201 | pci_devfn_t dev = PCH_DEV_ESPI; |
| 202 | uint16_t espiid = get_dev_id(dev); |
| 203 | const char *pch_type = "Unknown"; |
| 204 | |
| 205 | for (i = 0; i < ARRAY_SIZE(pch_table); i++) { |
| 206 | if (pch_table[i].espiid == espiid) { |
| 207 | pch_type = pch_table[i].name; |
| 208 | break; |
| 209 | } |
| 210 | } |
| 211 | printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n", |
| 212 | espiid, get_dev_revision(dev), pch_type); |
| 213 | } |
| 214 | |
| 215 | static void report_igd_info(void) |
| 216 | { |
| 217 | int i; |
| 218 | pci_devfn_t dev = SA_DEV_IGD; |
| 219 | uint16_t igdid = get_dev_id(dev); |
| 220 | const char *igd_type = "Unknown"; |
| 221 | |
| 222 | for (i = 0; i < ARRAY_SIZE(igd_table); i++) { |
| 223 | if (igd_table[i].igdid == igdid) { |
| 224 | igd_type = igd_table[i].name; |
| 225 | break; |
| 226 | } |
| 227 | } |
| 228 | printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n", |
| 229 | igdid, get_dev_revision(dev), igd_type); |
| 230 | } |
| 231 | |
| 232 | void report_platform_info(void) |
| 233 | { |
| 234 | report_cpu_info(); |
| 235 | report_mch_info(); |
| 236 | report_pch_info(); |
| 237 | report_igd_info(); |
| 238 | } |