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" }, |
Krishna Prasad Bhat | 20f580b | 2020-09-17 19:42:39 +0530 | [diff] [blame^] | 32 | { PCI_DEVICE_ID_INTEL_JSL_ID_5, "Jasperlake SKU4-3" }, |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | static struct { |
| 36 | u16 espiid; |
| 37 | const char *name; |
| 38 | } pch_table[] = { |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 39 | { PCI_DEVICE_ID_INTEL_JSP_SUPER_ESPI, "Jasperlake Super" }, |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | static struct { |
| 43 | u16 igdid; |
| 44 | const char *name; |
| 45 | } igd_table[] = { |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 46 | { PCI_DEVICE_ID_INTEL_JSL_GT1, "Jasperlake GT1" }, |
| 47 | { PCI_DEVICE_ID_INTEL_JSL_GT2, "Jasperlake GT2" }, |
Krishna Prasad Bhat | 166d930 | 2020-07-28 20:46:39 +0530 | [diff] [blame] | 48 | { PCI_DEVICE_ID_INTEL_JSL_GT3, "Jasperlake GT3" }, |
Krishna Prasad Bhat | 20f580b | 2020-09-17 19:42:39 +0530 | [diff] [blame^] | 49 | { PCI_DEVICE_ID_INTEL_JSL_GT4, "Jasperlake GT4" }, |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | static inline uint8_t get_dev_revision(pci_devfn_t dev) |
| 53 | { |
| 54 | return pci_read_config8(dev, PCI_REVISION_ID); |
| 55 | } |
| 56 | |
| 57 | static inline uint16_t get_dev_id(pci_devfn_t dev) |
| 58 | { |
| 59 | return pci_read_config16(dev, PCI_DEVICE_ID); |
| 60 | } |
| 61 | |
| 62 | static void report_cpu_info(void) |
| 63 | { |
Usha P | a5f9a4a | 2020-07-15 14:25:14 +0530 | [diff] [blame] | 64 | u32 i, cpu_id, cpu_feature_flag; |
| 65 | char cpu_name[49]; |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 66 | int vt, txt, aes; |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 67 | static const char *const mode[] = {"NOT ", ""}; |
| 68 | const char *cpu_type = "Unknown"; |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 69 | |
Usha P | a5f9a4a | 2020-07-15 14:25:14 +0530 | [diff] [blame] | 70 | fill_processor_name(cpu_name); |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 71 | cpu_id = cpu_get_cpuid(); |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 72 | |
| 73 | /* Look for string to match the name */ |
| 74 | for (i = 0; i < ARRAY_SIZE(cpu_table); i++) { |
| 75 | if (cpu_table[i].cpuid == cpu_id) { |
| 76 | cpu_type = cpu_table[i].name; |
| 77 | break; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | printk(BIOS_DEBUG, "CPU: %s\n", cpu_name); |
| 82 | printk(BIOS_DEBUG, "CPU: ID %x, %s, ucode: %08x\n", |
Subrata Banik | b7db12b | 2020-08-04 18:01:27 +0530 | [diff] [blame] | 83 | cpu_id, cpu_type, get_current_microcode_rev()); |
Aamir Bohra | dd7acaa | 2020-03-25 11:36:22 +0530 | [diff] [blame] | 84 | |
| 85 | cpu_feature_flag = cpu_get_feature_flags_ecx(); |
| 86 | aes = (cpu_feature_flag & CPUID_AES) ? 1 : 0; |
| 87 | txt = (cpu_feature_flag & CPUID_SMX) ? 1 : 0; |
| 88 | vt = (cpu_feature_flag & CPUID_VMX) ? 1 : 0; |
| 89 | printk(BIOS_DEBUG, |
| 90 | "CPU: AES %ssupported, TXT %ssupported, VT %ssupported\n", |
| 91 | mode[aes], mode[txt], mode[vt]); |
| 92 | } |
| 93 | |
| 94 | static void report_mch_info(void) |
| 95 | { |
| 96 | int 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_DEBUG, "MCH: device id %04x (rev %02x) is %s\n", |
| 110 | mchid, mch_revision, mch_type); |
| 111 | } |
| 112 | |
| 113 | static void report_pch_info(void) |
| 114 | { |
| 115 | int i; |
| 116 | pci_devfn_t dev = PCH_DEV_ESPI; |
| 117 | uint16_t espiid = 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].espiid == espiid) { |
| 122 | pch_type = pch_table[i].name; |
| 123 | break; |
| 124 | } |
| 125 | } |
| 126 | printk(BIOS_DEBUG, "PCH: device id %04x (rev %02x) is %s\n", |
| 127 | espiid, get_dev_revision(dev), pch_type); |
| 128 | } |
| 129 | |
| 130 | static void report_igd_info(void) |
| 131 | { |
| 132 | int 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_DEBUG, "IGD: device id %04x (rev %02x) is %s\n", |
| 144 | igdid, get_dev_revision(dev), igd_type); |
| 145 | } |
| 146 | |
| 147 | void report_platform_info(void) |
| 148 | { |
| 149 | report_cpu_info(); |
| 150 | report_mch_info(); |
| 151 | report_pch_info(); |
| 152 | report_igd_info(); |
| 153 | } |