blob: d7eb490709238a712e8b2bc5cb3d2a166dc5512e [file] [log] [blame]
Angel Ponsfabfe9d2020-04-05 15:47:07 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Aamir Bohradd7acaa2020-03-25 11:36:22 +05302
Aamir Bohradd7acaa2020-03-25 11:36:22 +05303#include <arch/cpu.h>
4#include <device/pci_ops.h>
5#include <console/console.h>
Subrata Banikb7db12b2020-08-04 18:01:27 +05306#include <cpu/intel/microcode.h>
Aamir Bohradd7acaa2020-03-25 11:36:22 +05307#include <cpu/x86/msr.h>
Usha Pa5f9a4a2020-07-15 14:25:14 +05308#include <cpu/x86/name.h>
Aamir Bohradd7acaa2020-03-25 11:36:22 +05309#include <device/pci.h>
10#include <device/pci_ids.h>
11#include <intelblocks/mp_init.h>
12#include <soc/bootblock.h>
13#include <soc/pch.h>
14#include <soc/pci_devs.h>
15#include <string.h>
16
Aamir Bohradd7acaa2020-03-25 11:36:22 +053017static struct {
18 u32 cpuid;
19 const char *name;
20} cpu_table[] = {
Aamir Bohradd7acaa2020-03-25 11:36:22 +053021 { CPUID_JASPERLAKE_A0, "Jasperlake A0" },
22};
23
24static struct {
25 u16 mchid;
26 const char *name;
27} mch_table[] = {
Maulik V Vaghela8745a272020-04-22 12:13:40 +053028 { PCI_DEVICE_ID_INTEL_JSL_ID_1, "Jasperlake SKU4-1" },
29 { PCI_DEVICE_ID_INTEL_JSL_ID_2, "Jasperlake SKU4-2" },
30 { PCI_DEVICE_ID_INTEL_JSL_ID_3, "Jasperlake SKU2-1" },
31 { PCI_DEVICE_ID_INTEL_JSL_ID_4, "Jasperlake SKU2-2" },
Aamir Bohradd7acaa2020-03-25 11:36:22 +053032};
33
34static struct {
35 u16 espiid;
36 const char *name;
37} pch_table[] = {
Aamir Bohradd7acaa2020-03-25 11:36:22 +053038 { PCI_DEVICE_ID_INTEL_JSP_SUPER_ESPI, "Jasperlake Super" },
Aamir Bohradd7acaa2020-03-25 11:36:22 +053039};
40
41static struct {
42 u16 igdid;
43 const char *name;
44} igd_table[] = {
Aamir Bohradd7acaa2020-03-25 11:36:22 +053045 { PCI_DEVICE_ID_INTEL_JSL_GT1, "Jasperlake GT1" },
46 { PCI_DEVICE_ID_INTEL_JSL_GT2, "Jasperlake GT2" },
Krishna Prasad Bhat166d9302020-07-28 20:46:39 +053047 { PCI_DEVICE_ID_INTEL_JSL_GT3, "Jasperlake GT3" },
Aamir Bohradd7acaa2020-03-25 11:36:22 +053048};
49
50static inline uint8_t get_dev_revision(pci_devfn_t dev)
51{
52 return pci_read_config8(dev, PCI_REVISION_ID);
53}
54
55static inline uint16_t get_dev_id(pci_devfn_t dev)
56{
57 return pci_read_config16(dev, PCI_DEVICE_ID);
58}
59
60static void report_cpu_info(void)
61{
Usha Pa5f9a4a2020-07-15 14:25:14 +053062 u32 i, cpu_id, cpu_feature_flag;
63 char cpu_name[49];
Aamir Bohradd7acaa2020-03-25 11:36:22 +053064 int vt, txt, aes;
Aamir Bohradd7acaa2020-03-25 11:36:22 +053065 static const char *const mode[] = {"NOT ", ""};
66 const char *cpu_type = "Unknown";
Aamir Bohradd7acaa2020-03-25 11:36:22 +053067
Usha Pa5f9a4a2020-07-15 14:25:14 +053068 fill_processor_name(cpu_name);
Aamir Bohradd7acaa2020-03-25 11:36:22 +053069 cpu_id = cpu_get_cpuid();
Aamir Bohradd7acaa2020-03-25 11:36:22 +053070
71 /* Look for string to match the name */
72 for (i = 0; i < ARRAY_SIZE(cpu_table); i++) {
73 if (cpu_table[i].cpuid == cpu_id) {
74 cpu_type = cpu_table[i].name;
75 break;
76 }
77 }
78
79 printk(BIOS_DEBUG, "CPU: %s\n", cpu_name);
80 printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n",
Subrata Banikb7db12b2020-08-04 18:01:27 +053081 cpu_id, cpu_type, get_current_microcode_rev());
Aamir Bohradd7acaa2020-03-25 11:36:22 +053082
83 cpu_feature_flag = cpu_get_feature_flags_ecx();
84 aes = (cpu_feature_flag & CPUID_AES) ? 1 : 0;
85 txt = (cpu_feature_flag & CPUID_SMX) ? 1 : 0;
86 vt = (cpu_feature_flag & CPUID_VMX) ? 1 : 0;
87 printk(BIOS_DEBUG,
88 "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n",
89 mode[aes], mode[txt], mode[vt]);
90}
91
92static void report_mch_info(void)
93{
94 int i;
95 pci_devfn_t dev = SA_DEV_ROOT;
96 uint16_t mchid = get_dev_id(dev);
97 uint8_t mch_revision = get_dev_revision(dev);
98 const char *mch_type = "Unknown";
99
100 for (i = 0; i < ARRAY_SIZE(mch_table); i++) {
101 if (mch_table[i].mchid == mchid) {
102 mch_type = mch_table[i].name;
103 break;
104 }
105 }
106
107 printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n",
108 mchid, mch_revision, mch_type);
109}
110
111static void report_pch_info(void)
112{
113 int i;
114 pci_devfn_t dev = PCH_DEV_ESPI;
115 uint16_t espiid = get_dev_id(dev);
116 const char *pch_type = "Unknown";
117
118 for (i = 0; i < ARRAY_SIZE(pch_table); i++) {
119 if (pch_table[i].espiid == espiid) {
120 pch_type = pch_table[i].name;
121 break;
122 }
123 }
124 printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n",
125 espiid, get_dev_revision(dev), pch_type);
126}
127
128static void report_igd_info(void)
129{
130 int i;
131 pci_devfn_t dev = SA_DEV_IGD;
132 uint16_t igdid = get_dev_id(dev);
133 const char *igd_type = "Unknown";
134
135 for (i = 0; i < ARRAY_SIZE(igd_table); i++) {
136 if (igd_table[i].igdid == igdid) {
137 igd_type = igd_table[i].name;
138 break;
139 }
140 }
141 printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n",
142 igdid, get_dev_revision(dev), igd_type);
143}
144
145void report_platform_info(void)
146{
147 report_cpu_info();
148 report_mch_info();
149 report_pch_info();
150 report_igd_info();
151}