blob: 6a58ea7c977d6d7bc3bec96496720c62631ed48e [file] [log] [blame]
Subrata Banik930c31c2019-11-01 18:12:58 +05301/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2019 Intel Corp.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16/*
17 * This file is created based on Intel Tiger Lake Platform Stepping and IDs
18 * Document number: 605534
19 * Chapter number: 2, 4, 5, 6
20 */
21
22#include <arch/cpu.h>
23#include <device/pci_ops.h>
24#include <console/console.h>
25#include <cpu/x86/msr.h>
26#include <device/pci.h>
27#include <device/pci_ids.h>
28#include <intelblocks/mp_init.h>
29#include <soc/bootblock.h>
30#include <soc/pch.h>
31#include <soc/pci_devs.h>
32#include <string.h>
33
34#define BIOS_SIGN_ID 0x8B
35
36/*
37 * TODO: Add TGL specific CPU/SA/PCH IDs here
38 */
39
40static inline uint8_t get_dev_revision(pci_devfn_t dev)
41{
42 return pci_read_config8(dev, PCI_REVISION_ID);
43}
44
45static inline uint16_t get_dev_id(pci_devfn_t dev)
46{
47 return pci_read_config16(dev, PCI_DEVICE_ID);
48}
49
50static void report_cpu_info(void)
51{
52 struct cpuid_result cpuidr;
53 u32 i, index, cpu_id, cpu_feature_flag;
54 const char cpu_not_found[] = "Platform info not available";
55 const char *cpu_name = cpu_not_found; /* 48 bytes are reported */
56 int vt, txt, aes;
57 msr_t microcode_ver;
58 static const char *const mode[] = {"NOT ", ""};
59 const char *cpu_type = "Unknown";
60 u32 p[13];
61
62 index = 0x80000000;
63 cpuidr = cpuid(index);
64 if (cpuidr.eax >= 0x80000004) {
65 int j = 0;
66
67 for (i = 2; i <= 4; i++) {
68 cpuidr = cpuid(index + i);
69 p[j++] = cpuidr.eax;
70 p[j++] = cpuidr.ebx;
71 p[j++] = cpuidr.ecx;
72 p[j++] = cpuidr.edx;
73 }
74 p[12] = 0;
75 cpu_name = (char *)p;
76
77 /* Skip leading spaces in CPU name string */
78 while (cpu_name[0] == ' ' && strlen(cpu_name) > 0)
79 cpu_name++;
80 }
81
82 microcode_ver.lo = 0;
83 microcode_ver.hi = 0;
84 wrmsr(BIOS_SIGN_ID, microcode_ver);
85 cpu_id = cpu_get_cpuid();
86 microcode_ver = rdmsr(BIOS_SIGN_ID);
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, microcode_ver.hi);
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}