blob: 19327776d97636d10c9e384197ab93768aa0bcc4 [file] [log] [blame]
Martin Roth1a3de8e2022-10-06 15:57:21 -06001/* SPDX-License-Identifier: GPL-2.0-only */
2
Martin Roth20646cd2023-01-04 21:27:06 -07003/* TODO: Update for Phoenix */
Martin Roth1a3de8e2022-10-06 15:57:21 -06004
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 Guru6de377e2023-01-06 00:20:10 +053019_Static_assert(CONFIG_MAX_CPUS == 16, "Do not override MAX_CPUS. To reduce the number of "
Martin Roth1a3de8e2022-10-06 15:57:21 -060020 "available cores, use the downcore_mode and disable_smt devicetree settings instead.");
21
22/* MP and SMM loading initialization */
23
24void 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)
lilacious40cb3fe2023-06-21 23:24:14 +020028 die_with_post_code(POSTCODE_HW_INIT_FAILURE,
Martin Roth1a3de8e2022-10-06 15:57:21 -060029 "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
40static void zen_2_3_init(struct device *dev)
41{
42 check_mca();
43 set_cstate_io_addr();
44
Grzegorz Bernackid34dbe52023-04-25 15:30:14 +000045 amd_apply_microcode_patch();
Martin Roth1a3de8e2022-10-06 15:57:21 -060046}
47
48static struct device_operations cpu_dev_ops = {
49 .init = zen_2_3_init,
50};
51
52static struct cpu_device_id cpu_table[] = {
Felix Held57001492023-02-06 17:46:59 +010053 { X86_VENDOR_AMD, PHOENIX_A0_CPUID, CPUID_ALL_STEPPINGS_MASK },
Felix Helda5d7f162023-02-06 17:27:07 +010054 { X86_VENDOR_AMD, PHOENIX2_A0_CPUID, CPUID_ALL_STEPPINGS_MASK },
Felix Held1e781652023-02-08 11:39:16 +010055 CPU_TABLE_END
Martin Roth1a3de8e2022-10-06 15:57:21 -060056};
57
58static const struct cpu_driver zen_2_3 __cpu_driver = {
59 .ops = &cpu_dev_ops,
60 .id_table = cpu_table,
61};