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