blob: 195ef158102d272aa0c4092193f0c5f2ec95156d [file] [log] [blame]
Angel Ponsf23ae0b2020-04-02 23:48:12 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer5c554632012-04-04 00:09:50 +02002
3#ifndef _CPU_INTEL_MODEL_206AX_H
4#define _CPU_INTEL_MODEL_206AX_H
5
Angel Pons964d91f2020-12-07 13:11:17 +01006#include <arch/cpu.h>
Elyes HAOUASdfbe6bd2018-10-29 06:56:52 +01007#include <stdint.h>
8
Angel Pons47a80a02020-12-07 13:15:23 +01009/* SandyBridge CPU stepping */
10#define SNB_STEP_D0 5 /* Also J0 */
11#define SNB_STEP_D1 6
12#define SNB_STEP_D2 7 /* Also J1/Q0 */
13
14/* IvyBridge CPU stepping */
15#define IVB_STEP_A0 0
16#define IVB_STEP_B0 2
17#define IVB_STEP_C0 4
18#define IVB_STEP_K0 5
19#define IVB_STEP_D0 6
20
21#define IS_SANDY_CPU(x) ((x & 0xffff0) == 0x206a0)
22#define IS_SANDY_CPU_C(x) ((x & 0xf) == 4)
23#define IS_SANDY_CPU_D0(x) ((x & 0xf) == 5)
24#define IS_SANDY_CPU_D1(x) ((x & 0xf) == 6)
25#define IS_SANDY_CPU_D2(x) ((x & 0xf) == 7)
26
27#define IS_IVY_CPU(x) ((x & 0xffff0) == 0x306a0)
28#define IS_IVY_CPU_C(x) ((x & 0xf) == 4)
29#define IS_IVY_CPU_K(x) ((x & 0xf) == 5)
30#define IS_IVY_CPU_D(x) ((x & 0xf) == 6)
31#define IS_IVY_CPU_E(x) ((x & 0xf) >= 8)
32
Stefan Reinauerc0f2cfb2012-07-10 17:16:10 -070033/* SandyBridge/IvyBridge bus clock is fixed at 100MHz */
Stefan Reinauer5c554632012-04-04 00:09:50 +020034#define SANDYBRIDGE_BCLK 100
35
Elyes HAOUASa6a396d2019-05-26 13:25:30 +020036#define MSR_CORE_THREAD_COUNT 0x35
Stefan Reinauer5c554632012-04-04 00:09:50 +020037#define MSR_FEATURE_CONFIG 0x13c
Duncan Laurie22935e12012-07-09 09:58:35 -070038#define MSR_FLEX_RATIO 0x194
39#define FLEX_RATIO_LOCK (1 << 20)
40#define FLEX_RATIO_EN (1 << 16)
Duncan Laurie55632112012-07-16 12:19:00 -070041#define MSR_TEMPERATURE_TARGET 0x1a2
Stefan Reinauer5c554632012-04-04 00:09:50 +020042#define MSR_LT_LOCK_MEMORY 0x2e7
Stefan Reinauer5c554632012-04-04 00:09:50 +020043#define MSR_PLATFORM_INFO 0xce
44#define PLATFORM_INFO_SET_TDP (1 << 29)
Stefan Reinauer5c554632012-04-04 00:09:50 +020045
46#define MSR_MISC_PWR_MGMT 0x1aa
47#define MISC_PWR_MGMT_EIST_HW_DIS (1 << 0)
48#define MSR_TURBO_RATIO_LIMIT 0x1ad
49#define MSR_POWER_CTL 0x1fc
50
51#define MSR_PKGC3_IRTL 0x60a
52#define MSR_PKGC6_IRTL 0x60b
53#define MSR_PKGC7_IRTL 0x60c
54#define IRTL_VALID (1 << 15)
55#define IRTL_1_NS (0 << 10)
56#define IRTL_32_NS (1 << 10)
57#define IRTL_1024_NS (2 << 10)
58#define IRTL_32768_NS (3 << 10)
59#define IRTL_1048576_NS (4 << 10)
60#define IRTL_33554432_NS (5 << 10)
61#define IRTL_RESPONSE_MASK (0x3ff)
62
63/* long duration in low dword, short duration in high dword */
64#define MSR_PKG_POWER_LIMIT 0x610
65#define PKG_POWER_LIMIT_MASK 0x7fff
66#define PKG_POWER_LIMIT_EN (1 << 15)
67#define PKG_POWER_LIMIT_CLAMP (1 << 16)
68#define PKG_POWER_LIMIT_TIME_SHIFT 17
69#define PKG_POWER_LIMIT_TIME_MASK 0x7f
70
71#define MSR_PP0_CURRENT_CONFIG 0x601
72#define PP0_CURRENT_LIMIT (112 << 3) /* 112 A */
73#define MSR_PP1_CURRENT_CONFIG 0x602
Duncan Laurie4e4320f2012-06-25 09:53:58 -070074#define PP1_CURRENT_LIMIT_SNB (35 << 3) /* 35 A */
75#define PP1_CURRENT_LIMIT_IVB (50 << 3) /* 50 A */
Stefan Reinauer5c554632012-04-04 00:09:50 +020076#define MSR_PKG_POWER_SKU_UNIT 0x606
77#define MSR_PKG_POWER_SKU 0x614
78#define MSR_PP0_POWER_LIMIT 0x638
79#define MSR_PP1_POWER_LIMIT 0x640
80
Duncan Laurie77dbbac2012-06-25 09:51:59 -070081#define IVB_CONFIG_TDP_MIN_CPUID 0x306a2
82#define MSR_CONFIG_TDP_NOMINAL 0x648
83#define MSR_CONFIG_TDP_LEVEL1 0x649
84#define MSR_CONFIG_TDP_LEVEL2 0x64a
85#define MSR_CONFIG_TDP_CONTROL 0x64b
86#define MSR_TURBO_ACTIVATION_RATIO 0x64c
87
Stefan Reinauer5c554632012-04-04 00:09:50 +020088/* P-state configuration */
89#define PSS_MAX_ENTRIES 8
90#define PSS_RATIO_STEP 2
91#define PSS_LATENCY_TRANSITION 10
92#define PSS_LATENCY_BUSMASTER 10
93
Arthur Heymans67031a52018-02-05 19:08:03 +010094/* Sanity check config options. */
Kyösti Mälkkif6c20682019-08-02 06:14:50 +030095#if (CONFIG_SMM_TSEG_SIZE <= (CONFIG_IED_REGION_SIZE + CONFIG_SMM_RESERVED_SIZE))
96# error "CONFIG_SMM_TSEG_SIZE <= (CONFIG_IED_REGION_SIZE + CONFIG_SMM_RESERVED_SIZE)"
Arthur Heymans67031a52018-02-05 19:08:03 +010097#endif
98#if (CONFIG_SMM_TSEG_SIZE < 0x800000)
99# error "CONFIG_SMM_TSEG_SIZE must at least be 8MiB"
100#endif
101#if ((CONFIG_SMM_TSEG_SIZE & (CONFIG_SMM_TSEG_SIZE - 1)) != 0)
102# error "CONFIG_SMM_TSEG_SIZE is not a power of 2"
103#endif
104#if ((CONFIG_IED_REGION_SIZE & (CONFIG_IED_REGION_SIZE - 1)) != 0)
105# error "CONFIG_IED_REGION_SIZE is not a power of 2"
106#endif
107
Stefan Reinauer5c554632012-04-04 00:09:50 +0200108/* Lock MSRs */
109void intel_model_206ax_finalize_smm(void);
Kyösti Mälkki82c0e7e2019-11-05 19:06:56 +0200110
Stefan Reinauer5c554632012-04-04 00:09:50 +0200111/* Configure power limits for turbo mode */
112void set_power_limits(u8 power_limit_1_time);
Duncan Laurie77dbbac2012-06-25 09:51:59 -0700113int cpu_config_tdp_levels(void);
Patrick Rudolph74203de2017-11-20 11:57:01 +0100114int get_platform_id(void);
Stefan Reinauer5c554632012-04-04 00:09:50 +0200115
Angel Pons964d91f2020-12-07 13:11:17 +0100116static inline u8 cpu_stepping(void)
117{
118 return cpuid_eax(1) & 0xf;
119}
120
Stefan Reinauer5c554632012-04-04 00:09:50 +0200121#endif