blob: 5d6bb169d713d96b2551d17560e4f2c4c661fcee [file] [log] [blame]
Felix Held3c44c622022-01-10 20:57:29 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2
Arthur Heymansa19bc342022-05-31 21:25:53 +02003#include <acpi/acpi.h>
Felix Held3c44c622022-01-10 20:57:29 +01004#include <amdblocks/cpu.h>
Felix Held199b10f2022-08-13 00:29:23 +02005#include <amdblocks/iomap.h>
Felix Held3c44c622022-01-10 20:57:29 +01006#include <amdblocks/mca.h>
Felix Held3c44c622022-01-10 20:57:29 +01007#include <console/console.h>
8#include <cpu/amd/microcode.h>
9#include <cpu/cpu.h>
Felix Held3c44c622022-01-10 20:57:29 +010010#include <cpu/x86/mp.h>
11#include <cpu/x86/mtrr.h>
Fred Reitberger135f9eb2022-03-24 07:43:17 -040012#include <acpi/acpi.h>
Felix Held3c44c622022-01-10 20:57:29 +010013#include <device/device.h>
14#include <soc/cpu.h>
15#include <soc/iomap.h>
Felix Held3c44c622022-01-10 20:57:29 +010016
Felix Heldd40e8b62022-02-07 17:25:44 +010017_Static_assert(CONFIG_MAX_CPUS == 8, "Do not override MAX_CPUS. To reduce the number of "
Felix Held3c44c622022-01-10 20:57:29 +010018 "available cores, use the downcore_mode and disable_smt devicetree settings instead.");
19
20/* MP and SMM loading initialization */
21
Felix Held3c44c622022-01-10 20:57:29 +010022void mp_init_cpus(struct bus *cpu_bus)
23{
Arthur Heymanse48dcb72022-05-31 21:48:15 +020024 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)
lilacious40cb3fe2023-06-21 23:24:14 +020026 die_with_post_code(POSTCODE_HW_INIT_FAILURE,
Felix Held3c44c622022-01-10 20:57:29 +010027 "mp_init_with_smm failed. Halting.\n");
28
29 /* pre_mp_init made the flash not cacheable. Reset to WP for performance. */
Felix Held199b10f2022-08-13 00:29:23 +020030 mtrr_use_temp_range(FLASH_BELOW_4GB_MAPPING_REGION_BASE,
31 FLASH_BELOW_4GB_MAPPING_REGION_SIZE, MTRR_TYPE_WRPROT);
Arthur Heymansa19bc342022-05-31 21:25:53 +020032
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 Held3c44c622022-01-10 20:57:29 +010036}
37
38static void zen_2_3_init(struct device *dev)
39{
40 check_mca();
Felix Held3c44c622022-01-10 20:57:29 +010041 set_cstate_io_addr();
42
Grzegorz Bernackid34dbe52023-04-25 15:30:14 +000043 amd_apply_microcode_patch();
Felix Held3c44c622022-01-10 20:57:29 +010044}
45
46static struct device_operations cpu_dev_ops = {
47 .init = zen_2_3_init,
48};
49
50static struct cpu_device_id cpu_table[] = {
Felix Held309043e2023-02-06 17:25:35 +010051 { X86_VENDOR_AMD, MENDOCINO_A0_CPUID, CPUID_ALL_STEPPINGS_MASK },
Felix Held1e781652023-02-08 11:39:16 +010052 CPU_TABLE_END
Felix Held3c44c622022-01-10 20:57:29 +010053};
54
55static const struct cpu_driver zen_2_3 __cpu_driver = {
56 .ops = &cpu_dev_ops,
57 .id_table = cpu_table,
58};