Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | /* TODO: Check if this is still correct */ |
| 4 | |
| 5 | #include <acpi/acpigen.h> |
| 6 | #include <amdblocks/acpi.h> |
| 7 | #include <amdblocks/alib.h> |
Arthur Heymans | ce17972 | 2023-06-07 15:27:18 +0200 | [diff] [blame] | 8 | #include <amdblocks/data_fabric.h> |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 9 | #include <amdblocks/ioapic.h> |
Felix Held | 12a4482 | 2023-06-02 15:30:50 +0200 | [diff] [blame] | 10 | #include <amdblocks/iomap.h> |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 11 | #include <amdblocks/memmap.h> |
Felix Held | 81c81e3 | 2023-07-18 20:37:36 +0200 | [diff] [blame] | 12 | #include <amdblocks/root_complex.h> |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 13 | #include <arch/ioapic.h> |
Felix Held | a4ced63 | 2023-06-05 21:22:15 +0200 | [diff] [blame] | 14 | #include <arch/vga.h> |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 15 | #include <cbmem.h> |
| 16 | #include <console/console.h> |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 17 | #include <device/device.h> |
| 18 | #include <device/pci.h> |
Tim Van Patten | f5ae1dd | 2023-03-31 17:31:10 -0600 | [diff] [blame] | 19 | #include <fsp/amd_misc_data.h> |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 20 | #include <soc/iomap.h> |
| 21 | #include <stdint.h> |
| 22 | #include "chip.h" |
| 23 | |
Tim Van Patten | f5ae1dd | 2023-03-31 17:31:10 -0600 | [diff] [blame] | 24 | #define TDP_15W 15 |
Chris Wang | 50aa3d9 | 2023-02-20 10:27:50 +0800 | [diff] [blame] | 25 | #define DPTC_TOTAL_UPDATE_PARAMS 13 |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 26 | |
| 27 | struct dptc_input { |
| 28 | uint16_t size; |
| 29 | struct alib_dptc_param params[DPTC_TOTAL_UPDATE_PARAMS]; |
| 30 | } __packed; |
| 31 | |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 32 | |
Chris Wang | 50aa3d9 | 2023-02-20 10:27:50 +0800 | [diff] [blame] | 33 | #define DPTC_INPUTS(_thermctllmit, _spptTimeConst, _fast, _slow, \ |
| 34 | _vrmCurrentLimit, _vrmMaxCurrentLimit, _vrmSocCurrentLimit, \ |
Chris Wang | eede5a2 | 2023-02-20 09:43:38 +0800 | [diff] [blame] | 35 | _sttMinLimit, _sttM1, _sttM2, _sttCApu, _sttAlphaApu, _sttSkinTempLimitApu) \ |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 36 | { \ |
| 37 | .size = sizeof(struct dptc_input), \ |
| 38 | .params = { \ |
| 39 | { \ |
| 40 | .id = ALIB_DPTC_THERMAL_CONTROL_LIMIT_ID, \ |
| 41 | .value = _thermctllmit, \ |
| 42 | }, \ |
| 43 | { \ |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 44 | .id = ALIB_DPTC_SLOW_PPT_TIME_CONSTANT_ID, \ |
| 45 | .value = _spptTimeConst, \ |
| 46 | }, \ |
| 47 | { \ |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 48 | .id = ALIB_DPTC_FAST_PPT_LIMIT_ID, \ |
| 49 | .value = _fast, \ |
| 50 | }, \ |
| 51 | { \ |
| 52 | .id = ALIB_DPTC_SLOW_PPT_LIMIT_ID, \ |
| 53 | .value = _slow, \ |
| 54 | }, \ |
Tim Van Patten | 11ca995 | 2022-09-15 17:08:29 -0600 | [diff] [blame] | 55 | { \ |
| 56 | .id = ALIB_DPTC_VRM_CURRENT_LIMIT_ID, \ |
| 57 | .value = _vrmCurrentLimit, \ |
| 58 | }, \ |
| 59 | { \ |
| 60 | .id = ALIB_DPTC_VRM_MAXIMUM_CURRENT_LIMIT, \ |
| 61 | .value = _vrmMaxCurrentLimit, \ |
| 62 | }, \ |
| 63 | { \ |
| 64 | .id = ALIB_DPTC_VRM_SOC_CURRENT_LIMIT_ID, \ |
| 65 | .value = _vrmSocCurrentLimit, \ |
| 66 | }, \ |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 67 | { \ |
| 68 | .id = ALIB_DPTC_STT_MIN_LIMIT_ID, \ |
| 69 | .value = _sttMinLimit, \ |
| 70 | }, \ |
| 71 | { \ |
| 72 | .id = ALIB_DPTC_STT_M1_ID, \ |
| 73 | .value = _sttM1, \ |
| 74 | }, \ |
| 75 | { \ |
| 76 | .id = ALIB_DPTC_STT_M2_ID, \ |
| 77 | .value = _sttM2, \ |
| 78 | }, \ |
| 79 | { \ |
| 80 | .id = ALIB_DPTC_STT_C_APU_ID, \ |
| 81 | .value = _sttCApu, \ |
| 82 | }, \ |
| 83 | { \ |
Chris Wang | eede5a2 | 2023-02-20 09:43:38 +0800 | [diff] [blame] | 84 | .id = ALIB_DPTC_STT_ALPHA_APU, \ |
| 85 | .value = _sttAlphaApu, \ |
| 86 | }, \ |
| 87 | { \ |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 88 | .id = ALIB_DPTC_STT_SKIN_TEMPERATURE_LIMIT_APU_ID, \ |
| 89 | .value = _sttSkinTempLimitApu, \ |
| 90 | }, \ |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 91 | }, \ |
| 92 | } |
| 93 | |
| 94 | /* |
| 95 | * |
| 96 | * +--------------------------------+ |
| 97 | * | | |
| 98 | * | | |
| 99 | * | | |
| 100 | * | | |
| 101 | * | | |
| 102 | * | | |
| 103 | * | | |
| 104 | * reserved_dram_end +--------------------------------+ |
| 105 | * | | |
| 106 | * | verstage (if reqd) | |
| 107 | * | (VERSTAGE_SIZE) | |
| 108 | * +--------------------------------+ VERSTAGE_ADDR |
| 109 | * | | |
| 110 | * | FSP-M | |
| 111 | * | (FSP_M_SIZE) | |
| 112 | * +--------------------------------+ FSP_M_ADDR |
| 113 | * | romstage | |
| 114 | * | (ROMSTAGE_SIZE) | |
| 115 | * +--------------------------------+ ROMSTAGE_ADDR = BOOTBLOCK_END |
| 116 | * | | X86_RESET_VECTOR = BOOTBLOCK_END - 0x10 |
| 117 | * | bootblock | |
| 118 | * | (C_ENV_BOOTBLOCK_SIZE) | |
| 119 | * +--------------------------------+ BOOTBLOCK_ADDR = BOOTBLOCK_END - C_ENV_BOOTBLOCK_SIZE |
| 120 | * | Unused hole | |
Fred Reitberger | fdb0758 | 2022-07-15 08:05:56 -0400 | [diff] [blame] | 121 | * | (30KiB) | |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 122 | * +--------------------------------+ |
| 123 | * | FMAP cache (FMAP_SIZE) | |
| 124 | * +--------------------------------+ PSP_SHAREDMEM_BASE + PSP_SHAREDMEM_SIZE + PRERAM_CBMEM_CONSOLE_SIZE + 0x200 |
| 125 | * | Early Timestamp region (512B) | |
| 126 | * +--------------------------------+ PSP_SHAREDMEM_BASE + PSP_SHAREDMEM_SIZE + PRERAM_CBMEM_CONSOLE_SIZE |
| 127 | * | Preram CBMEM console | |
| 128 | * | (PRERAM_CBMEM_CONSOLE_SIZE) | |
| 129 | * +--------------------------------+ PSP_SHAREDMEM_BASE + PSP_SHAREDMEM_SIZE |
| 130 | * | PSP shared (vboot workbuf) | |
| 131 | * | (PSP_SHAREDMEM_SIZE) | |
| 132 | * +--------------------------------+ PSP_SHAREDMEM_BASE |
Fred Reitberger | fdb0758 | 2022-07-15 08:05:56 -0400 | [diff] [blame] | 133 | * | APOB (120KiB) | |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 134 | * +--------------------------------+ PSP_APOB_DRAM_ADDRESS |
| 135 | * | Early BSP stack | |
| 136 | * | (EARLYRAM_BSP_STACK_SIZE) | |
| 137 | * reserved_dram_start +--------------------------------+ EARLY_RESERVED_DRAM_BASE |
| 138 | * | DRAM | |
| 139 | * +--------------------------------+ 0x100000 |
| 140 | * | Option ROM | |
| 141 | * +--------------------------------+ 0xc0000 |
| 142 | * | Legacy VGA | |
| 143 | * +--------------------------------+ 0xa0000 |
| 144 | * | DRAM | |
| 145 | * +--------------------------------+ 0x0 |
| 146 | */ |
| 147 | static void read_resources(struct device *dev) |
| 148 | { |
| 149 | uint32_t mem_usable = (uintptr_t)cbmem_top(); |
| 150 | unsigned int idx = 0; |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 151 | |
| 152 | uintptr_t early_reserved_dram_start, early_reserved_dram_end; |
| 153 | const struct memmap_early_dram *e = memmap_get_early_dram_usage(); |
| 154 | |
| 155 | early_reserved_dram_start = e->base; |
| 156 | early_reserved_dram_end = e->base + e->size; |
| 157 | |
Felix Held | af17f0b | 2022-03-02 23:36:55 +0100 | [diff] [blame] | 158 | /* The root complex has no PCI BARs implemented, so there's no need to call |
| 159 | pci_dev_read_resources for it */ |
| 160 | |
Felix Held | d0959dc | 2023-05-10 15:07:47 +0200 | [diff] [blame] | 161 | fixed_io_range_reserved(dev, idx++, PCI_IO_CONFIG_INDEX, PCI_IO_CONFIG_PORT_COUNT); |
| 162 | |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 163 | /* 0x0 - 0x9ffff */ |
Arthur Heymans | b2de1a3 | 2023-07-05 12:15:51 +0200 | [diff] [blame] | 164 | ram_range(dev, idx++, 0, 0xa0000); |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 165 | |
| 166 | /* 0xa0000 - 0xbffff: legacy VGA */ |
Arthur Heymans | b2de1a3 | 2023-07-05 12:15:51 +0200 | [diff] [blame] | 167 | mmio_range(dev, idx++, VGA_MMIO_BASE, VGA_MMIO_SIZE); |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 168 | |
| 169 | /* 0xc0000 - 0xfffff: Option ROM */ |
Arthur Heymans | b2de1a3 | 2023-07-05 12:15:51 +0200 | [diff] [blame] | 170 | reserved_ram_from_to(dev, idx++, 0xc0000, 1 * MiB); |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 171 | |
| 172 | /* 1MiB - bottom of DRAM reserved for early coreboot usage */ |
Arthur Heymans | b2de1a3 | 2023-07-05 12:15:51 +0200 | [diff] [blame] | 173 | ram_from_to(dev, idx++, 1 * MiB, early_reserved_dram_start); |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 174 | |
| 175 | /* DRAM reserved for early coreboot usage */ |
Arthur Heymans | b2de1a3 | 2023-07-05 12:15:51 +0200 | [diff] [blame] | 176 | reserved_ram_from_to(dev, idx++, early_reserved_dram_start, early_reserved_dram_end); |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 177 | |
| 178 | /* |
| 179 | * top of DRAM consumed early - low top usable RAM |
| 180 | * cbmem_top() accounts for low UMA and TSEG if they are used. |
| 181 | */ |
Arthur Heymans | b2de1a3 | 2023-07-05 12:15:51 +0200 | [diff] [blame] | 182 | ram_from_to(dev, idx++, early_reserved_dram_end, mem_usable); |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 183 | |
Felix Held | 56b037b | 2022-03-02 22:57:01 +0100 | [diff] [blame] | 184 | mmconf_resource(dev, idx++); |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 185 | |
Felix Held | 12a4482 | 2023-06-02 15:30:50 +0200 | [diff] [blame] | 186 | /* Reserve fixed IOMMU MMIO region */ |
| 187 | mmio_range(dev, idx++, IOMMU_RESERVED_MMIO_BASE, IOMMU_RESERVED_MMIO_SIZE); |
| 188 | |
Felix Held | 6b248a2 | 2023-07-26 16:42:46 +0200 | [diff] [blame] | 189 | read_fsp_resources(dev, &idx); |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | static void root_complex_init(struct device *dev) |
| 193 | { |
Kyösti Mälkki | 2e65e9c | 2021-06-16 11:00:40 +0300 | [diff] [blame] | 194 | register_new_ioapic((u8 *)GNB_IO_APIC_ADDR); |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | static void acipgen_dptci(void) |
| 198 | { |
Jon Murphy | 4f73242 | 2022-08-05 15:43:44 -0600 | [diff] [blame] | 199 | const struct soc_amd_mendocino_config *config = config_of_soc(); |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 200 | |
Tim Van Patten | 53ba14d | 2022-09-13 15:42:01 -0600 | [diff] [blame] | 201 | /* Normal mode DPTC values. */ |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 202 | struct dptc_input default_input = DPTC_INPUTS( |
| 203 | config->thermctl_limit_degreeC, |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 204 | config->slow_ppt_time_constant_s, |
Tim Van Patten | 9244358 | 2022-08-23 16:06:33 -0600 | [diff] [blame] | 205 | config->fast_ppt_limit_mW, |
Tim Van Patten | 11ca995 | 2022-09-15 17:08:29 -0600 | [diff] [blame] | 206 | config->slow_ppt_limit_mW, |
| 207 | config->vrm_current_limit_mA, |
| 208 | config->vrm_maximum_current_limit_mA, |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 209 | config->vrm_soc_current_limit_mA, |
| 210 | config->stt_min_limit, |
| 211 | config->stt_m1, |
| 212 | config->stt_m2, |
| 213 | config->stt_c_apu, |
Chris Wang | eede5a2 | 2023-02-20 09:43:38 +0800 | [diff] [blame] | 214 | config->stt_alpha_apu, |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 215 | config->stt_skin_temp_apu); |
Tim Van Patten | 9244358 | 2022-08-23 16:06:33 -0600 | [diff] [blame] | 216 | acpigen_write_alib_dptc_default((uint8_t *)&default_input, sizeof(default_input)); |
Tim Van Patten | 1075fef | 2022-05-20 11:06:03 -0600 | [diff] [blame] | 217 | |
| 218 | /* Low/No Battery */ |
| 219 | struct dptc_input no_battery_input = DPTC_INPUTS( |
| 220 | config->thermctl_limit_degreeC, |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 221 | config->slow_ppt_time_constant_s, |
Tim Van Patten | 1075fef | 2022-05-20 11:06:03 -0600 | [diff] [blame] | 222 | config->fast_ppt_limit_mW, |
| 223 | config->slow_ppt_limit_mW, |
| 224 | config->vrm_current_limit_throttle_mA, |
| 225 | config->vrm_maximum_current_limit_throttle_mA, |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 226 | config->vrm_soc_current_limit_throttle_mA, |
| 227 | config->stt_min_limit, |
| 228 | config->stt_m1, |
| 229 | config->stt_m2, |
| 230 | config->stt_c_apu, |
Chris Wang | eede5a2 | 2023-02-20 09:43:38 +0800 | [diff] [blame] | 231 | config->stt_alpha_apu, |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 232 | config->stt_skin_temp_apu); |
Tim Van Patten | 1075fef | 2022-05-20 11:06:03 -0600 | [diff] [blame] | 233 | acpigen_write_alib_dptc_no_battery((uint8_t *)&no_battery_input, |
| 234 | sizeof(no_battery_input)); |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 235 | |
Chris.Wang | 9ac0984 | 2022-12-13 14:31:38 +0800 | [diff] [blame] | 236 | #if (CONFIG(FEATURE_TABLET_MODE_DPTC)) |
| 237 | struct dptc_input tablet_input = DPTC_INPUTS( |
| 238 | config->thermctl_limit_degreeC, |
Chris.Wang | 9ac0984 | 2022-12-13 14:31:38 +0800 | [diff] [blame] | 239 | config->slow_ppt_time_constant_s, |
| 240 | config->fast_ppt_limit_mW, |
| 241 | config->slow_ppt_limit_mW, |
| 242 | config->vrm_current_limit_mA, |
| 243 | config->vrm_maximum_current_limit_mA, |
| 244 | config->vrm_soc_current_limit_mA, |
| 245 | config->stt_min_limit, |
Chris Wang | 2809507 | 2023-02-23 16:25:52 +0800 | [diff] [blame] | 246 | config->stt_m1_tablet, |
| 247 | config->stt_m2_tablet, |
| 248 | config->stt_c_apu_tablet, |
| 249 | config->stt_alpha_apu_tablet, |
Chris.Wang | 9ac0984 | 2022-12-13 14:31:38 +0800 | [diff] [blame] | 250 | config->stt_skin_temp_apu); |
| 251 | acpigen_write_alib_dptc_tablet((uint8_t *)&tablet_input, sizeof(tablet_input)); |
| 252 | #endif |
| 253 | |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 254 | #if (CONFIG(FEATURE_DYNAMIC_DPTC)) |
| 255 | /* Profile B */ |
| 256 | struct dptc_input thermal_B_input = DPTC_INPUTS( |
| 257 | config->thermctl_limit_degreeC, |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 258 | config->slow_ppt_time_constant_s_B, |
| 259 | config->fast_ppt_limit_mW_B, |
| 260 | config->slow_ppt_limit_mW_B, |
| 261 | config->vrm_current_limit_throttle_mA, |
| 262 | config->vrm_maximum_current_limit_mA, |
| 263 | config->vrm_soc_current_limit_mA, |
| 264 | config->stt_min_limit_B, |
| 265 | config->stt_m1_B, |
| 266 | config->stt_m2_B, |
| 267 | config->stt_c_apu_B, |
Chris Wang | eede5a2 | 2023-02-20 09:43:38 +0800 | [diff] [blame] | 268 | config->stt_alpha_apu, |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 269 | config->stt_skin_temp_apu_B); |
| 270 | acpigen_write_alib_dptc_thermal_B((uint8_t *)&thermal_B_input, |
| 271 | sizeof(thermal_B_input)); |
| 272 | |
| 273 | /* Profile C */ |
| 274 | struct dptc_input thermal_C_input = DPTC_INPUTS( |
| 275 | config->thermctl_limit_degreeC, |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 276 | config->slow_ppt_time_constant_s_C, |
| 277 | config->fast_ppt_limit_mW_C, |
| 278 | config->slow_ppt_limit_mW_C, |
| 279 | config->vrm_current_limit_mA, |
| 280 | config->vrm_maximum_current_limit_mA, |
| 281 | config->vrm_soc_current_limit_mA, |
| 282 | config->stt_min_limit_C, |
| 283 | config->stt_m1_C, |
| 284 | config->stt_m2_C, |
| 285 | config->stt_c_apu_C, |
Chris Wang | eede5a2 | 2023-02-20 09:43:38 +0800 | [diff] [blame] | 286 | config->stt_alpha_apu, |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 287 | config->stt_skin_temp_apu_C); |
| 288 | acpigen_write_alib_dptc_thermal_C((uint8_t *)&thermal_C_input, |
| 289 | sizeof(thermal_C_input)); |
| 290 | |
| 291 | /* Profile D */ |
| 292 | struct dptc_input thermal_D_input = DPTC_INPUTS( |
| 293 | config->thermctl_limit_degreeC, |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 294 | config->slow_ppt_time_constant_s_D, |
| 295 | config->fast_ppt_limit_mW_D, |
| 296 | config->slow_ppt_limit_mW_D, |
| 297 | config->vrm_current_limit_mA, |
| 298 | config->vrm_maximum_current_limit_mA, |
| 299 | config->vrm_soc_current_limit_mA, |
| 300 | config->stt_min_limit_D, |
| 301 | config->stt_m1_D, |
| 302 | config->stt_m2_D, |
| 303 | config->stt_c_apu_D, |
Chris Wang | eede5a2 | 2023-02-20 09:43:38 +0800 | [diff] [blame] | 304 | config->stt_alpha_apu, |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 305 | config->stt_skin_temp_apu_D); |
| 306 | acpigen_write_alib_dptc_thermal_D((uint8_t *)&thermal_D_input, |
| 307 | sizeof(thermal_D_input)); |
| 308 | |
| 309 | /* Profile E */ |
| 310 | struct dptc_input thermal_E_input = DPTC_INPUTS( |
| 311 | config->thermctl_limit_degreeC, |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 312 | config->slow_ppt_time_constant_s_E, |
| 313 | config->fast_ppt_limit_mW_E, |
| 314 | config->slow_ppt_limit_mW_E, |
| 315 | config->vrm_current_limit_mA, |
| 316 | config->vrm_maximum_current_limit_mA, |
| 317 | config->vrm_soc_current_limit_mA, |
| 318 | config->stt_min_limit_E, |
| 319 | config->stt_m1_E, |
| 320 | config->stt_m2_E, |
| 321 | config->stt_c_apu_E, |
Chris Wang | eede5a2 | 2023-02-20 09:43:38 +0800 | [diff] [blame] | 322 | config->stt_alpha_apu, |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 323 | config->stt_skin_temp_apu_E); |
| 324 | acpigen_write_alib_dptc_thermal_E((uint8_t *)&thermal_E_input, |
| 325 | sizeof(thermal_E_input)); |
| 326 | |
| 327 | /* Profile F */ |
| 328 | struct dptc_input thermal_F_input = DPTC_INPUTS( |
| 329 | config->thermctl_limit_degreeC, |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 330 | config->slow_ppt_time_constant_s_F, |
| 331 | config->fast_ppt_limit_mW_F, |
| 332 | config->slow_ppt_limit_mW_F, |
| 333 | config->vrm_current_limit_mA, |
| 334 | config->vrm_maximum_current_limit_mA, |
| 335 | config->vrm_soc_current_limit_mA, |
| 336 | config->stt_min_limit_F, |
| 337 | config->stt_m1_F, |
| 338 | config->stt_m2_F, |
| 339 | config->stt_c_apu_F, |
Chris Wang | eede5a2 | 2023-02-20 09:43:38 +0800 | [diff] [blame] | 340 | config->stt_alpha_apu, |
EricKY Cheng | 33e0df1 | 2022-10-21 19:35:30 +0800 | [diff] [blame] | 341 | config->stt_skin_temp_apu_F); |
| 342 | acpigen_write_alib_dptc_thermal_F((uint8_t *)&thermal_F_input, |
| 343 | sizeof(thermal_F_input)); |
| 344 | #endif |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | static void root_complex_fill_ssdt(const struct device *device) |
| 348 | { |
Tim Van Patten | f5ae1dd | 2023-03-31 17:31:10 -0600 | [diff] [blame] | 349 | uint32_t tdp = 0; |
| 350 | |
Tim Van Patten | f5ae1dd | 2023-03-31 17:31:10 -0600 | [diff] [blame] | 351 | if (get_amd_smu_reported_tdp(&tdp) != CB_SUCCESS) { |
| 352 | /* Unknown TDP, so return rather than setting invalid values. */ |
| 353 | return; |
| 354 | } |
| 355 | /* TODO(b/249359574): Add support for 6W DPTC values. */ |
| 356 | if (tdp != TDP_15W) |
| 357 | return; |
| 358 | |
Tim Van Patten | 53ba14d | 2022-09-13 15:42:01 -0600 | [diff] [blame] | 359 | if (CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)) |
| 360 | acipgen_dptci(); |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | static const char *gnb_acpi_name(const struct device *dev) |
| 364 | { |
| 365 | return "GNB"; |
| 366 | } |
| 367 | |
Arthur Heymans | 6a5d770 | 2022-10-05 14:41:51 +0200 | [diff] [blame] | 368 | struct device_operations mendocino_root_complex_operations = { |
Felix Held | 3c44c62 | 2022-01-10 20:57:29 +0100 | [diff] [blame] | 369 | .read_resources = read_resources, |
| 370 | .set_resources = noop_set_resources, |
| 371 | .enable_resources = pci_dev_enable_resources, |
| 372 | .init = root_complex_init, |
| 373 | .acpi_name = gnb_acpi_name, |
| 374 | .acpi_fill_ssdt = root_complex_fill_ssdt, |
| 375 | }; |
Felix Held | 81c81e3 | 2023-07-18 20:37:36 +0200 | [diff] [blame] | 376 | |
| 377 | uint32_t get_iohc_misc_smn_base(struct device *domain) |
| 378 | { |
Felix Held | 69ffebf | 2023-07-24 21:31:44 +0200 | [diff] [blame] | 379 | return SMN_IOHC_MISC_BASE_13B1; |
Felix Held | 81c81e3 | 2023-07-18 20:37:36 +0200 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | static const struct non_pci_mmio_reg non_pci_mmio[] = { |
| 383 | { 0x2d8, 0xfffffff00000ull, 1 * MiB, NON_PCI_RES_IDX_AUTO }, |
| 384 | { 0x2e0, 0xfffffff00000ull, 1 * MiB, NON_PCI_RES_IDX_AUTO }, |
| 385 | { 0x2e8, 0xfffffff00000ull, 1 * MiB, NON_PCI_RES_IDX_AUTO }, |
| 386 | /* The hardware has a 256 byte alignment requirement for the IOAPIC MMIO base, but we |
| 387 | tell the FSP to configure a 4k-aligned base address and this is reported as 4 KiB |
| 388 | resource. */ |
| 389 | { 0x2f0, 0xffffffffff00ull, 4 * KiB, IOMMU_IOAPIC_IDX }, |
| 390 | { 0x2f8, 0xfffffff00000ull, 1 * MiB, NON_PCI_RES_IDX_AUTO }, |
| 391 | { 0x300, 0xfffffff00000ull, 1 * MiB, NON_PCI_RES_IDX_AUTO }, |
| 392 | { 0x308, 0xfffffffff000ull, 4 * KiB, NON_PCI_RES_IDX_AUTO }, |
| 393 | { 0x318, 0xfffffff80000ull, 512 * KiB, NON_PCI_RES_IDX_AUTO }, |
| 394 | }; |
| 395 | |
| 396 | const struct non_pci_mmio_reg *get_iohc_non_pci_mmio_regs(size_t *count) |
| 397 | { |
| 398 | *count = ARRAY_SIZE(non_pci_mmio); |
| 399 | return non_pci_mmio; |
| 400 | } |
Felix Held | b0ab545 | 2023-08-11 22:24:00 +0200 | [diff] [blame] | 401 | |
| 402 | signed int get_iohc_fabric_id(struct device *domain) |
| 403 | { |
| 404 | switch (domain->path.domain.domain) { |
| 405 | case 0: |
| 406 | return IOMS0_FABRIC_ID; |
| 407 | default: |
| 408 | return -1; |
| 409 | } |
| 410 | } |