blob: 31a6458d476c886c71a114c63719aeddc06f68f8 [file] [log] [blame]
Angel Pons6bc13742020-04-05 15:46:38 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Usha Paaf28d22020-02-17 15:14:18 +05302
3#include <arch/cpu.h>
4#include <device/pci_ops.h>
5#include <console/console.h>
Subrata Banikdbb4e4b2021-07-16 13:30:32 +05306#include <cpu/intel/cpu_ids.h>
Subrata Banikb7db12b2020-08-04 18:01:27 +05307#include <cpu/intel/microcode.h>
Usha Paaf28d22020-02-17 15:14:18 +05308#include <cpu/x86/msr.h>
9#include <cpu/x86/name.h>
10#include <device/pci.h>
11#include <device/pci_ids.h>
Usha Paaf28d22020-02-17 15:14:18 +053012#include <soc/romstage.h>
13#include <soc/pci_devs.h>
14
15static struct {
16 u32 cpuid;
17 const char *name;
18} cpu_table[] = {
19 { CPUID_APOLLOLAKE_A0, "Apollolake A0" },
20 { CPUID_APOLLOLAKE_B0, "Apollolake B0" },
21 { CPUID_APOLLOLAKE_E0, "Apollolake E0" },
22 { CPUID_GLK_A0, "Geminilake A0" },
23 { CPUID_GLK_B0, "Geminilake B0" },
24 { CPUID_GLK_R0, "Geminilake R0" },
25};
26
27static struct {
28 u16 mchid;
29 const char *name;
30} mch_table[] = {
Felix Singer43b7f412022-03-07 04:34:52 +010031 { PCI_DID_INTEL_GLK_NB, "Geminilake" },
32 { PCI_DID_INTEL_APL_NB, "Apollolake" },
Usha Paaf28d22020-02-17 15:14:18 +053033};
34
35static struct {
36 u16 lpcid;
37 const char *name;
38} pch_table[] = {
Felix Singer43b7f412022-03-07 04:34:52 +010039 { PCI_DID_INTEL_APL_LPC, "Apollolake" },
40 { PCI_DID_INTEL_GLK_LPC, "Geminilake" },
41 { PCI_DID_INTEL_GLK_ESPI, "Geminilake" },
Usha Paaf28d22020-02-17 15:14:18 +053042};
43
44static struct {
45 u16 igdid;
46 const char *name;
47} igd_table[] = {
Felix Singer43b7f412022-03-07 04:34:52 +010048 { PCI_DID_INTEL_APL_IGD_HD_505, "Apollolake HD 505" },
49 { PCI_DID_INTEL_APL_IGD_HD_500, "Apollolake HD 500" },
50 { PCI_DID_INTEL_GLK_IGD, "Geminilake" },
51 { PCI_DID_INTEL_GLK_IGD_EU12, "Geminilake EU12" },
Usha Paaf28d22020-02-17 15:14:18 +053052};
53
54static uint8_t get_dev_revision(pci_devfn_t dev)
55{
56 return pci_read_config8(dev, PCI_REVISION_ID);
57}
58
59static uint16_t get_dev_id(pci_devfn_t dev)
60{
61 return pci_read_config16(dev, PCI_DEVICE_ID);
62}
63
64static void report_cpu_info(void)
65{
66 uint32_t i, cpu_id, cpu_feature_flag;
67 char cpu_name[49];
Usha Paaf28d22020-02-17 15:14:18 +053068 const char *support = "Supported";
69 const char *no_support = "Not Supported";
70 const char *cpu_type = "Unknown";
71
72 fill_processor_name(cpu_name);
Usha Paaf28d22020-02-17 15:14:18 +053073 cpu_id = cpu_get_cpuid();
Usha Paaf28d22020-02-17 15:14:18 +053074
75 /* Look for string to match the name */
76 for (i = 0; i < ARRAY_SIZE(cpu_table); i++) {
77 if (cpu_table[i].cpuid == cpu_id) {
78 cpu_type = cpu_table[i].name;
79 break;
80 }
81 }
82
83 printk(BIOS_INFO, "CPU: %s\n", cpu_name);
Subrata Banikb7db12b2020-08-04 18:01:27 +053084 printk(BIOS_INFO, "CPU: ID %x, %s, ucode: %08x\n", cpu_id, cpu_type,
85 get_current_microcode_rev());
Usha Paaf28d22020-02-17 15:14:18 +053086
87 cpu_feature_flag = cpu_get_feature_flags_ecx();
88 printk(BIOS_INFO, "CPU: AES %s, TXT %s, VT %s\n",
89 (cpu_feature_flag & CPUID_AES) ? support : no_support,
90 (cpu_feature_flag & CPUID_SMX) ? support : no_support,
91 (cpu_feature_flag & CPUID_VMX) ? support : no_support);
92}
93
94static void report_mch_info(void)
95{
96 uint32_t i;
97 pci_devfn_t dev = SA_DEV_ROOT;
98 uint16_t mchid = get_dev_id(dev);
99 uint8_t mch_revision = get_dev_revision(dev);
100 const char *mch_type = "Unknown";
101
102 for (i = 0; i < ARRAY_SIZE(mch_table); i++) {
103 if (mch_table[i].mchid == mchid) {
104 mch_type = mch_table[i].name;
105 break;
106 }
107 }
108
109 printk(BIOS_INFO, "MCH: device id %04x (rev %02x) is %s\n",
110 mchid, mch_revision, mch_type);
111}
112
113static void report_pch_info(void)
114{
115 uint32_t i;
116 pci_devfn_t dev = PCH_DEV_LPC;
117 uint16_t lpcid = get_dev_id(dev);
118 const char *pch_type = "Unknown";
119
120 for (i = 0; i < ARRAY_SIZE(pch_table); i++) {
121 if (pch_table[i].lpcid == lpcid) {
122 pch_type = pch_table[i].name;
123 break;
124 }
125 }
126 printk(BIOS_INFO, "PCH: device id %04x (rev %02x) is %s\n",
127 lpcid, get_dev_revision(dev), pch_type);
128}
129
130static void report_igd_info(void)
131{
132 uint32_t i;
133 pci_devfn_t dev = SA_DEV_IGD;
134 uint16_t igdid = get_dev_id(dev);
135 const char *igd_type = "Unknown";
136
137 for (i = 0; i < ARRAY_SIZE(igd_table); i++) {
138 if (igd_table[i].igdid == igdid) {
139 igd_type = igd_table[i].name;
140 break;
141 }
142 }
143 printk(BIOS_INFO, "IGD: device id %04x (rev %02x) is %s\n",
144 igdid, get_dev_revision(dev), igd_type);
145}
146
147void report_platform_info(void)
148{
149 report_cpu_info();
150 report_mch_info();
151 report_pch_info();
152 report_igd_info();
153}