blob: 1dd31975ac52f3ffad465d5fbf54548d5af81b30 [file] [log] [blame]
Tan, Lean Sheng4ce4afa2020-08-25 18:07:16 -07001/* SPDX-License-Identifier: GPL-2.0-only */
2
3#include <arch/cpu.h>
4#include <console/console.h>
5#include <cpu/intel/microcode.h>
6#include <cpu/x86/msr.h>
7#include <cpu/x86/name.h>
8#include <device/pci.h>
9#include <device/pci_ids.h>
10#include <device/pci_ops.h>
11#include <intelblocks/mp_init.h>
12#include <soc/bootblock.h>
13#include <soc/pch.h>
14#include <soc/pci_devs.h>
Tan, Lean Sheng4ce4afa2020-08-25 18:07:16 -070015
Tan, Lean Sheng9440c532020-09-03 06:40:46 -070016static struct {
17 uint32_t cpuid;
18 const char *name;
19} cpu_table[] = {
20 { CPUID_ELKHARTLAKE_A0, "Elkhartlake A0" },
21 { CPUID_ELKHARTLAKE_B0, "Elkhartlake B0" },
22};
23
24static struct {
25 u16 mchid;
26 const char *name;
27} mch_table[] = {
28 { PCI_DEVICE_ID_INTEL_EHL_ID_1, "Elkhartlake SKU-0" },
29 { PCI_DEVICE_ID_INTEL_EHL_ID_2, "Elkhartlake SKU-1" },
30 { PCI_DEVICE_ID_INTEL_EHL_ID_3, "Elkhartlake SKU-2" },
31 { PCI_DEVICE_ID_INTEL_EHL_ID_4, "Elkhartlake SKU-3" },
32 { PCI_DEVICE_ID_INTEL_EHL_ID_5, "Elkhartlake SKU-4" },
33 { PCI_DEVICE_ID_INTEL_EHL_ID_6, "Elkhartlake SKU-5" },
34 { PCI_DEVICE_ID_INTEL_EHL_ID_7, "Elkhartlake SKU-6" },
35 { PCI_DEVICE_ID_INTEL_EHL_ID_8, "Elkhartlake SKU-7" },
36 { PCI_DEVICE_ID_INTEL_EHL_ID_9, "Elkhartlake SKU-8" },
37 { PCI_DEVICE_ID_INTEL_EHL_ID_10, "Elkhartlake SKU-9" },
38 { PCI_DEVICE_ID_INTEL_EHL_ID_11, "Elkhartlake SKU-10" },
39 { PCI_DEVICE_ID_INTEL_JSL_EHL, "Elkhartlake SKU-11" },
40 { PCI_DEVICE_ID_INTEL_EHL_ID_12, "Elkhartlake SKU-12" },
41 { PCI_DEVICE_ID_INTEL_EHL_ID_13, "Elkhartlake SKU-13" },
42};
43
44static struct {
45 u16 espiid;
46 const char *name;
47} pch_table[] = {
48 { PCI_DEVICE_ID_INTEL_MCC_ESPI_0, "Elkhartlake-0" },
49 { PCI_DEVICE_ID_INTEL_MCC_ESPI_1, "Elkhartlake-1" },
50 { PCI_DEVICE_ID_INTEL_MCC_BASE_ESPI, "Elkhartlake Base" },
51 { PCI_DEVICE_ID_INTEL_MCC_PREMIUM_ESPI, "Elkhartlake Premium" },
52 { PCI_DEVICE_ID_INTEL_MCC_SUPER_ESPI, "Elkhartlake Super" },
53};
54
55static struct {
56 u16 igdid;
57 const char *name;
58} igd_table[] = {
59 { PCI_DEVICE_ID_INTEL_EHL_GT1_1, "Elkhartlake GT1-1" },
60 { PCI_DEVICE_ID_INTEL_EHL_GT2_1, "Elkhartlake GT2-1" },
61 { PCI_DEVICE_ID_INTEL_EHL_GT1_2, "Elkhartlake GT1-2" },
62 { PCI_DEVICE_ID_INTEL_EHL_GT2_2, "Elkhartlake GT2-2" },
63 { PCI_DEVICE_ID_INTEL_EHL_GT1_3, "Elkhartlake GT1-3" },
64 { PCI_DEVICE_ID_INTEL_EHL_GT2_3, "Elkhartlake GT2-3" },
65};
Tan, Lean Sheng4ce4afa2020-08-25 18:07:16 -070066
67static inline uint8_t get_dev_revision(pci_devfn_t dev)
68{
69 return pci_read_config8(dev, PCI_REVISION_ID);
70}
71
72static inline uint16_t get_dev_id(pci_devfn_t dev)
73{
74 return pci_read_config16(dev, PCI_DEVICE_ID);
75}
76
77static void report_cpu_info(void)
78{
79 uint32_t i, cpu_id, cpu_feature_flag;
80 char cpu_name[49];
81 int vt, txt, aes;
82 static const char *const mode[] = {"NOT ", ""};
83 const char *cpu_type = "Unknown";
84
85 fill_processor_name(cpu_name);
86 cpu_id = cpu_get_cpuid();
87
88 /* Look for string to match the name */
89 for (i = 0; i < ARRAY_SIZE(cpu_table); i++) {
90 if (cpu_table[i].cpuid == cpu_id) {
91 cpu_type = cpu_table[i].name;
92 break;
93 }
94 }
95
96 printk(BIOS_DEBUG, "CPU: %s\n", cpu_name);
97 printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n",
98 cpu_id, cpu_type, get_current_microcode_rev());
99
100 cpu_feature_flag = cpu_get_feature_flags_ecx();
101 aes = (cpu_feature_flag & CPUID_AES) ? 1 : 0;
102 txt = (cpu_feature_flag & CPUID_SMX) ? 1 : 0;
103 vt = (cpu_feature_flag & CPUID_VMX) ? 1 : 0;
104 printk(BIOS_DEBUG,
105 "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n",
106 mode[aes], mode[txt], mode[vt]);
107}
108
109static void report_mch_info(void)
110{
111 int i;
112 pci_devfn_t dev = SA_DEV_ROOT;
113 uint16_t mchid = get_dev_id(dev);
114 uint8_t mch_revision = get_dev_revision(dev);
115 const char *mch_type = "Unknown";
116
117 for (i = 0; i < ARRAY_SIZE(mch_table); i++) {
118 if (mch_table[i].mchid == mchid) {
119 mch_type = mch_table[i].name;
120 break;
121 }
122 }
123
124 printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n",
125 mchid, mch_revision, mch_type);
126}
127
128static void report_pch_info(void)
129{
130 int i;
131 pci_devfn_t dev = PCH_DEV_ESPI;
132 uint16_t espiid = get_dev_id(dev);
133 const char *pch_type = "Unknown";
134
135 for (i = 0; i < ARRAY_SIZE(pch_table); i++) {
136 if (pch_table[i].espiid == espiid) {
137 pch_type = pch_table[i].name;
138 break;
139 }
140 }
141 printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n",
142 espiid, get_dev_revision(dev), pch_type);
143}
144
145static void report_igd_info(void)
146{
147 int i;
148 pci_devfn_t dev = SA_DEV_IGD;
149 uint16_t igdid = get_dev_id(dev);
150 const char *igd_type = "Unknown";
151
152 for (i = 0; i < ARRAY_SIZE(igd_table); i++) {
153 if (igd_table[i].igdid == igdid) {
154 igd_type = igd_table[i].name;
155 break;
156 }
157 }
158 printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n",
159 igdid, get_dev_revision(dev), igd_type);
160}
161
162void report_platform_info(void)
163{
164 report_cpu_info();
165 report_mch_info();
166 report_pch_info();
167 report_igd_info();
168}