Angel Pons | f23ae0b | 2020-04-02 23:48:12 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 2 | |
| 3 | #include <console/console.h> |
| 4 | #include <device/device.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 5 | #include <acpi/acpi.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 6 | #include <cpu/cpu.h> |
| 7 | #include <cpu/x86/mtrr.h> |
| 8 | #include <cpu/x86/msr.h> |
Aaron Durbin | 014baea | 2014-03-28 22:01:05 -0500 | [diff] [blame] | 9 | #include <cpu/x86/mp.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 10 | #include <cpu/x86/lapic.h> |
| 11 | #include <cpu/intel/microcode.h> |
Kyösti Mälkki | faf20d3 | 2019-08-14 05:41:41 +0300 | [diff] [blame] | 12 | #include <cpu/intel/smm_reloc.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 13 | #include <cpu/intel/speedstep.h> |
| 14 | #include <cpu/intel/turbo.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 15 | #include <cpu/x86/name.h> |
Aaron Durbin | f24262d | 2013-04-10 14:59:21 -0500 | [diff] [blame] | 16 | #include <delay.h> |
Aaron Durbin | 7c35131 | 2013-04-10 14:46:25 -0500 | [diff] [blame] | 17 | #include <northbridge/intel/haswell/haswell.h> |
| 18 | #include <southbridge/intel/lynxpoint/pch.h> |
Matt DeVillier | ed6fe2f | 2016-12-14 16:12:43 -0600 | [diff] [blame] | 19 | #include <cpu/intel/common/common.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 20 | #include "haswell.h" |
| 21 | #include "chip.h" |
| 22 | |
| 23 | /* |
Aaron Durbin | 7c35131 | 2013-04-10 14:46:25 -0500 | [diff] [blame] | 24 | * List of supported C-states in this processor. Only the ULT parts support C8, |
| 25 | * C9, and C10. |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 26 | */ |
Aaron Durbin | 7c35131 | 2013-04-10 14:46:25 -0500 | [diff] [blame] | 27 | enum { |
| 28 | C_STATE_C0, /* 0 */ |
| 29 | C_STATE_C1, /* 1 */ |
| 30 | C_STATE_C1E, /* 2 */ |
| 31 | C_STATE_C3, /* 3 */ |
| 32 | C_STATE_C6_SHORT_LAT, /* 4 */ |
| 33 | C_STATE_C6_LONG_LAT, /* 5 */ |
| 34 | C_STATE_C7_SHORT_LAT, /* 6 */ |
| 35 | C_STATE_C7_LONG_LAT, /* 7 */ |
| 36 | C_STATE_C7S_SHORT_LAT, /* 8 */ |
| 37 | C_STATE_C7S_LONG_LAT, /* 9 */ |
| 38 | C_STATE_C8, /* 10 */ |
| 39 | C_STATE_C9, /* 11 */ |
| 40 | C_STATE_C10, /* 12 */ |
| 41 | NUM_C_STATES |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 42 | }; |
Aaron Durbin | 7c35131 | 2013-04-10 14:46:25 -0500 | [diff] [blame] | 43 | |
| 44 | #define MWAIT_RES(state, sub_state) \ |
| 45 | { \ |
| 46 | .addrl = (((state) << 4) | (sub_state)), \ |
| 47 | .space_id = ACPI_ADDRESS_SPACE_FIXED, \ |
| 48 | .bit_width = ACPI_FFIXEDHW_VENDOR_INTEL, \ |
| 49 | .bit_offset = ACPI_FFIXEDHW_CLASS_MWAIT, \ |
| 50 | .access_size = ACPI_FFIXEDHW_FLAG_HW_COORD, \ |
| 51 | } |
| 52 | |
| 53 | static acpi_cstate_t cstate_map[NUM_C_STATES] = { |
| 54 | [C_STATE_C0] = { }, |
| 55 | [C_STATE_C1] = { |
| 56 | .latency = 0, |
| 57 | .power = 1000, |
Lee Leahy | 9d62e7e | 2017-03-15 17:40:50 -0700 | [diff] [blame] | 58 | .resource = MWAIT_RES(0, 0), |
Aaron Durbin | 7c35131 | 2013-04-10 14:46:25 -0500 | [diff] [blame] | 59 | }, |
| 60 | [C_STATE_C1E] = { |
| 61 | .latency = 0, |
| 62 | .power = 1000, |
Lee Leahy | 9d62e7e | 2017-03-15 17:40:50 -0700 | [diff] [blame] | 63 | .resource = MWAIT_RES(0, 1), |
Aaron Durbin | 7c35131 | 2013-04-10 14:46:25 -0500 | [diff] [blame] | 64 | }, |
| 65 | [C_STATE_C3] = { |
| 66 | .latency = C_STATE_LATENCY_FROM_LAT_REG(0), |
| 67 | .power = 900, |
| 68 | .resource = MWAIT_RES(1, 0), |
| 69 | }, |
| 70 | [C_STATE_C6_SHORT_LAT] = { |
| 71 | .latency = C_STATE_LATENCY_FROM_LAT_REG(1), |
| 72 | .power = 800, |
| 73 | .resource = MWAIT_RES(2, 0), |
| 74 | }, |
| 75 | [C_STATE_C6_LONG_LAT] = { |
| 76 | .latency = C_STATE_LATENCY_FROM_LAT_REG(2), |
| 77 | .power = 800, |
| 78 | .resource = MWAIT_RES(2, 1), |
| 79 | }, |
| 80 | [C_STATE_C7_SHORT_LAT] = { |
| 81 | .latency = C_STATE_LATENCY_FROM_LAT_REG(1), |
| 82 | .power = 700, |
| 83 | .resource = MWAIT_RES(3, 0), |
| 84 | }, |
| 85 | [C_STATE_C7_LONG_LAT] = { |
| 86 | .latency = C_STATE_LATENCY_FROM_LAT_REG(2), |
| 87 | .power = 700, |
| 88 | .resource = MWAIT_RES(3, 1), |
| 89 | }, |
| 90 | [C_STATE_C7S_SHORT_LAT] = { |
| 91 | .latency = C_STATE_LATENCY_FROM_LAT_REG(1), |
| 92 | .power = 700, |
| 93 | .resource = MWAIT_RES(3, 2), |
| 94 | }, |
| 95 | [C_STATE_C7S_LONG_LAT] = { |
| 96 | .latency = C_STATE_LATENCY_FROM_LAT_REG(2), |
| 97 | .power = 700, |
| 98 | .resource = MWAIT_RES(3, 3), |
| 99 | }, |
| 100 | [C_STATE_C8] = { |
| 101 | .latency = C_STATE_LATENCY_FROM_LAT_REG(3), |
| 102 | .power = 600, |
| 103 | .resource = MWAIT_RES(4, 0), |
| 104 | }, |
| 105 | [C_STATE_C9] = { |
| 106 | .latency = C_STATE_LATENCY_FROM_LAT_REG(4), |
| 107 | .power = 500, |
| 108 | .resource = MWAIT_RES(5, 0), |
| 109 | }, |
| 110 | [C_STATE_C10] = { |
| 111 | .latency = C_STATE_LATENCY_FROM_LAT_REG(5), |
| 112 | .power = 400, |
| 113 | .resource = MWAIT_RES(6, 0), |
| 114 | }, |
| 115 | }; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 116 | |
| 117 | /* Convert time in seconds to POWER_LIMIT_1_TIME MSR value */ |
| 118 | static const u8 power_limit_time_sec_to_msr[] = { |
| 119 | [0] = 0x00, |
| 120 | [1] = 0x0a, |
| 121 | [2] = 0x0b, |
| 122 | [3] = 0x4b, |
| 123 | [4] = 0x0c, |
| 124 | [5] = 0x2c, |
| 125 | [6] = 0x4c, |
| 126 | [7] = 0x6c, |
| 127 | [8] = 0x0d, |
| 128 | [10] = 0x2d, |
| 129 | [12] = 0x4d, |
| 130 | [14] = 0x6d, |
| 131 | [16] = 0x0e, |
| 132 | [20] = 0x2e, |
| 133 | [24] = 0x4e, |
| 134 | [28] = 0x6e, |
| 135 | [32] = 0x0f, |
| 136 | [40] = 0x2f, |
| 137 | [48] = 0x4f, |
| 138 | [56] = 0x6f, |
| 139 | [64] = 0x10, |
| 140 | [80] = 0x30, |
| 141 | [96] = 0x50, |
| 142 | [112] = 0x70, |
| 143 | [128] = 0x11, |
| 144 | }; |
| 145 | |
| 146 | /* Convert POWER_LIMIT_1_TIME MSR value to seconds */ |
| 147 | static const u8 power_limit_time_msr_to_sec[] = { |
| 148 | [0x00] = 0, |
| 149 | [0x0a] = 1, |
| 150 | [0x0b] = 2, |
| 151 | [0x4b] = 3, |
| 152 | [0x0c] = 4, |
| 153 | [0x2c] = 5, |
| 154 | [0x4c] = 6, |
| 155 | [0x6c] = 7, |
| 156 | [0x0d] = 8, |
| 157 | [0x2d] = 10, |
| 158 | [0x4d] = 12, |
| 159 | [0x6d] = 14, |
| 160 | [0x0e] = 16, |
| 161 | [0x2e] = 20, |
| 162 | [0x4e] = 24, |
| 163 | [0x6e] = 28, |
| 164 | [0x0f] = 32, |
| 165 | [0x2f] = 40, |
| 166 | [0x4f] = 48, |
| 167 | [0x6f] = 56, |
| 168 | [0x10] = 64, |
| 169 | [0x30] = 80, |
| 170 | [0x50] = 96, |
| 171 | [0x70] = 112, |
| 172 | [0x11] = 128, |
| 173 | }; |
| 174 | |
Angel Pons | 5d92aa5 | 2020-10-14 00:02:37 +0200 | [diff] [blame] | 175 | /* The core 100MHz BCLK is disabled in deeper c-states. One needs to calibrate |
| 176 | * the 100MHz BCLK against the 24MHz BCLK to restore the clocks properly |
Aaron Durbin | f24262d | 2013-04-10 14:59:21 -0500 | [diff] [blame] | 177 | * when a core is woken up. */ |
| 178 | static int pcode_ready(void) |
| 179 | { |
| 180 | int wait_count; |
| 181 | const int delay_step = 10; |
| 182 | |
| 183 | wait_count = 0; |
| 184 | do { |
| 185 | if (!(MCHBAR32(BIOS_MAILBOX_INTERFACE) & MAILBOX_RUN_BUSY)) |
| 186 | return 0; |
| 187 | wait_count += delay_step; |
| 188 | udelay(delay_step); |
| 189 | } while (wait_count < 1000); |
| 190 | |
| 191 | return -1; |
| 192 | } |
| 193 | |
| 194 | static void calibrate_24mhz_bclk(void) |
| 195 | { |
| 196 | int err_code; |
| 197 | |
| 198 | if (pcode_ready() < 0) { |
| 199 | printk(BIOS_ERR, "PCODE: mailbox timeout on wait ready.\n"); |
| 200 | return; |
| 201 | } |
| 202 | |
| 203 | /* A non-zero value initiates the PCODE calibration. */ |
| 204 | MCHBAR32(BIOS_MAILBOX_DATA) = ~0; |
| 205 | MCHBAR32(BIOS_MAILBOX_INTERFACE) = |
| 206 | MAILBOX_RUN_BUSY | MAILBOX_BIOS_CMD_FSM_MEASURE_INTVL; |
| 207 | |
| 208 | if (pcode_ready() < 0) { |
| 209 | printk(BIOS_ERR, "PCODE: mailbox timeout on completion.\n"); |
| 210 | return; |
| 211 | } |
| 212 | |
| 213 | err_code = MCHBAR32(BIOS_MAILBOX_INTERFACE) & 0xff; |
| 214 | |
Angel Pons | 5d92aa5 | 2020-10-14 00:02:37 +0200 | [diff] [blame] | 215 | printk(BIOS_DEBUG, "PCODE: 24MHz BCLK calibration response: %d\n", |
Aaron Durbin | f24262d | 2013-04-10 14:59:21 -0500 | [diff] [blame] | 216 | err_code); |
| 217 | |
| 218 | /* Read the calibrated value. */ |
| 219 | MCHBAR32(BIOS_MAILBOX_INTERFACE) = |
| 220 | MAILBOX_RUN_BUSY | MAILBOX_BIOS_CMD_READ_CALIBRATION; |
| 221 | |
| 222 | if (pcode_ready() < 0) { |
| 223 | printk(BIOS_ERR, "PCODE: mailbox timeout on read.\n"); |
| 224 | return; |
| 225 | } |
| 226 | |
Angel Pons | 5d92aa5 | 2020-10-14 00:02:37 +0200 | [diff] [blame] | 227 | printk(BIOS_DEBUG, "PCODE: 24MHz BCLK calibration value: 0x%08x\n", |
Aaron Durbin | f24262d | 2013-04-10 14:59:21 -0500 | [diff] [blame] | 228 | MCHBAR32(BIOS_MAILBOX_DATA)); |
| 229 | } |
| 230 | |
Duncan Laurie | e1e87e0 | 2013-04-26 10:35:19 -0700 | [diff] [blame] | 231 | static u32 pcode_mailbox_read(u32 command) |
| 232 | { |
| 233 | if (pcode_ready() < 0) { |
| 234 | printk(BIOS_ERR, "PCODE: mailbox timeout on wait ready.\n"); |
| 235 | return 0; |
| 236 | } |
| 237 | |
| 238 | /* Send command and start transaction */ |
| 239 | MCHBAR32(BIOS_MAILBOX_INTERFACE) = command | MAILBOX_RUN_BUSY; |
| 240 | |
| 241 | if (pcode_ready() < 0) { |
| 242 | printk(BIOS_ERR, "PCODE: mailbox timeout on completion.\n"); |
| 243 | return 0; |
| 244 | } |
| 245 | |
| 246 | /* Read mailbox */ |
| 247 | return MCHBAR32(BIOS_MAILBOX_DATA); |
| 248 | } |
| 249 | |
Aaron Durbin | 16cbf89 | 2013-07-03 16:21:28 -0500 | [diff] [blame] | 250 | static void initialize_vr_config(void) |
| 251 | { |
| 252 | msr_t msr; |
| 253 | |
| 254 | printk(BIOS_DEBUG, "Initializing VR config.\n"); |
| 255 | |
| 256 | /* Configure VR_CURRENT_CONFIG. */ |
| 257 | msr = rdmsr(MSR_VR_CURRENT_CONFIG); |
| 258 | /* Preserve bits 63 and 62. Bit 62 is PSI4 enable, but it is only valid |
| 259 | * on ULT systems. */ |
| 260 | msr.hi &= 0xc0000000; |
| 261 | msr.hi |= (0x01 << (52 - 32)); /* PSI3 threshold - 1A. */ |
| 262 | msr.hi |= (0x05 << (42 - 32)); /* PSI2 threshold - 5A. */ |
| 263 | msr.hi |= (0x0f << (32 - 32)); /* PSI1 threshold - 15A. */ |
| 264 | |
Duncan Laurie | 118d105 | 2013-07-09 15:34:25 -0700 | [diff] [blame] | 265 | if (haswell_is_ult()) |
Aaron Durbin | 16cbf89 | 2013-07-03 16:21:28 -0500 | [diff] [blame] | 266 | msr.hi |= (1 << (62 - 32)); /* Enable PSI4 */ |
| 267 | /* Leave the max instantaneous current limit (12:0) to default. */ |
| 268 | wrmsr(MSR_VR_CURRENT_CONFIG, msr); |
| 269 | |
| 270 | /* Configure VR_MISC_CONFIG MSR. */ |
| 271 | msr = rdmsr(MSR_VR_MISC_CONFIG); |
| 272 | /* Set the IOUT_SLOPE scalar applied to dIout in U10.1.9 format. */ |
| 273 | msr.hi &= ~(0x3ff << (40 - 32)); |
| 274 | msr.hi |= (0x200 << (40 - 32)); /* 1.0 */ |
| 275 | /* Set IOUT_OFFSET to 0. */ |
| 276 | msr.hi &= ~0xff; |
| 277 | /* Set exit ramp rate to fast. */ |
| 278 | msr.hi |= (1 << (50 - 32)); |
| 279 | /* Set entry ramp rate to slow. */ |
| 280 | msr.hi &= ~(1 << (51 - 32)); |
| 281 | /* Enable decay mode on C-state entry. */ |
| 282 | msr.hi |= (1 << (52 - 32)); |
Tristan Corrick | fdf907e | 2018-10-31 02:27:12 +1300 | [diff] [blame] | 283 | if (haswell_is_ult()) { |
| 284 | /* Set the slow ramp rate to be fast ramp rate / 4 */ |
| 285 | msr.hi &= ~(0x3 << (53 - 32)); |
| 286 | msr.hi |= (0x01 << (53 - 32)); |
| 287 | } |
Aaron Durbin | 16cbf89 | 2013-07-03 16:21:28 -0500 | [diff] [blame] | 288 | /* Set MIN_VID (31:24) to allow CPU to have full control. */ |
| 289 | msr.lo &= ~0xff000000; |
| 290 | wrmsr(MSR_VR_MISC_CONFIG, msr); |
| 291 | |
| 292 | /* Configure VR_MISC_CONFIG2 MSR. */ |
Angel Pons | 4c95f10 | 2020-10-28 19:38:12 +0100 | [diff] [blame] | 293 | if (!haswell_is_ult()) |
| 294 | return; |
| 295 | |
| 296 | msr = rdmsr(MSR_VR_MISC_CONFIG2); |
| 297 | msr.lo &= ~0xffff; |
| 298 | /* Allow CPU to control minimum voltage completely (15:8) and |
| 299 | * set the fast ramp voltage to 1110mV (0x6f in 10mV steps). */ |
| 300 | msr.lo |= 0x006f; |
| 301 | wrmsr(MSR_VR_MISC_CONFIG2, msr); |
Aaron Durbin | 16cbf89 | 2013-07-03 16:21:28 -0500 | [diff] [blame] | 302 | } |
| 303 | |
Duncan Laurie | e1e87e0 | 2013-04-26 10:35:19 -0700 | [diff] [blame] | 304 | static void configure_pch_power_sharing(void) |
| 305 | { |
| 306 | u32 pch_power, pch_power_ext, pmsync, pmsync2; |
| 307 | int i; |
| 308 | |
| 309 | /* Read PCH Power levels from PCODE */ |
| 310 | pch_power = pcode_mailbox_read(MAILBOX_BIOS_CMD_READ_PCH_POWER); |
| 311 | pch_power_ext = pcode_mailbox_read(MAILBOX_BIOS_CMD_READ_PCH_POWER_EXT); |
| 312 | |
| 313 | printk(BIOS_INFO, "PCH Power: PCODE Levels 0x%08x 0x%08x\n", |
Lee Leahy | 7b5f12b9 | 2017-03-15 17:16:59 -0700 | [diff] [blame] | 314 | pch_power, pch_power_ext); |
Duncan Laurie | e1e87e0 | 2013-04-26 10:35:19 -0700 | [diff] [blame] | 315 | |
| 316 | pmsync = RCBA32(PMSYNC_CONFIG); |
| 317 | pmsync2 = RCBA32(PMSYNC_CONFIG2); |
| 318 | |
| 319 | /* Program PMSYNC_TPR_CONFIG PCH power limit values |
| 320 | * pmsync[0:4] = mailbox[0:5] |
| 321 | * pmsync[8:12] = mailbox[6:11] |
| 322 | * pmsync[16:20] = mailbox[12:17] |
| 323 | */ |
| 324 | for (i = 0; i < 3; i++) { |
| 325 | u32 level = pch_power & 0x3f; |
| 326 | pch_power >>= 6; |
| 327 | pmsync &= ~(0x1f << (i * 8)); |
| 328 | pmsync |= (level & 0x1f) << (i * 8); |
| 329 | } |
| 330 | RCBA32(PMSYNC_CONFIG) = pmsync; |
| 331 | |
| 332 | /* Program PMSYNC_TPR_CONFIG2 Extended PCH power limit values |
| 333 | * pmsync2[0:4] = mailbox[23:18] |
| 334 | * pmsync2[8:12] = mailbox_ext[6:11] |
| 335 | * pmsync2[16:20] = mailbox_ext[12:17] |
| 336 | * pmsync2[24:28] = mailbox_ext[18:22] |
| 337 | */ |
| 338 | pmsync2 &= ~0x1f; |
| 339 | pmsync2 |= pch_power & 0x1f; |
| 340 | |
| 341 | for (i = 1; i < 4; i++) { |
| 342 | u32 level = pch_power_ext & 0x3f; |
| 343 | pch_power_ext >>= 6; |
| 344 | pmsync2 &= ~(0x1f << (i * 8)); |
| 345 | pmsync2 |= (level & 0x1f) << (i * 8); |
| 346 | } |
| 347 | RCBA32(PMSYNC_CONFIG2) = pmsync2; |
| 348 | } |
| 349 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 350 | int cpu_config_tdp_levels(void) |
| 351 | { |
| 352 | msr_t platform_info; |
| 353 | |
| 354 | /* Bits 34:33 indicate how many levels supported */ |
| 355 | platform_info = rdmsr(MSR_PLATFORM_INFO); |
| 356 | return (platform_info.hi >> 1) & 3; |
| 357 | } |
| 358 | |
| 359 | /* |
| 360 | * Configure processor power limits if possible |
| 361 | * This must be done AFTER set of BIOS_RESET_CPL |
| 362 | */ |
| 363 | void set_power_limits(u8 power_limit_1_time) |
| 364 | { |
| 365 | msr_t msr = rdmsr(MSR_PLATFORM_INFO); |
| 366 | msr_t limit; |
Lee Leahy | 73a2894 | 2017-03-15 17:52:06 -0700 | [diff] [blame] | 367 | unsigned int power_unit; |
| 368 | unsigned int tdp, min_power, max_power, max_time; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 369 | u8 power_limit_1_val; |
| 370 | |
Edward O'Callaghan | 5cfef13 | 2014-08-03 20:00:47 +1000 | [diff] [blame] | 371 | if (power_limit_1_time >= ARRAY_SIZE(power_limit_time_sec_to_msr)) |
Angel Pons | 4c95f10 | 2020-10-28 19:38:12 +0100 | [diff] [blame] | 372 | power_limit_1_time = ARRAY_SIZE(power_limit_time_sec_to_msr) - 1; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 373 | |
| 374 | if (!(msr.lo & PLATFORM_INFO_SET_TDP)) |
| 375 | return; |
| 376 | |
| 377 | /* Get units */ |
| 378 | msr = rdmsr(MSR_PKG_POWER_SKU_UNIT); |
| 379 | power_unit = 2 << ((msr.lo & 0xf) - 1); |
| 380 | |
| 381 | /* Get power defaults for this SKU */ |
| 382 | msr = rdmsr(MSR_PKG_POWER_SKU); |
| 383 | tdp = msr.lo & 0x7fff; |
| 384 | min_power = (msr.lo >> 16) & 0x7fff; |
| 385 | max_power = msr.hi & 0x7fff; |
| 386 | max_time = (msr.hi >> 16) & 0x7f; |
| 387 | |
| 388 | printk(BIOS_DEBUG, "CPU TDP: %u Watts\n", tdp / power_unit); |
| 389 | |
| 390 | if (power_limit_time_msr_to_sec[max_time] > power_limit_1_time) |
| 391 | power_limit_1_time = power_limit_time_msr_to_sec[max_time]; |
| 392 | |
| 393 | if (min_power > 0 && tdp < min_power) |
| 394 | tdp = min_power; |
| 395 | |
| 396 | if (max_power > 0 && tdp > max_power) |
| 397 | tdp = max_power; |
| 398 | |
| 399 | power_limit_1_val = power_limit_time_sec_to_msr[power_limit_1_time]; |
| 400 | |
| 401 | /* Set long term power limit to TDP */ |
| 402 | limit.lo = 0; |
| 403 | limit.lo |= tdp & PKG_POWER_LIMIT_MASK; |
| 404 | limit.lo |= PKG_POWER_LIMIT_EN; |
| 405 | limit.lo |= (power_limit_1_val & PKG_POWER_LIMIT_TIME_MASK) << |
| 406 | PKG_POWER_LIMIT_TIME_SHIFT; |
| 407 | |
| 408 | /* Set short term power limit to 1.25 * TDP */ |
| 409 | limit.hi = 0; |
| 410 | limit.hi |= ((tdp * 125) / 100) & PKG_POWER_LIMIT_MASK; |
| 411 | limit.hi |= PKG_POWER_LIMIT_EN; |
Duncan Laurie | c70353f | 2013-06-28 14:40:38 -0700 | [diff] [blame] | 412 | /* Power limit 2 time is only programmable on server SKU */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 413 | |
| 414 | wrmsr(MSR_PKG_POWER_LIMIT, limit); |
| 415 | |
Duncan Laurie | c70353f | 2013-06-28 14:40:38 -0700 | [diff] [blame] | 416 | /* Set power limit values in MCHBAR as well */ |
| 417 | MCHBAR32(MCH_PKG_POWER_LIMIT_LO) = limit.lo; |
| 418 | MCHBAR32(MCH_PKG_POWER_LIMIT_HI) = limit.hi; |
| 419 | |
| 420 | /* Set DDR RAPL power limit by copying from MMIO to MSR */ |
| 421 | msr.lo = MCHBAR32(MCH_DDR_POWER_LIMIT_LO); |
| 422 | msr.hi = MCHBAR32(MCH_DDR_POWER_LIMIT_HI); |
| 423 | wrmsr(MSR_DDR_RAPL_LIMIT, msr); |
| 424 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 425 | /* Use nominal TDP values for CPUs with configurable TDP */ |
| 426 | if (cpu_config_tdp_levels()) { |
| 427 | msr = rdmsr(MSR_CONFIG_TDP_NOMINAL); |
| 428 | limit.hi = 0; |
| 429 | limit.lo = msr.lo & 0xff; |
| 430 | wrmsr(MSR_TURBO_ACTIVATION_RATIO, limit); |
| 431 | } |
| 432 | } |
| 433 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 434 | static void configure_c_states(void) |
| 435 | { |
| 436 | msr_t msr; |
| 437 | |
Elyes HAOUAS | 4e6b790 | 2018-10-02 08:44:47 +0200 | [diff] [blame] | 438 | msr = rdmsr(MSR_PKG_CST_CONFIG_CONTROL); |
Aaron Durbin | 7c35131 | 2013-04-10 14:46:25 -0500 | [diff] [blame] | 439 | msr.lo |= (1 << 30); // Package c-state Undemotion Enable |
| 440 | msr.lo |= (1 << 29); // Package c-state Demotion Enable |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 441 | msr.lo |= (1 << 28); // C1 Auto Undemotion Enable |
| 442 | msr.lo |= (1 << 27); // C3 Auto Undemotion Enable |
| 443 | msr.lo |= (1 << 26); // C1 Auto Demotion Enable |
| 444 | msr.lo |= (1 << 25); // C3 Auto Demotion Enable |
| 445 | msr.lo &= ~(1 << 10); // Disable IO MWAIT redirection |
Duncan Laurie | 1c09710 | 2013-05-07 13:19:56 -0700 | [diff] [blame] | 446 | /* The deepest package c-state defaults to factory-configured value. */ |
Elyes HAOUAS | 4e6b790 | 2018-10-02 08:44:47 +0200 | [diff] [blame] | 447 | wrmsr(MSR_PKG_CST_CONFIG_CONTROL, msr); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 448 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 449 | msr = rdmsr(MSR_MISC_PWR_MGMT); |
| 450 | msr.lo &= ~(1 << 0); // Enable P-state HW_ALL coordination |
| 451 | wrmsr(MSR_MISC_PWR_MGMT, msr); |
| 452 | |
| 453 | msr = rdmsr(MSR_POWER_CTL); |
| 454 | msr.lo |= (1 << 18); // Enable Energy Perf Bias MSR 0x1b0 |
| 455 | msr.lo |= (1 << 1); // C1E Enable |
| 456 | msr.lo |= (1 << 0); // Bi-directional PROCHOT# |
| 457 | wrmsr(MSR_POWER_CTL, msr); |
| 458 | |
Aaron Durbin | 7c35131 | 2013-04-10 14:46:25 -0500 | [diff] [blame] | 459 | /* C-state Interrupt Response Latency Control 0 - package C3 latency */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 460 | msr.hi = 0; |
Aaron Durbin | 7c35131 | 2013-04-10 14:46:25 -0500 | [diff] [blame] | 461 | msr.lo = IRTL_VALID | IRTL_1024_NS | C_STATE_LATENCY_CONTROL_0_LIMIT; |
| 462 | wrmsr(MSR_C_STATE_LATENCY_CONTROL_0, msr); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 463 | |
Aaron Durbin | 7c35131 | 2013-04-10 14:46:25 -0500 | [diff] [blame] | 464 | /* C-state Interrupt Response Latency Control 1 */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 465 | msr.hi = 0; |
Aaron Durbin | 7c35131 | 2013-04-10 14:46:25 -0500 | [diff] [blame] | 466 | msr.lo = IRTL_VALID | IRTL_1024_NS | C_STATE_LATENCY_CONTROL_1_LIMIT; |
| 467 | wrmsr(MSR_C_STATE_LATENCY_CONTROL_1, msr); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 468 | |
Aaron Durbin | 7c35131 | 2013-04-10 14:46:25 -0500 | [diff] [blame] | 469 | /* C-state Interrupt Response Latency Control 2 - package C6/C7 short */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 470 | msr.hi = 0; |
Aaron Durbin | 7c35131 | 2013-04-10 14:46:25 -0500 | [diff] [blame] | 471 | msr.lo = IRTL_VALID | IRTL_1024_NS | C_STATE_LATENCY_CONTROL_2_LIMIT; |
| 472 | wrmsr(MSR_C_STATE_LATENCY_CONTROL_2, msr); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 473 | |
Angel Pons | 4c95f10 | 2020-10-28 19:38:12 +0100 | [diff] [blame] | 474 | /* Only Haswell ULT supports the 3-5 latency response registers */ |
| 475 | if (!haswell_is_ult()) |
| 476 | return; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 477 | |
Angel Pons | 4c95f10 | 2020-10-28 19:38:12 +0100 | [diff] [blame] | 478 | /* C-state Interrupt Response Latency Control 3 - package C8 */ |
| 479 | msr.hi = 0; |
| 480 | msr.lo = IRTL_VALID | IRTL_1024_NS | C_STATE_LATENCY_CONTROL_3_LIMIT; |
| 481 | wrmsr(MSR_C_STATE_LATENCY_CONTROL_3, msr); |
Aaron Durbin | 7c35131 | 2013-04-10 14:46:25 -0500 | [diff] [blame] | 482 | |
Angel Pons | 4c95f10 | 2020-10-28 19:38:12 +0100 | [diff] [blame] | 483 | /* C-state Interrupt Response Latency Control 4 - package C9 */ |
| 484 | msr.hi = 0; |
| 485 | msr.lo = IRTL_VALID | IRTL_1024_NS | C_STATE_LATENCY_CONTROL_4_LIMIT; |
| 486 | wrmsr(MSR_C_STATE_LATENCY_CONTROL_4, msr); |
| 487 | |
| 488 | /* C-state Interrupt Response Latency Control 5 - package C10 */ |
| 489 | msr.hi = 0; |
| 490 | msr.lo = IRTL_VALID | IRTL_1024_NS | C_STATE_LATENCY_CONTROL_5_LIMIT; |
| 491 | wrmsr(MSR_C_STATE_LATENCY_CONTROL_5, msr); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 492 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 493 | |
| 494 | static void configure_thermal_target(void) |
| 495 | { |
| 496 | struct cpu_intel_haswell_config *conf; |
Edward O'Callaghan | 2c9d2cf | 2014-10-27 23:29:29 +1100 | [diff] [blame] | 497 | struct device *lapic; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 498 | msr_t msr; |
| 499 | |
| 500 | /* Find pointer to CPU configuration */ |
| 501 | lapic = dev_find_lapic(SPEEDSTEP_APIC_MAGIC); |
| 502 | if (!lapic || !lapic->chip_info) |
| 503 | return; |
| 504 | conf = lapic->chip_info; |
| 505 | |
Martin Roth | 4c3ab73 | 2013-07-08 16:23:54 -0600 | [diff] [blame] | 506 | /* Set TCC activation offset if supported */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 507 | msr = rdmsr(MSR_PLATFORM_INFO); |
| 508 | if ((msr.lo & (1 << 30)) && conf->tcc_offset) { |
| 509 | msr = rdmsr(MSR_TEMPERATURE_TARGET); |
| 510 | msr.lo &= ~(0xf << 24); /* Bits 27:24 */ |
| 511 | msr.lo |= (conf->tcc_offset & 0xf) << 24; |
| 512 | wrmsr(MSR_TEMPERATURE_TARGET, msr); |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | static void configure_misc(void) |
| 517 | { |
| 518 | msr_t msr; |
| 519 | |
| 520 | msr = rdmsr(IA32_MISC_ENABLE); |
| 521 | msr.lo |= (1 << 0); /* Fast String enable */ |
Lee Leahy | 7b5f12b9 | 2017-03-15 17:16:59 -0700 | [diff] [blame] | 522 | msr.lo |= (1 << 3); /* TM1/TM2/EMTTM enable */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 523 | msr.lo |= (1 << 16); /* Enhanced SpeedStep Enable */ |
| 524 | wrmsr(IA32_MISC_ENABLE, msr); |
| 525 | |
| 526 | /* Disable Thermal interrupts */ |
| 527 | msr.lo = 0; |
| 528 | msr.hi = 0; |
| 529 | wrmsr(IA32_THERM_INTERRUPT, msr); |
| 530 | |
| 531 | /* Enable package critical interrupt only */ |
| 532 | msr.lo = 1 << 4; |
| 533 | msr.hi = 0; |
| 534 | wrmsr(IA32_PACKAGE_THERM_INTERRUPT, msr); |
| 535 | } |
| 536 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 537 | static void set_max_ratio(void) |
| 538 | { |
| 539 | msr_t msr, perf_ctl; |
| 540 | |
| 541 | perf_ctl.hi = 0; |
| 542 | |
| 543 | /* Check for configurable TDP option */ |
Angel Pons | 053deb8 | 2020-10-28 22:40:02 +0100 | [diff] [blame^] | 544 | if (get_turbo_state() == TURBO_ENABLED) { |
| 545 | msr = rdmsr(MSR_TURBO_RATIO_LIMIT); |
| 546 | perf_ctl.lo = (msr.lo & 0xff) << 8; |
| 547 | } else if (cpu_config_tdp_levels()) { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 548 | /* Set to nominal TDP ratio */ |
| 549 | msr = rdmsr(MSR_CONFIG_TDP_NOMINAL); |
| 550 | perf_ctl.lo = (msr.lo & 0xff) << 8; |
| 551 | } else { |
| 552 | /* Platform Info bits 15:8 give max ratio */ |
| 553 | msr = rdmsr(MSR_PLATFORM_INFO); |
| 554 | perf_ctl.lo = msr.lo & 0xff00; |
| 555 | } |
| 556 | wrmsr(IA32_PERF_CTL, perf_ctl); |
| 557 | |
Angel Pons | f6cf4927 | 2020-09-25 01:14:24 +0200 | [diff] [blame] | 558 | printk(BIOS_DEBUG, "CPU: frequency set to %d\n", |
Angel Pons | ca96549 | 2020-10-28 19:15:36 +0100 | [diff] [blame] | 559 | ((perf_ctl.lo >> 8) & 0xff) * CPU_BCLK); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 560 | } |
| 561 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 562 | static void configure_mca(void) |
| 563 | { |
| 564 | msr_t msr; |
| 565 | int i; |
Aaron Durbin | 24614af | 2013-01-12 01:07:28 -0600 | [diff] [blame] | 566 | int num_banks; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 567 | |
Elyes HAOUAS | 419bfbc | 2018-10-01 08:47:51 +0200 | [diff] [blame] | 568 | msr = rdmsr(IA32_MCG_CAP); |
Aaron Durbin | 24614af | 2013-01-12 01:07:28 -0600 | [diff] [blame] | 569 | num_banks = msr.lo & 0xff; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 570 | msr.lo = msr.hi = 0; |
Aaron Durbin | 24614af | 2013-01-12 01:07:28 -0600 | [diff] [blame] | 571 | /* TODO(adurbin): This should only be done on a cold boot. Also, some |
| 572 | * of these banks are core vs package scope. For now every CPU clears |
| 573 | * every bank. */ |
| 574 | for (i = 0; i < num_banks; i++) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 575 | wrmsr(IA32_MC0_STATUS + (i * 4), msr); |
| 576 | } |
| 577 | |
Aaron Durbin | 305b1f0 | 2013-01-15 08:27:05 -0600 | [diff] [blame] | 578 | /* All CPUs including BSP will run the following function. */ |
Angel Pons | 4c95f10 | 2020-10-28 19:38:12 +0100 | [diff] [blame] | 579 | static void cpu_core_init(struct device *cpu) |
Aaron Durbin | 7af2069 | 2013-01-14 14:54:41 -0600 | [diff] [blame] | 580 | { |
| 581 | /* Clear out pending MCEs */ |
| 582 | configure_mca(); |
| 583 | |
Elyes HAOUAS | d6e9686 | 2016-08-21 10:12:15 +0200 | [diff] [blame] | 584 | /* Enable the local CPU APICs */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 585 | enable_lapic_tpr(); |
| 586 | setup_lapic(); |
| 587 | |
Matt DeVillier | ed6fe2f | 2016-12-14 16:12:43 -0600 | [diff] [blame] | 588 | /* Set virtualization based on Kconfig option */ |
Matt DeVillier | f9aed65 | 2018-12-15 15:57:33 -0600 | [diff] [blame] | 589 | set_vmx_and_lock(); |
Matt DeVillier | b2a14fb | 2014-07-07 18:48:16 -0500 | [diff] [blame] | 590 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 591 | /* Configure C States */ |
Aaron Durbin | 7c35131 | 2013-04-10 14:46:25 -0500 | [diff] [blame] | 592 | configure_c_states(); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 593 | |
| 594 | /* Configure Enhanced SpeedStep and Thermal Sensors */ |
| 595 | configure_misc(); |
| 596 | |
| 597 | /* Thermal throttle activation offset */ |
| 598 | configure_thermal_target(); |
| 599 | |
| 600 | /* Enable Direct Cache Access */ |
| 601 | configure_dca_cap(); |
| 602 | |
| 603 | /* Set energy policy */ |
| 604 | set_energy_perf_bias(ENERGY_POLICY_NORMAL); |
| 605 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 606 | /* Enable Turbo */ |
| 607 | enable_turbo(); |
Aaron Durbin | 7af2069 | 2013-01-14 14:54:41 -0600 | [diff] [blame] | 608 | } |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 609 | |
Aaron Durbin | 014baea | 2014-03-28 22:01:05 -0500 | [diff] [blame] | 610 | /* MP initialization support. */ |
| 611 | static const void *microcode_patch; |
Aaron Durbin | 014baea | 2014-03-28 22:01:05 -0500 | [diff] [blame] | 612 | |
Aaron Durbin | 463af33 | 2016-05-03 17:26:35 -0500 | [diff] [blame] | 613 | static void pre_mp_init(void) |
Aaron Durbin | 014baea | 2014-03-28 22:01:05 -0500 | [diff] [blame] | 614 | { |
Aaron Durbin | 463af33 | 2016-05-03 17:26:35 -0500 | [diff] [blame] | 615 | /* Setup MTRRs based on physical address size. */ |
| 616 | x86_setup_mtrrs_with_detect(); |
| 617 | x86_mtrr_check(); |
| 618 | |
| 619 | initialize_vr_config(); |
| 620 | |
Angel Pons | 4c95f10 | 2020-10-28 19:38:12 +0100 | [diff] [blame] | 621 | if (!haswell_is_ult()) |
| 622 | return; |
| 623 | |
| 624 | calibrate_24mhz_bclk(); |
| 625 | configure_pch_power_sharing(); |
Aaron Durbin | 014baea | 2014-03-28 22:01:05 -0500 | [diff] [blame] | 626 | } |
| 627 | |
Aaron Durbin | 463af33 | 2016-05-03 17:26:35 -0500 | [diff] [blame] | 628 | static int get_cpu_count(void) |
Aaron Durbin | 014baea | 2014-03-28 22:01:05 -0500 | [diff] [blame] | 629 | { |
Aaron Durbin | 463af33 | 2016-05-03 17:26:35 -0500 | [diff] [blame] | 630 | msr_t msr; |
Aaron Durbin | 014baea | 2014-03-28 22:01:05 -0500 | [diff] [blame] | 631 | int num_threads; |
| 632 | int num_cores; |
Aaron Durbin | 014baea | 2014-03-28 22:01:05 -0500 | [diff] [blame] | 633 | |
Elyes HAOUAS | a6a396d | 2019-05-26 13:25:30 +0200 | [diff] [blame] | 634 | msr = rdmsr(MSR_CORE_THREAD_COUNT); |
Aaron Durbin | 014baea | 2014-03-28 22:01:05 -0500 | [diff] [blame] | 635 | num_threads = (msr.lo >> 0) & 0xffff; |
| 636 | num_cores = (msr.lo >> 16) & 0xffff; |
| 637 | printk(BIOS_DEBUG, "CPU has %u cores, %u threads enabled.\n", |
| 638 | num_cores, num_threads); |
| 639 | |
Aaron Durbin | 463af33 | 2016-05-03 17:26:35 -0500 | [diff] [blame] | 640 | return num_threads; |
| 641 | } |
Aaron Durbin | 7af2069 | 2013-01-14 14:54:41 -0600 | [diff] [blame] | 642 | |
Aaron Durbin | 463af33 | 2016-05-03 17:26:35 -0500 | [diff] [blame] | 643 | static void get_microcode_info(const void **microcode, int *parallel) |
| 644 | { |
Aaron Durbin | 305b1f0 | 2013-01-15 08:27:05 -0600 | [diff] [blame] | 645 | microcode_patch = intel_microcode_find(); |
Aaron Durbin | 463af33 | 2016-05-03 17:26:35 -0500 | [diff] [blame] | 646 | *microcode = microcode_patch; |
| 647 | *parallel = 1; |
| 648 | } |
Aaron Durbin | 7af2069 | 2013-01-14 14:54:41 -0600 | [diff] [blame] | 649 | |
Aaron Durbin | 463af33 | 2016-05-03 17:26:35 -0500 | [diff] [blame] | 650 | static void per_cpu_smm_trigger(void) |
| 651 | { |
| 652 | /* Relocate the SMM handler. */ |
| 653 | smm_relocate(); |
Aaron Durbin | 305b1f0 | 2013-01-15 08:27:05 -0600 | [diff] [blame] | 654 | |
Aaron Durbin | 463af33 | 2016-05-03 17:26:35 -0500 | [diff] [blame] | 655 | /* After SMM relocation a 2nd microcode load is required. */ |
| 656 | intel_microcode_load_unlocked(microcode_patch); |
| 657 | } |
| 658 | |
| 659 | static void post_mp_init(void) |
| 660 | { |
Angel Pons | 053deb8 | 2020-10-28 22:40:02 +0100 | [diff] [blame^] | 661 | /* Set Max Ratio */ |
| 662 | set_max_ratio(); |
| 663 | |
Aaron Durbin | 463af33 | 2016-05-03 17:26:35 -0500 | [diff] [blame] | 664 | /* Now that all APs have been relocated as well as the BSP let SMIs |
| 665 | * start flowing. */ |
Kyösti Mälkki | 0778c86 | 2020-06-10 12:44:03 +0300 | [diff] [blame] | 666 | global_smi_enable(); |
Aaron Durbin | 463af33 | 2016-05-03 17:26:35 -0500 | [diff] [blame] | 667 | |
| 668 | /* Lock down the SMRAM space. */ |
| 669 | smm_lock(); |
| 670 | } |
| 671 | |
| 672 | static const struct mp_ops mp_ops = { |
| 673 | .pre_mp_init = pre_mp_init, |
| 674 | .get_cpu_count = get_cpu_count, |
| 675 | .get_smm_info = smm_info, |
| 676 | .get_microcode_info = get_microcode_info, |
Aaron Durbin | 463af33 | 2016-05-03 17:26:35 -0500 | [diff] [blame] | 677 | .pre_mp_smm_init = smm_initialize, |
| 678 | .per_cpu_smm_trigger = per_cpu_smm_trigger, |
| 679 | .relocation_handler = smm_relocation_handler, |
| 680 | .post_mp_init = post_mp_init, |
| 681 | }; |
| 682 | |
Kyösti Mälkki | b3267e0 | 2019-08-13 16:44:04 +0300 | [diff] [blame] | 683 | void mp_init_cpus(struct bus *cpu_bus) |
Aaron Durbin | 463af33 | 2016-05-03 17:26:35 -0500 | [diff] [blame] | 684 | { |
Lee Leahy | 26eeb0f | 2017-03-15 18:08:50 -0700 | [diff] [blame] | 685 | if (mp_init_with_smm(cpu_bus, &mp_ops)) |
Aaron Durbin | 014baea | 2014-03-28 22:01:05 -0500 | [diff] [blame] | 686 | printk(BIOS_ERR, "MP initialization failure.\n"); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 687 | } |
| 688 | |
| 689 | static struct device_operations cpu_dev_ops = { |
Angel Pons | 4c95f10 | 2020-10-28 19:38:12 +0100 | [diff] [blame] | 690 | .init = cpu_core_init, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 691 | }; |
| 692 | |
Jonathan Neuschäfer | 8f06ce3 | 2017-11-20 01:56:44 +0100 | [diff] [blame] | 693 | static const struct cpu_device_id cpu_table[] = { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 694 | { X86_VENDOR_INTEL, 0x306c1 }, /* Intel Haswell 4+2 A0 */ |
| 695 | { X86_VENDOR_INTEL, 0x306c2 }, /* Intel Haswell 4+2 B0 */ |
Tristan Corrick | 22f9700 | 2018-10-31 02:22:39 +1300 | [diff] [blame] | 696 | { X86_VENDOR_INTEL, 0x306c3 }, /* Intel Haswell C0 */ |
Duncan Laurie | 51254049 | 2012-12-17 11:24:45 -0800 | [diff] [blame] | 697 | { X86_VENDOR_INTEL, 0x40650 }, /* Intel Haswell ULT B0 */ |
| 698 | { X86_VENDOR_INTEL, 0x40651 }, /* Intel Haswell ULT B1 */ |
Iru Cai | 27126f1 | 2020-07-30 23:04:03 +0800 | [diff] [blame] | 699 | { X86_VENDOR_INTEL, 0x40660 }, /* Intel Crystal Well C0 */ |
| 700 | { X86_VENDOR_INTEL, 0x40661 }, /* Intel Crystal Well C1 */ |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 701 | { 0, 0 }, |
| 702 | }; |
| 703 | |
| 704 | static const struct cpu_driver driver __cpu_driver = { |
| 705 | .ops = &cpu_dev_ops, |
| 706 | .id_table = cpu_table, |
Aaron Durbin | 7c35131 | 2013-04-10 14:46:25 -0500 | [diff] [blame] | 707 | .cstates = cstate_map, |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 708 | }; |