Angel Pons | f23ae0b | 2020-04-02 23:48:12 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 2 | |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 3 | #include <acpi/acpi.h> |
| 4 | #include <acpi/acpigen.h> |
Elyes Haouas | ad65e8c | 2022-10-31 14:02:13 +0100 | [diff] [blame] | 5 | #include <console/console.h> |
| 6 | #include <cpu/cpu.h> |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 7 | #include <cpu/intel/speedstep.h> |
| 8 | #include <cpu/intel/turbo.h> |
Elyes Haouas | ad65e8c | 2022-10-31 14:02:13 +0100 | [diff] [blame] | 9 | #include <cpu/x86/msr.h> |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 10 | #include <device/device.h> |
Elyes HAOUAS | 7cf1f20 | 2020-07-22 07:53:53 +0200 | [diff] [blame] | 11 | #include <stdint.h> |
| 12 | |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 13 | #include "model_206ax.h" |
| 14 | #include "chip.h" |
| 15 | |
Patrick Rudolph | 588c6f0 | 2023-09-30 10:45:33 +0200 | [diff] [blame^] | 16 | #define MWAIT_RES(state, sub_state) \ |
| 17 | { \ |
| 18 | .addrl = (((state) << 4) | (sub_state)), \ |
| 19 | .space_id = ACPI_ADDRESS_SPACE_FIXED, \ |
| 20 | .bit_width = ACPI_FFIXEDHW_VENDOR_INTEL, \ |
| 21 | .bit_offset = ACPI_FFIXEDHW_CLASS_MWAIT, \ |
| 22 | .access_size = ACPI_FFIXEDHW_FLAG_HW_COORD, \ |
| 23 | } |
| 24 | |
Angel Pons | 85790d0 | 2021-01-21 21:12:27 +0100 | [diff] [blame] | 25 | /* |
| 26 | * List of supported C-states in this processor |
| 27 | * |
| 28 | * Latencies are typical worst-case package exit time in uS |
| 29 | * taken from the SandyBridge BIOS specification. |
| 30 | */ |
Patrick Rudolph | 588c6f0 | 2023-09-30 10:45:33 +0200 | [diff] [blame^] | 31 | static acpi_cstate_t cstate_map[NUM_C_STATES] = { |
| 32 | [C_STATE_C0] = { }, |
| 33 | [C_STATE_C1] = { |
Angel Pons | 85790d0 | 2021-01-21 21:12:27 +0100 | [diff] [blame] | 34 | .latency = 1, |
| 35 | .power = 1000, |
Patrick Rudolph | 588c6f0 | 2023-09-30 10:45:33 +0200 | [diff] [blame^] | 36 | .resource = MWAIT_RES(0, 0), |
Angel Pons | 85790d0 | 2021-01-21 21:12:27 +0100 | [diff] [blame] | 37 | }, |
Patrick Rudolph | 588c6f0 | 2023-09-30 10:45:33 +0200 | [diff] [blame^] | 38 | [C_STATE_C1E] = { |
Angel Pons | 85790d0 | 2021-01-21 21:12:27 +0100 | [diff] [blame] | 39 | .latency = 1, |
| 40 | .power = 1000, |
Patrick Rudolph | 588c6f0 | 2023-09-30 10:45:33 +0200 | [diff] [blame^] | 41 | .resource = MWAIT_RES(0, 1), |
Angel Pons | 85790d0 | 2021-01-21 21:12:27 +0100 | [diff] [blame] | 42 | }, |
Patrick Rudolph | 588c6f0 | 2023-09-30 10:45:33 +0200 | [diff] [blame^] | 43 | [C_STATE_C3] = { |
Angel Pons | 85790d0 | 2021-01-21 21:12:27 +0100 | [diff] [blame] | 44 | .latency = 63, |
| 45 | .power = 500, |
Patrick Rudolph | 588c6f0 | 2023-09-30 10:45:33 +0200 | [diff] [blame^] | 46 | .resource = MWAIT_RES(1, 0), |
Angel Pons | 85790d0 | 2021-01-21 21:12:27 +0100 | [diff] [blame] | 47 | }, |
Patrick Rudolph | 588c6f0 | 2023-09-30 10:45:33 +0200 | [diff] [blame^] | 48 | [C_STATE_C6] = { |
Angel Pons | 85790d0 | 2021-01-21 21:12:27 +0100 | [diff] [blame] | 49 | .latency = 87, |
| 50 | .power = 350, |
Patrick Rudolph | 588c6f0 | 2023-09-30 10:45:33 +0200 | [diff] [blame^] | 51 | .resource = MWAIT_RES(2, 0), |
Angel Pons | 85790d0 | 2021-01-21 21:12:27 +0100 | [diff] [blame] | 52 | }, |
Patrick Rudolph | 588c6f0 | 2023-09-30 10:45:33 +0200 | [diff] [blame^] | 53 | [C_STATE_C7] = { |
Angel Pons | 85790d0 | 2021-01-21 21:12:27 +0100 | [diff] [blame] | 54 | .latency = 90, |
| 55 | .power = 200, |
Patrick Rudolph | 588c6f0 | 2023-09-30 10:45:33 +0200 | [diff] [blame^] | 56 | .resource = MWAIT_RES(3, 0), |
Angel Pons | 85790d0 | 2021-01-21 21:12:27 +0100 | [diff] [blame] | 57 | }, |
Patrick Rudolph | 588c6f0 | 2023-09-30 10:45:33 +0200 | [diff] [blame^] | 58 | [C_STATE_C7S] = { |
Angel Pons | 85790d0 | 2021-01-21 21:12:27 +0100 | [diff] [blame] | 59 | .latency = 90, |
| 60 | .power = 200, |
Patrick Rudolph | 588c6f0 | 2023-09-30 10:45:33 +0200 | [diff] [blame^] | 61 | .resource = MWAIT_RES(3, 1), |
Angel Pons | 85790d0 | 2021-01-21 21:12:27 +0100 | [diff] [blame] | 62 | }, |
| 63 | }; |
| 64 | |
Patrick Rudolph | 1306432 | 2023-09-25 08:10:58 +0200 | [diff] [blame] | 65 | static const char *const c_state_names[] = {"C0", "C1", "C1E", "C3", "C6", "C7", "C7S"}; |
| 66 | |
Evgeny Zinoviev | 920d2b7 | 2020-06-16 08:23:09 +0300 | [diff] [blame] | 67 | static int get_logical_cores_per_package(void) |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 68 | { |
Evgeny Zinoviev | 920d2b7 | 2020-06-16 08:23:09 +0300 | [diff] [blame] | 69 | msr_t msr = rdmsr(MSR_CORE_THREAD_COUNT); |
| 70 | return msr.lo & 0xffff; |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 71 | } |
| 72 | |
Patrick Rudolph | 1306432 | 2023-09-25 08:10:58 +0200 | [diff] [blame] | 73 | static void print_supported_cstates(void) |
| 74 | { |
| 75 | uint8_t state, substate; |
| 76 | |
| 77 | printk(BIOS_DEBUG, "Supported C-states: "); |
| 78 | |
| 79 | for (size_t i = 0; i < ARRAY_SIZE(cstate_map); i++) { |
| 80 | state = (cstate_map[i].resource.addrl >> 4) + 1; |
| 81 | substate = cstate_map[i].resource.addrl & 0xf; |
| 82 | |
| 83 | /* CPU C0 is always supported */ |
| 84 | if (i == 0 || cpu_get_c_substate_support(state) > substate) |
| 85 | printk(BIOS_DEBUG, " %s", c_state_names[i]); |
| 86 | } |
| 87 | printk(BIOS_DEBUG, "\n"); |
| 88 | } |
| 89 | |
Arthur Heymans | cdb26fd | 2021-11-15 20:12:02 +0100 | [diff] [blame] | 90 | static void generate_C_state_entries(const struct device *dev) |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 91 | { |
Arthur Heymans | e64b8ac | 2022-12-12 19:28:44 +0100 | [diff] [blame] | 92 | struct cpu_intel_model_206ax_config *conf = dev->chip_info; |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 93 | |
Angel Pons | d8b9e56 | 2021-01-04 17:37:46 +0100 | [diff] [blame] | 94 | const int acpi_cstates[3] = { conf->acpi_c1, conf->acpi_c2, conf->acpi_c3 }; |
| 95 | |
| 96 | acpi_cstate_t acpi_cstate_map[ARRAY_SIZE(acpi_cstates)] = { 0 }; |
Angel Pons | d8b9e56 | 2021-01-04 17:37:46 +0100 | [diff] [blame] | 97 | /* Count number of active C-states */ |
| 98 | int count = 0; |
| 99 | |
| 100 | for (int i = 0; i < ARRAY_SIZE(acpi_cstates); i++) { |
Angel Pons | 85790d0 | 2021-01-21 21:12:27 +0100 | [diff] [blame] | 101 | if (acpi_cstates[i] > 0 && acpi_cstates[i] < ARRAY_SIZE(cstate_map)) { |
| 102 | acpi_cstate_map[count] = cstate_map[acpi_cstates[i]]; |
Angel Pons | d8b9e56 | 2021-01-04 17:37:46 +0100 | [diff] [blame] | 103 | acpi_cstate_map[count].ctype = i + 1; |
| 104 | count++; |
| 105 | } |
| 106 | } |
| 107 | acpigen_write_CST_package(acpi_cstate_map, count); |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | static acpi_tstate_t tss_table_fine[] = { |
| 111 | { 100, 1000, 0, 0x00, 0 }, |
| 112 | { 94, 940, 0, 0x1f, 0 }, |
| 113 | { 88, 880, 0, 0x1e, 0 }, |
| 114 | { 82, 820, 0, 0x1d, 0 }, |
| 115 | { 75, 760, 0, 0x1c, 0 }, |
| 116 | { 69, 700, 0, 0x1b, 0 }, |
| 117 | { 63, 640, 0, 0x1a, 0 }, |
| 118 | { 57, 580, 0, 0x19, 0 }, |
| 119 | { 50, 520, 0, 0x18, 0 }, |
| 120 | { 44, 460, 0, 0x17, 0 }, |
| 121 | { 38, 400, 0, 0x16, 0 }, |
| 122 | { 32, 340, 0, 0x15, 0 }, |
| 123 | { 25, 280, 0, 0x14, 0 }, |
| 124 | { 19, 220, 0, 0x13, 0 }, |
| 125 | { 13, 160, 0, 0x12, 0 }, |
| 126 | }; |
| 127 | |
| 128 | static acpi_tstate_t tss_table_coarse[] = { |
| 129 | { 100, 1000, 0, 0x00, 0 }, |
| 130 | { 88, 875, 0, 0x1f, 0 }, |
| 131 | { 75, 750, 0, 0x1e, 0 }, |
| 132 | { 63, 625, 0, 0x1d, 0 }, |
| 133 | { 50, 500, 0, 0x1c, 0 }, |
| 134 | { 38, 375, 0, 0x1b, 0 }, |
| 135 | { 25, 250, 0, 0x1a, 0 }, |
| 136 | { 13, 125, 0, 0x19, 0 }, |
| 137 | }; |
| 138 | |
Vladimir Serbinenko | 9bb5c5c | 2014-11-09 03:51:32 +0100 | [diff] [blame] | 139 | static void generate_T_state_entries(int core, int cores_per_package) |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 140 | { |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 141 | /* Indicate SW_ALL coordination for T-states */ |
Vladimir Serbinenko | 9bb5c5c | 2014-11-09 03:51:32 +0100 | [diff] [blame] | 142 | acpigen_write_TSD_package(core, cores_per_package, SW_ALL); |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 143 | |
| 144 | /* Indicate FFixedHW so OS will use MSR */ |
Vladimir Serbinenko | 9bb5c5c | 2014-11-09 03:51:32 +0100 | [diff] [blame] | 145 | acpigen_write_empty_PTC(); |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 146 | |
| 147 | /* Set a T-state limit that can be modified in NVS */ |
Vladimir Serbinenko | 9bb5c5c | 2014-11-09 03:51:32 +0100 | [diff] [blame] | 148 | acpigen_write_TPC("\\TLVL"); |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 149 | |
| 150 | /* |
| 151 | * CPUID.(EAX=6):EAX[5] indicates support |
| 152 | * for extended throttle levels. |
| 153 | */ |
| 154 | if (cpuid_eax(6) & (1 << 5)) |
Vladimir Serbinenko | 9bb5c5c | 2014-11-09 03:51:32 +0100 | [diff] [blame] | 155 | acpigen_write_TSS_package( |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 156 | ARRAY_SIZE(tss_table_fine), tss_table_fine); |
| 157 | else |
Vladimir Serbinenko | 9bb5c5c | 2014-11-09 03:51:32 +0100 | [diff] [blame] | 158 | acpigen_write_TSS_package( |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 159 | ARRAY_SIZE(tss_table_coarse), tss_table_coarse); |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 160 | } |
| 161 | |
| 162 | static int calculate_power(int tdp, int p1_ratio, int ratio) |
| 163 | { |
| 164 | u32 m; |
| 165 | u32 power; |
| 166 | |
| 167 | /* |
| 168 | * M = ((1.1 - ((p1_ratio - ratio) * 0.00625)) / 1.1) ^ 2 |
| 169 | * |
| 170 | * Power = (ratio / p1_ratio) * m * tdp |
| 171 | */ |
| 172 | |
| 173 | m = (110000 - ((p1_ratio - ratio) * 625)) / 11; |
| 174 | m = (m * m) / 1000; |
| 175 | |
| 176 | power = ((ratio * 100000 / p1_ratio) / 100); |
| 177 | power *= (m / 100) * (tdp / 1000); |
| 178 | power /= 1000; |
| 179 | |
| 180 | return (int)power; |
| 181 | } |
| 182 | |
Vladimir Serbinenko | 226d784 | 2014-11-04 21:09:23 +0100 | [diff] [blame] | 183 | static void generate_P_state_entries(int core, int cores_per_package) |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 184 | { |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 185 | int ratio_min, ratio_max, ratio_turbo, ratio_step; |
| 186 | int coord_type, power_max, power_unit, num_entries; |
| 187 | int ratio, power, clock, clock_max; |
| 188 | msr_t msr; |
| 189 | |
| 190 | /* Determine P-state coordination type from MISC_PWR_MGMT[0] */ |
| 191 | msr = rdmsr(MSR_MISC_PWR_MGMT); |
| 192 | if (msr.lo & MISC_PWR_MGMT_EIST_HW_DIS) |
| 193 | coord_type = SW_ANY; |
| 194 | else |
| 195 | coord_type = HW_ALL; |
| 196 | |
| 197 | /* Get bus ratio limits and calculate clock speeds */ |
| 198 | msr = rdmsr(MSR_PLATFORM_INFO); |
| 199 | ratio_min = (msr.hi >> (40-32)) & 0xff; /* Max Efficiency Ratio */ |
Duncan Laurie | 77dbbac | 2012-06-25 09:51:59 -0700 | [diff] [blame] | 200 | |
| 201 | /* Determine if this CPU has configurable TDP */ |
| 202 | if (cpu_config_tdp_levels()) { |
| 203 | /* Set max ratio to nominal TDP ratio */ |
| 204 | msr = rdmsr(MSR_CONFIG_TDP_NOMINAL); |
| 205 | ratio_max = msr.lo & 0xff; |
| 206 | } else { |
| 207 | /* Max Non-Turbo Ratio */ |
| 208 | ratio_max = (msr.lo >> 8) & 0xff; |
| 209 | } |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 210 | clock_max = ratio_max * SANDYBRIDGE_BCLK; |
| 211 | |
| 212 | /* Calculate CPU TDP in mW */ |
| 213 | msr = rdmsr(MSR_PKG_POWER_SKU_UNIT); |
| 214 | power_unit = 2 << ((msr.lo & 0xf) - 1); |
| 215 | msr = rdmsr(MSR_PKG_POWER_SKU); |
| 216 | power_max = ((msr.lo & 0x7fff) / power_unit) * 1000; |
| 217 | |
| 218 | /* Write _PCT indicating use of FFixedHW */ |
Vladimir Serbinenko | 226d784 | 2014-11-04 21:09:23 +0100 | [diff] [blame] | 219 | acpigen_write_empty_PCT(); |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 220 | |
| 221 | /* Write _PPC with no limit on supported P-state */ |
Vladimir Serbinenko | 226d784 | 2014-11-04 21:09:23 +0100 | [diff] [blame] | 222 | acpigen_write_PPC_NVS(); |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 223 | |
| 224 | /* Write PSD indicating configured coordination type */ |
Vladimir Serbinenko | 226d784 | 2014-11-04 21:09:23 +0100 | [diff] [blame] | 225 | acpigen_write_PSD_package(core, cores_per_package, coord_type); |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 226 | |
| 227 | /* Add P-state entries in _PSS table */ |
Vladimir Serbinenko | 226d784 | 2014-11-04 21:09:23 +0100 | [diff] [blame] | 228 | acpigen_write_name("_PSS"); |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 229 | |
| 230 | /* Determine ratio points */ |
| 231 | ratio_step = PSS_RATIO_STEP; |
| 232 | num_entries = (ratio_max - ratio_min) / ratio_step; |
| 233 | while (num_entries > PSS_MAX_ENTRIES-1) { |
| 234 | ratio_step <<= 1; |
| 235 | num_entries >>= 1; |
| 236 | } |
| 237 | |
| 238 | /* P[T] is Turbo state if enabled */ |
| 239 | if (get_turbo_state() == TURBO_ENABLED) { |
| 240 | /* _PSS package count including Turbo */ |
Vladimir Serbinenko | 226d784 | 2014-11-04 21:09:23 +0100 | [diff] [blame] | 241 | acpigen_write_package(num_entries + 2); |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 242 | |
| 243 | msr = rdmsr(MSR_TURBO_RATIO_LIMIT); |
| 244 | ratio_turbo = msr.lo & 0xff; |
| 245 | |
| 246 | /* Add entry for Turbo ratio */ |
Vladimir Serbinenko | 226d784 | 2014-11-04 21:09:23 +0100 | [diff] [blame] | 247 | acpigen_write_PSS_package( |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 248 | clock_max + 1, /*MHz*/ |
| 249 | power_max, /*mW*/ |
| 250 | PSS_LATENCY_TRANSITION, /*lat1*/ |
| 251 | PSS_LATENCY_BUSMASTER, /*lat2*/ |
| 252 | ratio_turbo << 8, /*control*/ |
| 253 | ratio_turbo << 8); /*status*/ |
| 254 | } else { |
| 255 | /* _PSS package count without Turbo */ |
Vladimir Serbinenko | 226d784 | 2014-11-04 21:09:23 +0100 | [diff] [blame] | 256 | acpigen_write_package(num_entries + 1); |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | /* First regular entry is max non-turbo ratio */ |
Vladimir Serbinenko | 226d784 | 2014-11-04 21:09:23 +0100 | [diff] [blame] | 260 | acpigen_write_PSS_package( |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 261 | clock_max, /*MHz*/ |
| 262 | power_max, /*mW*/ |
| 263 | PSS_LATENCY_TRANSITION, /*lat1*/ |
| 264 | PSS_LATENCY_BUSMASTER, /*lat2*/ |
| 265 | ratio_max << 8, /*control*/ |
| 266 | ratio_max << 8); /*status*/ |
| 267 | |
| 268 | /* Generate the remaining entries */ |
| 269 | for (ratio = ratio_min + ((num_entries - 1) * ratio_step); |
| 270 | ratio >= ratio_min; ratio -= ratio_step) { |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 271 | /* Calculate power at this ratio */ |
| 272 | power = calculate_power(power_max, ratio_max, ratio); |
| 273 | clock = ratio * SANDYBRIDGE_BCLK; |
| 274 | |
Vladimir Serbinenko | 226d784 | 2014-11-04 21:09:23 +0100 | [diff] [blame] | 275 | acpigen_write_PSS_package( |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 276 | clock, /*MHz*/ |
| 277 | power, /*mW*/ |
| 278 | PSS_LATENCY_TRANSITION, /*lat1*/ |
| 279 | PSS_LATENCY_BUSMASTER, /*lat2*/ |
| 280 | ratio << 8, /*control*/ |
| 281 | ratio << 8); /*status*/ |
| 282 | } |
| 283 | |
| 284 | /* Fix package length */ |
Vladimir Serbinenko | 226d784 | 2014-11-04 21:09:23 +0100 | [diff] [blame] | 285 | acpigen_pop_len(); |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 286 | } |
| 287 | |
Kyösti Mälkki | d521b96 | 2023-04-12 21:44:49 +0300 | [diff] [blame] | 288 | static void generate_cpu_entry(const struct device *device, int cpu, int core, int cores_per_package) |
| 289 | { |
| 290 | /* Generate Scope(\_SB) { Device(CPUx */ |
| 291 | acpigen_write_processor_device(cpu * cores_per_package + core); |
| 292 | |
| 293 | /* Generate P-state tables */ |
| 294 | generate_P_state_entries(cpu, cores_per_package); |
| 295 | |
| 296 | /* Generate C-state tables */ |
| 297 | generate_C_state_entries(device); |
| 298 | |
| 299 | /* Generate T-state tables */ |
| 300 | generate_T_state_entries(cpu, cores_per_package); |
| 301 | |
| 302 | acpigen_write_processor_device_end(); |
| 303 | } |
| 304 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 305 | void generate_cpu_entries(const struct device *device) |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 306 | { |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 307 | int totalcores = dev_count_cpu(); |
Evgeny Zinoviev | 920d2b7 | 2020-06-16 08:23:09 +0300 | [diff] [blame] | 308 | int cores_per_package = get_logical_cores_per_package(); |
Kyösti Mälkki | e39a3e3 | 2023-04-12 16:39:12 +0300 | [diff] [blame] | 309 | int numcpus = totalcores / cores_per_package; |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 310 | |
| 311 | printk(BIOS_DEBUG, "Found %d CPU(s) with %d core(s) each.\n", |
| 312 | numcpus, cores_per_package); |
| 313 | |
Patrick Rudolph | 1306432 | 2023-09-25 08:10:58 +0200 | [diff] [blame] | 314 | print_supported_cstates(); |
| 315 | |
Kyösti Mälkki | d521b96 | 2023-04-12 21:44:49 +0300 | [diff] [blame] | 316 | for (int cpu_id = 0; cpu_id < numcpus; cpu_id++) |
| 317 | for (int core_id = 0; core_id < cores_per_package; core_id++) |
| 318 | generate_cpu_entry(device, cpu_id, core_id, cores_per_package); |
Arthur Heymans | 04008a9 | 2018-11-28 12:13:54 +0100 | [diff] [blame] | 319 | |
| 320 | /* PPKG is usually used for thermal management |
| 321 | of the first and only package. */ |
| 322 | acpigen_write_processor_package("PPKG", 0, cores_per_package); |
| 323 | |
| 324 | /* Add a method to notify processor nodes */ |
| 325 | acpigen_write_processor_cnot(cores_per_package); |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | struct chip_operations cpu_intel_model_206ax_ops = { |
Stefan Reinauer | 0b7b7b6 | 2012-07-10 17:13:04 -0700 | [diff] [blame] | 329 | CHIP_NAME("Intel SandyBridge/IvyBridge CPU") |
Stefan Reinauer | 5c55463 | 2012-04-04 00:09:50 +0200 | [diff] [blame] | 330 | }; |