mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-11 22:03:15 +00:00
83d290c56f
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
112 lines
2.5 KiB
C
112 lines
2.5 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (c) 2016 Google, Inc
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <errno.h>
|
|
#include <asm/cpu_common.h>
|
|
#include <asm/intel_regs.h>
|
|
#include <asm/lapic.h>
|
|
#include <asm/lpc_common.h>
|
|
#include <asm/msr.h>
|
|
#include <asm/mtrr.h>
|
|
#include <asm/post.h>
|
|
#include <asm/microcode.h>
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
static int report_bist_failure(void)
|
|
{
|
|
if (gd->arch.bist != 0) {
|
|
post_code(POST_BIST_FAILURE);
|
|
printf("BIST failed: %08x\n", gd->arch.bist);
|
|
return -EFAULT;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int cpu_common_init(void)
|
|
{
|
|
struct udevice *dev, *lpc;
|
|
int ret;
|
|
|
|
/* Halt if there was a built in self test failure */
|
|
ret = report_bist_failure();
|
|
if (ret)
|
|
return ret;
|
|
|
|
enable_lapic();
|
|
|
|
ret = microcode_update_intel();
|
|
if (ret && ret != -EEXIST) {
|
|
debug("%s: Microcode update failure (err=%d)\n", __func__, ret);
|
|
return ret;
|
|
}
|
|
|
|
/* Enable upper 128bytes of CMOS */
|
|
writel(1 << 2, RCB_REG(RC));
|
|
|
|
/* Early chipset init required before RAM init can work */
|
|
uclass_first_device(UCLASS_NORTHBRIDGE, &dev);
|
|
|
|
ret = uclass_first_device(UCLASS_LPC, &lpc);
|
|
if (ret)
|
|
return ret;
|
|
if (!lpc)
|
|
return -ENODEV;
|
|
|
|
/* Cause the SATA device to do its early init */
|
|
uclass_first_device(UCLASS_AHCI, &dev);
|
|
|
|
return 0;
|
|
}
|
|
|
|
int cpu_set_flex_ratio_to_tdp_nominal(void)
|
|
{
|
|
msr_t flex_ratio, msr;
|
|
u8 nominal_ratio;
|
|
|
|
/* Check for Flex Ratio support */
|
|
flex_ratio = msr_read(MSR_FLEX_RATIO);
|
|
if (!(flex_ratio.lo & FLEX_RATIO_EN))
|
|
return -EINVAL;
|
|
|
|
/* Check for >0 configurable TDPs */
|
|
msr = msr_read(MSR_PLATFORM_INFO);
|
|
if (((msr.hi >> 1) & 3) == 0)
|
|
return -EINVAL;
|
|
|
|
/* Use nominal TDP ratio for flex ratio */
|
|
msr = msr_read(MSR_CONFIG_TDP_NOMINAL);
|
|
nominal_ratio = msr.lo & 0xff;
|
|
|
|
/* See if flex ratio is already set to nominal TDP ratio */
|
|
if (((flex_ratio.lo >> 8) & 0xff) == nominal_ratio)
|
|
return 0;
|
|
|
|
/* Set flex ratio to nominal TDP ratio */
|
|
flex_ratio.lo &= ~0xff00;
|
|
flex_ratio.lo |= nominal_ratio << 8;
|
|
flex_ratio.lo |= FLEX_RATIO_LOCK;
|
|
msr_write(MSR_FLEX_RATIO, flex_ratio);
|
|
|
|
/* Set flex ratio in soft reset data register bits 11:6 */
|
|
clrsetbits_le32(RCB_REG(SOFT_RESET_DATA), 0x3f << 6,
|
|
(nominal_ratio & 0x3f) << 6);
|
|
|
|
debug("CPU: Soft reset to set up flex ratio\n");
|
|
|
|
/* Set soft reset control to use register value */
|
|
setbits_le32(RCB_REG(SOFT_RESET_CTRL), 1);
|
|
|
|
/* Issue warm reset, will be "CPU only" due to soft reset data */
|
|
outb(0x0, IO_PORT_RESET);
|
|
outb(SYS_RST | RST_CPU, IO_PORT_RESET);
|
|
cpu_hlt();
|
|
|
|
/* Not reached */
|
|
return -EINVAL;
|
|
}
|