Angel Pons | ae59387 | 2020-04-04 18:50:57 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 2 | |
| 3 | /* |
| 4 | * ACPI - create the Fixed ACPI Description Tables (FADT) |
| 5 | */ |
| 6 | |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 7 | #include <console/console.h> |
Furquan Shaikh | 76cedd2 | 2020-05-02 10:24:23 -0700 | [diff] [blame] | 8 | #include <acpi/acpi.h> |
| 9 | #include <acpi/acpigen.h> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 10 | #include <device/pci_ops.h> |
| 11 | #include <arch/ioapic.h> |
Raul E Rangel | 93b62e6 | 2020-01-31 12:53:45 -0700 | [diff] [blame] | 12 | #include <arch/smp/mpspec.h> |
Jason Glenesk | 498015d | 2020-12-10 03:28:38 -0800 | [diff] [blame] | 13 | #include <cpu/amd/cpuid.h> |
Jason Glenesk | bc52143 | 2020-09-14 05:22:47 -0700 | [diff] [blame] | 14 | #include <cpu/amd/msr.h> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 15 | #include <cpu/x86/smm.h> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 16 | #include <device/device.h> |
| 17 | #include <device/pci.h> |
| 18 | #include <amdblocks/acpimmio.h> |
| 19 | #include <amdblocks/acpi.h> |
Raul E Rangel | 1c88b10 | 2021-02-11 10:35:32 -0700 | [diff] [blame] | 20 | #include <amdblocks/chip.h> |
Felix Held | dd2f3fa | 2021-02-08 22:23:54 +0100 | [diff] [blame] | 21 | #include <amdblocks/cpu.h> |
Felix Held | 604ffa6 | 2021-02-12 00:43:20 +0100 | [diff] [blame] | 22 | #include <amdblocks/ioapic.h> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 23 | #include <soc/acpi.h> |
| 24 | #include <soc/pci_devs.h> |
Jason Glenesk | bc52143 | 2020-09-14 05:22:47 -0700 | [diff] [blame] | 25 | #include <soc/msr.h> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 26 | #include <soc/southbridge.h> |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 27 | #include <soc/gpio.h> |
| 28 | #include <version.h> |
Raul E Rangel | 93b62e6 | 2020-01-31 12:53:45 -0700 | [diff] [blame] | 29 | #include "chip.h" |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 30 | |
| 31 | unsigned long acpi_fill_madt(unsigned long current) |
| 32 | { |
| 33 | /* create all subtables for processors */ |
| 34 | current = acpi_create_madt_lapics(current); |
| 35 | |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 36 | current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *)current, |
Felix Held | 604ffa6 | 2021-02-12 00:43:20 +0100 | [diff] [blame] | 37 | FCH_IOAPIC_ID, IO_APIC_ADDR, 0); |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 38 | |
Jason Glenesk | f459a40 | 2020-09-02 16:49:10 -0700 | [diff] [blame] | 39 | current += acpi_create_madt_ioapic((acpi_madt_ioapic_t *)current, |
Felix Held | 604ffa6 | 2021-02-12 00:43:20 +0100 | [diff] [blame] | 40 | GNB_IOAPIC_ID, GNB_IO_APIC_ADDR, IO_APIC_INTERRUPTS); |
Jason Glenesk | f459a40 | 2020-09-02 16:49:10 -0700 | [diff] [blame] | 41 | |
Felix Held | 69a957f | 2021-06-17 15:48:25 +0200 | [diff] [blame] | 42 | /* PIT is connected to legacy IRQ 0, but IOAPIC GSI 2 */ |
| 43 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)current, |
| 44 | MP_BUS_ISA, 0, 2, |
| 45 | MP_IRQ_TRIGGER_DEFAULT | MP_IRQ_POLARITY_DEFAULT); |
| 46 | /* SCI IRQ type override */ |
| 47 | current += acpi_create_madt_irqoverride((acpi_madt_irqoverride_t *)current, |
| 48 | MP_BUS_ISA, 9, 9, |
| 49 | MP_IRQ_TRIGGER_LEVEL | MP_IRQ_POLARITY_LOW); |
Raul E Rangel | 93b62e6 | 2020-01-31 12:53:45 -0700 | [diff] [blame] | 50 | |
Raul E Rangel | ffab5e6 | 2021-02-11 11:07:11 -0700 | [diff] [blame] | 51 | current = acpi_fill_madt_irqoverride(current); |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 52 | |
| 53 | /* create all subtables for processors */ |
| 54 | current += acpi_create_madt_lapic_nmi((acpi_madt_lapic_nmi_t *)current, |
Felix Held | 69a957f | 2021-06-17 15:48:25 +0200 | [diff] [blame] | 55 | ACPI_MADT_LAPIC_NMI_ALL_PROCESSORS, |
| 56 | MP_IRQ_TRIGGER_EDGE | MP_IRQ_POLARITY_HIGH, |
| 57 | 1 /* 1: LINT1 connect to NMI */); |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 58 | |
| 59 | return current; |
| 60 | } |
| 61 | |
| 62 | /* |
| 63 | * Reference section 5.2.9 Fixed ACPI Description Table (FADT) |
| 64 | * in the ACPI 3.0b specification. |
| 65 | */ |
Kyösti Mälkki | 61ef71b | 2020-05-30 18:54:39 +0300 | [diff] [blame] | 66 | void acpi_fill_fadt(acpi_fadt_t *fadt) |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 67 | { |
Raul E Rangel | 1c88b10 | 2021-02-11 10:35:32 -0700 | [diff] [blame] | 68 | const struct soc_amd_common_config *cfg = soc_get_common_config(); |
Martin Roth | eca8faa | 2019-12-01 16:49:19 -0700 | [diff] [blame] | 69 | |
Felix Held | 757d645 | 2021-02-04 21:31:49 +0100 | [diff] [blame] | 70 | printk(BIOS_DEBUG, "pm_base: 0x%04x\n", ACPI_IO_BASE); |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 71 | |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 72 | fadt->sci_int = 9; /* IRQ 09 - ACPI SCI */ |
| 73 | |
Kyösti Mälkki | 0a9e72e | 2019-08-11 01:22:28 +0300 | [diff] [blame] | 74 | if (permanent_smi_handler()) { |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 75 | fadt->smi_cmd = APM_CNT; |
| 76 | fadt->acpi_enable = APM_CNT_ACPI_ENABLE; |
| 77 | fadt->acpi_disable = APM_CNT_ACPI_DISABLE; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | fadt->pm1a_evt_blk = ACPI_PM_EVT_BLK; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 81 | fadt->pm1a_cnt_blk = ACPI_PM1_CNT_BLK; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 82 | fadt->pm_tmr_blk = ACPI_PM_TMR_BLK; |
| 83 | fadt->gpe0_blk = ACPI_GPE0_BLK; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 84 | |
| 85 | fadt->pm1_evt_len = 4; /* 32 bits */ |
| 86 | fadt->pm1_cnt_len = 2; /* 16 bits */ |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 87 | fadt->pm_tmr_len = 4; /* 32 bits */ |
| 88 | fadt->gpe0_blk_len = 8; /* 64 bits */ |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 89 | |
| 90 | fadt->p_lvl2_lat = ACPI_FADT_C2_NOT_SUPPORTED; |
| 91 | fadt->p_lvl3_lat = ACPI_FADT_C3_NOT_SUPPORTED; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 92 | fadt->duty_offset = 1; /* CLK_VAL bits 3:1 */ |
| 93 | fadt->duty_width = 3; /* CLK_VAL bits 3:1 */ |
Felix Held | 72b92c9 | 2021-11-18 20:41:40 +0100 | [diff] [blame] | 94 | fadt->day_alrm = RTC_DATE_ALARM; |
Raul E Rangel | 041fcf5 | 2020-08-12 12:13:35 -0600 | [diff] [blame] | 95 | fadt->mon_alrm = 0; |
Martin Roth | eca8faa | 2019-12-01 16:49:19 -0700 | [diff] [blame] | 96 | fadt->iapc_boot_arch = cfg->fadt_boot_arch; /* legacy free default */ |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 97 | fadt->res2 = 0; /* reserved, MUST be 0 ACPI 3.0 */ |
Martin Roth | eca8faa | 2019-12-01 16:49:19 -0700 | [diff] [blame] | 98 | fadt->flags |= ACPI_FADT_WBINVD | /* See table 5-34 ACPI 6.3 spec */ |
| 99 | ACPI_FADT_C1_SUPPORTED | |
| 100 | ACPI_FADT_S4_RTC_WAKE | |
| 101 | ACPI_FADT_32BIT_TIMER | |
| 102 | ACPI_FADT_PCI_EXPRESS_WAKE | |
| 103 | ACPI_FADT_PLATFORM_CLOCK | |
| 104 | ACPI_FADT_S4_RTC_VALID | |
| 105 | ACPI_FADT_REMOTE_POWER_ON; |
| 106 | fadt->flags |= cfg->fadt_flags; /* additional board-specific flags */ |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 107 | |
Elyes Haouas | b55ac09 | 2022-02-16 14:42:19 +0100 | [diff] [blame] | 108 | fadt->ARM_boot_arch = 0; /* Must be zero if ACPI Revision <= 5.0 */ |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 109 | |
| 110 | fadt->x_firmware_ctl_l = 0; /* set to 0 if firmware_ctrl is used */ |
| 111 | fadt->x_firmware_ctl_h = 0; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 112 | |
| 113 | fadt->x_pm1a_evt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 114 | fadt->x_pm1a_evt_blk.bit_width = 32; |
| 115 | fadt->x_pm1a_evt_blk.bit_offset = 0; |
| 116 | fadt->x_pm1a_evt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
| 117 | fadt->x_pm1a_evt_blk.addrl = ACPI_PM_EVT_BLK; |
| 118 | fadt->x_pm1a_evt_blk.addrh = 0x0; |
| 119 | |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 120 | fadt->x_pm1a_cnt_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 121 | fadt->x_pm1a_cnt_blk.bit_width = 16; |
| 122 | fadt->x_pm1a_cnt_blk.bit_offset = 0; |
Patrick Rudolph | c02bda0 | 2020-02-28 10:19:41 +0100 | [diff] [blame] | 123 | fadt->x_pm1a_cnt_blk.access_size = ACPI_ACCESS_SIZE_WORD_ACCESS; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 124 | fadt->x_pm1a_cnt_blk.addrl = ACPI_PM1_CNT_BLK; |
| 125 | fadt->x_pm1a_cnt_blk.addrh = 0x0; |
| 126 | |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 127 | fadt->x_pm_tmr_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 128 | fadt->x_pm_tmr_blk.bit_width = 32; |
| 129 | fadt->x_pm_tmr_blk.bit_offset = 0; |
| 130 | fadt->x_pm_tmr_blk.access_size = ACPI_ACCESS_SIZE_DWORD_ACCESS; |
| 131 | fadt->x_pm_tmr_blk.addrl = ACPI_PM_TMR_BLK; |
| 132 | fadt->x_pm_tmr_blk.addrh = 0x0; |
| 133 | |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 134 | fadt->x_gpe0_blk.space_id = ACPI_ADDRESS_SPACE_IO; |
| 135 | fadt->x_gpe0_blk.bit_width = 64; /* EventStatus + Event Enable */ |
| 136 | fadt->x_gpe0_blk.bit_offset = 0; |
Angel Pons | a23aff3 | 2020-06-21 20:47:54 +0200 | [diff] [blame] | 137 | fadt->x_gpe0_blk.access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 138 | fadt->x_gpe0_blk.addrl = ACPI_GPE0_BLK; |
| 139 | fadt->x_gpe0_blk.addrh = 0x0; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 140 | } |
| 141 | |
Jason Glenesk | bc52143 | 2020-09-14 05:22:47 -0700 | [diff] [blame] | 142 | static uint32_t get_pstate_core_freq(msr_t pstate_def) |
| 143 | { |
| 144 | uint32_t core_freq, core_freq_mul, core_freq_div; |
| 145 | bool valid_freq_divisor; |
| 146 | |
| 147 | /* Core frequency multiplier */ |
| 148 | core_freq_mul = pstate_def.lo & PSTATE_DEF_LO_FREQ_MUL_MASK; |
| 149 | |
| 150 | /* Core frequency divisor ID */ |
| 151 | core_freq_div = |
| 152 | (pstate_def.lo & PSTATE_DEF_LO_FREQ_DIV_MASK) >> PSTATE_DEF_LO_FREQ_DIV_SHIFT; |
| 153 | |
| 154 | if (core_freq_div == 0) { |
| 155 | return 0; |
| 156 | } else if ((core_freq_div >= PSTATE_DEF_LO_FREQ_DIV_MIN) |
| 157 | && (core_freq_div <= PSTATE_DEF_LO_EIGHTH_STEP_MAX)) { |
| 158 | /* Allow 1/8 integer steps for this range */ |
| 159 | valid_freq_divisor = 1; |
| 160 | } else if ((core_freq_div > PSTATE_DEF_LO_EIGHTH_STEP_MAX) |
| 161 | && (core_freq_div <= PSTATE_DEF_LO_FREQ_DIV_MAX) && !(core_freq_div & 0x1)) { |
| 162 | /* Only allow 1/4 integer steps for this range */ |
| 163 | valid_freq_divisor = 1; |
| 164 | } else { |
| 165 | valid_freq_divisor = 0; |
| 166 | } |
| 167 | |
| 168 | if (valid_freq_divisor) { |
| 169 | /* 25 * core_freq_mul / (core_freq_div / 8) */ |
| 170 | core_freq = |
| 171 | ((PSTATE_DEF_LO_CORE_FREQ_BASE * core_freq_mul * 8) / (core_freq_div)); |
| 172 | } else { |
| 173 | printk(BIOS_WARNING, "Undefined core_freq_div %x used. Force to 1.\n", |
| 174 | core_freq_div); |
| 175 | core_freq = (PSTATE_DEF_LO_CORE_FREQ_BASE * core_freq_mul); |
| 176 | } |
| 177 | return core_freq; |
| 178 | } |
| 179 | |
| 180 | static uint32_t get_pstate_core_power(msr_t pstate_def) |
| 181 | { |
| 182 | uint32_t voltage_in_uvolts, core_vid, current_value_amps, current_divisor, power_in_mw; |
| 183 | |
| 184 | /* Core voltage ID */ |
| 185 | core_vid = |
| 186 | (pstate_def.lo & PSTATE_DEF_LO_CORE_VID_MASK) >> PSTATE_DEF_LO_CORE_VID_SHIFT; |
| 187 | |
| 188 | /* Current value in amps */ |
| 189 | current_value_amps = |
| 190 | (pstate_def.lo & PSTATE_DEF_LO_CUR_VAL_MASK) >> PSTATE_DEF_LO_CUR_VAL_SHIFT; |
| 191 | |
| 192 | /* Current divisor */ |
| 193 | current_divisor = |
| 194 | (pstate_def.lo & PSTATE_DEF_LO_CUR_DIV_MASK) >> PSTATE_DEF_LO_CUR_DIV_SHIFT; |
| 195 | |
| 196 | /* Voltage */ |
| 197 | if ((core_vid >= 0xF8) && (core_vid <= 0xFF)) { |
| 198 | /* Voltage off for VID codes 0xF8 to 0xFF */ |
| 199 | voltage_in_uvolts = 0; |
| 200 | } else { |
| 201 | voltage_in_uvolts = |
| 202 | SERIAL_VID_MAX_MICROVOLTS - (SERIAL_VID_DECODE_MICROVOLTS * core_vid); |
| 203 | } |
| 204 | |
| 205 | /* Power in mW */ |
| 206 | power_in_mw = (voltage_in_uvolts) / 1000 * current_value_amps; |
| 207 | |
| 208 | switch (current_divisor) { |
| 209 | case 0: |
| 210 | break; |
| 211 | case 1: |
| 212 | power_in_mw = power_in_mw / 10L; |
| 213 | break; |
| 214 | case 2: |
| 215 | power_in_mw = power_in_mw / 100L; |
| 216 | break; |
| 217 | case 3: |
| 218 | /* current_divisor is set to an undefined value.*/ |
| 219 | printk(BIOS_WARNING, "Undefined current_divisor set for enabled P-state .\n"); |
| 220 | power_in_mw = 0; |
| 221 | break; |
| 222 | } |
| 223 | |
| 224 | return power_in_mw; |
| 225 | } |
| 226 | |
| 227 | /* |
| 228 | * Populate structure describing enabled p-states and return count of enabled p-states. |
| 229 | */ |
| 230 | static size_t get_pstate_info(struct acpi_sw_pstate *pstate_values, |
| 231 | struct acpi_xpss_sw_pstate *pstate_xpss_values) |
| 232 | { |
| 233 | msr_t pstate_def; |
| 234 | size_t pstate_count, pstate; |
| 235 | uint32_t pstate_enable, max_pstate; |
| 236 | |
| 237 | pstate_count = 0; |
| 238 | max_pstate = (rdmsr(PS_LIM_REG).lo & PS_LIM_MAX_VAL_MASK) >> PS_MAX_VAL_SHFT; |
| 239 | |
| 240 | for (pstate = 0; pstate <= max_pstate; pstate++) { |
| 241 | pstate_def = rdmsr(PSTATE_0_MSR + pstate); |
| 242 | |
| 243 | pstate_enable = (pstate_def.hi & PSTATE_DEF_HI_ENABLE_MASK) |
| 244 | >> PSTATE_DEF_HI_ENABLE_SHIFT; |
| 245 | if (!pstate_enable) |
| 246 | continue; |
| 247 | |
| 248 | pstate_values[pstate_count].core_freq = get_pstate_core_freq(pstate_def); |
| 249 | pstate_values[pstate_count].power = get_pstate_core_power(pstate_def); |
| 250 | pstate_values[pstate_count].transition_latency = 0; |
| 251 | pstate_values[pstate_count].bus_master_latency = 0; |
| 252 | pstate_values[pstate_count].control_value = pstate; |
| 253 | pstate_values[pstate_count].status_value = pstate; |
| 254 | |
| 255 | pstate_xpss_values[pstate_count].core_freq = |
| 256 | (uint64_t)pstate_values[pstate_count].core_freq; |
| 257 | pstate_xpss_values[pstate_count].power = |
| 258 | (uint64_t)pstate_values[pstate_count].power; |
| 259 | pstate_xpss_values[pstate_count].transition_latency = 0; |
| 260 | pstate_xpss_values[pstate_count].bus_master_latency = 0; |
| 261 | pstate_xpss_values[pstate_count].control_value = (uint64_t)pstate; |
| 262 | pstate_xpss_values[pstate_count].status_value = (uint64_t)pstate; |
| 263 | pstate_count++; |
| 264 | } |
| 265 | |
| 266 | return pstate_count; |
| 267 | } |
| 268 | |
Furquan Shaikh | 7536a39 | 2020-04-24 21:59:21 -0700 | [diff] [blame] | 269 | void generate_cpu_entries(const struct device *device) |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 270 | { |
Jason Glenesk | bc52143 | 2020-09-14 05:22:47 -0700 | [diff] [blame] | 271 | int logical_cores; |
| 272 | size_t pstate_count, cpu, proc_blk_len; |
| 273 | struct acpi_sw_pstate pstate_values[MAX_PSTATES] = { {0} }; |
| 274 | struct acpi_xpss_sw_pstate pstate_xpss_values[MAX_PSTATES] = { {0} }; |
| 275 | uint32_t threads_per_core, proc_blk_addr; |
| 276 | uint32_t cstate_base_address = |
| 277 | rdmsr(MSR_CSTATE_ADDRESS).lo & MSR_CSTATE_ADDRESS_MASK; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 278 | |
Jason Glenesk | bc52143 | 2020-09-14 05:22:47 -0700 | [diff] [blame] | 279 | const acpi_addr_t perf_ctrl = { |
| 280 | .space_id = ACPI_ADDRESS_SPACE_FIXED, |
| 281 | .bit_width = 64, |
| 282 | .addrl = PS_CTL_REG, |
| 283 | }; |
| 284 | const acpi_addr_t perf_sts = { |
| 285 | .space_id = ACPI_ADDRESS_SPACE_FIXED, |
| 286 | .bit_width = 64, |
| 287 | .addrl = PS_STS_REG, |
| 288 | }; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 289 | |
Angel Pons | d2794ce | 2021-10-17 12:59:43 +0200 | [diff] [blame] | 290 | const acpi_cstate_t cstate_info[] = { |
Jason Glenesk | bc52143 | 2020-09-14 05:22:47 -0700 | [diff] [blame] | 291 | [0] = { |
| 292 | .ctype = 1, |
| 293 | .latency = 1, |
| 294 | .power = 0, |
| 295 | .resource = { |
| 296 | .space_id = ACPI_ADDRESS_SPACE_FIXED, |
| 297 | .bit_width = 2, |
| 298 | .bit_offset = 2, |
| 299 | .addrl = 0, |
| 300 | .addrh = 0, |
| 301 | }, |
| 302 | }, |
| 303 | [1] = { |
| 304 | .ctype = 2, |
| 305 | .latency = 400, |
| 306 | .power = 0, |
| 307 | .resource = { |
| 308 | .space_id = ACPI_ADDRESS_SPACE_IO, |
| 309 | .bit_width = 8, |
| 310 | .bit_offset = 0, |
| 311 | .addrl = cstate_base_address + 1, |
| 312 | .addrh = 0, |
| 313 | .access_size = ACPI_ACCESS_SIZE_BYTE_ACCESS, |
| 314 | }, |
| 315 | }, |
| 316 | }; |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 317 | |
Felix Held | d4b5ad0 | 2022-01-25 04:14:05 +0100 | [diff] [blame] | 318 | threads_per_core = get_threads_per_core(); |
Jason Glenesk | bc52143 | 2020-09-14 05:22:47 -0700 | [diff] [blame] | 319 | pstate_count = get_pstate_info(pstate_values, pstate_xpss_values); |
| 320 | logical_cores = get_cpu_count(); |
| 321 | |
| 322 | for (cpu = 0; cpu < logical_cores; cpu++) { |
| 323 | |
| 324 | if (cpu == 0) { |
| 325 | /* BSP values for \_SB.Pxxx */ |
| 326 | proc_blk_len = 6; |
| 327 | proc_blk_addr = ACPI_GPE0_BLK; |
| 328 | } else { |
| 329 | /* AP values for \_SB.Pxxx */ |
| 330 | proc_blk_addr = 0; |
| 331 | proc_blk_len = 0; |
| 332 | } |
| 333 | |
| 334 | acpigen_write_processor(cpu, proc_blk_addr, proc_blk_len); |
| 335 | |
| 336 | acpigen_write_pct_package(&perf_ctrl, &perf_sts); |
| 337 | |
| 338 | acpigen_write_pss_object(pstate_values, pstate_count); |
| 339 | |
| 340 | acpigen_write_xpss_object(pstate_xpss_values, pstate_count); |
| 341 | |
| 342 | if (CONFIG(ACPI_SSDT_PSD_INDEPENDENT)) |
| 343 | acpigen_write_PSD_package(cpu / threads_per_core, threads_per_core, |
| 344 | HW_ALL); |
| 345 | else |
| 346 | acpigen_write_PSD_package(0, logical_cores, SW_ALL); |
| 347 | |
| 348 | acpigen_write_PPC(0); |
| 349 | |
| 350 | acpigen_write_CST_package(cstate_info, ARRAY_SIZE(cstate_info)); |
| 351 | |
Felix Held | c563508 | 2021-03-30 02:04:02 +0200 | [diff] [blame] | 352 | acpigen_write_CSD_package(cpu / threads_per_core, threads_per_core, |
| 353 | CSD_HW_ALL, 0); |
Jason Glenesk | bc52143 | 2020-09-14 05:22:47 -0700 | [diff] [blame] | 354 | |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 355 | acpigen_pop_len(); |
| 356 | } |
Kyösti Mälkki | da321d8 | 2021-01-27 20:22:33 +0200 | [diff] [blame] | 357 | |
Felix Held | cf2eeff | 2022-03-02 15:00:59 +0100 | [diff] [blame] | 358 | acpigen_write_processor_package("PPKG", 0, logical_cores); |
Martin Roth | 5c354b9 | 2019-04-22 14:55:16 -0600 | [diff] [blame] | 359 | } |