Angel Pons | fabfe9d | 2020-04-05 15:47:07 +0200 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | /* This file is part of the coreboot project. */ |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 3 | |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 4 | #include <arch/cpu.h> |
| 5 | #include <device/pci_ops.h> |
| 6 | #include <console/console.h> |
| 7 | #include <cpu/x86/msr.h> |
| 8 | #include <device/pci.h> |
| 9 | #include <device/pci_ids.h> |
| 10 | #include <intelblocks/mp_init.h> |
| 11 | #include <soc/bootblock.h> |
| 12 | #include <soc/pch.h> |
| 13 | #include <soc/pci_devs.h> |
| 14 | #include <string.h> |
| 15 | |
| 16 | #define BIOS_SIGN_ID 0x8B |
| 17 | |
| 18 | static struct { |
| 19 | u32 cpuid; |
| 20 | const char *name; |
| 21 | } cpu_table[] = { |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 22 | { CPUID_JASPERLAKE_A0, "Jasperlake A0" }, |
| 23 | }; |
| 24 | |
| 25 | static struct { |
| 26 | u16 mchid; |
| 27 | const char *name; |
| 28 | } mch_table[] = { |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 29 | { PCI_DEVICE_ID_INTEL_JSL_ID_1, "Jasperlake-1" }, |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | static struct { |
| 33 | u16 espiid; |
| 34 | const char *name; |
| 35 | } pch_table[] = { |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 36 | { PCI_DEVICE_ID_INTEL_JSP_SUPER_ESPI, "Jasperlake Super" }, |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | static struct { |
| 40 | u16 igdid; |
| 41 | const char *name; |
| 42 | } igd_table[] = { |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 43 | { PCI_DEVICE_ID_INTEL_JSL_GT1, "Jasperlake GT1" }, |
| 44 | { PCI_DEVICE_ID_INTEL_JSL_GT2, "Jasperlake GT2" }, |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | static inline uint8_t get_dev_revision(pci_devfn_t dev) |
| 48 | { |
| 49 | return pci_read_config8(dev, PCI_REVISION_ID); |
| 50 | } |
| 51 | |
| 52 | static inline uint16_t get_dev_id(pci_devfn_t dev) |
| 53 | { |
| 54 | return pci_read_config16(dev, PCI_DEVICE_ID); |
| 55 | } |
| 56 | |
| 57 | static void report_cpu_info(void) |
| 58 | { |
| 59 | struct cpuid_result cpuidr; |
| 60 | u32 i, index, cpu_id, cpu_feature_flag; |
| 61 | const char cpu_not_found[] = "Platform info not available"; |
| 62 | const char *cpu_name = cpu_not_found; /* 48 bytes are reported */ |
| 63 | int vt, txt, aes; |
| 64 | msr_t microcode_ver; |
| 65 | static const char *const mode[] = {"NOT ", ""}; |
| 66 | const char *cpu_type = "Unknown"; |
| 67 | u32 p[13]; |
| 68 | |
| 69 | index = 0x80000000; |
| 70 | cpuidr = cpuid(index); |
| 71 | if (cpuidr.eax >= 0x80000004) { |
| 72 | int j = 0; |
| 73 | |
| 74 | for (i = 2; i <= 4; i++) { |
| 75 | cpuidr = cpuid(index + i); |
| 76 | p[j++] = cpuidr.eax; |
| 77 | p[j++] = cpuidr.ebx; |
| 78 | p[j++] = cpuidr.ecx; |
| 79 | p[j++] = cpuidr.edx; |
| 80 | } |
| 81 | p[12] = 0; |
| 82 | cpu_name = (char *)p; |
| 83 | |
| 84 | /* Skip leading spaces in CPU name string */ |
| 85 | while (cpu_name[0] == ' ' && strlen(cpu_name) > 0) |
| 86 | cpu_name++; |
| 87 | } |
| 88 | |
| 89 | microcode_ver.lo = 0; |
| 90 | microcode_ver.hi = 0; |
| 91 | wrmsr(BIOS_SIGN_ID, microcode_ver); |
| 92 | cpu_id = cpu_get_cpuid(); |
| 93 | microcode_ver = rdmsr(BIOS_SIGN_ID); |
| 94 | |
| 95 | /* Look for string to match the name */ |
| 96 | for (i = 0; i < ARRAY_SIZE(cpu_table); i++) { |
| 97 | if (cpu_table[i].cpuid == cpu_id) { |
| 98 | cpu_type = cpu_table[i].name; |
| 99 | break; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | printk(BIOS_DEBUG, "CPU: %s\n", cpu_name); |
| 104 | printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n", |
| 105 | cpu_id, cpu_type, microcode_ver.hi); |
| 106 | |
| 107 | cpu_feature_flag = cpu_get_feature_flags_ecx(); |
| 108 | aes = (cpu_feature_flag & CPUID_AES) ? 1 : 0; |
| 109 | txt = (cpu_feature_flag & CPUID_SMX) ? 1 : 0; |
| 110 | vt = (cpu_feature_flag & CPUID_VMX) ? 1 : 0; |
| 111 | printk(BIOS_DEBUG, |
| 112 | "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n", |
| 113 | mode[aes], mode[txt], mode[vt]); |
| 114 | } |
| 115 | |
| 116 | static void report_mch_info(void) |
| 117 | { |
| 118 | int i; |
| 119 | pci_devfn_t dev = SA_DEV_ROOT; |
| 120 | uint16_t mchid = get_dev_id(dev); |
| 121 | uint8_t mch_revision = get_dev_revision(dev); |
| 122 | const char *mch_type = "Unknown"; |
| 123 | |
| 124 | for (i = 0; i < ARRAY_SIZE(mch_table); i++) { |
| 125 | if (mch_table[i].mchid == mchid) { |
| 126 | mch_type = mch_table[i].name; |
| 127 | break; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | printk(BIOS_DEBUG, "MCH: device id %04x (rev %02x) is %s\n", |
| 132 | mchid, mch_revision, mch_type); |
| 133 | } |
| 134 | |
| 135 | static void report_pch_info(void) |
| 136 | { |
| 137 | int i; |
| 138 | pci_devfn_t dev = PCH_DEV_ESPI; |
| 139 | uint16_t espiid = get_dev_id(dev); |
| 140 | const char *pch_type = "Unknown"; |
| 141 | |
| 142 | for (i = 0; i < ARRAY_SIZE(pch_table); i++) { |
| 143 | if (pch_table[i].espiid == espiid) { |
| 144 | pch_type = pch_table[i].name; |
| 145 | break; |
| 146 | } |
| 147 | } |
| 148 | printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n", |
| 149 | espiid, get_dev_revision(dev), pch_type); |
| 150 | } |
| 151 | |
| 152 | static void report_igd_info(void) |
| 153 | { |
| 154 | int i; |
| 155 | pci_devfn_t dev = SA_DEV_IGD; |
| 156 | uint16_t igdid = get_dev_id(dev); |
| 157 | const char *igd_type = "Unknown"; |
| 158 | |
| 159 | for (i = 0; i < ARRAY_SIZE(igd_table); i++) { |
| 160 | if (igd_table[i].igdid == igdid) { |
| 161 | igd_type = igd_table[i].name; |
| 162 | break; |
| 163 | } |
| 164 | } |
| 165 | printk(BIOS_DEBUG, "IGD: device id %04x (rev %02x) is %s\n", |
| 166 | igdid, get_dev_revision(dev), igd_type); |
| 167 | } |
| 168 | |
| 169 | void report_platform_info(void) |
| 170 | { |
| 171 | report_cpu_info(); |
| 172 | report_mch_info(); |
| 173 | report_pch_info(); |
| 174 | report_igd_info(); |
| 175 | } |