Martin Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
Martin Roth | 20646cd | 2023-01-04 21:27:06 -0700 | [diff] [blame] | 3 | /* TODO: Update for Phoenix */ |
Martin Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 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 | |
Ritul Guru | 6de377e | 2023-01-06 00:20:10 +0530 | [diff] [blame] | 19 | _Static_assert(CONFIG_MAX_CPUS == 16, "Do not override MAX_CPUS. To reduce the number of " |
Martin Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 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 | 5700149 | 2023-02-06 17:46:59 +0100 | [diff] [blame] | 53 | { X86_VENDOR_AMD, PHOENIX_A0_CPUID, CPUID_ALL_STEPPINGS_MASK }, |
Felix Held | a5d7f16 | 2023-02-06 17:27:07 +0100 | [diff] [blame] | 54 | { X86_VENDOR_AMD, PHOENIX2_A0_CPUID, CPUID_ALL_STEPPINGS_MASK }, |
Felix Held | 1e78165 | 2023-02-08 11:39:16 +0100 | [diff] [blame] | 55 | CPU_TABLE_END |
Martin Roth | 1a3de8e | 2022-10-06 15:57:21 -0600 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | static const struct cpu_driver zen_2_3 __cpu_driver = { |
| 59 | .ops = &cpu_dev_ops, |
| 60 | .id_table = cpu_table, |
| 61 | }; |