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