1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2016 Google, Inc
5 * Based on code from coreboot src/soc/intel/broadwell/cpu.c
14 #include <asm/cpu_x86.h>
15 #include <asm/cpu_common.h>
16 #include <asm/intel_regs.h>
17 #include <asm/lpc_common.h>
21 #include <asm/turbo.h>
22 #include <asm/arch/cpu.h>
23 #include <asm/arch/pch.h>
24 #include <asm/arch/rcb.h>
26 int arch_cpu_init_dm(void)
31 /* Start up the LPC so we have serial */
32 ret = uclass_first_device(UCLASS_LPC, &dev);
37 ret = cpu_set_flex_ratio_to_tdp_nominal();
44 void set_max_freq(void)
48 if (cpu_config_tdp_levels()) {
49 /* Set to nominal TDP ratio */
50 msr = msr_read(MSR_CONFIG_TDP_NOMINAL);
51 perf_ctl.lo = (msr.lo & 0xff) << 8;
53 /* Platform Info bits 15:8 give max ratio */
54 msr = msr_read(MSR_PLATFORM_INFO);
55 perf_ctl.lo = msr.lo & 0xff00;
59 msr_write(MSR_IA32_PERF_CTL, perf_ctl);
61 debug("CPU: frequency set to %d MHz\n",
62 ((perf_ctl.lo >> 8) & 0xff) * INTEL_BCLK_MHZ);
65 int arch_cpu_init(void)
67 post_code(POST_CPU_INIT);
70 /* Do a mini-init if TPL has already done the full init */
71 return x86_cpu_reinit_f();
73 return x86_cpu_init_f();
83 ret = cpu_common_init();
86 gd->arch.pei_boot_mode = PEI_BOOT_NONE;
91 int print_cpuinfo(void)
93 char processor_name[CPU_MAX_NAME_LEN];
96 /* Print processor name */
97 name = cpu_get_name(processor_name);
98 printf("CPU: %s\n", name);
103 void board_debug_uart_init(void)
105 /* com1 / com2 decode range */
106 pci_x86_write_config(PCH_DEV_LPC, LPC_IO_DEC, 1 << 4, PCI_SIZE_16);
108 pci_x86_write_config(PCH_DEV_LPC, LPC_EN, COMA_LPC_EN, PCI_SIZE_16);