Martin Roth | f95a11e | 2022-10-21 16:43:08 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | /* TODO: Update for Glinda */ |
| 4 | |
| 5 | #include <acpi/acpi.h> |
| 6 | #include <amdblocks/cpu.h> |
| 7 | #include <amdblocks/iomap.h> |
| 8 | #include <amdblocks/mca.h> |
| 9 | #include <console/console.h> |
| 10 | #include <cpu/amd/microcode.h> |
| 11 | #include <cpu/cpu.h> |
| 12 | #include <cpu/x86/mp.h> |
| 13 | #include <cpu/x86/mtrr.h> |
| 14 | #include <acpi/acpi.h> |
| 15 | #include <device/device.h> |
| 16 | #include <soc/cpu.h> |
| 17 | #include <soc/iomap.h> |
| 18 | |
| 19 | _Static_assert(CONFIG_MAX_CPUS == 8, "Do not override MAX_CPUS. To reduce the number of " |
| 20 | "available cores, use the downcore_mode and disable_smt devicetree settings instead."); |
| 21 | |
| 22 | /* MP and SMM loading initialization */ |
| 23 | |
| 24 | void mp_init_cpus(struct bus *cpu_bus) |
| 25 | { |
| 26 | extern const struct mp_ops amd_mp_ops_with_smm; |
| 27 | if (mp_init_with_smm(cpu_bus, &amd_mp_ops_with_smm) != CB_SUCCESS) |
| 28 | die_with_post_code(POST_HW_INIT_FAILURE, |
| 29 | "mp_init_with_smm failed. Halting.\n"); |
| 30 | |
| 31 | /* pre_mp_init made the flash not cacheable. Reset to WP for performance. */ |
| 32 | mtrr_use_temp_range(FLASH_BELOW_4GB_MAPPING_REGION_BASE, |
| 33 | FLASH_BELOW_4GB_MAPPING_REGION_SIZE, MTRR_TYPE_WRPROT); |
| 34 | |
| 35 | /* SMMINFO only needs to be set up when booting from S5 */ |
| 36 | if (!acpi_is_wakeup_s3()) |
| 37 | apm_control(APM_CNT_SMMINFO); |
| 38 | } |
| 39 | |
| 40 | static void zen_2_3_init(struct device *dev) |
| 41 | { |
| 42 | check_mca(); |
| 43 | set_cstate_io_addr(); |
| 44 | |
| 45 | amd_update_microcode_from_cbfs(); |
| 46 | } |
| 47 | |
| 48 | static struct device_operations cpu_dev_ops = { |
| 49 | .init = zen_2_3_init, |
| 50 | }; |
| 51 | |
| 52 | static struct cpu_device_id cpu_table[] = { |
Felix Held | 6a6ac1e | 2023-02-06 15:19:11 +0100 | [diff] [blame^] | 53 | { X86_VENDOR_AMD, GLINDA_A0_CPUID, CPUID_EXACT_MATCH_MASK }, /* TODO: Update for Glinda */ |
| 54 | { 0, 0, 0 }, |
Martin Roth | f95a11e | 2022-10-21 16:43:08 -0600 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | static const struct cpu_driver zen_2_3 __cpu_driver = { |
| 58 | .ops = &cpu_dev_ops, |
| 59 | .id_table = cpu_table, |
| 60 | }; |