blob: 8f1318d8d2c5813d0b849169b6e3c8dd8ce7951f [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" },
Aamir Bohradd7acaa2020-03-25 11:36:22 +053047};
48
49static inline uint8_t get_dev_revision(pci_devfn_t dev)
50{
51 return pci_read_config8(dev, PCI_REVISION_ID);
52}
53
54static inline uint16_t get_dev_id(pci_devfn_t dev)
55{
56 return pci_read_config16(dev, PCI_DEVICE_ID);
57}
58
59static void report_cpu_info(void)
60{
Usha Pa5f9a4a2020-07-15 14:25:14 +053061 u32 i, cpu_id, cpu_feature_flag;
62 char cpu_name[49];
Aamir Bohradd7acaa2020-03-25 11:36:22 +053063 int vt, txt, aes;
Aamir Bohradd7acaa2020-03-25 11:36:22 +053064 static const char *const mode[] = {"NOT ", ""};
65 const char *cpu_type = "Unknown";
Aamir Bohradd7acaa2020-03-25 11:36:22 +053066
Usha Pa5f9a4a2020-07-15 14:25:14 +053067 fill_processor_name(cpu_name);
Aamir Bohradd7acaa2020-03-25 11:36:22 +053068 cpu_id = cpu_get_cpuid();
Aamir Bohradd7acaa2020-03-25 11:36:22 +053069
70 /* Look for string to match the name */
71 for (i = 0; i < ARRAY_SIZE(cpu_table); i++) {
72 if (cpu_table[i].cpuid == cpu_id) {
73 cpu_type = cpu_table[i].name;
74 break;
75 }
76 }
77
78 printk(BIOS_DEBUG, "CPU: %s\n", cpu_name);
79 printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n",
Subrata Banikb7db12b2020-08-04 18:01:27 +053080 cpu_id, cpu_type, get_current_microcode_rev());
Aamir Bohradd7acaa2020-03-25 11:36:22 +053081
82 cpu_feature_flag = cpu_get_feature_flags_ecx();
83 aes = (cpu_feature_flag & CPUID_AES) ? 1 : 0;
84 txt = (cpu_feature_flag & CPUID_SMX) ? 1 : 0;
85 vt = (cpu_feature_flag & CPUID_VMX) ? 1 : 0;
86 printk(BIOS_DEBUG,
87 "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n",
88 mode[aes], mode[txt], mode[vt]);
89}
90
91static void report_mch_info(void)
92{
93 int i;
94 pci_devfn_t dev = SA_DEV_ROOT;
95 uint16_t mchid = get_dev_id(dev);
96 uint8_t mch_revision = get_dev_revision(dev);
97 const char *mch_type = "Unknown";
98
99 for (i = 0; i < ARRAY_SIZE(mch_table); i++) {
100 if (mch_table[i].mchid == mchid) {
101 mch_type = mch_table[i].name;
102 break;
103 }
104 }
105
106 printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n",
107 mchid, mch_revision, mch_type);
108}
109
110static void report_pch_info(void)
111{
112 int i;
113 pci_devfn_t dev = PCH_DEV_ESPI;
114 uint16_t espiid = get_dev_id(dev);
115 const char *pch_type = "Unknown";
116
117 for (i = 0; i < ARRAY_SIZE(pch_table); i++) {
118 if (pch_table[i].espiid == espiid) {
119 pch_type = pch_table[i].name;
120 break;
121 }
122 }
123 printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n",
124 espiid, get_dev_revision(dev), pch_type);
125}
126
127static void report_igd_info(void)
128{
129 int i;
130 pci_devfn_t dev = SA_DEV_IGD;
131 uint16_t igdid = get_dev_id(dev);
132 const char *igd_type = "Unknown";
133
134 for (i = 0; i < ARRAY_SIZE(igd_table); i++) {
135 if (igd_table[i].igdid == igdid) {
136 igd_type = igd_table[i].name;
137 break;
138 }
139 }
140 printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n",
141 igdid, get_dev_revision(dev), igd_type);
142}
143
144void report_platform_info(void)
145{
146 report_cpu_info();
147 report_mch_info();
148 report_pch_info();
149 report_igd_info();
150}