Angel Pons | 6bc1374 | 2020-04-05 15:46:38 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Usha P | aaf28d2 | 2020-02-17 15:14:18 +0530 | [diff] [blame] | 2 | |
| 3 | #include <arch/cpu.h> |
| 4 | #include <device/pci_ops.h> |
| 5 | #include <console/console.h> |
| 6 | #include <cpu/x86/msr.h> |
| 7 | #include <cpu/x86/name.h> |
| 8 | #include <device/pci.h> |
| 9 | #include <device/pci_ids.h> |
| 10 | #include <intelblocks/mp_init.h> |
| 11 | #include <soc/romstage.h> |
| 12 | #include <soc/pci_devs.h> |
| 13 | |
| 14 | static struct { |
| 15 | u32 cpuid; |
| 16 | const char *name; |
| 17 | } cpu_table[] = { |
| 18 | { CPUID_APOLLOLAKE_A0, "Apollolake A0" }, |
| 19 | { CPUID_APOLLOLAKE_B0, "Apollolake B0" }, |
| 20 | { CPUID_APOLLOLAKE_E0, "Apollolake E0" }, |
| 21 | { CPUID_GLK_A0, "Geminilake A0" }, |
| 22 | { CPUID_GLK_B0, "Geminilake B0" }, |
| 23 | { CPUID_GLK_R0, "Geminilake R0" }, |
| 24 | }; |
| 25 | |
| 26 | static struct { |
| 27 | u16 mchid; |
| 28 | const char *name; |
| 29 | } mch_table[] = { |
| 30 | { PCI_DEVICE_ID_INTEL_GLK_NB, "Geminilake" }, |
| 31 | { PCI_DEVICE_ID_INTEL_APL_NB, "Apollolake" }, |
| 32 | }; |
| 33 | |
| 34 | static struct { |
| 35 | u16 lpcid; |
| 36 | const char *name; |
| 37 | } pch_table[] = { |
| 38 | { PCI_DEVICE_ID_INTEL_APL_LPC, "Apollolake" }, |
| 39 | { PCI_DEVICE_ID_INTEL_GLK_LPC, "Geminilake" }, |
| 40 | { PCI_DEVICE_ID_INTEL_GLK_ESPI, "Geminilake" }, |
| 41 | }; |
| 42 | |
| 43 | static struct { |
| 44 | u16 igdid; |
| 45 | const char *name; |
| 46 | } igd_table[] = { |
| 47 | { PCI_DEVICE_ID_INTEL_APL_IGD_HD_505, "Apollolake HD 505" }, |
Angel Pons | 68da241 | 2020-04-15 16:30:27 +0200 | [diff] [blame] | 48 | { PCI_DEVICE_ID_INTEL_APL_IGD_HD_500, "Apollolake HD 500" }, |
Usha P | aaf28d2 | 2020-02-17 15:14:18 +0530 | [diff] [blame] | 49 | { PCI_DEVICE_ID_INTEL_GLK_IGD, "Geminilake" }, |
| 50 | { PCI_DEVICE_ID_INTEL_GLK_IGD_EU12, "Geminilake EU12" }, |
| 51 | }; |
| 52 | |
| 53 | static uint8_t get_dev_revision(pci_devfn_t dev) |
| 54 | { |
| 55 | return pci_read_config8(dev, PCI_REVISION_ID); |
| 56 | } |
| 57 | |
| 58 | static uint16_t get_dev_id(pci_devfn_t dev) |
| 59 | { |
| 60 | return pci_read_config16(dev, PCI_DEVICE_ID); |
| 61 | } |
| 62 | |
| 63 | static void report_cpu_info(void) |
| 64 | { |
| 65 | uint32_t i, cpu_id, cpu_feature_flag; |
| 66 | char cpu_name[49]; |
| 67 | msr_t microcode_ver; |
| 68 | const char *support = "Supported"; |
| 69 | const char *no_support = "Not Supported"; |
| 70 | const char *cpu_type = "Unknown"; |
| 71 | |
| 72 | fill_processor_name(cpu_name); |
| 73 | |
| 74 | microcode_ver.lo = 0; |
| 75 | microcode_ver.hi = 0; |
| 76 | wrmsr(IA32_BIOS_SIGN_ID, microcode_ver); |
| 77 | cpu_id = cpu_get_cpuid(); |
| 78 | microcode_ver = rdmsr(IA32_BIOS_SIGN_ID); |
| 79 | |
| 80 | /* Look for string to match the name */ |
| 81 | for (i = 0; i < ARRAY_SIZE(cpu_table); i++) { |
| 82 | if (cpu_table[i].cpuid == cpu_id) { |
| 83 | cpu_type = cpu_table[i].name; |
| 84 | break; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | printk(BIOS_INFO, "CPU: %s\n", cpu_name); |
| 89 | printk(BIOS_INFO, "CPU: ID %x, %s, ucode: %08x\n", cpu_id, cpu_type, microcode_ver.hi); |
| 90 | |
| 91 | cpu_feature_flag = cpu_get_feature_flags_ecx(); |
| 92 | printk(BIOS_INFO, "CPU: AES %s, TXT %s, VT %s\n", |
| 93 | (cpu_feature_flag & CPUID_AES) ? support : no_support, |
| 94 | (cpu_feature_flag & CPUID_SMX) ? support : no_support, |
| 95 | (cpu_feature_flag & CPUID_VMX) ? support : no_support); |
| 96 | } |
| 97 | |
| 98 | static void report_mch_info(void) |
| 99 | { |
| 100 | uint32_t i; |
| 101 | pci_devfn_t dev = SA_DEV_ROOT; |
| 102 | uint16_t mchid = get_dev_id(dev); |
| 103 | uint8_t mch_revision = get_dev_revision(dev); |
| 104 | const char *mch_type = "Unknown"; |
| 105 | |
| 106 | for (i = 0; i < ARRAY_SIZE(mch_table); i++) { |
| 107 | if (mch_table[i].mchid == mchid) { |
| 108 | mch_type = mch_table[i].name; |
| 109 | break; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | printk(BIOS_INFO, "MCH: device id %04x (rev %02x) is %s\n", |
| 114 | mchid, mch_revision, mch_type); |
| 115 | } |
| 116 | |
| 117 | static void report_pch_info(void) |
| 118 | { |
| 119 | uint32_t i; |
| 120 | pci_devfn_t dev = PCH_DEV_LPC; |
| 121 | uint16_t lpcid = get_dev_id(dev); |
| 122 | const char *pch_type = "Unknown"; |
| 123 | |
| 124 | for (i = 0; i < ARRAY_SIZE(pch_table); i++) { |
| 125 | if (pch_table[i].lpcid == lpcid) { |
| 126 | pch_type = pch_table[i].name; |
| 127 | break; |
| 128 | } |
| 129 | } |
| 130 | printk(BIOS_INFO, "PCH: device id %04x (rev %02x) is %s\n", |
| 131 | lpcid, get_dev_revision(dev), pch_type); |
| 132 | } |
| 133 | |
| 134 | static void report_igd_info(void) |
| 135 | { |
| 136 | uint32_t i; |
| 137 | pci_devfn_t dev = SA_DEV_IGD; |
| 138 | uint16_t igdid = get_dev_id(dev); |
| 139 | const char *igd_type = "Unknown"; |
| 140 | |
| 141 | for (i = 0; i < ARRAY_SIZE(igd_table); i++) { |
| 142 | if (igd_table[i].igdid == igdid) { |
| 143 | igd_type = igd_table[i].name; |
| 144 | break; |
| 145 | } |
| 146 | } |
| 147 | printk(BIOS_INFO, "IGD: device id %04x (rev %02x) is %s\n", |
| 148 | igdid, get_dev_revision(dev), igd_type); |
| 149 | } |
| 150 | |
| 151 | void report_platform_info(void) |
| 152 | { |
| 153 | report_cpu_info(); |
| 154 | report_mch_info(); |
| 155 | report_pch_info(); |
| 156 | report_igd_info(); |
| 157 | } |