blob: 47c71ab139e4c800f165dab48a160af9b3816934 [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)
Felix Held28a0a142021-11-02 17:15:58 +010025 die_with_post_code(POST_HW_INIT_FAILURE,
26 "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
43 amd_update_microcode_from_cbfs();
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 Held53c173e2020-11-05 17:24:18 +010051 { X86_VENDOR_AMD, RAVEN1_B0_CPUID},
Felix Heldab114c92020-05-22 02:40:40 +020052 { X86_VENDOR_AMD, PICASSO_B0_CPUID },
53 { X86_VENDOR_AMD, PICASSO_B1_CPUID },
54 { X86_VENDOR_AMD, RAVEN2_A0_CPUID },
55 { X86_VENDOR_AMD, RAVEN2_A1_CPUID },
Martin Roth5c354b92019-04-22 14:55:16 -060056 { 0, 0 },
57};
58
Marshall Dawson34c30562019-07-16 15:18:00 -060059static const struct cpu_driver model_17 __cpu_driver = {
Martin Roth5c354b92019-04-22 14:55:16 -060060 .ops = &cpu_dev_ops,
61 .id_table = cpu_table,
62};