blob: be767dcd18fac5df9ac0c552498449b787aca0a6 [file] [log] [blame]
Angel Ponsae593872020-04-04 18:50:57 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Martin Roth5c354b92019-04-22 14:55:16 -06002
Arthur Heymans615818f2022-05-31 21:33:43 +02003#include <acpi/acpi.h>
Felix Helddd2f3fa2021-02-08 22:23:54 +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>
Martin Roth5c354b92019-04-22 14:55:16 -06007#include <console/console.h>
Zheng Bao6ba591b2020-06-09 09:47:06 +08008#include <cpu/amd/microcode.h>
Arthur Heymans615818f2022-05-31 21:33:43 +02009#include <cpu/cpu.h>
10#include <cpu/x86/mp.h>
Arthur Heymans615818f2022-05-31 21:33:43 +020011#include <cpu/x86/mtrr.h>
Arthur Heymans615818f2022-05-31 21:33:43 +020012#include <device/device.h>
Arthur Heymans615818f2022-05-31 21:33:43 +020013#include <soc/cpu.h>
14#include <soc/iomap.h>
Martin Roth5c354b92019-04-22 14:55:16 -060015
Felix Heldf142ba52021-04-22 18:26:43 +020016_Static_assert(CONFIG_MAX_CPUS == 8, "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 Held79f5feb2021-04-22 18:49:49 +020019/* MP and SMM loading initialization. */
Martin Roth5c354b92019-04-22 14:55:16 -060020
Kyösti Mälkki79e12ab2020-05-31 09:21:07 +030021void mp_init_cpus(struct bus *cpu_bus)
Martin Roth5c354b92019-04-22 14:55:16 -060022{
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");
Martin Roth5c354b92019-04-22 14:55:16 -060027
Raul E Rangel93375f22020-06-05 15:48:21 -060028 /* 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);
35
Martin Roth5c354b92019-04-22 14:55:16 -060036}
37
Marshall Dawson34c30562019-07-16 15:18:00 -060038static void model_17_init(struct device *dev)
Martin Roth5c354b92019-04-22 14:55:16 -060039{
40 check_mca();
Chris Wange2497d02020-08-03 22:36:13 +080041 set_cstate_io_addr();
Zheng Bao6ba591b2020-06-09 09:47:06 +080042
Grzegorz Bernackid34dbe52023-04-25 15:30:14 +000043 amd_apply_microcode_patch();
Martin Roth5c354b92019-04-22 14:55:16 -060044}
45
46static struct device_operations cpu_dev_ops = {
Marshall Dawson34c30562019-07-16 15:18:00 -060047 .init = model_17_init,
Martin Roth5c354b92019-04-22 14:55:16 -060048};
49
50static struct cpu_device_id cpu_table[] = {
Felix Heldcf9b0692023-02-06 17:04:54 +010051 { X86_VENDOR_AMD, RAVEN1_B0_CPUID, CPUID_ALL_STEPPINGS_MASK },
52 { X86_VENDOR_AMD, PICASSO_B0_CPUID, CPUID_ALL_STEPPINGS_MASK },
53 { X86_VENDOR_AMD, RAVEN2_A0_CPUID, CPUID_ALL_STEPPINGS_MASK },
Felix Held1e781652023-02-08 11:39:16 +010054 CPU_TABLE_END
Martin Roth5c354b92019-04-22 14:55:16 -060055};
56
Marshall Dawson34c30562019-07-16 15:18:00 -060057static const struct cpu_driver model_17 __cpu_driver = {
Martin Roth5c354b92019-04-22 14:55:16 -060058 .ops = &cpu_dev_ops,
59 .id_table = cpu_table,
60};