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
15 #include <asm/cpu_x86.h>
16 #include <asm/cpu_common.h>
17 #include <asm/global_data.h>
18 #include <asm/intel_regs.h>
19 #include <asm/lpc_common.h>
23 #include <asm/turbo.h>
24 #include <asm/arch/cpu.h>
25 #include <asm/arch/pch.h>
26 #include <asm/arch/rcb.h>
28 static int broadwell_init_cpu(void *ctx, struct event *event)
33 /* Start up the LPC so we have serial */
34 ret = uclass_first_device(UCLASS_LPC, &dev);
39 ret = cpu_set_flex_ratio_to_tdp_nominal();
45 EVENT_SPY(EVT_DM_POST_INIT, broadwell_init_cpu);
47 void set_max_freq(void)
51 if (cpu_config_tdp_levels()) {
52 /* Set to nominal TDP ratio */
53 msr = msr_read(MSR_CONFIG_TDP_NOMINAL);
54 perf_ctl.lo = (msr.lo & 0xff) << 8;
56 /* Platform Info bits 15:8 give max ratio */
57 msr = msr_read(MSR_PLATFORM_INFO);
58 perf_ctl.lo = msr.lo & 0xff00;
62 msr_write(MSR_IA32_PERF_CTL, perf_ctl);
64 debug("CPU: frequency set to %d MHz\n",
65 ((perf_ctl.lo >> 8) & 0xff) * INTEL_BCLK_MHZ);
68 int arch_cpu_init(void)
70 post_code(POST_CPU_INIT);
73 /* Do a mini-init if TPL has already done the full init */
74 return x86_cpu_reinit_f();
76 return x86_cpu_init_f();
86 ret = cpu_common_init();
89 gd->arch.pei_boot_mode = PEI_BOOT_NONE;
94 int print_cpuinfo(void)
96 char processor_name[CPU_MAX_NAME_LEN];
99 /* Print processor name */
100 name = cpu_get_name(processor_name);
101 printf("CPU: %s\n", name);
106 void board_debug_uart_init(void)
108 /* com1 / com2 decode range */
109 pci_x86_write_config(PCH_DEV_LPC, LPC_IO_DEC, 1 << 4, PCI_SIZE_16);
111 pci_x86_write_config(PCH_DEV_LPC, LPC_EN, COMA_LPC_EN, PCI_SIZE_16);