blob: f780f2193d584f12b07466c9c094b9611dbeb88e [file] [log] [blame]
Martin Rothf95a11e2022-10-21 16:43:08 -06001/* SPDX-License-Identifier: GPL-2.0-only */
2
3/* TODO: Update for Glinda */
4
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
19_Static_assert(CONFIG_MAX_CPUS == 8, "Do not override MAX_CPUS. To reduce the number of "
20 "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 Rothf95a11e2022-10-21 16:43:08 -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 Rothf95a11e2022-10-21 16:43:08 -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 Held286c0032023-02-06 17:32:48 +010053 { X86_VENDOR_AMD, GLINDA_A0_CPUID, CPUID_ALL_STEPPINGS_MASK }, /* TODO: Update for Glinda */
Felix Held1e781652023-02-08 11:39:16 +010054 CPU_TABLE_END
Martin Rothf95a11e2022-10-21 16:43:08 -060055};
56
57static const struct cpu_driver zen_2_3 __cpu_driver = {
58 .ops = &cpu_dev_ops,
59 .id_table = cpu_table,
60};