Angel Pons | fabfe9d | 2020-04-05 15:47:07 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 2 | |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 3 | #include <arch/cpu.h> |
| 4 | #include <device/pci_ops.h> |
| 5 | #include <console/console.h> |
Subrata Banik | b7db12b | 2020-08-04 18:01:27 +0530 | [diff] [blame^] | 6 | #include <cpu/intel/microcode.h> |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 7 | #include <cpu/x86/msr.h> |
Usha P | a5f9a4a | 2020-07-15 14:25:14 +0530 | [diff] [blame] | 8 | #include <cpu/x86/name.h> |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 9 | #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 Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 17 | static struct { |
| 18 | u32 cpuid; |
| 19 | const char *name; |
| 20 | } cpu_table[] = { |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 21 | { CPUID_JASPERLAKE_A0, "Jasperlake A0" }, |
| 22 | }; |
| 23 | |
| 24 | static struct { |
| 25 | u16 mchid; |
| 26 | const char *name; |
| 27 | } mch_table[] = { |
Maulik V Vaghela | 8745a27 | 2020-04-22 12:13:40 +0530 | [diff] [blame] | 28 | { 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 Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | static struct { |
| 35 | u16 espiid; |
| 36 | const char *name; |
| 37 | } pch_table[] = { |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 38 | { PCI_DEVICE_ID_INTEL_JSP_SUPER_ESPI, "Jasperlake Super" }, |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | static struct { |
| 42 | u16 igdid; |
| 43 | const char *name; |
| 44 | } igd_table[] = { |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 45 | { PCI_DEVICE_ID_INTEL_JSL_GT1, "Jasperlake GT1" }, |
| 46 | { PCI_DEVICE_ID_INTEL_JSL_GT2, "Jasperlake GT2" }, |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | static inline uint8_t get_dev_revision(pci_devfn_t dev) |
| 50 | { |
| 51 | return pci_read_config8(dev, PCI_REVISION_ID); |
| 52 | } |
| 53 | |
| 54 | static inline uint16_t get_dev_id(pci_devfn_t dev) |
| 55 | { |
| 56 | return pci_read_config16(dev, PCI_DEVICE_ID); |
| 57 | } |
| 58 | |
| 59 | static void report_cpu_info(void) |
| 60 | { |
Usha P | a5f9a4a | 2020-07-15 14:25:14 +0530 | [diff] [blame] | 61 | u32 i, cpu_id, cpu_feature_flag; |
| 62 | char cpu_name[49]; |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 63 | int vt, txt, aes; |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 64 | static const char *const mode[] = {"NOT ", ""}; |
| 65 | const char *cpu_type = "Unknown"; |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 66 | |
Usha P | a5f9a4a | 2020-07-15 14:25:14 +0530 | [diff] [blame] | 67 | fill_processor_name(cpu_name); |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 68 | cpu_id = cpu_get_cpuid(); |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 69 | |
| 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 Banik | b7db12b | 2020-08-04 18:01:27 +0530 | [diff] [blame^] | 80 | cpu_id, cpu_type, get_current_microcode_rev()); |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 81 | |
| 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 | |
| 91 | static 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 | |
| 110 | static 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 | |
| 127 | static 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 | |
| 144 | void report_platform_info(void) |
| 145 | { |
| 146 | report_cpu_info(); |
| 147 | report_mch_info(); |
| 148 | report_pch_info(); |
| 149 | report_igd_info(); |
| 150 | } |