blob: c1cf6633363497b5f09829d070daf5d19c2adde2 [file] [log] [blame]
Felix Held060b8ad2021-02-05 22:51:33 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2
Arthur Heymanse48dcb72022-05-31 21:48:15 +02003#include <acpi/acpi.h>
Felix Heldaa77d132021-02-10 16:13:56 +01004#include <amdblocks/cpu.h>
Felix Held199b10f2022-08-13 00:29:23 +02005#include <amdblocks/iomap.h>
Felix Heldf1093af2021-07-13 23:00:26 +02006#include <amdblocks/mca.h>
Felix Held060b8ad2021-02-05 22:51:33 +01007#include <console/console.h>
Raul E Rangel35dc4b02021-02-12 16:04:27 -07008#include <cpu/amd/microcode.h>
Felix Held060b8ad2021-02-05 22:51:33 +01009#include <cpu/cpu.h>
Felix Held7aacdd12021-02-10 23:27:47 +010010#include <cpu/x86/mp.h>
11#include <cpu/x86/mtrr.h>
Felix Held060b8ad2021-02-05 22:51:33 +010012#include <device/device.h>
13#include <soc/cpu.h>
Felix Held7aacdd12021-02-10 23:27:47 +010014#include <soc/iomap.h>
Felix Held7aacdd12021-02-10 23:27:47 +010015
Felix Held79f705f2021-04-22 17:08:50 +020016_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 Held7aacdd12021-02-10 23:27:47 +010019/* MP and SMM loading initialization */
20
Felix Heldb2d8a5c2021-02-10 16:17:13 +010021void mp_init_cpus(struct bus *cpu_bus)
22{
Arthur Heymanse48dcb72022-05-31 21:48:15 +020023 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)
lilacious40cb3fe2023-06-21 23:24:14 +020025 die_with_post_code(POSTCODE_HW_INIT_FAILURE,
Felix Held28a0a142021-11-02 17:15:58 +010026 "mp_init_with_smm failed. Halting.\n");
Felix Held7aacdd12021-02-10 23:27:47 +010027
28 /* pre_mp_init made the flash not cacheable. Reset to WP for performance. */
Felix Held199b10f2022-08-13 00:29:23 +020029 mtrr_use_temp_range(FLASH_BELOW_4GB_MAPPING_REGION_BASE,
30 FLASH_BELOW_4GB_MAPPING_REGION_SIZE, MTRR_TYPE_WRPROT);
Arthur Heymansa19bc342022-05-31 21:25:53 +020031
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 Heldb2d8a5c2021-02-10 16:17:13 +010035}
36
Felix Held060b8ad2021-02-05 22:51:33 +010037static void zen_2_3_init(struct device *dev)
38{
Felix Helda24472a2021-07-13 18:21:27 +020039 check_mca();
Felix Heldaa77d132021-02-10 16:13:56 +010040 set_cstate_io_addr();
Raul E Rangel35dc4b02021-02-12 16:04:27 -070041
Grzegorz Bernackid34dbe52023-04-25 15:30:14 +000042 amd_apply_microcode_patch();
Felix Held060b8ad2021-02-05 22:51:33 +010043}
44
45static struct device_operations cpu_dev_ops = {
46 .init = zen_2_3_init,
47};
48
49static struct cpu_device_id cpu_table[] = {
Felix Held4e812bd2023-02-06 17:21:50 +010050 { X86_VENDOR_AMD, CEZANNE_A0_CPUID, CPUID_ALL_STEPPINGS_MASK },
Felix Held1e781652023-02-08 11:39:16 +010051 CPU_TABLE_END
Felix Held060b8ad2021-02-05 22:51:33 +010052};
53
54static const struct cpu_driver zen_2_3 __cpu_driver = {
55 .ops = &cpu_dev_ops,
56 .id_table = cpu_table,
57};