2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2016-03-12 05:07:18 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Google, Inc
|
|
|
|
*
|
|
|
|
* Based on code from coreboot src/soc/intel/broadwell/cpu.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <cpu.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2016-03-12 05:07:18 +00:00
|
|
|
#include <asm/cpu.h>
|
|
|
|
#include <asm/cpu_x86.h>
|
|
|
|
#include <asm/cpu_common.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2016-03-12 05:07:18 +00:00
|
|
|
#include <asm/intel_regs.h>
|
2019-04-26 03:58:50 +00:00
|
|
|
#include <asm/lpc_common.h>
|
2016-03-12 05:07:18 +00:00
|
|
|
#include <asm/msr.h>
|
2019-04-26 03:58:50 +00:00
|
|
|
#include <asm/pci.h>
|
2016-03-12 05:07:18 +00:00
|
|
|
#include <asm/post.h>
|
|
|
|
#include <asm/turbo.h>
|
|
|
|
#include <asm/arch/cpu.h>
|
|
|
|
#include <asm/arch/pch.h>
|
|
|
|
#include <asm/arch/rcb.h>
|
|
|
|
|
|
|
|
int arch_cpu_init_dm(void)
|
|
|
|
{
|
|
|
|
struct udevice *dev;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Start up the LPC so we have serial */
|
|
|
|
ret = uclass_first_device(UCLASS_LPC, &dev);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
if (!dev)
|
|
|
|
return -ENODEV;
|
|
|
|
ret = cpu_set_flex_ratio_to_tdp_nominal();
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_max_freq(void)
|
|
|
|
{
|
2019-09-25 14:56:38 +00:00
|
|
|
msr_t msr, perf_ctl;
|
2016-03-12 05:07:18 +00:00
|
|
|
|
2019-09-25 14:56:38 +00:00
|
|
|
if (cpu_config_tdp_levels()) {
|
2016-03-12 05:07:18 +00:00
|
|
|
/* Set to nominal TDP ratio */
|
|
|
|
msr = msr_read(MSR_CONFIG_TDP_NOMINAL);
|
|
|
|
perf_ctl.lo = (msr.lo & 0xff) << 8;
|
|
|
|
} else {
|
|
|
|
/* Platform Info bits 15:8 give max ratio */
|
|
|
|
msr = msr_read(MSR_PLATFORM_INFO);
|
|
|
|
perf_ctl.lo = msr.lo & 0xff00;
|
|
|
|
}
|
|
|
|
|
|
|
|
perf_ctl.hi = 0;
|
2019-09-25 14:56:35 +00:00
|
|
|
msr_write(MSR_IA32_PERF_CTL, perf_ctl);
|
2016-03-12 05:07:18 +00:00
|
|
|
|
|
|
|
debug("CPU: frequency set to %d MHz\n",
|
2019-09-25 14:56:37 +00:00
|
|
|
((perf_ctl.lo >> 8) & 0xff) * INTEL_BCLK_MHZ);
|
2016-03-12 05:07:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int arch_cpu_init(void)
|
|
|
|
{
|
|
|
|
post_code(POST_CPU_INIT);
|
|
|
|
|
2019-09-25 14:11:40 +00:00
|
|
|
#ifdef CONFIG_TPL
|
|
|
|
/* Do a mini-init if TPL has already done the full init */
|
|
|
|
return x86_cpu_reinit_f();
|
|
|
|
#else
|
2016-03-12 05:07:18 +00:00
|
|
|
return x86_cpu_init_f();
|
2019-09-25 14:11:40 +00:00
|
|
|
#endif
|
2016-03-12 05:07:18 +00:00
|
|
|
}
|
|
|
|
|
2017-03-28 16:27:30 +00:00
|
|
|
int checkcpu(void)
|
2016-03-12 05:07:18 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
set_max_freq();
|
|
|
|
|
|
|
|
ret = cpu_common_init();
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
gd->arch.pei_boot_mode = PEI_BOOT_NONE;
|
|
|
|
|
2017-03-28 16:27:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int print_cpuinfo(void)
|
|
|
|
{
|
|
|
|
char processor_name[CPU_MAX_NAME_LEN];
|
|
|
|
const char *name;
|
|
|
|
|
2016-03-12 05:07:18 +00:00
|
|
|
/* Print processor name */
|
|
|
|
name = cpu_get_name(processor_name);
|
|
|
|
printf("CPU: %s\n", name);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-04-26 03:58:50 +00:00
|
|
|
void board_debug_uart_init(void)
|
|
|
|
{
|
|
|
|
/* com1 / com2 decode range */
|
2019-09-01 03:23:18 +00:00
|
|
|
pci_x86_write_config(PCH_DEV_LPC, LPC_IO_DEC, 1 << 4, PCI_SIZE_16);
|
2019-04-26 03:58:50 +00:00
|
|
|
|
2019-09-01 03:23:18 +00:00
|
|
|
pci_x86_write_config(PCH_DEV_LPC, LPC_EN, COMA_LPC_EN, PCI_SIZE_16);
|
2019-04-26 03:58:50 +00:00
|
|
|
}
|