blob: 6754bba5b92891ed98bdb74c94b1a658969db75b [file] [log] [blame]
Felix Held060b8ad2021-02-05 22:51:33 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2
Felix Heldaa77d132021-02-10 16:13:56 +01003#include <amdblocks/cpu.h>
Felix Held7aacdd12021-02-10 23:27:47 +01004#include <amdblocks/smm.h>
Felix Held060b8ad2021-02-05 22:51:33 +01005#include <console/console.h>
Raul E Rangel35dc4b02021-02-12 16:04:27 -07006#include <cpu/amd/microcode.h>
Felix Held060b8ad2021-02-05 22:51:33 +01007#include <cpu/cpu.h>
Felix Heldaa77d132021-02-10 16:13:56 +01008#include <cpu/x86/lapic.h>
Felix Held7aacdd12021-02-10 23:27:47 +01009#include <cpu/x86/mp.h>
10#include <cpu/x86/mtrr.h>
11#include <cpu/x86/smm.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>
15#include <soc/reset.h>
16
17/* MP and SMM loading initialization */
18
19/*
20 * Do essential initialization tasks before APs can be fired up -
21 *
22 * 1. Prevent race condition in MTRR solution. Enable MTRRs on the BSP. This
23 * creates the MTRR solution that the APs will use. Otherwise APs will try to
24 * apply the incomplete solution as the BSP is calculating it.
25 */
26static void pre_mp_init(void)
27{
28 x86_setup_mtrrs_with_detect_no_above_4gb();
29 x86_mtrr_check();
30}
31
32static void post_mp_init(void)
33{
34 global_smi_enable();
35 apm_control(APM_CNT_SMMINFO);
36}
37
38static const struct mp_ops mp_ops = {
39 .pre_mp_init = pre_mp_init,
40 .get_cpu_count = get_cpu_count,
41 .get_smm_info = get_smm_info,
42 .relocation_handler = smm_relocation_handler,
43 .post_mp_init = post_mp_init,
44};
Felix Held060b8ad2021-02-05 22:51:33 +010045
Felix Heldb2d8a5c2021-02-10 16:17:13 +010046void mp_init_cpus(struct bus *cpu_bus)
47{
Felix Held7aacdd12021-02-10 23:27:47 +010048 /* Clear for take-off */
49 if (mp_init_with_smm(cpu_bus, &mp_ops) < 0)
50 printk(BIOS_ERR, "MP initialization failure.\n");
51
52 /* pre_mp_init made the flash not cacheable. Reset to WP for performance. */
53 mtrr_use_temp_range(FLASH_BASE_ADDR, CONFIG_ROM_SIZE, MTRR_TYPE_WRPROT);
54
55 set_warm_reset_flag();
Felix Heldb2d8a5c2021-02-10 16:17:13 +010056}
57
Felix Held060b8ad2021-02-05 22:51:33 +010058static void zen_2_3_init(struct device *dev)
59{
Felix Heldaa77d132021-02-10 16:13:56 +010060 setup_lapic();
61 set_cstate_io_addr();
Raul E Rangel35dc4b02021-02-12 16:04:27 -070062
63 amd_update_microcode_from_cbfs();
Felix Held060b8ad2021-02-05 22:51:33 +010064}
65
66static struct device_operations cpu_dev_ops = {
67 .init = zen_2_3_init,
68};
69
70static struct cpu_device_id cpu_table[] = {
71 { X86_VENDOR_AMD, CEZANNE_A0_CPUID},
72 { 0, 0 },
73};
74
75static const struct cpu_driver zen_2_3 __cpu_driver = {
76 .ops = &cpu_dev_ops,
77 .id_table = cpu_table,
78};