Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
Arthur Heymans | a19bc34 | 2022-05-31 21:25:53 +0200 | [diff] [blame] | 3 | #include <acpi/acpi.h> |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +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 | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 6 | #include <amdblocks/mca.h> |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 7 | #include <console/console.h> |
| 8 | #include <cpu/amd/microcode.h> |
| 9 | #include <cpu/cpu.h> |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 10 | #include <cpu/x86/mp.h> |
| 11 | #include <cpu/x86/mtrr.h> |
Fred Reitberger | 135f9eb | 2022-03-24 07:43:17 -0400 | [diff] [blame] | 12 | #include <acpi/acpi.h> |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 13 | #include <device/device.h> |
| 14 | #include <soc/cpu.h> |
| 15 | #include <soc/iomap.h> |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 16 | |
Felix Held | d40e8b6 | 2022-02-07 17:25:44 +0100 | [diff] [blame] | 17 | _Static_assert(CONFIG_MAX_CPUS == 8, "Do not override MAX_CPUS. To reduce the number of " |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 18 | "available cores, use the downcore_mode and disable_smt devicetree settings instead."); |
| 19 | |
| 20 | /* MP and SMM loading initialization */ |
| 21 | |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 22 | void mp_init_cpus(struct bus *cpu_bus) |
| 23 | { |
Arthur Heymans | e48dcb7 | 2022-05-31 21:48:15 +0200 | [diff] [blame] | 24 | extern const struct mp_ops amd_mp_ops_with_smm; |
| 25 | if (mp_init_with_smm(cpu_bus, &amd_mp_ops_with_smm) != CB_SUCCESS) |
lilacious | 40cb3fe | 2023-06-21 23:24:14 +0200 | [diff] [blame^] | 26 | die_with_post_code(POSTCODE_HW_INIT_FAILURE, |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 27 | "mp_init_with_smm failed. Halting.\n"); |
| 28 | |
| 29 | /* 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] | 30 | mtrr_use_temp_range(FLASH_BELOW_4GB_MAPPING_REGION_BASE, |
| 31 | FLASH_BELOW_4GB_MAPPING_REGION_SIZE, MTRR_TYPE_WRPROT); |
Arthur Heymans | a19bc34 | 2022-05-31 21:25:53 +0200 | [diff] [blame] | 32 | |
| 33 | /* SMMINFO only needs to be set up when booting from S5 */ |
| 34 | if (!acpi_is_wakeup_s3()) |
| 35 | apm_control(APM_CNT_SMMINFO); |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | static void zen_2_3_init(struct device *dev) |
| 39 | { |
| 40 | check_mca(); |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 41 | set_cstate_io_addr(); |
| 42 | |
Grzegorz Bernacki | d34dbe5 | 2023-04-25 15:30:14 +0000 | [diff] [blame] | 43 | amd_apply_microcode_patch(); |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | static struct device_operations cpu_dev_ops = { |
| 47 | .init = zen_2_3_init, |
| 48 | }; |
| 49 | |
| 50 | static struct cpu_device_id cpu_table[] = { |
Felix Held | 309043e | 2023-02-06 17:25:35 +0100 | [diff] [blame] | 51 | { X86_VENDOR_AMD, MENDOCINO_A0_CPUID, CPUID_ALL_STEPPINGS_MASK }, |
Felix Held | 1e78165 | 2023-02-08 11:39:16 +0100 | [diff] [blame] | 52 | CPU_TABLE_END |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | static const struct cpu_driver zen_2_3 __cpu_driver = { |
| 56 | .ops = &cpu_dev_ops, |
| 57 | .id_table = cpu_table, |
| 58 | }; |