From 66fe0c43be7d886bec8c8aef55c406a53e65642e Mon Sep 17 00:00:00 2001 From: Barnali Sarkar Date: Tue, 23 May 2017 18:17:14 +0530 Subject: soc/intel/apollolake: Use CPU common library code This patch makes SOC files to use common/block/cpu/cpulib.c file's helper functions. Change-Id: I529c67cf20253cf819d1c13849300788104b083c Signed-off-by: Barnali Sarkar Reviewed-on: https://review.coreboot.org/19827 Reviewed-by: Aaron Durbin Reviewed-by: Subrata Banik Tested-by: build bot (Jenkins) --- src/soc/intel/apollolake/Kconfig | 1 + src/soc/intel/apollolake/Makefile.inc | 6 --- src/soc/intel/apollolake/bootblock/bootblock.c | 1 + src/soc/intel/apollolake/car.c | 3 +- src/soc/intel/apollolake/chip.c | 6 ++- src/soc/intel/apollolake/cpu.c | 9 +--- src/soc/intel/apollolake/include/soc/cpu.h | 13 ------ src/soc/intel/apollolake/include/soc/romstage.h | 1 + src/soc/intel/apollolake/pmutil.c | 1 + src/soc/intel/apollolake/romstage.c | 22 +++++++++ src/soc/intel/apollolake/tsc_freq.c | 62 ------------------------- 11 files changed, 34 insertions(+), 91 deletions(-) delete mode 100644 src/soc/intel/apollolake/tsc_freq.c (limited to 'src/soc') diff --git a/src/soc/intel/apollolake/Kconfig b/src/soc/intel/apollolake/Kconfig index a923057d1b..b80941d0dd 100644 --- a/src/soc/intel/apollolake/Kconfig +++ b/src/soc/intel/apollolake/Kconfig @@ -55,6 +55,7 @@ config CPU_SPECIFIC_OPTIONS select SOC_INTEL_COMMON_ACPI select SOC_INTEL_COMMON_ACPI_WAKE_SOURCE select SOC_INTEL_COMMON_BLOCK + select SOC_INTEL_COMMON_BLOCK_CPU select SOC_INTEL_COMMON_BLOCK_FAST_SPI select SOC_INTEL_COMMON_BLOCK_ITSS select SOC_INTEL_COMMON_BLOCK_I2C diff --git a/src/soc/intel/apollolake/Makefile.inc b/src/soc/intel/apollolake/Makefile.inc index b1f92f04d0..619713876e 100644 --- a/src/soc/intel/apollolake/Makefile.inc +++ b/src/soc/intel/apollolake/Makefile.inc @@ -18,7 +18,6 @@ bootblock-y += lpc_lib.c bootblock-y += mmap_boot.c bootblock-y += pmutil.c bootblock-y += spi.c -bootblock-y += tsc_freq.c bootblock-$(CONFIG_SOC_UART_DEBUG) += uart_early.c bootblock-$(CONFIG_FSP_CAR) += bootblock/cache_as_ram_fsp.S @@ -32,7 +31,6 @@ romstage-y += lpc_lib.c romstage-y += memmap.c romstage-y += meminit.c romstage-y += mmap_boot.c -romstage-y += tsc_freq.c romstage-y += pmutil.c romstage-y += reset.c romstage-y += spi.c @@ -42,7 +40,6 @@ smm-y += pmutil.c smm-y += gpio.c smm-y += smihandler.c smm-y += spi.c -smm-y += tsc_freq.c smm-y += uart_early.c ramstage-$(CONFIG_HAVE_ACPI_TABLES) += acpi.c @@ -65,7 +62,6 @@ ramstage-y += uart.c ramstage-y += nhlt.c ramstage-y += systemagent.c ramstage-y += spi.c -ramstage-y += tsc_freq.c ramstage-y += pmutil.c ramstage-y += pmc.c ramstage-y += reset.c @@ -79,7 +75,6 @@ postcar-y += memmap.c postcar-y += mmap_boot.c postcar-y += spi.c postcar-$(CONFIG_SOC_UART_DEBUG) += uart_early.c -postcar-y += tsc_freq.c postcar-$(CONFIG_FSP_CAR) += exit_car_fsp.S @@ -89,7 +84,6 @@ verstage-y += heci.c verstage-y += memmap.c verstage-y += mmap_boot.c verstage-$(CONFIG_SOC_UART_DEBUG) += uart_early.c -verstage-y += tsc_freq.c verstage-y += pmutil.c verstage-y += reset.c verstage-y += spi.c diff --git a/src/soc/intel/apollolake/bootblock/bootblock.c b/src/soc/intel/apollolake/bootblock/bootblock.c index 705567a614..729134b933 100644 --- a/src/soc/intel/apollolake/bootblock/bootblock.c +++ b/src/soc/intel/apollolake/bootblock/bootblock.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include diff --git a/src/soc/intel/apollolake/car.c b/src/soc/intel/apollolake/car.c index 2d2f7a0721..f46e0f89ec 100644 --- a/src/soc/intel/apollolake/car.c +++ b/src/soc/intel/apollolake/car.c @@ -17,8 +17,9 @@ #include #include +#include +#include #include -#include /* * This file supports the necessary hoops one needs to jump through since diff --git a/src/soc/intel/apollolake/chip.c b/src/soc/intel/apollolake/chip.c index e7c4d4c2e3..ef29a0311f 100644 --- a/src/soc/intel/apollolake/chip.c +++ b/src/soc/intel/apollolake/chip.c @@ -22,16 +22,18 @@ #include #include #include +#include #include #include #include +#include #include #include +#include #include #include #include #include -#include #include #include #include @@ -547,7 +549,7 @@ struct chip_operations soc_intel_apollolake_ops = { static void drop_privilege_all(void) { /* Drop privilege level on all the CPUs */ - if (mp_run_on_all_cpus(&enable_untrusted_mode, 1000) < 0) + if (mp_run_on_all_cpus(&cpu_enable_untrusted_mode, 1000) < 0) printk(BIOS_ERR, "failed to enable untrusted mode\n"); } diff --git a/src/soc/intel/apollolake/cpu.c b/src/soc/intel/apollolake/cpu.c index 0919dfb3f7..ec202e4e29 100644 --- a/src/soc/intel/apollolake/cpu.c +++ b/src/soc/intel/apollolake/cpu.c @@ -28,7 +28,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -58,13 +60,6 @@ static const struct reg_script core_msr_script[] = { REG_SCRIPT_END }; -void enable_untrusted_mode(void) -{ - msr_t msr = rdmsr(MSR_POWER_MISC); - msr.lo |= ENABLE_IA_UNTRUSTED; - wrmsr(MSR_POWER_MISC, msr); -} - static void soc_core_init(device_t cpu) { /* Set core MSRs */ diff --git a/src/soc/intel/apollolake/include/soc/cpu.h b/src/soc/intel/apollolake/include/soc/cpu.h index 54fcf52625..0e73d115f4 100644 --- a/src/soc/intel/apollolake/include/soc/cpu.h +++ b/src/soc/intel/apollolake/include/soc/cpu.h @@ -18,23 +18,10 @@ #ifndef _SOC_APOLLOLAKE_CPU_H_ #define _SOC_APOLLOLAKE_CPU_H_ -#include - -#ifndef __ASSEMBLER__ -#include -#include - -void set_max_freq(void); -void enable_untrusted_mode(void); -#endif - #define CPUID_APOLLOLAKE_A0 0x506c8 #define CPUID_APOLLOLAKE_B0 0x506c9 /* Common Timer Copy (CTC) frequency - 19.2MHz. */ #define CTC_FREQ 19200000 -/* This is burst mode BIT 38 in MSR_IA32_MISC_ENABLES MSR at offset 1A0h */ -#define APL_BURST_MODE_DISABLE 0x40 - #endif /* _SOC_APOLLOLAKE_CPU_H_ */ diff --git a/src/soc/intel/apollolake/include/soc/romstage.h b/src/soc/intel/apollolake/include/soc/romstage.h index 6ae46b69dd..fe3add6eee 100644 --- a/src/soc/intel/apollolake/include/soc/romstage.h +++ b/src/soc/intel/apollolake/include/soc/romstage.h @@ -21,6 +21,7 @@ #include #include +void set_max_freq(void); void mainboard_memory_init_params(FSPM_UPD *mupd); void mainboard_save_dimm_info(void); diff --git a/src/soc/intel/apollolake/pmutil.c b/src/soc/intel/apollolake/pmutil.c index 3ceb066dd7..bf89a09726 100644 --- a/src/soc/intel/apollolake/pmutil.c +++ b/src/soc/intel/apollolake/pmutil.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/src/soc/intel/apollolake/romstage.c b/src/soc/intel/apollolake/romstage.c index 6d04878d7c..79b3cfd7f9 100644 --- a/src/soc/intel/apollolake/romstage.c +++ b/src/soc/intel/apollolake/romstage.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -188,6 +189,27 @@ static bool punit_init(void) return true; } +void set_max_freq(void) +{ + if (cpu_get_burst_mode_state() == BURST_MODE_UNAVAILABLE) { + /* Burst Mode has been factory configured as disabled + * and is not available in this physical processor + * package. + */ + printk(BIOS_DEBUG, "Burst Mode is factory disabled\n"); + return; + } + + /* Enable burst mode */ + cpu_enable_burst_mode(); + + /* Enable speed step. */ + cpu_enable_eist(); + + /* Set P-State ratio */ + cpu_set_p_state_to_turbo_ratio(); +} + asmlinkage void car_stage_entry(void) { struct postcar_frame pcf; diff --git a/src/soc/intel/apollolake/tsc_freq.c b/src/soc/intel/apollolake/tsc_freq.c deleted file mode 100644 index 18d28d80f0..0000000000 --- a/src/soc/intel/apollolake/tsc_freq.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright (C) 2015 Intel Corp. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include -#include "chip.h" - -void set_max_freq(void) -{ - msr_t msr, msr_rd; - unsigned int eax; - - eax = cpuid_eax(CPUID_LEAF_PM); - - msr = rdmsr(MSR_IA32_MISC_ENABLES); - eax &= 0x2; - if ((!eax) && ((msr.hi & APL_BURST_MODE_DISABLE) == 0)) { - /* Burst Mode has been factory configured as disabled - * and is not available in this physical processor - * package. - */ - printk(BIOS_DEBUG, "Burst Mode is factory disabled\n"); - return; - } - - /* Enable burst mode */ - msr.hi &= ~APL_BURST_MODE_DISABLE; - wrmsr(MSR_IA32_MISC_ENABLES, msr); - - /* Enable speed step. */ - msr = rdmsr(MSR_IA32_MISC_ENABLES); - msr.lo |= 1 << 16; - wrmsr(MSR_IA32_MISC_ENABLES, msr); - - /* Set P-State ratio */ - msr = rdmsr(IA32_PERF_CTL); - msr.lo &= ~0xff00; - - /* Read the frequency limit ratio and set it properly in PERF_CTL */ - msr_rd = rdmsr(FREQ_LIMIT_RATIO); - msr.lo |= (msr_rd.lo & 0xff) << 8; - - wrmsr(IA32_PERF_CTL, msr); -} -- cgit v1.2.3