blob: a053c7079cfa0b56209712e474b78d5de72431a7 [file] [log] [blame]
Subrata Banikb3ced6a2020-08-04 13:34:03 +05301/* 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 Banik55f54102021-07-23 21:04:41 +053011#include <commonlib/helpers.h>
Subrata Banikb3ced6a2020-08-04 13:34:03 +053012#include <console/console.h>
Subrata Banik87685c52021-07-15 16:31:30 +053013#include <cpu/intel/cpu_ids.h>
Subrata Banikb3ced6a2020-08-04 13:34:03 +053014#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 Banikb3ced6a2020-08-04 13:34:03 +053019#include <soc/bootblock.h>
Subrata Banikb3ced6a2020-08-04 13:34:03 +053020#include <soc/pci_devs.h>
Subrata Banikb3ced6a2020-08-04 13:34:03 +053021
22static struct {
23 u32 cpuid;
24 const char *name;
25} cpu_table[] = {
Sridhar Siricillaf93aa042021-06-07 21:28:00 +053026 { CPUID_ALDERLAKE_A0, "Alderlake Platform" },
27 { CPUID_ALDERLAKE_A1, "Alderlake Platform" },
28 { CPUID_ALDERLAKE_A2, "Alderlake Platform" },
Subrata Banikb3ced6a2020-08-04 13:34:03 +053029};
30
31static struct {
32 u16 mchid;
33 const char *name;
34} mch_table[] = {
35 { PCI_DEVICE_ID_INTEL_ADL_P_ID_1, "Alderlake-P" },
Subrata Banikb3ced6a2020-08-04 13:34:03 +053036 { PCI_DEVICE_ID_INTEL_ADL_P_ID_3, "Alderlake-P" },
37 { PCI_DEVICE_ID_INTEL_ADL_P_ID_4, "Alderlake-P" },
38 { PCI_DEVICE_ID_INTEL_ADL_P_ID_5, "Alderlake-P" },
39 { PCI_DEVICE_ID_INTEL_ADL_P_ID_6, "Alderlake-P" },
40 { PCI_DEVICE_ID_INTEL_ADL_P_ID_7, "Alderlake-P" },
41 { PCI_DEVICE_ID_INTEL_ADL_P_ID_8, "Alderlake-P" },
42 { PCI_DEVICE_ID_INTEL_ADL_P_ID_9, "Alderlake-P" },
Sumeet R Pawnikardd4861a2021-05-19 15:59:55 +053043 { PCI_DEVICE_ID_INTEL_ADL_M_ID_1, "Alderlake-M" },
Sumeet Pawnikar38882922021-07-29 22:09:14 +053044 { PCI_DEVICE_ID_INTEL_ADL_M_ID_2, "Alderlake-M" },
Subrata Banikb3ced6a2020-08-04 13:34:03 +053045};
46
47static struct {
48 u16 espiid;
49 const char *name;
50} pch_table[] = {
51 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_0, "Alderlake-P SKU" },
52 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_1, "Alderlake-P SKU" },
53 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_2, "Alderlake-P SKU" },
54 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_3, "Alderlake-P SKU" },
55 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_4, "Alderlake-P SKU" },
56 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_5, "Alderlake-P SKU" },
57 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_6, "Alderlake-P SKU" },
58 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_7, "Alderlake-P SKU" },
59 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_8, "Alderlake-P SKU" },
60 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_9, "Alderlake-P SKU" },
61 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_10, "Alderlake-P SKU" },
62 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_11, "Alderlake-P SKU" },
63 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_12, "Alderlake-P SKU" },
64 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_13, "Alderlake-P SKU" },
65 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_14, "Alderlake-P SKU" },
66 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_15, "Alderlake-P SKU" },
67 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_16, "Alderlake-P SKU" },
68 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_17, "Alderlake-P SKU" },
69 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_18, "Alderlake-P SKU" },
70 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_19, "Alderlake-P SKU" },
71 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_20, "Alderlake-P SKU" },
72 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_21, "Alderlake-P SKU" },
73 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_22, "Alderlake-P SKU" },
74 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_23, "Alderlake-P SKU" },
75 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_24, "Alderlake-P SKU" },
76 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_25, "Alderlake-P SKU" },
77 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_26, "Alderlake-P SKU" },
78 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_27, "Alderlake-P SKU" },
79 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_28, "Alderlake-P SKU" },
80 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_29, "Alderlake-P SKU" },
81 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_30, "Alderlake-P SKU" },
82 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_31, "Alderlake-P SKU" },
Subrata Banik4e8a9c72020-11-11 23:07:18 +053083 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_32, "Alderlake-P SKU" },
Subrata Banika19001b2021-01-11 15:04:11 +053084 { PCI_DEVICE_ID_INTEL_ADP_P_ESPI_33, "Alderlake-P SKU" },
Maulik V Vaghelaafb143d2021-01-29 22:42:08 +053085 { PCI_DEVICE_ID_INTEL_ADP_M_ESPI_32, "Alderlake-M SKU" },
Subrata Banikb3ced6a2020-08-04 13:34:03 +053086};
87
88static struct {
89 u16 igdid;
90 const char *name;
91} igd_table[] = {
92 { PCI_DEVICE_ID_INTEL_ADL_GT0, "Alderlake GT0" },
93 { PCI_DEVICE_ID_INTEL_ADL_GT1, "Alderlake GT1" },
94 { PCI_DEVICE_ID_INTEL_ADL_GT1_1, "Alderlake GT1" },
95 { PCI_DEVICE_ID_INTEL_ADL_GT1_2, "Alderlake GT1" },
96 { PCI_DEVICE_ID_INTEL_ADL_GT1_3, "Alderlake GT1" },
97 { PCI_DEVICE_ID_INTEL_ADL_GT1_4, "Alderlake GT1" },
98 { PCI_DEVICE_ID_INTEL_ADL_GT1_5, "Alderlake GT1" },
99 { PCI_DEVICE_ID_INTEL_ADL_GT1_6, "Alderlake GT1" },
100 { PCI_DEVICE_ID_INTEL_ADL_GT1_7, "Alderlake GT1" },
101 { PCI_DEVICE_ID_INTEL_ADL_GT1_8, "Alderlake GT1" },
102 { PCI_DEVICE_ID_INTEL_ADL_GT1_9, "Alderlake GT1" },
103 { PCI_DEVICE_ID_INTEL_ADL_P_GT2, "Alderlake P GT2" },
Maulik V Vaghela351f1e62021-05-13 11:34:14 +0530104 { PCI_DEVICE_ID_INTEL_ADL_P_GT2_1, "Alderlake P GT2" },
Sumeet R Pawnikardd4861a2021-05-19 15:59:55 +0530105 { PCI_DEVICE_ID_INTEL_ADL_P_GT2_2, "Alderlake P GT2" },
106 { PCI_DEVICE_ID_INTEL_ADL_P_GT2_3, "Alderlake P GT2" },
Sridhar Siricilla3102fd02021-06-07 23:38:17 +0530107 { PCI_DEVICE_ID_INTEL_ADL_P_GT2_4, "Alderlake P GT2" },
Meera Ravindranath8b60afe2021-06-18 11:02:45 +0530108 { PCI_DEVICE_ID_INTEL_ADL_P_GT2_5, "Alderlake P GT2" },
Maulik V Vaghelab3d24d32021-07-02 14:42:03 +0530109 { PCI_DEVICE_ID_INTEL_ADL_P_GT2_6, "Alderlake P GT2" },
Maulik V Vaghelaafb143d2021-01-29 22:42:08 +0530110 { PCI_DEVICE_ID_INTEL_ADL_M_GT1, "Alderlake M GT1" },
Bora Guvendik31988482021-07-23 14:12:57 -0700111 { PCI_DEVICE_ID_INTEL_ADL_M_GT2, "Alderlake M GT2" },
Selma Bensaid326a2c42021-09-23 18:45:14 -0700112 { PCI_DEVICE_ID_INTEL_ADL_M_GT3, "Alderlake M GT3" },
Subrata Banikb3ced6a2020-08-04 13:34:03 +0530113};
114
115static inline uint8_t get_dev_revision(pci_devfn_t dev)
116{
117 return pci_read_config8(dev, PCI_REVISION_ID);
118}
119
120static inline uint16_t get_dev_id(pci_devfn_t dev)
121{
122 return pci_read_config16(dev, PCI_DEVICE_ID);
123}
124
Subrata Banik55f54102021-07-23 21:04:41 +0530125static void report_cache_info(void)
126{
127 int cache_level = CACHE_L3;
128 struct cpu_cache_info info;
129
130 if (!fill_cpu_cache_info(cache_level, &info))
131 return;
132
133 printk(BIOS_INFO, "Cache: Level %d: ", cache_level);
134 printk(BIOS_INFO, "Associativity = %zd Partitions = %zd Line Size = %zd Sets = %zd\n",
135 info.num_ways, info.physical_partitions, info.line_size, info.num_sets);
136
137 printk(BIOS_INFO, "Cache size = %ld MiB\n", get_cache_size(&info)/MiB);
138}
139
Subrata Banikb3ced6a2020-08-04 13:34:03 +0530140static void report_cpu_info(void)
141{
142 u32 i, cpu_id, cpu_feature_flag;
143 char cpu_name[49];
144 int vt, txt, aes;
145 static const char *const mode[] = {"NOT ", ""};
146 const char *cpu_type = "Unknown";
147
148 fill_processor_name(cpu_name);
149 cpu_id = cpu_get_cpuid();
150
151 /* Look for string to match the name */
152 for (i = 0; i < ARRAY_SIZE(cpu_table); i++) {
153 if (cpu_table[i].cpuid == cpu_id) {
154 cpu_type = cpu_table[i].name;
155 break;
156 }
157 }
158
159 printk(BIOS_DEBUG, "CPU: %s\n", cpu_name);
160 printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n",
161 cpu_id, cpu_type, get_current_microcode_rev());
162
163 cpu_feature_flag = cpu_get_feature_flags_ecx();
164 aes = !!(cpu_feature_flag & CPUID_AES);
165 txt = !!(cpu_feature_flag & CPUID_SMX);
166 vt = !!(cpu_feature_flag & CPUID_VMX);
167 printk(BIOS_DEBUG,
168 "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n",
169 mode[aes], mode[txt], mode[vt]);
Subrata Banik55f54102021-07-23 21:04:41 +0530170
171 report_cache_info();
Subrata Banikb3ced6a2020-08-04 13:34:03 +0530172}
173
174static void report_mch_info(void)
175{
176 int i;
177 uint16_t mchid = get_dev_id(SA_DEV_ROOT);
178 const char *mch_type = "Unknown";
179
180 for (i = 0; i < ARRAY_SIZE(mch_table); i++) {
181 if (mch_table[i].mchid == mchid) {
182 mch_type = mch_table[i].name;
183 break;
184 }
185 }
186
187 printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n",
188 mchid, get_dev_revision(SA_DEV_ROOT), mch_type);
189}
190
191static void report_pch_info(void)
192{
193 int i;
194 pci_devfn_t dev = PCH_DEV_ESPI;
195 uint16_t espiid = get_dev_id(dev);
196 const char *pch_type = "Unknown";
197
198 for (i = 0; i < ARRAY_SIZE(pch_table); i++) {
199 if (pch_table[i].espiid == espiid) {
200 pch_type = pch_table[i].name;
201 break;
202 }
203 }
204 printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n",
205 espiid, get_dev_revision(dev), pch_type);
206}
207
208static void report_igd_info(void)
209{
210 int i;
211 pci_devfn_t dev = SA_DEV_IGD;
212 uint16_t igdid = get_dev_id(dev);
213 const char *igd_type = "Unknown";
214
215 for (i = 0; i < ARRAY_SIZE(igd_table); i++) {
216 if (igd_table[i].igdid == igdid) {
217 igd_type = igd_table[i].name;
218 break;
219 }
220 }
221 printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n",
222 igdid, get_dev_revision(dev), igd_type);
223}
224
225void report_platform_info(void)
226{
227 report_cpu_info();
228 report_mch_info();
229 report_pch_info();
230 report_igd_info();
231}