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 <types.h> |
| 4 | #include <console/console.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 5 | #include <acpi/acpi.h> |
| 6 | #include <acpi/acpigen.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 7 | #include <arch/cpu.h> |
| 8 | #include <cpu/x86/msr.h> |
| 9 | #include <cpu/intel/speedstep.h> |
| 10 | #include <cpu/intel/turbo.h> |
| 11 | #include <device/device.h> |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 12 | #include "haswell.h" |
| 13 | #include "chip.h" |
| 14 | |
Duncan Laurie | 1ad5564 | 2013-03-07 14:08:04 -0800 | [diff] [blame] | 15 | #include <southbridge/intel/lynxpoint/pch.h> |
| 16 | |
Angel Pons | 618b9ad | 2021-01-21 21:22:19 +0100 | [diff] [blame] | 17 | #define MWAIT_RES(state, sub_state) \ |
| 18 | { \ |
| 19 | .addrl = (((state) << 4) | (sub_state)), \ |
| 20 | .space_id = ACPI_ADDRESS_SPACE_FIXED, \ |
| 21 | .bit_width = ACPI_FFIXEDHW_VENDOR_INTEL, \ |
| 22 | .bit_offset = ACPI_FFIXEDHW_CLASS_MWAIT, \ |
| 23 | .access_size = ACPI_FFIXEDHW_FLAG_HW_COORD, \ |
| 24 | } |
| 25 | |
| 26 | static acpi_cstate_t cstate_map[NUM_C_STATES] = { |
| 27 | [C_STATE_C0] = { }, |
| 28 | [C_STATE_C1] = { |
| 29 | .latency = 0, |
| 30 | .power = 1000, |
| 31 | .resource = MWAIT_RES(0, 0), |
| 32 | }, |
| 33 | [C_STATE_C1E] = { |
| 34 | .latency = 0, |
| 35 | .power = 1000, |
| 36 | .resource = MWAIT_RES(0, 1), |
| 37 | }, |
| 38 | [C_STATE_C3] = { |
| 39 | .latency = C_STATE_LATENCY_FROM_LAT_REG(0), |
| 40 | .power = 900, |
| 41 | .resource = MWAIT_RES(1, 0), |
| 42 | }, |
| 43 | [C_STATE_C6_SHORT_LAT] = { |
| 44 | .latency = C_STATE_LATENCY_FROM_LAT_REG(1), |
| 45 | .power = 800, |
| 46 | .resource = MWAIT_RES(2, 0), |
| 47 | }, |
| 48 | [C_STATE_C6_LONG_LAT] = { |
| 49 | .latency = C_STATE_LATENCY_FROM_LAT_REG(2), |
| 50 | .power = 800, |
| 51 | .resource = MWAIT_RES(2, 1), |
| 52 | }, |
| 53 | [C_STATE_C7_SHORT_LAT] = { |
| 54 | .latency = C_STATE_LATENCY_FROM_LAT_REG(1), |
| 55 | .power = 700, |
| 56 | .resource = MWAIT_RES(3, 0), |
| 57 | }, |
| 58 | [C_STATE_C7_LONG_LAT] = { |
| 59 | .latency = C_STATE_LATENCY_FROM_LAT_REG(2), |
| 60 | .power = 700, |
| 61 | .resource = MWAIT_RES(3, 1), |
| 62 | }, |
| 63 | [C_STATE_C7S_SHORT_LAT] = { |
| 64 | .latency = C_STATE_LATENCY_FROM_LAT_REG(1), |
| 65 | .power = 700, |
| 66 | .resource = MWAIT_RES(3, 2), |
| 67 | }, |
| 68 | [C_STATE_C7S_LONG_LAT] = { |
| 69 | .latency = C_STATE_LATENCY_FROM_LAT_REG(2), |
| 70 | .power = 700, |
| 71 | .resource = MWAIT_RES(3, 3), |
| 72 | }, |
| 73 | [C_STATE_C8] = { |
| 74 | .latency = C_STATE_LATENCY_FROM_LAT_REG(3), |
| 75 | .power = 600, |
| 76 | .resource = MWAIT_RES(4, 0), |
| 77 | }, |
| 78 | [C_STATE_C9] = { |
| 79 | .latency = C_STATE_LATENCY_FROM_LAT_REG(4), |
| 80 | .power = 500, |
| 81 | .resource = MWAIT_RES(5, 0), |
| 82 | }, |
| 83 | [C_STATE_C10] = { |
| 84 | .latency = C_STATE_LATENCY_FROM_LAT_REG(5), |
| 85 | .power = 400, |
| 86 | .resource = MWAIT_RES(6, 0), |
| 87 | }, |
| 88 | }; |
| 89 | |
Angel Pons | e49dec4 | 2021-01-21 21:54:14 +0100 | [diff] [blame] | 90 | static const int cstate_set_s0ix[3] = { |
Angel Pons | 8e6f162 | 2020-10-29 00:18:11 +0100 | [diff] [blame] | 91 | C_STATE_C1E, |
| 92 | C_STATE_C7S_LONG_LAT, |
| 93 | C_STATE_C10, |
| 94 | }; |
| 95 | |
Angel Pons | e49dec4 | 2021-01-21 21:54:14 +0100 | [diff] [blame] | 96 | static const int cstate_set_lp[3] = { |
Angel Pons | bda1c55 | 2020-10-29 00:08:24 +0100 | [diff] [blame] | 97 | C_STATE_C1E, |
| 98 | C_STATE_C3, |
| 99 | C_STATE_C7S_LONG_LAT, |
Angel Pons | ba5761a | 2020-10-28 18:50:26 +0100 | [diff] [blame] | 100 | }; |
| 101 | |
Angel Pons | e49dec4 | 2021-01-21 21:54:14 +0100 | [diff] [blame] | 102 | static const int cstate_set_trad[3] = { |
Angel Pons | bda1c55 | 2020-10-29 00:08:24 +0100 | [diff] [blame] | 103 | C_STATE_C1, |
| 104 | C_STATE_C3, |
| 105 | C_STATE_C6_LONG_LAT, |
Angel Pons | ba5761a | 2020-10-28 18:50:26 +0100 | [diff] [blame] | 106 | }; |
| 107 | |
Angel Pons | 11235d6 | 2021-01-04 17:56:44 +0100 | [diff] [blame] | 108 | static int get_logical_cores_per_package(void) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 109 | { |
Angel Pons | 11235d6 | 2021-01-04 17:56:44 +0100 | [diff] [blame] | 110 | msr_t msr = rdmsr(MSR_CORE_THREAD_COUNT); |
| 111 | return msr.lo & 0xffff; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 112 | } |
| 113 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 114 | static acpi_tstate_t tss_table_fine[] = { |
| 115 | { 100, 1000, 0, 0x00, 0 }, |
| 116 | { 94, 940, 0, 0x1f, 0 }, |
| 117 | { 88, 880, 0, 0x1e, 0 }, |
| 118 | { 82, 820, 0, 0x1d, 0 }, |
| 119 | { 75, 760, 0, 0x1c, 0 }, |
| 120 | { 69, 700, 0, 0x1b, 0 }, |
| 121 | { 63, 640, 0, 0x1a, 0 }, |
| 122 | { 57, 580, 0, 0x19, 0 }, |
| 123 | { 50, 520, 0, 0x18, 0 }, |
| 124 | { 44, 460, 0, 0x17, 0 }, |
| 125 | { 38, 400, 0, 0x16, 0 }, |
| 126 | { 32, 340, 0, 0x15, 0 }, |
| 127 | { 25, 280, 0, 0x14, 0 }, |
| 128 | { 19, 220, 0, 0x13, 0 }, |
| 129 | { 13, 160, 0, 0x12, 0 }, |
| 130 | }; |
| 131 | |
| 132 | static acpi_tstate_t tss_table_coarse[] = { |
| 133 | { 100, 1000, 0, 0x00, 0 }, |
| 134 | { 88, 875, 0, 0x1f, 0 }, |
| 135 | { 75, 750, 0, 0x1e, 0 }, |
| 136 | { 63, 625, 0, 0x1d, 0 }, |
| 137 | { 50, 500, 0, 0x1c, 0 }, |
| 138 | { 38, 375, 0, 0x1b, 0 }, |
| 139 | { 25, 250, 0, 0x1a, 0 }, |
| 140 | { 13, 125, 0, 0x19, 0 }, |
| 141 | }; |
| 142 | |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 143 | static void generate_T_state_entries(int core, int cores_per_package) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 144 | { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 145 | /* Indicate SW_ALL coordination for T-states */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 146 | acpigen_write_TSD_package(core, cores_per_package, SW_ALL); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 147 | |
| 148 | /* Indicate FFixedHW so OS will use MSR */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 149 | acpigen_write_empty_PTC(); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 150 | |
| 151 | /* Set a T-state limit that can be modified in NVS */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 152 | acpigen_write_TPC("\\TLVL"); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 153 | |
| 154 | /* |
| 155 | * CPUID.(EAX=6):EAX[5] indicates support |
| 156 | * for extended throttle levels. |
| 157 | */ |
| 158 | if (cpuid_eax(6) & (1 << 5)) |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 159 | acpigen_write_TSS_package( |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 160 | ARRAY_SIZE(tss_table_fine), tss_table_fine); |
| 161 | else |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 162 | acpigen_write_TSS_package( |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 163 | ARRAY_SIZE(tss_table_coarse), tss_table_coarse); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 164 | } |
| 165 | |
Angel Pons | 8e6f162 | 2020-10-29 00:18:11 +0100 | [diff] [blame] | 166 | static bool is_s0ix_enabled(void) |
| 167 | { |
| 168 | if (!haswell_is_ult()) |
| 169 | return false; |
| 170 | |
| 171 | const struct device *lapic = dev_find_lapic(SPEEDSTEP_APIC_MAGIC); |
| 172 | |
| 173 | if (!lapic || !lapic->chip_info) |
| 174 | return false; |
| 175 | |
| 176 | const struct cpu_intel_haswell_config *conf = lapic->chip_info; |
| 177 | |
| 178 | return conf->s0ix_enable; |
| 179 | } |
| 180 | |
Angel Pons | 2aaf7c0 | 2020-09-24 18:03:18 +0200 | [diff] [blame] | 181 | static void generate_C_state_entries(void) |
| 182 | { |
Angel Pons | 618b9ad | 2021-01-21 21:22:19 +0100 | [diff] [blame] | 183 | acpi_cstate_t acpi_cstate_map[3] = {0}; |
Angel Pons | ba5761a | 2020-10-28 18:50:26 +0100 | [diff] [blame] | 184 | |
Angel Pons | e49dec4 | 2021-01-21 21:54:14 +0100 | [diff] [blame] | 185 | const int *acpi_cstates; |
Angel Pons | 2aaf7c0 | 2020-09-24 18:03:18 +0200 | [diff] [blame] | 186 | |
Angel Pons | 8e6f162 | 2020-10-29 00:18:11 +0100 | [diff] [blame] | 187 | if (is_s0ix_enabled()) |
Angel Pons | 618b9ad | 2021-01-21 21:22:19 +0100 | [diff] [blame] | 188 | acpi_cstates = cstate_set_s0ix; |
Angel Pons | 8e6f162 | 2020-10-29 00:18:11 +0100 | [diff] [blame] | 189 | else if (haswell_is_ult()) |
Angel Pons | 618b9ad | 2021-01-21 21:22:19 +0100 | [diff] [blame] | 190 | acpi_cstates = cstate_set_lp; |
Angel Pons | ba5761a | 2020-10-28 18:50:26 +0100 | [diff] [blame] | 191 | else |
Angel Pons | 618b9ad | 2021-01-21 21:22:19 +0100 | [diff] [blame] | 192 | acpi_cstates = cstate_set_trad; |
Angel Pons | 2aaf7c0 | 2020-09-24 18:03:18 +0200 | [diff] [blame] | 193 | |
Angel Pons | 618b9ad | 2021-01-21 21:22:19 +0100 | [diff] [blame] | 194 | /* Count number of active C-states */ |
| 195 | int count = 0; |
| 196 | |
| 197 | for (int i = 0; i < ARRAY_SIZE(acpi_cstate_map); i++) { |
| 198 | if (acpi_cstates[i] > 0 && acpi_cstates[i] < ARRAY_SIZE(cstate_map)) { |
| 199 | acpi_cstate_map[count] = cstate_map[acpi_cstates[i]]; |
| 200 | acpi_cstate_map[count].ctype = i + 1; |
| 201 | count++; |
| 202 | } |
Angel Pons | ba5761a | 2020-10-28 18:50:26 +0100 | [diff] [blame] | 203 | } |
Angel Pons | 618b9ad | 2021-01-21 21:22:19 +0100 | [diff] [blame] | 204 | acpigen_write_CST_package(acpi_cstate_map, count); |
Angel Pons | 2aaf7c0 | 2020-09-24 18:03:18 +0200 | [diff] [blame] | 205 | } |
| 206 | |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 207 | static int calculate_power(int tdp, int p1_ratio, int ratio) |
| 208 | { |
| 209 | u32 m; |
| 210 | u32 power; |
| 211 | |
| 212 | /* |
| 213 | * M = ((1.1 - ((p1_ratio - ratio) * 0.00625)) / 1.1) ^ 2 |
| 214 | * |
| 215 | * Power = (ratio / p1_ratio) * m * tdp |
| 216 | */ |
| 217 | |
| 218 | m = (110000 - ((p1_ratio - ratio) * 625)) / 11; |
| 219 | m = (m * m) / 1000; |
| 220 | |
| 221 | power = ((ratio * 100000 / p1_ratio) / 100); |
| 222 | power *= (m / 100) * (tdp / 1000); |
| 223 | power /= 1000; |
| 224 | |
| 225 | return (int)power; |
| 226 | } |
| 227 | |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 228 | static void generate_P_state_entries(int core, int cores_per_package) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 229 | { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 230 | int ratio_min, ratio_max, ratio_turbo, ratio_step; |
| 231 | int coord_type, power_max, power_unit, num_entries; |
| 232 | int ratio, power, clock, clock_max; |
| 233 | msr_t msr; |
| 234 | |
| 235 | /* Determine P-state coordination type from MISC_PWR_MGMT[0] */ |
| 236 | msr = rdmsr(MSR_MISC_PWR_MGMT); |
| 237 | if (msr.lo & MISC_PWR_MGMT_EIST_HW_DIS) |
| 238 | coord_type = SW_ANY; |
| 239 | else |
| 240 | coord_type = HW_ALL; |
| 241 | |
| 242 | /* Get bus ratio limits and calculate clock speeds */ |
| 243 | msr = rdmsr(MSR_PLATFORM_INFO); |
| 244 | ratio_min = (msr.hi >> (40-32)) & 0xff; /* Max Efficiency Ratio */ |
| 245 | |
| 246 | /* Determine if this CPU has configurable TDP */ |
| 247 | if (cpu_config_tdp_levels()) { |
| 248 | /* Set max ratio to nominal TDP ratio */ |
| 249 | msr = rdmsr(MSR_CONFIG_TDP_NOMINAL); |
| 250 | ratio_max = msr.lo & 0xff; |
| 251 | } else { |
| 252 | /* Max Non-Turbo Ratio */ |
| 253 | ratio_max = (msr.lo >> 8) & 0xff; |
| 254 | } |
Angel Pons | ca96549 | 2020-10-28 19:15:36 +0100 | [diff] [blame] | 255 | clock_max = ratio_max * CPU_BCLK; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 256 | |
| 257 | /* Calculate CPU TDP in mW */ |
| 258 | msr = rdmsr(MSR_PKG_POWER_SKU_UNIT); |
| 259 | power_unit = 2 << ((msr.lo & 0xf) - 1); |
| 260 | msr = rdmsr(MSR_PKG_POWER_SKU); |
| 261 | power_max = ((msr.lo & 0x7fff) / power_unit) * 1000; |
| 262 | |
| 263 | /* Write _PCT indicating use of FFixedHW */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 264 | acpigen_write_empty_PCT(); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 265 | |
| 266 | /* Write _PPC with no limit on supported P-state */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 267 | acpigen_write_PPC_NVS(); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 268 | |
| 269 | /* Write PSD indicating configured coordination type */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 270 | acpigen_write_PSD_package(core, 1, coord_type); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 271 | |
| 272 | /* Add P-state entries in _PSS table */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 273 | acpigen_write_name("_PSS"); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 274 | |
| 275 | /* Determine ratio points */ |
| 276 | ratio_step = PSS_RATIO_STEP; |
| 277 | num_entries = (ratio_max - ratio_min) / ratio_step; |
| 278 | while (num_entries > PSS_MAX_ENTRIES-1) { |
| 279 | ratio_step <<= 1; |
| 280 | num_entries >>= 1; |
| 281 | } |
| 282 | |
| 283 | /* P[T] is Turbo state if enabled */ |
| 284 | if (get_turbo_state() == TURBO_ENABLED) { |
| 285 | /* _PSS package count including Turbo */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 286 | acpigen_write_package(num_entries + 2); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 287 | |
| 288 | msr = rdmsr(MSR_TURBO_RATIO_LIMIT); |
| 289 | ratio_turbo = msr.lo & 0xff; |
| 290 | |
| 291 | /* Add entry for Turbo ratio */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 292 | acpigen_write_PSS_package( |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 293 | clock_max + 1, /*MHz*/ |
| 294 | power_max, /*mW*/ |
| 295 | PSS_LATENCY_TRANSITION, /*lat1*/ |
| 296 | PSS_LATENCY_BUSMASTER, /*lat2*/ |
| 297 | ratio_turbo << 8, /*control*/ |
| 298 | ratio_turbo << 8); /*status*/ |
| 299 | } else { |
| 300 | /* _PSS package count without Turbo */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 301 | acpigen_write_package(num_entries + 1); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | /* First regular entry is max non-turbo ratio */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 305 | acpigen_write_PSS_package( |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 306 | clock_max, /*MHz*/ |
| 307 | power_max, /*mW*/ |
| 308 | PSS_LATENCY_TRANSITION, /*lat1*/ |
| 309 | PSS_LATENCY_BUSMASTER, /*lat2*/ |
| 310 | ratio_max << 8, /*control*/ |
| 311 | ratio_max << 8); /*status*/ |
| 312 | |
| 313 | /* Generate the remaining entries */ |
| 314 | for (ratio = ratio_min + ((num_entries - 1) * ratio_step); |
| 315 | ratio >= ratio_min; ratio -= ratio_step) { |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 316 | /* Calculate power at this ratio */ |
| 317 | power = calculate_power(power_max, ratio_max, ratio); |
Angel Pons | ca96549 | 2020-10-28 19:15:36 +0100 | [diff] [blame] | 318 | clock = ratio * CPU_BCLK; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 319 | |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 320 | acpigen_write_PSS_package( |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 321 | clock, /*MHz*/ |
| 322 | power, /*mW*/ |
| 323 | PSS_LATENCY_TRANSITION, /*lat1*/ |
| 324 | PSS_LATENCY_BUSMASTER, /*lat2*/ |
| 325 | ratio << 8, /*control*/ |
| 326 | ratio << 8); /*status*/ |
| 327 | } |
| 328 | |
| 329 | /* Fix package length */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 330 | acpigen_pop_len(); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 331 | } |
| 332 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 333 | void generate_cpu_entries(const struct device *device) |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 334 | { |
Angel Pons | 151d561 | 2021-06-04 12:11:26 +0200 | [diff] [blame] | 335 | int coreID, cpuID; |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 336 | int totalcores = dev_count_cpu(); |
Angel Pons | 11235d6 | 2021-01-04 17:56:44 +0100 | [diff] [blame] | 337 | int cores_per_package = get_logical_cores_per_package(); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 338 | int numcpus = totalcores/cores_per_package; |
| 339 | |
| 340 | printk(BIOS_DEBUG, "Found %d CPU(s) with %d core(s) each.\n", |
| 341 | numcpus, cores_per_package); |
| 342 | |
Martin Roth | 9944b28 | 2014-08-11 11:24:55 -0600 | [diff] [blame] | 343 | for (cpuID = 1; cpuID <= numcpus; cpuID++) { |
Lee Leahy | 9d62e7e | 2017-03-15 17:40:50 -0700 | [diff] [blame] | 344 | for (coreID = 1; coreID <= cores_per_package; coreID++) { |
Christian Walter | be3979c | 2019-12-18 15:07:59 +0100 | [diff] [blame] | 345 | /* Generate processor \_SB.CPUx */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 346 | acpigen_write_processor( |
Angel Pons | 151d561 | 2021-06-04 12:11:26 +0200 | [diff] [blame] | 347 | (cpuID - 1) * cores_per_package+coreID - 1, 0, 0); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 348 | |
| 349 | /* Generate P-state tables */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 350 | generate_P_state_entries( |
Angel Pons | 2aaf7c0 | 2020-09-24 18:03:18 +0200 | [diff] [blame] | 351 | coreID - 1, cores_per_package); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 352 | |
| 353 | /* Generate C-state tables */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 354 | generate_C_state_entries(); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 355 | |
| 356 | /* Generate T-state tables */ |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 357 | generate_T_state_entries( |
Angel Pons | 2aaf7c0 | 2020-09-24 18:03:18 +0200 | [diff] [blame] | 358 | cpuID - 1, cores_per_package); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 359 | |
Vladimir Serbinenko | be0fd0a | 2014-11-04 21:10:59 +0100 | [diff] [blame] | 360 | acpigen_pop_len(); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 361 | } |
| 362 | } |
Arthur Heymans | c54d14f | 2018-11-28 12:09:23 +0100 | [diff] [blame] | 363 | |
| 364 | /* PPKG is usually used for thermal management |
| 365 | of the first and only package. */ |
| 366 | acpigen_write_processor_package("PPKG", 0, cores_per_package); |
| 367 | |
| 368 | /* Add a method to notify processor nodes */ |
| 369 | acpigen_write_processor_cnot(cores_per_package); |
Aaron Durbin | 76c3700 | 2012-10-30 09:03:43 -0500 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | struct chip_operations cpu_intel_haswell_ops = { |
| 373 | CHIP_NAME("Intel Haswell CPU") |
| 374 | }; |