2020-04-04 18:50:57 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2019-04-22 22:55:16 +02:00
|
|
|
|
2021-02-08 22:23:54 +01:00
|
|
|
#include <amdblocks/cpu.h>
|
2021-03-10 15:47:00 +01:00
|
|
|
#include <amdblocks/reset.h>
|
2021-02-10 02:26:10 +01:00
|
|
|
#include <amdblocks/smm.h>
|
2019-04-22 22:55:16 +02:00
|
|
|
#include <cpu/cpu.h>
|
|
|
|
#include <cpu/x86/mp.h>
|
|
|
|
#include <cpu/x86/mtrr.h>
|
|
|
|
#include <cpu/x86/msr.h>
|
2019-08-04 18:54:32 +02:00
|
|
|
#include <cpu/x86/smm.h>
|
2019-04-22 22:55:16 +02:00
|
|
|
#include <cpu/x86/lapic.h>
|
|
|
|
#include <device/device.h>
|
|
|
|
#include <device/pci_ops.h>
|
|
|
|
#include <soc/pci_devs.h>
|
|
|
|
#include <soc/cpu.h>
|
|
|
|
#include <soc/smi.h>
|
|
|
|
#include <soc/iomap.h>
|
|
|
|
#include <console/console.h>
|
2020-06-09 03:47:06 +02:00
|
|
|
#include <cpu/amd/microcode.h>
|
2019-04-22 22:55:16 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* MP and SMM loading initialization.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do essential initialization tasks before APs can be fired up -
|
|
|
|
*
|
|
|
|
* 1. Prevent race condition in MTRR solution. Enable MTRRs on the BSP. This
|
|
|
|
* creates the MTRR solution that the APs will use. Otherwise APs will try to
|
|
|
|
* apply the incomplete solution as the BSP is calculating it.
|
|
|
|
*/
|
|
|
|
static void pre_mp_init(void)
|
|
|
|
{
|
2020-05-28 18:19:18 +02:00
|
|
|
x86_setup_mtrrs_with_detect_no_above_4gb();
|
2019-04-22 22:55:16 +02:00
|
|
|
x86_mtrr_check();
|
|
|
|
}
|
|
|
|
|
2020-07-01 14:59:20 +02:00
|
|
|
static void post_mp_init(void)
|
|
|
|
{
|
|
|
|
global_smi_enable();
|
|
|
|
apm_control(APM_CNT_SMMINFO);
|
|
|
|
}
|
|
|
|
|
2019-04-22 22:55:16 +02:00
|
|
|
static const struct mp_ops mp_ops = {
|
|
|
|
.pre_mp_init = pre_mp_init,
|
|
|
|
.get_cpu_count = get_cpu_count,
|
|
|
|
.get_smm_info = get_smm_info,
|
2021-02-10 02:26:10 +01:00
|
|
|
.relocation_handler = smm_relocation_handler,
|
2020-07-01 14:59:20 +02:00
|
|
|
.post_mp_init = post_mp_init,
|
2019-04-22 22:55:16 +02:00
|
|
|
};
|
|
|
|
|
2020-05-31 08:21:07 +02:00
|
|
|
void mp_init_cpus(struct bus *cpu_bus)
|
2019-04-22 22:55:16 +02:00
|
|
|
{
|
|
|
|
/* Clear for take-off */
|
2020-05-31 08:21:07 +02:00
|
|
|
if (mp_init_with_smm(cpu_bus, &mp_ops) < 0)
|
2019-04-22 22:55:16 +02:00
|
|
|
printk(BIOS_ERR, "MP initialization failure.\n");
|
|
|
|
|
2020-06-05 23:48:21 +02:00
|
|
|
/* pre_mp_init made the flash not cacheable. Reset to WP for performance. */
|
2019-04-22 22:55:16 +02:00
|
|
|
mtrr_use_temp_range(FLASH_BASE_ADDR, CONFIG_ROM_SIZE, MTRR_TYPE_WRPROT);
|
|
|
|
|
|
|
|
set_warm_reset_flag();
|
|
|
|
}
|
|
|
|
|
2019-07-16 23:18:00 +02:00
|
|
|
static void model_17_init(struct device *dev)
|
2019-04-22 22:55:16 +02:00
|
|
|
{
|
|
|
|
check_mca();
|
|
|
|
setup_lapic();
|
2020-08-03 16:36:13 +02:00
|
|
|
set_cstate_io_addr();
|
2020-06-09 03:47:06 +02:00
|
|
|
|
|
|
|
amd_update_microcode_from_cbfs();
|
2019-04-22 22:55:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct device_operations cpu_dev_ops = {
|
2019-07-16 23:18:00 +02:00
|
|
|
.init = model_17_init,
|
2019-04-22 22:55:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct cpu_device_id cpu_table[] = {
|
2020-11-05 17:24:18 +01:00
|
|
|
{ X86_VENDOR_AMD, RAVEN1_B0_CPUID},
|
2020-05-22 02:40:40 +02:00
|
|
|
{ X86_VENDOR_AMD, PICASSO_B0_CPUID },
|
|
|
|
{ X86_VENDOR_AMD, PICASSO_B1_CPUID },
|
|
|
|
{ X86_VENDOR_AMD, RAVEN2_A0_CPUID },
|
|
|
|
{ X86_VENDOR_AMD, RAVEN2_A1_CPUID },
|
2019-04-22 22:55:16 +02:00
|
|
|
{ 0, 0 },
|
|
|
|
};
|
|
|
|
|
2019-07-16 23:18:00 +02:00
|
|
|
static const struct cpu_driver model_17 __cpu_driver = {
|
2019-04-22 22:55:16 +02:00
|
|
|
.ops = &cpu_dev_ops,
|
|
|
|
.id_table = cpu_table,
|
|
|
|
};
|