Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <assert.h> |
Subrata Banik | 0cf2674 | 2023-05-16 12:18:00 +0530 | [diff] [blame] | 4 | #include <bootsplash.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 5 | #include <console/console.h> |
Subrata Banik | 7b523a4 | 2021-09-22 16:46:16 +0530 | [diff] [blame] | 6 | #include <cpu/intel/microcode.h> |
Jeremy Compostella | a2a7fec | 2023-01-19 19:06:09 -0700 | [diff] [blame] | 7 | #include <delay.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 8 | #include <device/device.h> |
| 9 | #include <device/pci.h> |
V Sowmya | 458708f | 2021-07-09 22:11:04 +0530 | [diff] [blame] | 10 | #include <device/pci_ids.h> |
Jeremy Compostella | a2a7fec | 2023-01-19 19:06:09 -0700 | [diff] [blame] | 11 | #include <device/pci_ops.h> |
| 12 | #include <drivers/intel/gma/i915_reg.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 13 | #include <fsp/api.h> |
Subrata Banik | 7cb6d72 | 2022-03-23 01:33:27 +0530 | [diff] [blame] | 14 | #include <fsp/fsp_debug_event.h> |
Subrata Banik | 03dfc21 | 2023-08-16 02:50:16 +0530 | [diff] [blame] | 15 | #include <fsp/fsp_gop_blt.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 16 | #include <fsp/ppi/mp_service_ppi.h> |
| 17 | #include <fsp/util.h> |
Dinesh Gehlot | d910fec | 2022-12-25 13:00:04 +0000 | [diff] [blame] | 18 | #include <gpio.h> |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 19 | #include <intelblocks/irq.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 20 | #include <intelblocks/lpss.h> |
Subrata Banik | b6c3a03 | 2022-06-05 22:39:34 +0530 | [diff] [blame] | 21 | #include <intelblocks/mp_init.h> |
Tim Wawrzynczak | ab0e081 | 2021-09-21 10:28:16 -0600 | [diff] [blame] | 22 | #include <intelblocks/pmclib.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 23 | #include <intelblocks/xdci.h> |
| 24 | #include <intelpch/lockdown.h> |
Subrata Banik | b6c3a03 | 2022-06-05 22:39:34 +0530 | [diff] [blame] | 25 | #include <intelblocks/systemagent.h> |
Deepti Deshatty | 8e7facf | 2021-05-12 17:45:37 +0530 | [diff] [blame] | 26 | #include <intelblocks/tcss.h> |
Dinesh Gehlot | d910fec | 2022-12-25 13:00:04 +0000 | [diff] [blame] | 27 | #include <option.h> |
Tim Wawrzynczak | e2b8f30 | 2021-07-19 15:35:47 -0600 | [diff] [blame] | 28 | #include <soc/cpu.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 29 | #include <soc/intel/common/vbt.h> |
| 30 | #include <soc/pci_devs.h> |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 31 | #include <soc/pcie.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 32 | #include <soc/ramstage.h> |
| 33 | #include <soc/soc_chip.h> |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 34 | #include <stdlib.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 35 | #include <string.h> |
Sean Rhodes | bc35bed | 2021-07-13 13:36:28 +0100 | [diff] [blame] | 36 | #include <types.h> |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 37 | |
| 38 | /* THC assignment definition */ |
| 39 | #define THC_NONE 0 |
| 40 | #define THC_0 1 |
| 41 | #define THC_1 2 |
| 42 | |
| 43 | /* SATA DEVSLP idle timeout default values */ |
| 44 | #define DEF_DMVAL 15 |
| 45 | #define DEF_DITOVAL 625 |
| 46 | |
V Sowmya | 458708f | 2021-07-09 22:11:04 +0530 | [diff] [blame] | 47 | /* VccIn Aux Imon IccMax values in mA */ |
Curtis Chen | ea1bb5f | 2021-11-25 13:17:42 +0800 | [diff] [blame] | 48 | #define MILLIAMPS_TO_AMPS 1000 |
| 49 | #define ICC_MAX_TDP_45W 34250 |
| 50 | #define ICC_MAX_TDP_15W_28W 32000 |
| 51 | #define ICC_MAX_ID_ADL_M_MA 12000 |
V Sowmya | 2af9602 | 2022-04-05 17:03:04 +0530 | [diff] [blame] | 52 | #define ICC_MAX_ID_ADL_N_MA 27000 |
Michał Żygowski | bda2a15 | 2022-04-25 15:02:10 +0200 | [diff] [blame] | 53 | #define ICC_MAX_ADL_S 33000 |
Max Fritz | 573e6de | 2022-11-19 01:54:44 +0100 | [diff] [blame] | 54 | #define ICC_MAX_RPL_S 36000 |
V Sowmya | 458708f | 2021-07-09 22:11:04 +0530 | [diff] [blame] | 55 | |
Tim Wawrzynczak | c0e82e7 | 2021-06-17 12:42:35 -0600 | [diff] [blame] | 56 | /* |
| 57 | * ME End of Post configuration |
| 58 | * 0 - Disable EOP. |
| 59 | * 1 - Send in PEI (Applicable for FSP in API mode) |
| 60 | * 2 - Send in DXE (Not applicable for FSP in API mode) |
| 61 | */ |
| 62 | enum fsp_end_of_post { |
| 63 | EOP_DISABLE = 0, |
| 64 | EOP_PEI = 1, |
| 65 | EOP_DXE = 2, |
| 66 | }; |
| 67 | |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 68 | static const struct slot_irq_constraints irq_constraints[] = { |
| 69 | { |
Tim Crawford | b739d80 | 2022-07-29 12:07:15 -0600 | [diff] [blame] | 70 | .slot = SA_DEV_SLOT_CPU_1, |
| 71 | .fns = { |
| 72 | FIXED_INT_PIRQ(SA_DEVFN_CPU_PCIE1_0, PCI_INT_A, PIRQ_A), |
| 73 | }, |
| 74 | }, |
| 75 | { |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 76 | .slot = SA_DEV_SLOT_IGD, |
| 77 | .fns = { |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 78 | /* INTERRUPT_PIN is RO/0x01 */ |
| 79 | FIXED_INT_ANY_PIRQ(SA_DEVFN_IGD, PCI_INT_A), |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 80 | }, |
| 81 | }, |
| 82 | { |
| 83 | .slot = SA_DEV_SLOT_DPTF, |
| 84 | .fns = { |
| 85 | ANY_PIRQ(SA_DEVFN_DPTF), |
| 86 | }, |
| 87 | }, |
| 88 | { |
| 89 | .slot = SA_DEV_SLOT_IPU, |
| 90 | .fns = { |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 91 | /* INTERRUPT_PIN is RO/0x01, and INTERRUPT_LINE is RW, |
| 92 | but S0ix fails when not set to 16 (b/193434192) */ |
| 93 | FIXED_INT_PIRQ(SA_DEVFN_IPU, PCI_INT_A, PIRQ_A), |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 94 | }, |
| 95 | }, |
| 96 | { |
| 97 | .slot = SA_DEV_SLOT_CPU_6, |
| 98 | .fns = { |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 99 | FIXED_INT_PIRQ(SA_DEVFN_CPU_PCIE6_0, PCI_INT_A, PIRQ_A), |
| 100 | FIXED_INT_PIRQ(SA_DEVFN_CPU_PCIE6_2, PCI_INT_C, PIRQ_C), |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 101 | }, |
| 102 | }, |
| 103 | { |
| 104 | .slot = SA_DEV_SLOT_TBT, |
| 105 | .fns = { |
| 106 | ANY_PIRQ(SA_DEVFN_TBT0), |
| 107 | ANY_PIRQ(SA_DEVFN_TBT1), |
| 108 | ANY_PIRQ(SA_DEVFN_TBT2), |
| 109 | ANY_PIRQ(SA_DEVFN_TBT3), |
| 110 | }, |
| 111 | }, |
| 112 | { |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 113 | .slot = SA_DEV_SLOT_GNA, |
| 114 | .fns = { |
| 115 | /* INTERRUPT_PIN is RO/0x01 */ |
| 116 | FIXED_INT_ANY_PIRQ(SA_DEVFN_GNA, PCI_INT_A), |
| 117 | }, |
| 118 | }, |
| 119 | { |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 120 | .slot = SA_DEV_SLOT_TCSS, |
| 121 | .fns = { |
| 122 | ANY_PIRQ(SA_DEVFN_TCSS_XHCI), |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 123 | ANY_PIRQ(SA_DEVFN_TCSS_XDCI), |
| 124 | }, |
| 125 | }, |
| 126 | { |
| 127 | .slot = PCH_DEV_SLOT_SIO0, |
| 128 | .fns = { |
| 129 | DIRECT_IRQ(PCH_DEVFN_I2C6), |
| 130 | DIRECT_IRQ(PCH_DEVFN_I2C7), |
| 131 | ANY_PIRQ(PCH_DEVFN_THC0), |
| 132 | ANY_PIRQ(PCH_DEVFN_THC1), |
| 133 | }, |
| 134 | }, |
| 135 | { |
| 136 | .slot = PCH_DEV_SLOT_SIO6, |
| 137 | .fns = { |
| 138 | DIRECT_IRQ(PCH_DEVFN_UART3), |
| 139 | DIRECT_IRQ(PCH_DEVFN_UART4), |
| 140 | DIRECT_IRQ(PCH_DEVFN_UART5), |
| 141 | DIRECT_IRQ(PCH_DEVFN_UART6), |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 142 | }, |
| 143 | }, |
| 144 | { |
| 145 | .slot = PCH_DEV_SLOT_ISH, |
| 146 | .fns = { |
| 147 | DIRECT_IRQ(PCH_DEVFN_ISH), |
| 148 | DIRECT_IRQ(PCH_DEVFN_GSPI2), |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 149 | ANY_PIRQ(PCH_DEVFN_UFS), |
| 150 | }, |
| 151 | }, |
| 152 | { |
| 153 | .slot = PCH_DEV_SLOT_SIO2, |
| 154 | .fns = { |
| 155 | DIRECT_IRQ(PCH_DEVFN_GSPI3), |
| 156 | DIRECT_IRQ(PCH_DEVFN_GSPI4), |
| 157 | DIRECT_IRQ(PCH_DEVFN_GSPI5), |
| 158 | DIRECT_IRQ(PCH_DEVFN_GSPI6), |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 159 | }, |
| 160 | }, |
| 161 | { |
| 162 | .slot = PCH_DEV_SLOT_XHCI, |
| 163 | .fns = { |
| 164 | ANY_PIRQ(PCH_DEVFN_XHCI), |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 165 | DIRECT_IRQ(PCH_DEVFN_USBOTG), |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 166 | ANY_PIRQ(PCH_DEVFN_CNVI_WIFI), |
| 167 | }, |
| 168 | }, |
| 169 | { |
| 170 | .slot = PCH_DEV_SLOT_SIO3, |
| 171 | .fns = { |
| 172 | DIRECT_IRQ(PCH_DEVFN_I2C0), |
| 173 | DIRECT_IRQ(PCH_DEVFN_I2C1), |
| 174 | DIRECT_IRQ(PCH_DEVFN_I2C2), |
| 175 | DIRECT_IRQ(PCH_DEVFN_I2C3), |
| 176 | }, |
| 177 | }, |
| 178 | { |
| 179 | .slot = PCH_DEV_SLOT_CSE, |
| 180 | .fns = { |
| 181 | ANY_PIRQ(PCH_DEVFN_CSE), |
| 182 | ANY_PIRQ(PCH_DEVFN_CSE_2), |
| 183 | ANY_PIRQ(PCH_DEVFN_CSE_IDER), |
| 184 | ANY_PIRQ(PCH_DEVFN_CSE_KT), |
| 185 | ANY_PIRQ(PCH_DEVFN_CSE_3), |
| 186 | ANY_PIRQ(PCH_DEVFN_CSE_4), |
| 187 | }, |
| 188 | }, |
| 189 | { |
| 190 | .slot = PCH_DEV_SLOT_SATA, |
| 191 | .fns = { |
| 192 | ANY_PIRQ(PCH_DEVFN_SATA), |
| 193 | }, |
| 194 | }, |
| 195 | { |
| 196 | .slot = PCH_DEV_SLOT_SIO4, |
| 197 | .fns = { |
| 198 | DIRECT_IRQ(PCH_DEVFN_I2C4), |
| 199 | DIRECT_IRQ(PCH_DEVFN_I2C5), |
| 200 | DIRECT_IRQ(PCH_DEVFN_UART2), |
| 201 | }, |
| 202 | }, |
Krishna Prasad Bhat | a6d642f | 2022-01-16 23:16:24 +0530 | [diff] [blame] | 203 | #if CONFIG(SOC_INTEL_ALDERLAKE_PCH_N) |
| 204 | { |
| 205 | .slot = PCH_DEV_SLOT_EMMC, |
| 206 | .fns = { |
| 207 | ANY_PIRQ(PCH_DEVFN_EMMC), |
| 208 | }, |
| 209 | }, |
| 210 | #endif |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 211 | { |
| 212 | .slot = PCH_DEV_SLOT_PCIE, |
| 213 | .fns = { |
| 214 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE1, PCI_INT_A, PIRQ_A), |
| 215 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE2, PCI_INT_B, PIRQ_B), |
| 216 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE3, PCI_INT_C, PIRQ_C), |
| 217 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE4, PCI_INT_D, PIRQ_D), |
| 218 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE5, PCI_INT_A, PIRQ_A), |
| 219 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE6, PCI_INT_B, PIRQ_B), |
| 220 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE7, PCI_INT_C, PIRQ_C), |
| 221 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE8, PCI_INT_D, PIRQ_D), |
| 222 | }, |
| 223 | }, |
| 224 | { |
| 225 | .slot = PCH_DEV_SLOT_PCIE_1, |
| 226 | .fns = { |
| 227 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE9, PCI_INT_A, PIRQ_A), |
| 228 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE10, PCI_INT_B, PIRQ_B), |
| 229 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE11, PCI_INT_C, PIRQ_C), |
| 230 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE12, PCI_INT_D, PIRQ_D), |
| 231 | }, |
| 232 | }, |
| 233 | { |
| 234 | .slot = PCH_DEV_SLOT_SIO5, |
| 235 | .fns = { |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 236 | /* UART0 shares an interrupt line with TSN0, so must use |
| 237 | a PIRQ */ |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 238 | FIXED_INT_ANY_PIRQ(PCH_DEVFN_UART0, PCI_INT_A), |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 239 | /* UART1 shares an interrupt line with TSN1, so must use |
| 240 | a PIRQ */ |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 241 | FIXED_INT_ANY_PIRQ(PCH_DEVFN_UART1, PCI_INT_B), |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 242 | DIRECT_IRQ(PCH_DEVFN_GSPI0), |
| 243 | DIRECT_IRQ(PCH_DEVFN_GSPI1), |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 244 | }, |
| 245 | }, |
| 246 | { |
| 247 | .slot = PCH_DEV_SLOT_ESPI, |
| 248 | .fns = { |
| 249 | ANY_PIRQ(PCH_DEVFN_HDA), |
| 250 | ANY_PIRQ(PCH_DEVFN_SMBUS), |
| 251 | ANY_PIRQ(PCH_DEVFN_GBE), |
Tim Wawrzynczak | 82225b8 | 2021-07-09 10:23:10 -0600 | [diff] [blame] | 252 | /* INTERRUPT_PIN is RO/0x01 */ |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 253 | FIXED_INT_ANY_PIRQ(PCH_DEVFN_TRACEHUB, PCI_INT_A), |
| 254 | }, |
| 255 | }, |
| 256 | }; |
| 257 | |
Michał Żygowski | 72704be | 2022-06-20 18:10:14 +0200 | [diff] [blame] | 258 | static const struct slot_irq_constraints irq_constraints_pch_s[] = { |
| 259 | { |
| 260 | .slot = SA_DEV_SLOT_CPU_1, |
| 261 | .fns = { |
| 262 | FIXED_INT_PIRQ(SA_DEVFN_CPU_PCIE1_0, PCI_INT_A, PIRQ_A), |
| 263 | FIXED_INT_PIRQ(SA_DEVFN_CPU_PCIE1_1, PCI_INT_B, PIRQ_B), |
| 264 | }, |
| 265 | }, |
| 266 | { |
| 267 | .slot = SA_DEV_SLOT_IGD, |
| 268 | .fns = { |
| 269 | /* INTERRUPT_PIN is RO/0x01 */ |
| 270 | FIXED_INT_ANY_PIRQ(SA_DEVFN_IGD, PCI_INT_A), |
| 271 | }, |
| 272 | }, |
| 273 | { |
| 274 | .slot = SA_DEV_SLOT_DPTF, |
| 275 | .fns = { |
| 276 | ANY_PIRQ(SA_DEVFN_DPTF), |
| 277 | }, |
| 278 | }, |
| 279 | { |
| 280 | .slot = SA_DEV_SLOT_CPU_6, |
| 281 | .fns = { |
| 282 | FIXED_INT_PIRQ(SA_DEVFN_CPU_PCIE6_0, PCI_INT_D, PIRQ_A), |
| 283 | }, |
| 284 | }, |
| 285 | { |
| 286 | .slot = SA_DEV_SLOT_GNA, |
| 287 | .fns = { |
| 288 | /* INTERRUPT_PIN is RO/0x01 */ |
| 289 | FIXED_INT_ANY_PIRQ(SA_DEVFN_GNA, PCI_INT_A), |
| 290 | }, |
| 291 | }, |
| 292 | { |
| 293 | .slot = PCH_DEV_SLOT_SIO6, |
| 294 | .fns = { |
| 295 | DIRECT_IRQ(PCH_DEVFN_UART3), |
| 296 | }, |
| 297 | }, |
| 298 | { |
| 299 | .slot = PCH_DEV_SLOT_ISH, |
| 300 | .fns = { |
| 301 | DIRECT_IRQ(PCH_DEVFN_ISH), |
| 302 | DIRECT_IRQ(PCH_DEVFN_GSPI2), |
| 303 | }, |
| 304 | }, |
| 305 | { |
| 306 | .slot = PCH_DEV_SLOT_SIO2, |
| 307 | .fns = { |
| 308 | DIRECT_IRQ(PCH_DEVFN_GSPI3), |
| 309 | }, |
| 310 | }, |
| 311 | { |
| 312 | .slot = PCH_DEV_SLOT_XHCI, |
| 313 | .fns = { |
| 314 | ANY_PIRQ(PCH_DEVFN_XHCI), |
| 315 | DIRECT_IRQ(PCH_DEVFN_USBOTG), |
| 316 | ANY_PIRQ(PCH_DEVFN_CNVI_WIFI), |
| 317 | }, |
| 318 | }, |
| 319 | { |
| 320 | .slot = PCH_DEV_SLOT_SIO3, |
| 321 | .fns = { |
| 322 | DIRECT_IRQ(PCH_DEVFN_I2C0), |
| 323 | DIRECT_IRQ(PCH_DEVFN_I2C1), |
| 324 | DIRECT_IRQ(PCH_DEVFN_I2C2), |
| 325 | DIRECT_IRQ(PCH_DEVFN_I2C3), |
| 326 | }, |
| 327 | }, |
| 328 | { |
| 329 | .slot = PCH_DEV_SLOT_CSE, |
| 330 | .fns = { |
| 331 | ANY_PIRQ(PCH_DEVFN_CSE), |
| 332 | ANY_PIRQ(PCH_DEVFN_CSE_2), |
| 333 | ANY_PIRQ(PCH_DEVFN_CSE_IDER), |
| 334 | ANY_PIRQ(PCH_DEVFN_CSE_KT), |
| 335 | ANY_PIRQ(PCH_DEVFN_CSE_3), |
| 336 | ANY_PIRQ(PCH_DEVFN_CSE_4), |
| 337 | }, |
| 338 | }, |
| 339 | { |
| 340 | .slot = PCH_DEV_SLOT_SATA, |
| 341 | .fns = { |
| 342 | ANY_PIRQ(PCH_DEVFN_SATA), |
| 343 | }, |
| 344 | }, |
| 345 | { |
| 346 | .slot = PCH_DEV_SLOT_SIO4, |
| 347 | .fns = { |
| 348 | DIRECT_IRQ(PCH_DEVFN_I2C4), |
| 349 | DIRECT_IRQ(PCH_DEVFN_I2C5), |
| 350 | DIRECT_IRQ(PCH_DEVFN_UART2), |
| 351 | }, |
| 352 | }, |
| 353 | { |
| 354 | .slot = PCH_DEV_SLOT_PCIE, |
| 355 | .fns = { |
| 356 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE1, PCI_INT_A, PIRQ_A), |
| 357 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE2, PCI_INT_B, PIRQ_B), |
| 358 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE3, PCI_INT_C, PIRQ_C), |
| 359 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE4, PCI_INT_D, PIRQ_D), |
| 360 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE5, PCI_INT_A, PIRQ_A), |
| 361 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE6, PCI_INT_B, PIRQ_B), |
| 362 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE7, PCI_INT_C, PIRQ_C), |
| 363 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE8, PCI_INT_D, PIRQ_D), |
| 364 | }, |
| 365 | }, |
| 366 | { |
| 367 | .slot = PCH_DEV_SLOT_PCIE_1, |
| 368 | .fns = { |
| 369 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE9, PCI_INT_A, PIRQ_A), |
| 370 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE10, PCI_INT_B, PIRQ_B), |
| 371 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE11, PCI_INT_C, PIRQ_C), |
| 372 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE12, PCI_INT_D, PIRQ_D), |
| 373 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE13, PCI_INT_A, PIRQ_A), |
| 374 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE14, PCI_INT_B, PIRQ_B), |
| 375 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE15, PCI_INT_C, PIRQ_C), |
| 376 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE16, PCI_INT_D, PIRQ_D), |
| 377 | }, |
| 378 | }, |
| 379 | { |
| 380 | .slot = PCH_DEV_SLOT_PCIE_2, |
| 381 | .fns = { |
| 382 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE17, PCI_INT_A, PIRQ_A), |
| 383 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE18, PCI_INT_B, PIRQ_B), |
| 384 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE19, PCI_INT_C, PIRQ_C), |
| 385 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE20, PCI_INT_D, PIRQ_D), |
| 386 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE21, PCI_INT_A, PIRQ_A), |
| 387 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE22, PCI_INT_B, PIRQ_B), |
| 388 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE23, PCI_INT_C, PIRQ_C), |
| 389 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE24, PCI_INT_D, PIRQ_D), |
| 390 | }, |
| 391 | }, |
| 392 | { |
| 393 | .slot = PCH_DEV_SLOT_PCIE_3, |
| 394 | .fns = { |
| 395 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE25, PCI_INT_A, PIRQ_A), |
| 396 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE26, PCI_INT_B, PIRQ_B), |
| 397 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE27, PCI_INT_C, PIRQ_C), |
| 398 | FIXED_INT_PIRQ(PCH_DEVFN_PCIE28, PCI_INT_D, PIRQ_D), |
| 399 | }, |
| 400 | }, |
| 401 | { |
| 402 | .slot = PCH_DEV_SLOT_SIO5, |
| 403 | .fns = { |
| 404 | /* UART0 shares an interrupt line with TSN0, so must use |
| 405 | a PIRQ */ |
| 406 | FIXED_INT_ANY_PIRQ(PCH_DEVFN_UART0, PCI_INT_A), |
| 407 | /* UART1 shares an interrupt line with TSN1, so must use |
| 408 | a PIRQ */ |
| 409 | FIXED_INT_ANY_PIRQ(PCH_DEVFN_UART1, PCI_INT_B), |
| 410 | DIRECT_IRQ(PCH_DEVFN_GSPI0), |
| 411 | DIRECT_IRQ(PCH_DEVFN_GSPI1), |
| 412 | }, |
| 413 | }, |
| 414 | { |
| 415 | .slot = PCH_DEV_SLOT_ESPI, |
| 416 | .fns = { |
| 417 | ANY_PIRQ(PCH_DEVFN_HDA), |
| 418 | ANY_PIRQ(PCH_DEVFN_SMBUS), |
| 419 | ANY_PIRQ(PCH_DEVFN_GBE), |
| 420 | /* INTERRUPT_PIN is RO/0x01 */ |
| 421 | FIXED_INT_ANY_PIRQ(PCH_DEVFN_TRACEHUB, PCI_INT_A), |
| 422 | }, |
| 423 | }, |
| 424 | }; |
| 425 | |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 426 | static const SI_PCH_DEVICE_INTERRUPT_CONFIG *pci_irq_to_fsp(size_t *out_count) |
| 427 | { |
| 428 | const struct pci_irq_entry *entry = get_cached_pci_irqs(); |
| 429 | SI_PCH_DEVICE_INTERRUPT_CONFIG *config; |
| 430 | size_t pch_total = 0; |
| 431 | size_t cfg_count = 0; |
| 432 | |
| 433 | if (!entry) |
| 434 | return NULL; |
| 435 | |
| 436 | /* Count PCH devices */ |
| 437 | while (entry) { |
Kapil Porwal | 9395cf9 | 2022-12-22 23:08:26 +0530 | [diff] [blame] | 438 | if (is_pch_slot(entry->devfn)) |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 439 | ++pch_total; |
| 440 | entry = entry->next; |
| 441 | } |
| 442 | |
| 443 | /* Convert PCH device entries to FSP format */ |
| 444 | config = calloc(pch_total, sizeof(*config)); |
| 445 | entry = get_cached_pci_irqs(); |
| 446 | while (entry) { |
Kapil Porwal | 9395cf9 | 2022-12-22 23:08:26 +0530 | [diff] [blame] | 447 | if (!is_pch_slot(entry->devfn)) { |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 448 | entry = entry->next; |
| 449 | continue; |
| 450 | } |
| 451 | |
| 452 | config[cfg_count].Device = PCI_SLOT(entry->devfn); |
| 453 | config[cfg_count].Function = PCI_FUNC(entry->devfn); |
| 454 | config[cfg_count].IntX = (SI_PCH_INT_PIN)entry->pin; |
| 455 | config[cfg_count].Irq = entry->irq; |
| 456 | ++cfg_count; |
| 457 | |
| 458 | entry = entry->next; |
| 459 | } |
| 460 | |
| 461 | *out_count = cfg_count; |
| 462 | |
| 463 | return config; |
| 464 | } |
| 465 | |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 466 | /* |
| 467 | * Chip config parameter PcieRpL1Substates uses (UPD value + 1) |
| 468 | * because UPD value of 0 for PcieRpL1Substates means disabled for FSP. |
| 469 | * In order to ensure that mainboard setting does not disable L1 substates |
| 470 | * incorrectly, chip config parameter values are offset by 1 with 0 meaning |
| 471 | * use FSP UPD default. get_l1_substate_control() ensures that the right UPD |
| 472 | * value is set in fsp_params. |
| 473 | * 0: Use FSP UPD default |
| 474 | * 1: Disable L1 substates |
| 475 | * 2: Use L1.1 |
| 476 | * 3: Use L1.2 (FSP UPD default) |
| 477 | */ |
| 478 | static int get_l1_substate_control(enum L1_substates_control ctl) |
| 479 | { |
Bora Guvendik | 8c46232 | 2022-11-29 15:45:06 -0800 | [diff] [blame] | 480 | if (CONFIG(SOC_INTEL_COMPLIANCE_TEST_MODE)) |
| 481 | ctl = L1_SS_DISABLED; |
| 482 | else if ((ctl > L1_SS_L1_2) || (ctl == L1_SS_FSP_DEFAULT)) |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 483 | ctl = L1_SS_L1_2; |
| 484 | return ctl - 1; |
| 485 | } |
| 486 | |
Kevin Chang | 6e52c1d | 2022-03-18 21:04:07 +0800 | [diff] [blame] | 487 | /* |
Jeremy Soller | d59c799 | 2023-05-16 15:04:08 -0600 | [diff] [blame] | 488 | * Chip config parameter pcie_rp_aspm uses (UPD value + 1) because |
| 489 | * a UPD value of 0 for pcie_rp_aspm means disabled. In order to ensure |
| 490 | * that the mainboard setting does not disable ASPM incorrectly, chip |
| 491 | * config parameter values are offset by 1 with 0 meaning use FSP UPD default. |
Kevin Chang | 6e52c1d | 2022-03-18 21:04:07 +0800 | [diff] [blame] | 492 | * get_aspm_control() ensures that the right UPD value is set in fsp_params. |
Jeremy Soller | d59c799 | 2023-05-16 15:04:08 -0600 | [diff] [blame] | 493 | * 0: Use FSP UPD default |
| 494 | * 1: Disable ASPM |
| 495 | * 2: L0s only |
| 496 | * 3: L1 only |
| 497 | * 4: L0s and L1 |
| 498 | * 5: Auto configuration |
Kevin Chang | 6e52c1d | 2022-03-18 21:04:07 +0800 | [diff] [blame] | 499 | */ |
| 500 | static unsigned int get_aspm_control(enum ASPM_control ctl) |
| 501 | { |
Jeremy Soller | d59c799 | 2023-05-16 15:04:08 -0600 | [diff] [blame] | 502 | if ((ctl > ASPM_AUTO) || (ctl == ASPM_DEFAULT)) |
Kevin Chang | 6e52c1d | 2022-03-18 21:04:07 +0800 | [diff] [blame] | 503 | ctl = ASPM_AUTO; |
Jeremy Soller | d59c799 | 2023-05-16 15:04:08 -0600 | [diff] [blame] | 504 | return ctl - 1; |
Kevin Chang | 6e52c1d | 2022-03-18 21:04:07 +0800 | [diff] [blame] | 505 | } |
| 506 | |
Jeremy Compostella | 1b44c81 | 2022-06-17 15:18:02 -0700 | [diff] [blame] | 507 | /* This function returns the VccIn Aux Imon IccMax values for ADL and RPL |
| 508 | SKU's */ |
V Sowmya | 458708f | 2021-07-09 22:11:04 +0530 | [diff] [blame] | 509 | static uint16_t get_vccin_aux_imon_iccmax(void) |
| 510 | { |
Jeremy Compostella | cb08c79 | 2022-06-30 16:31:14 -0700 | [diff] [blame] | 511 | struct device *dev = pcidev_path_on_root(SA_DEVFN_ROOT); |
| 512 | uint16_t mch_id = dev ? pci_read_config16(dev, PCI_DEVICE_ID) : 0xffff; |
Curtis Chen | ea1bb5f | 2021-11-25 13:17:42 +0800 | [diff] [blame] | 513 | uint8_t tdp; |
V Sowmya | 458708f | 2021-07-09 22:11:04 +0530 | [diff] [blame] | 514 | |
V Sowmya | 458708f | 2021-07-09 22:11:04 +0530 | [diff] [blame] | 515 | switch (mch_id) { |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 516 | case PCI_DID_INTEL_ADL_P_ID_1: |
| 517 | case PCI_DID_INTEL_ADL_P_ID_3: |
Curtis Chen | 3fc3e6c | 2022-03-10 11:51:38 +0800 | [diff] [blame] | 518 | case PCI_DID_INTEL_ADL_P_ID_4: |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 519 | case PCI_DID_INTEL_ADL_P_ID_5: |
| 520 | case PCI_DID_INTEL_ADL_P_ID_6: |
| 521 | case PCI_DID_INTEL_ADL_P_ID_7: |
Curtis Chen | 3fc3e6c | 2022-03-10 11:51:38 +0800 | [diff] [blame] | 522 | case PCI_DID_INTEL_ADL_P_ID_8: |
| 523 | case PCI_DID_INTEL_ADL_P_ID_9: |
| 524 | case PCI_DID_INTEL_ADL_P_ID_10: |
Jeremy Compostella | 1b44c81 | 2022-06-17 15:18:02 -0700 | [diff] [blame] | 525 | case PCI_DID_INTEL_RPL_P_ID_1: |
| 526 | case PCI_DID_INTEL_RPL_P_ID_2: |
| 527 | case PCI_DID_INTEL_RPL_P_ID_3: |
Lawrence Chang | 0a5da51 | 2022-10-19 14:38:41 +0800 | [diff] [blame] | 528 | case PCI_DID_INTEL_RPL_P_ID_4: |
Marx Wang | 39ede0a | 2022-12-20 10:48:33 +0800 | [diff] [blame] | 529 | case PCI_DID_INTEL_RPL_P_ID_5: |
Curtis Chen | ea1bb5f | 2021-11-25 13:17:42 +0800 | [diff] [blame] | 530 | tdp = get_cpu_tdp(); |
| 531 | if (tdp == TDP_45W) |
| 532 | return ICC_MAX_TDP_45W; |
| 533 | return ICC_MAX_TDP_15W_28W; |
Felix Singer | 43b7f41 | 2022-03-07 04:34:52 +0100 | [diff] [blame] | 534 | case PCI_DID_INTEL_ADL_M_ID_1: |
| 535 | case PCI_DID_INTEL_ADL_M_ID_2: |
Bora Guvendik | 3160595 | 2021-09-01 17:32:07 -0700 | [diff] [blame] | 536 | return ICC_MAX_ID_ADL_M_MA; |
V Sowmya | 2af9602 | 2022-04-05 17:03:04 +0530 | [diff] [blame] | 537 | case PCI_DID_INTEL_ADL_N_ID_1: |
| 538 | case PCI_DID_INTEL_ADL_N_ID_2: |
| 539 | case PCI_DID_INTEL_ADL_N_ID_3: |
| 540 | case PCI_DID_INTEL_ADL_N_ID_4: |
| 541 | return ICC_MAX_ID_ADL_N_MA; |
Michał Żygowski | bda2a15 | 2022-04-25 15:02:10 +0200 | [diff] [blame] | 542 | case PCI_DID_INTEL_ADL_S_ID_1: |
| 543 | case PCI_DID_INTEL_ADL_S_ID_3: |
| 544 | case PCI_DID_INTEL_ADL_S_ID_8: |
| 545 | case PCI_DID_INTEL_ADL_S_ID_10: |
Michał Żygowski | a01b62a | 2022-07-21 18:08:19 +0200 | [diff] [blame] | 546 | case PCI_DID_INTEL_ADL_S_ID_11: |
| 547 | case PCI_DID_INTEL_ADL_S_ID_12: |
Tim Crawford | 53c6eea | 2023-07-07 09:59:56 -0600 | [diff] [blame] | 548 | case PCI_DID_INTEL_RPL_HX_ID_1: |
| 549 | case PCI_DID_INTEL_RPL_HX_ID_2: |
| 550 | case PCI_DID_INTEL_RPL_HX_ID_3: |
| 551 | case PCI_DID_INTEL_RPL_HX_ID_4: |
| 552 | case PCI_DID_INTEL_RPL_HX_ID_5: |
| 553 | case PCI_DID_INTEL_RPL_HX_ID_6: |
| 554 | case PCI_DID_INTEL_RPL_HX_ID_7: |
| 555 | case PCI_DID_INTEL_RPL_HX_ID_8: |
Michał Żygowski | bda2a15 | 2022-04-25 15:02:10 +0200 | [diff] [blame] | 556 | return ICC_MAX_ADL_S; |
Max Fritz | 573e6de | 2022-11-19 01:54:44 +0100 | [diff] [blame] | 557 | case PCI_DID_INTEL_RPL_S_ID_1: |
| 558 | case PCI_DID_INTEL_RPL_S_ID_2: |
| 559 | case PCI_DID_INTEL_RPL_S_ID_3: |
| 560 | case PCI_DID_INTEL_RPL_S_ID_4: |
| 561 | case PCI_DID_INTEL_RPL_S_ID_5: |
| 562 | return ICC_MAX_RPL_S; |
V Sowmya | 458708f | 2021-07-09 22:11:04 +0530 | [diff] [blame] | 563 | default: |
| 564 | printk(BIOS_ERR, "Unknown MCH ID: 0x%4x, skipping VccInAuxImonIccMax config\n", |
| 565 | mch_id); |
| 566 | return 0; |
| 567 | } |
| 568 | } |
| 569 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 570 | __weak void mainboard_update_soc_chip_config(struct soc_intel_alderlake_config *config) |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 571 | { |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 572 | /* Override settings per board. */ |
| 573 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 574 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 575 | static void fill_fsps_lpss_params(FSP_S_CONFIG *s_cfg, |
| 576 | const struct soc_intel_alderlake_config *config) |
| 577 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 578 | for (int i = 0; i < CONFIG_SOC_INTEL_I2C_DEV_MAX; i++) |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 579 | s_cfg->SerialIoI2cMode[i] = config->serial_io_i2c_mode[i]; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 580 | |
| 581 | for (int i = 0; i < CONFIG_SOC_INTEL_COMMON_BLOCK_GSPI_MAX; i++) { |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 582 | s_cfg->SerialIoSpiMode[i] = config->serial_io_gspi_mode[i]; |
| 583 | s_cfg->SerialIoSpiCsMode[i] = config->serial_io_gspi_cs_mode[i]; |
| 584 | s_cfg->SerialIoSpiCsState[i] = config->serial_io_gspi_cs_state[i]; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | for (int i = 0; i < CONFIG_SOC_INTEL_UART_DEV_MAX; i++) |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 588 | s_cfg->SerialIoUartMode[i] = config->serial_io_uart_mode[i]; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 589 | } |
| 590 | |
Subrata Banik | fad1cb0 | 2022-08-12 18:12:46 +0530 | [diff] [blame] | 591 | static void fill_fsps_microcode_params(FSP_S_CONFIG *s_cfg, |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 592 | const struct soc_intel_alderlake_config *config) |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 593 | { |
Subrata Banik | 99289a8 | 2020-12-22 10:54:44 +0530 | [diff] [blame] | 594 | const struct microcode *microcode_file; |
| 595 | size_t microcode_len; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 596 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 597 | /* Locate microcode and pass to FSP-S for 2nd microcode loading */ |
Subrata Banik | 7b523a4 | 2021-09-22 16:46:16 +0530 | [diff] [blame] | 598 | microcode_file = intel_microcode_find(); |
Subrata Banik | 99289a8 | 2020-12-22 10:54:44 +0530 | [diff] [blame] | 599 | |
Selma Bensaid | 291294d | 2021-10-11 16:37:36 -0700 | [diff] [blame] | 600 | if (microcode_file != NULL) { |
| 601 | microcode_len = get_microcode_size(microcode_file); |
| 602 | if (microcode_len != 0) { |
| 603 | /* Update CPU Microcode patch base address/size */ |
| 604 | s_cfg->MicrocodeRegionBase = (uint32_t)(uintptr_t)microcode_file; |
| 605 | s_cfg->MicrocodeRegionSize = (uint32_t)microcode_len; |
| 606 | } |
Subrata Banik | 99289a8 | 2020-12-22 10:54:44 +0530 | [diff] [blame] | 607 | } |
Subrata Banik | fad1cb0 | 2022-08-12 18:12:46 +0530 | [diff] [blame] | 608 | } |
Subrata Banik | 99289a8 | 2020-12-22 10:54:44 +0530 | [diff] [blame] | 609 | |
Subrata Banik | fad1cb0 | 2022-08-12 18:12:46 +0530 | [diff] [blame] | 610 | static void fill_fsps_cpu_params(FSP_S_CONFIG *s_cfg, |
| 611 | const struct soc_intel_alderlake_config *config) |
| 612 | { |
Subrata Banik | 8409f15 | 2022-08-15 17:08:13 +0530 | [diff] [blame] | 613 | /* |
| 614 | * FIXME: FSP assumes ownership of the APs (Application Processors) |
| 615 | * upon passing `NULL` pointer to the CpuMpPpi FSP-S UPD. |
| 616 | * Hence, pass a valid pointer to the CpuMpPpi UPD unconditionally. |
| 617 | * This would avoid APs from getting hijacked by FSP while coreboot |
| 618 | * decides to set SkipMpInit UPD. |
| 619 | */ |
Elyes Haouas | 9018dee | 2022-11-18 15:07:33 +0100 | [diff] [blame] | 620 | s_cfg->CpuMpPpi = (uintptr_t)mp_fill_ppi_services_data(); |
Subrata Banik | 8409f15 | 2022-08-15 17:08:13 +0530 | [diff] [blame] | 621 | |
Subrata Banik | a247319 | 2023-02-22 13:03:04 +0000 | [diff] [blame] | 622 | if (CONFIG(USE_FSP_FEATURE_PROGRAM_ON_APS)) |
Subrata Banik | ceaf9d1 | 2022-06-05 19:33:33 +0530 | [diff] [blame] | 623 | /* |
Subrata Banik | fad1cb0 | 2022-08-12 18:12:46 +0530 | [diff] [blame] | 624 | * Fill `2nd microcode loading FSP UPD` if FSP is running CPU feature |
| 625 | * programming. |
| 626 | */ |
| 627 | fill_fsps_microcode_params(s_cfg, config); |
Subrata Banik | 8409f15 | 2022-08-15 17:08:13 +0530 | [diff] [blame] | 628 | else |
Subrata Banik | ceaf9d1 | 2022-06-05 19:33:33 +0530 | [diff] [blame] | 629 | s_cfg->SkipMpInit = !CONFIG(USE_INTEL_FSP_MP_INIT); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 630 | } |
| 631 | |
| 632 | static void fill_fsps_igd_params(FSP_S_CONFIG *s_cfg, |
| 633 | const struct soc_intel_alderlake_config *config) |
| 634 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 635 | /* Load VBT before devicetree-specific config. */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 636 | s_cfg->GraphicsConfigPtr = (uintptr_t)vbt_get(); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 637 | |
| 638 | /* Check if IGD is present and fill Graphics init param accordingly */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 639 | s_cfg->PeiGraphicsPeimInit = CONFIG(RUN_FSP_GOP) && is_devfn_enabled(SA_DEVFN_IGD); |
| 640 | s_cfg->LidStatus = CONFIG(RUN_FSP_GOP); |
Lean Sheng Tan | e8df93a | 2022-04-01 19:07:53 +0200 | [diff] [blame] | 641 | s_cfg->PavpEnable = CONFIG(PAVP); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 642 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 643 | |
Michał Kopeć | 75a49fe | 2022-04-08 11:28:45 +0200 | [diff] [blame] | 644 | WEAK_DEV_PTR(tcss_usb3_port1); |
| 645 | WEAK_DEV_PTR(tcss_usb3_port2); |
| 646 | WEAK_DEV_PTR(tcss_usb3_port3); |
| 647 | WEAK_DEV_PTR(tcss_usb3_port4); |
| 648 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 649 | static void fill_fsps_tcss_params(FSP_S_CONFIG *s_cfg, |
| 650 | const struct soc_intel_alderlake_config *config) |
| 651 | { |
Furquan Shaikh | eafca1f | 2021-09-22 13:59:39 -0700 | [diff] [blame] | 652 | const struct device *tcss_port_arr[] = { |
| 653 | DEV_PTR(tcss_usb3_port1), |
| 654 | DEV_PTR(tcss_usb3_port2), |
| 655 | DEV_PTR(tcss_usb3_port3), |
| 656 | DEV_PTR(tcss_usb3_port4), |
| 657 | }; |
| 658 | |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 659 | s_cfg->TcssAuxOri = config->tcss_aux_ori; |
Deepti Deshatty | 8e7facf | 2021-05-12 17:45:37 +0530 | [diff] [blame] | 660 | |
| 661 | /* Explicitly clear this field to avoid using defaults */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 662 | memset(s_cfg->IomTypeCPortPadCfg, 0, sizeof(s_cfg->IomTypeCPortPadCfg)); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 663 | |
| 664 | /* |
| 665 | * Set FSPS UPD ITbtConnectTopologyTimeoutInMs with value 0. FSP will |
| 666 | * evaluate this UPD value and skip sending command. There will be no |
| 667 | * delay for command completion. |
| 668 | */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 669 | s_cfg->ITbtConnectTopologyTimeoutInMs = 0; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 670 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 671 | /* D3Hot and D3Cold for TCSS */ |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 672 | s_cfg->D3HotEnable = !config->tcss_d3_hot_disable; |
Sean Rhodes | 6bb11a3 | 2023-04-17 20:29:45 +0100 | [diff] [blame] | 673 | s_cfg->D3ColdEnable = CONFIG(D3COLD_SUPPORT); |
Bernardo Perez Priego | 421ce56 | 2021-06-09 09:40:31 -0700 | [diff] [blame] | 674 | |
| 675 | s_cfg->UsbTcPortEn = 0; |
| 676 | for (int i = 0; i < MAX_TYPE_C_PORTS; i++) { |
Furquan Shaikh | eafca1f | 2021-09-22 13:59:39 -0700 | [diff] [blame] | 677 | if (is_dev_enabled(tcss_port_arr[i])) |
Bernardo Perez Priego | 421ce56 | 2021-06-09 09:40:31 -0700 | [diff] [blame] | 678 | s_cfg->UsbTcPortEn |= BIT(i); |
| 679 | } |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 680 | } |
| 681 | |
| 682 | static void fill_fsps_chipset_lockdown_params(FSP_S_CONFIG *s_cfg, |
| 683 | const struct soc_intel_alderlake_config *config) |
| 684 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 685 | /* Chipset Lockdown */ |
Felix Singer | f9d7dc7 | 2021-05-03 02:33:15 +0200 | [diff] [blame] | 686 | const bool lockdown_by_fsp = get_lockdown_config() == CHIPSET_LOCKDOWN_FSP; |
| 687 | s_cfg->PchLockDownGlobalSmi = lockdown_by_fsp; |
| 688 | s_cfg->PchLockDownBiosInterface = lockdown_by_fsp; |
Subrata Banik | 393b093 | 2022-01-11 11:59:39 +0530 | [diff] [blame] | 689 | s_cfg->PchUnlockGpioPads = lockdown_by_fsp; |
Felix Singer | f9d7dc7 | 2021-05-03 02:33:15 +0200 | [diff] [blame] | 690 | s_cfg->RtcMemoryLock = lockdown_by_fsp; |
Tim Wawrzynczak | 091dfa1 | 2021-08-24 09:32:09 -0600 | [diff] [blame] | 691 | s_cfg->SkipPamLock = !lockdown_by_fsp; |
Tim Wawrzynczak | c0e82e7 | 2021-06-17 12:42:35 -0600 | [diff] [blame] | 692 | |
| 693 | /* coreboot will send EOP before loading payload */ |
| 694 | s_cfg->EndOfPostMessage = EOP_DISABLE; |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 695 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 696 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 697 | static void fill_fsps_xhci_params(FSP_S_CONFIG *s_cfg, |
| 698 | const struct soc_intel_alderlake_config *config) |
| 699 | { |
| 700 | int i; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 701 | /* USB */ |
| 702 | for (i = 0; i < ARRAY_SIZE(config->usb2_ports); i++) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 703 | s_cfg->PortUsb20Enable[i] = config->usb2_ports[i].enable; |
| 704 | s_cfg->Usb2PhyPetxiset[i] = config->usb2_ports[i].pre_emp_bias; |
| 705 | s_cfg->Usb2PhyTxiset[i] = config->usb2_ports[i].tx_bias; |
| 706 | s_cfg->Usb2PhyPredeemp[i] = config->usb2_ports[i].tx_emp_enable; |
| 707 | s_cfg->Usb2PhyPehalfbit[i] = config->usb2_ports[i].pre_emp_bit; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 708 | |
| 709 | if (config->usb2_ports[i].enable) |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 710 | s_cfg->Usb2OverCurrentPin[i] = config->usb2_ports[i].ocpin; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 711 | else |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 712 | s_cfg->Usb2OverCurrentPin[i] = OC_SKIP; |
Anil Kumar | c6b65c1 | 2022-02-01 12:59:03 -0800 | [diff] [blame] | 713 | |
| 714 | if (config->usb2_ports[i].type_c) |
| 715 | s_cfg->PortResetMessageEnable[i] = 1; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 716 | } |
| 717 | |
| 718 | for (i = 0; i < ARRAY_SIZE(config->usb3_ports); i++) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 719 | s_cfg->PortUsb30Enable[i] = config->usb3_ports[i].enable; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 720 | if (config->usb3_ports[i].enable) |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 721 | s_cfg->Usb3OverCurrentPin[i] = config->usb3_ports[i].ocpin; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 722 | else |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 723 | s_cfg->Usb3OverCurrentPin[i] = OC_SKIP; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 724 | |
| 725 | if (config->usb3_ports[i].tx_de_emp) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 726 | s_cfg->Usb3HsioTxDeEmphEnable[i] = 1; |
| 727 | s_cfg->Usb3HsioTxDeEmph[i] = config->usb3_ports[i].tx_de_emp; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 728 | } |
| 729 | if (config->usb3_ports[i].tx_downscale_amp) { |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 730 | s_cfg->Usb3HsioTxDownscaleAmpEnable[i] = 1; |
| 731 | s_cfg->Usb3HsioTxDownscaleAmp[i] = |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 732 | config->usb3_ports[i].tx_downscale_amp; |
| 733 | } |
| 734 | } |
| 735 | |
Maulik V Vaghela | 6935350 | 2021-04-14 14:01:02 +0530 | [diff] [blame] | 736 | for (i = 0; i < ARRAY_SIZE(config->tcss_ports); i++) { |
| 737 | if (config->tcss_ports[i].enable) |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 738 | s_cfg->CpuUsb3OverCurrentPin[i] = config->tcss_ports[i].ocpin; |
Maulik V Vaghela | 6935350 | 2021-04-14 14:01:02 +0530 | [diff] [blame] | 739 | } |
Sridhar Siricilla | 37c3305 | 2022-04-02 10:33:00 +0530 | [diff] [blame] | 740 | |
| 741 | s_cfg->PmcUsb2PhySusPgEnable = !config->usb2_phy_sus_pg_disable; |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 742 | } |
Maulik V Vaghela | 6935350 | 2021-04-14 14:01:02 +0530 | [diff] [blame] | 743 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 744 | static void fill_fsps_xdci_params(FSP_S_CONFIG *s_cfg, |
| 745 | const struct soc_intel_alderlake_config *config) |
| 746 | { |
Angel Pons | c7cfe0b | 2021-06-23 12:39:22 +0200 | [diff] [blame] | 747 | s_cfg->XdciEnable = xdci_can_enable(PCH_DEVFN_USBOTG); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 748 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 749 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 750 | static void fill_fsps_uart_params(FSP_S_CONFIG *s_cfg, |
| 751 | const struct soc_intel_alderlake_config *config) |
| 752 | { |
Subrata Banik | 88381c9 | 2022-03-29 11:26:11 +0530 | [diff] [blame] | 753 | if (CONFIG(FSP_USES_CB_DEBUG_EVENT_HANDLER) && CONFIG(CONSOLE_SERIAL) && |
| 754 | CONFIG(FSP_ENABLE_SERIAL_DEBUG)) |
| 755 | s_cfg->FspEventHandler = (UINT32)((FSP_EVENT_HANDLER *) |
| 756 | fsp_debug_event_handler); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 757 | /* PCH UART selection for FSP Debug */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 758 | s_cfg->SerialIoDebugUartNumber = CONFIG_UART_FOR_CONSOLE; |
| 759 | ASSERT(ARRAY_SIZE(s_cfg->SerialIoUartAutoFlow) > CONFIG_UART_FOR_CONSOLE); |
| 760 | s_cfg->SerialIoUartAutoFlow[CONFIG_UART_FOR_CONSOLE] = 0; |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 761 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 762 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 763 | static void fill_fsps_sata_params(FSP_S_CONFIG *s_cfg, |
| 764 | const struct soc_intel_alderlake_config *config) |
| 765 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 766 | /* SATA */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 767 | s_cfg->SataEnable = is_devfn_enabled(PCH_DEVFN_SATA); |
| 768 | if (s_cfg->SataEnable) { |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 769 | s_cfg->SataMode = config->sata_mode; |
| 770 | s_cfg->SataSalpSupport = config->sata_salp_support; |
| 771 | memcpy(s_cfg->SataPortsEnable, config->sata_ports_enable, |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 772 | sizeof(s_cfg->SataPortsEnable)); |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 773 | memcpy(s_cfg->SataPortsDevSlp, config->sata_ports_dev_slp, |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 774 | sizeof(s_cfg->SataPortsDevSlp)); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 775 | } |
| 776 | |
| 777 | /* |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 778 | * Power Optimizer for SATA. |
| 779 | * SataPwrOptimizeDisable is default to 0. |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 780 | * Boards not needing the optimizers explicitly disables them by setting |
| 781 | * these disable variables to 1 in devicetree overrides. |
| 782 | */ |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 783 | s_cfg->SataPwrOptEnable = !(config->sata_pwr_optimize_disable); |
Lean Sheng Tan | 1ec8f97 | 2022-09-07 16:07:33 +0200 | [diff] [blame] | 784 | /* Test mode for SATA margining */ |
| 785 | s_cfg->SataTestMode = CONFIG(ENABLE_SATA_TEST_MODE); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 786 | /* |
| 787 | * Enable DEVSLP Idle Timeout settings DmVal and DitoVal. |
| 788 | * SataPortsDmVal is the DITO multiplier. Default is 15. |
| 789 | * SataPortsDitoVal is the DEVSLP Idle Timeout (DITO), Default is 625ms. |
| 790 | * The default values can be changed from devicetree. |
| 791 | */ |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 792 | for (size_t i = 0; i < ARRAY_SIZE(config->sata_ports_enable_dito_config); i++) { |
| 793 | if (config->sata_ports_enable_dito_config[i]) { |
| 794 | s_cfg->SataPortsDmVal[i] = config->sata_ports_dm_val[i]; |
| 795 | s_cfg->SataPortsDitoVal[i] = config->sata_ports_dito_val[i]; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 796 | } |
| 797 | } |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 798 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 799 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 800 | static void fill_fsps_thermal_params(FSP_S_CONFIG *s_cfg, |
| 801 | const struct soc_intel_alderlake_config *config) |
| 802 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 803 | /* Enable TCPU for processor thermal control */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 804 | s_cfg->Device4Enable = is_devfn_enabled(SA_DEVFN_DPTF); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 805 | |
| 806 | /* Set TccActivationOffset */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 807 | s_cfg->TccActivationOffset = config->tcc_offset; |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 808 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 809 | |
Jeremy Soller | 9601b1e | 2022-05-26 10:21:36 -0600 | [diff] [blame] | 810 | static void fill_fsps_gna_params(FSP_S_CONFIG *s_cfg, |
| 811 | const struct soc_intel_alderlake_config *config) |
| 812 | { |
| 813 | s_cfg->GnaEnable = is_devfn_enabled(SA_DEVFN_GNA); |
| 814 | } |
| 815 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 816 | static void fill_fsps_lan_params(FSP_S_CONFIG *s_cfg, |
| 817 | const struct soc_intel_alderlake_config *config) |
| 818 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 819 | /* LAN */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 820 | s_cfg->PchLanEnable = is_devfn_enabled(PCH_DEVFN_GBE); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 821 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 822 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 823 | static void fill_fsps_cnvi_params(FSP_S_CONFIG *s_cfg, |
| 824 | const struct soc_intel_alderlake_config *config) |
| 825 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 826 | /* CNVi */ |
Michał Żygowski | 01025d3 | 2023-07-12 13:22:09 +0200 | [diff] [blame] | 827 | #if CONFIG(FSP_USE_REPO) |
| 828 | /* This option is only available in public FSP headers on FSP repo */ |
Michał Żygowski | 9707464 | 2022-06-30 18:19:27 +0200 | [diff] [blame] | 829 | s_cfg->CnviWifiCore = is_devfn_enabled(PCH_DEVFN_CNVI_WIFI); |
| 830 | #endif |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 831 | s_cfg->CnviMode = is_devfn_enabled(PCH_DEVFN_CNVI_WIFI); |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 832 | s_cfg->CnviBtCore = config->cnvi_bt_core; |
| 833 | s_cfg->CnviBtAudioOffload = config->cnvi_bt_audio_offload; |
Cliff Huang | bc1941f | 2021-02-10 17:41:41 -0800 | [diff] [blame] | 834 | /* Assert if CNVi BT is enabled without CNVi being enabled. */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 835 | assert(s_cfg->CnviMode || !s_cfg->CnviBtCore); |
Cliff Huang | bc1941f | 2021-02-10 17:41:41 -0800 | [diff] [blame] | 836 | /* Assert if CNVi BT offload is enabled without CNVi BT being enabled. */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 837 | assert(s_cfg->CnviBtCore || !s_cfg->CnviBtAudioOffload); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 838 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 839 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 840 | static void fill_fsps_vmd_params(FSP_S_CONFIG *s_cfg, |
| 841 | const struct soc_intel_alderlake_config *config) |
| 842 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 843 | /* VMD */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 844 | s_cfg->VmdEnable = is_devfn_enabled(SA_DEVFN_VMD); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 845 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 846 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 847 | static void fill_fsps_thc_params(FSP_S_CONFIG *s_cfg, |
| 848 | const struct soc_intel_alderlake_config *config) |
| 849 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 850 | /* THC */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 851 | s_cfg->ThcPort0Assignment = is_devfn_enabled(PCH_DEVFN_THC0) ? THC_0 : THC_NONE; |
| 852 | s_cfg->ThcPort1Assignment = is_devfn_enabled(PCH_DEVFN_THC1) ? THC_1 : THC_NONE; |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 853 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 854 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 855 | static void fill_fsps_tbt_params(FSP_S_CONFIG *s_cfg, |
| 856 | const struct soc_intel_alderlake_config *config) |
| 857 | { |
Bernardo Perez Priego | 095f97b | 2021-05-18 18:39:19 -0700 | [diff] [blame] | 858 | /* USB4/TBT */ |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 859 | for (int i = 0; i < ARRAY_SIZE(s_cfg->ITbtPcieRootPortEn); i++) |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 860 | s_cfg->ITbtPcieRootPortEn[i] = is_devfn_enabled(SA_DEVFN_TBT(i)); |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 861 | } |
Bernardo Perez Priego | 095f97b | 2021-05-18 18:39:19 -0700 | [diff] [blame] | 862 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 863 | static void fill_fsps_8254_params(FSP_S_CONFIG *s_cfg, |
| 864 | const struct soc_intel_alderlake_config *config) |
| 865 | { |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 866 | /* Legacy 8254 timer support */ |
Sean Rhodes | bc35bed | 2021-07-13 13:36:28 +0100 | [diff] [blame] | 867 | bool use_8254 = get_uint_option("legacy_8254_timer", CONFIG(USE_LEGACY_8254_TIMER)); |
| 868 | s_cfg->Enable8254ClockGating = !use_8254; |
| 869 | s_cfg->Enable8254ClockGatingOnS3 = !use_8254; |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 870 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 871 | |
Michael Niewöhner | 0e90580 | 2021-09-25 00:10:30 +0200 | [diff] [blame] | 872 | static void fill_fsps_pm_timer_params(FSP_S_CONFIG *s_cfg, |
| 873 | const struct soc_intel_alderlake_config *config) |
| 874 | { |
| 875 | /* |
| 876 | * Legacy PM ACPI Timer (and TCO Timer) |
| 877 | * This *must* be 1 in any case to keep FSP from |
| 878 | * 1) enabling PM ACPI Timer emulation in uCode. |
| 879 | * 2) disabling the PM ACPI Timer. |
| 880 | * We handle both by ourself! |
| 881 | */ |
| 882 | s_cfg->EnableTcoTimer = 1; |
| 883 | } |
| 884 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 885 | static void fill_fsps_storage_params(FSP_S_CONFIG *s_cfg, |
| 886 | const struct soc_intel_alderlake_config *config) |
| 887 | { |
Krishna Prasad Bhat | a6d642f | 2022-01-16 23:16:24 +0530 | [diff] [blame] | 888 | #if CONFIG(SOC_INTEL_ALDERLAKE_PCH_N) |
| 889 | /* eMMC Configuration */ |
| 890 | s_cfg->ScsEmmcEnabled = is_devfn_enabled(PCH_DEVFN_EMMC); |
| 891 | if (s_cfg->ScsEmmcEnabled) |
| 892 | s_cfg->ScsEmmcHs400Enabled = config->emmc_enable_hs400_mode; |
| 893 | #endif |
Meera Ravindranath | d8ea360 | 2022-03-16 15:27:00 +0530 | [diff] [blame] | 894 | |
| 895 | /* UFS Configuration */ |
| 896 | s_cfg->UfsEnable[0] = 0; /* UFS Controller 0 is fuse disabled */ |
| 897 | s_cfg->UfsEnable[1] = is_devfn_enabled(PCH_DEVFN_UFS); |
| 898 | |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 899 | /* Enable Hybrid storage auto detection */ |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 900 | s_cfg->HybridStorageMode = config->hybrid_storage_mode; |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 901 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 902 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 903 | static void fill_fsps_pcie_params(FSP_S_CONFIG *s_cfg, |
| 904 | const struct soc_intel_alderlake_config *config) |
| 905 | { |
| 906 | uint32_t enable_mask = pcie_rp_enable_mask(get_pch_pcie_rp_table()); |
| 907 | for (int i = 0; i < CONFIG_MAX_PCH_ROOT_PORTS; i++) { |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 908 | if (!(enable_mask & BIT(i))) |
| 909 | continue; |
| 910 | const struct pcie_rp_config *rp_cfg = &config->pch_pcie_rp[i]; |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 911 | s_cfg->PcieRpL1Substates[i] = |
Eric Lai | 5b302b2 | 2020-12-05 16:49:43 +0800 | [diff] [blame] | 912 | get_l1_substate_control(rp_cfg->PcieRpL1Substates); |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 913 | s_cfg->PcieRpLtrEnable[i] = !!(rp_cfg->flags & PCIE_RP_LTR); |
| 914 | s_cfg->PcieRpAdvancedErrorReporting[i] = !!(rp_cfg->flags & PCIE_RP_AER); |
Sridahr Siricilla | 096ce14 | 2021-09-17 22:25:17 +0530 | [diff] [blame] | 915 | s_cfg->PcieRpHotPlug[i] = !!(rp_cfg->flags & PCIE_RP_HOTPLUG) |
| 916 | || CONFIG(SOC_INTEL_COMPLIANCE_TEST_MODE); |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 917 | s_cfg->PcieRpClkReqDetect[i] = !!(rp_cfg->flags & PCIE_RP_CLK_REQ_DETECT); |
Kevin Chang | 6e52c1d | 2022-03-18 21:04:07 +0800 | [diff] [blame] | 918 | if (rp_cfg->pcie_rp_aspm) |
| 919 | s_cfg->PcieRpAspm[i] = get_aspm_control(rp_cfg->pcie_rp_aspm); |
Cliff Huang | 61a442ec | 2022-04-28 18:06:54 -0700 | [diff] [blame] | 920 | /* PcieRpSlotImplemented default to 1 (slot implemented) in FSP; 0: built-in */ |
| 921 | if (!!(rp_cfg->flags & PCIE_RP_BUILT_IN)) |
| 922 | s_cfg->PcieRpSlotImplemented[i] = 0; |
| 923 | s_cfg->PcieRpDetectTimeoutMs[i] = rp_cfg->pcie_rp_detect_timeout_ms; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 924 | } |
Sridahr Siricilla | 096ce14 | 2021-09-17 22:25:17 +0530 | [diff] [blame] | 925 | s_cfg->PcieComplianceTestMode = CONFIG(SOC_INTEL_COMPLIANCE_TEST_MODE); |
Patrick Rudolph | b8abde7 | 2023-07-21 09:09:07 +0200 | [diff] [blame] | 926 | |
Michał Żygowski | 12a1fc2 | 2023-08-21 11:12:04 +0200 | [diff] [blame] | 927 | #if CONFIG(FSP_TYPE_IOT) && !CONFIG(SOC_INTEL_RAPTORLAKE) |
Patrick Rudolph | b8abde7 | 2023-07-21 09:09:07 +0200 | [diff] [blame] | 928 | /* |
| 929 | * Intel requires that all enabled PCH PCIe ports have a CLK_REQ signal connected. |
| 930 | * The CLK_REQ is used to wake the silicon when link entered L1 link-state. L1 |
| 931 | * link-state is also entered on PCI-PM D3, even with ASPM L1 disabled. |
| 932 | * When no CLK_REQ signal is used, for example when it's using a free running |
| 933 | * clock the Root port silicon will never wake from L1 link state. |
| 934 | * This will trigger a MCE. |
| 935 | * |
| 936 | * Starting with FSP MR4 the UPD 'PchPcieClockGating' allows to work around |
| 937 | * this issue by disabling ClockGating. Disabling ClockGating should be avoided |
| 938 | * as the silicon draws more power when it is idle. |
| 939 | */ |
| 940 | for (int i = 0; i < CONFIG_MAX_PCH_ROOT_PORTS; i++) { |
| 941 | bool clk_req_missing = false; |
| 942 | if (!(enable_mask & BIT(i))) |
| 943 | continue; |
| 944 | const struct pcie_rp_config *rp_cfg = &config->pch_pcie_rp[i]; |
| 945 | if (CONFIG(SOC_INTEL_COMPLIANCE_TEST_MODE)) { |
| 946 | clk_req_missing = true; |
| 947 | } else if (!rp_cfg->flags && rp_cfg->clk_src == 0 && rp_cfg->clk_req == 0) { |
| 948 | clk_req_missing = true; |
| 949 | } else if (rp_cfg->flags & PCIE_RP_CLK_REQ_UNUSED) { |
| 950 | clk_req_missing = true; |
| 951 | } |
| 952 | if (clk_req_missing) { |
| 953 | printk(BIOS_INFO, "PCH PCIe port %d has no CLK_REQ\n", i + 1); |
| 954 | printk(BIOS_INFO, "Disabling PCH PCIE ClockGating+PowerGating.\n"); |
| 955 | s_cfg->PchPcieClockGating = false; |
| 956 | s_cfg->PchPciePowerGating = false; |
| 957 | break; |
| 958 | } |
| 959 | } |
| 960 | #endif |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 961 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 962 | |
Tim Wawrzynczak | f944052 | 2021-12-16 15:07:15 -0700 | [diff] [blame] | 963 | static void fill_fsps_cpu_pcie_params(FSP_S_CONFIG *s_cfg, |
| 964 | const struct soc_intel_alderlake_config *config) |
| 965 | { |
| 966 | if (!CONFIG_MAX_CPU_ROOT_PORTS) |
| 967 | return; |
| 968 | |
| 969 | const uint32_t enable_mask = pcie_rp_enable_mask(get_cpu_pcie_rp_table()); |
| 970 | for (int i = 0; i < CONFIG_MAX_CPU_ROOT_PORTS; i++) { |
| 971 | if (!(enable_mask & BIT(i))) |
| 972 | continue; |
| 973 | |
| 974 | const struct pcie_rp_config *rp_cfg = &config->cpu_pcie_rp[i]; |
| 975 | s_cfg->CpuPcieRpL1Substates[i] = |
| 976 | get_l1_substate_control(rp_cfg->PcieRpL1Substates); |
| 977 | s_cfg->CpuPcieRpLtrEnable[i] = !!(rp_cfg->flags & PCIE_RP_LTR); |
| 978 | s_cfg->CpuPcieRpAdvancedErrorReporting[i] = !!(rp_cfg->flags & PCIE_RP_AER); |
Sridahr Siricilla | 096ce14 | 2021-09-17 22:25:17 +0530 | [diff] [blame] | 979 | s_cfg->CpuPcieRpHotPlug[i] = !!(rp_cfg->flags & PCIE_RP_HOTPLUG) |
| 980 | || CONFIG(SOC_INTEL_COMPLIANCE_TEST_MODE); |
Tim Wawrzynczak | d6b763c | 2022-07-27 09:53:58 -0600 | [diff] [blame] | 981 | s_cfg->CpuPcieRpDetectTimeoutMs[i] = rp_cfg->pcie_rp_detect_timeout_ms; |
Tim Wawrzynczak | f944052 | 2021-12-16 15:07:15 -0700 | [diff] [blame] | 982 | s_cfg->PtmEnabled[i] = 0; |
Tim Wawrzynczak | d6b763c | 2022-07-27 09:53:58 -0600 | [diff] [blame] | 983 | if (rp_cfg->pcie_rp_aspm) |
| 984 | s_cfg->CpuPcieRpAspm[i] = get_aspm_control(rp_cfg->pcie_rp_aspm); |
| 985 | |
| 986 | if (!!(rp_cfg->flags & PCIE_RP_BUILT_IN)) |
| 987 | s_cfg->CpuPcieRpSlotImplemented[i] = 0; |
Tim Wawrzynczak | f944052 | 2021-12-16 15:07:15 -0700 | [diff] [blame] | 988 | } |
Sridahr Siricilla | 096ce14 | 2021-09-17 22:25:17 +0530 | [diff] [blame] | 989 | s_cfg->CpuPcieComplianceTestMode = CONFIG(SOC_INTEL_COMPLIANCE_TEST_MODE); |
Tim Wawrzynczak | f944052 | 2021-12-16 15:07:15 -0700 | [diff] [blame] | 990 | } |
| 991 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 992 | static void fill_fsps_misc_power_params(FSP_S_CONFIG *s_cfg, |
| 993 | const struct soc_intel_alderlake_config *config) |
| 994 | { |
Anil Kumar | e822fb3 | 2023-02-09 16:55:57 -0800 | [diff] [blame] | 995 | u32 cpu_id = cpu_get_cpuid(); |
Subrata Banik | d6da4ef | 2021-10-07 00:39:31 +0530 | [diff] [blame] | 996 | /* Skip setting D0I3 bit for all HECI devices */ |
| 997 | s_cfg->DisableD0I3SettingForHeci = 1; |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 998 | /* |
| 999 | * Power Optimizer for DMI |
| 1000 | * DmiPwrOptimizeDisable is default to 0. |
| 1001 | * Boards not needing the optimizers explicitly disables them by setting |
| 1002 | * these disable variables to 1 in devicetree overrides. |
| 1003 | */ |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 1004 | s_cfg->PchPwrOptEnable = !(config->dmi_power_optimize_disable); |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 1005 | s_cfg->PmSupport = 1; |
| 1006 | s_cfg->Hwp = 1; |
| 1007 | s_cfg->Cx = 1; |
| 1008 | s_cfg->PsOnEnable = 1; |
V Sowmya | af42906 | 2021-06-21 10:23:33 +0530 | [diff] [blame] | 1009 | s_cfg->PkgCStateLimit = LIMIT_AUTO; |
V Sowmya | 458708f | 2021-07-09 22:11:04 +0530 | [diff] [blame] | 1010 | |
Jeremy Compostella | 92d3899 | 2022-09-14 11:06:06 -0700 | [diff] [blame] | 1011 | /* Disable Energy Efficient Turbo mode */ |
| 1012 | s_cfg->EnergyEfficientTurbo = 0; |
| 1013 | |
V Sowmya | 458708f | 2021-07-09 22:11:04 +0530 | [diff] [blame] | 1014 | /* VccIn Aux Imon IccMax. Values are in 1/4 Amp increments and range is 0-512. */ |
| 1015 | s_cfg->VccInAuxImonIccImax = get_vccin_aux_imon_iccmax() * 4 / MILLIAMPS_TO_AMPS; |
V Sowmya | c6d7166 | 2021-07-15 08:11:08 +0530 | [diff] [blame] | 1016 | |
| 1017 | /* VrConfig Settings for IA and GT domains */ |
| 1018 | for (size_t i = 0; i < ARRAY_SIZE(config->domain_vr_config); i++) |
| 1019 | fill_vr_domain_config(s_cfg, i, &config->domain_vr_config[i]); |
Tim Wawrzynczak | e2b8f30 | 2021-07-19 15:35:47 -0600 | [diff] [blame] | 1020 | |
Nick Vaccaro | 577afe6 | 2022-01-12 12:03:41 -0800 | [diff] [blame] | 1021 | s_cfg->PmcLpmS0ixSubStateEnableMask = get_supported_lpm_mask(); |
Tim Wawrzynczak | ab0e081 | 2021-09-21 10:28:16 -0600 | [diff] [blame] | 1022 | |
| 1023 | /* Apply minimum assertion width settings */ |
| 1024 | if (config->pch_slp_s3_min_assertion_width == SLP_S3_ASSERTION_DEFAULT) |
| 1025 | s_cfg->PchPmSlpS3MinAssert = SLP_S3_ASSERTION_50_MS; |
| 1026 | else |
| 1027 | s_cfg->PchPmSlpS3MinAssert = config->pch_slp_s3_min_assertion_width; |
| 1028 | |
| 1029 | if (config->pch_slp_s4_min_assertion_width == SLP_S4_ASSERTION_DEFAULT) |
| 1030 | s_cfg->PchPmSlpS4MinAssert = SLP_S4_ASSERTION_1S; |
| 1031 | else |
| 1032 | s_cfg->PchPmSlpS4MinAssert = config->pch_slp_s4_min_assertion_width; |
| 1033 | |
| 1034 | if (config->pch_slp_sus_min_assertion_width == SLP_SUS_ASSERTION_DEFAULT) |
| 1035 | s_cfg->PchPmSlpSusMinAssert = SLP_SUS_ASSERTION_4_S; |
| 1036 | else |
| 1037 | s_cfg->PchPmSlpSusMinAssert = config->pch_slp_sus_min_assertion_width; |
| 1038 | |
| 1039 | if (config->pch_slp_a_min_assertion_width == SLP_A_ASSERTION_DEFAULT) |
| 1040 | s_cfg->PchPmSlpAMinAssert = SLP_A_ASSERTION_2_S; |
| 1041 | else |
| 1042 | s_cfg->PchPmSlpAMinAssert = config->pch_slp_a_min_assertion_width; |
| 1043 | |
| 1044 | unsigned int power_cycle_duration = config->pch_reset_power_cycle_duration; |
| 1045 | if (power_cycle_duration == POWER_CYCLE_DURATION_DEFAULT) |
| 1046 | power_cycle_duration = POWER_CYCLE_DURATION_4S; |
| 1047 | |
| 1048 | s_cfg->PchPmPwrCycDur = get_pm_pwr_cyc_dur(s_cfg->PchPmSlpS4MinAssert, |
| 1049 | s_cfg->PchPmSlpS3MinAssert, |
| 1050 | s_cfg->PchPmSlpAMinAssert, |
| 1051 | power_cycle_duration); |
Ryan Lin | 4a48dbe | 2021-09-28 15:59:34 +0800 | [diff] [blame] | 1052 | |
| 1053 | /* Set PsysPmax if it is available from DT */ |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 1054 | if (config->platform_pmax) { |
| 1055 | printk(BIOS_DEBUG, "PsysPmax = %dW\n", config->platform_pmax); |
Ryan Lin | 4a48dbe | 2021-09-28 15:59:34 +0800 | [diff] [blame] | 1056 | /* PsysPmax is in unit of 1/8 Watt */ |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 1057 | s_cfg->PsysPmax = config->platform_pmax * 8; |
Ryan Lin | 4a48dbe | 2021-09-28 15:59:34 +0800 | [diff] [blame] | 1058 | } |
MAULIK V VAGHELA | 9935638 | 2022-03-03 13:07:57 +0530 | [diff] [blame] | 1059 | |
| 1060 | s_cfg->C1StateAutoDemotion = !config->disable_c1_state_auto_demotion; |
Lean Sheng Tan | 4b45d4c | 2022-04-01 19:01:59 +0200 | [diff] [blame] | 1061 | |
| 1062 | s_cfg->VrPowerDeliveryDesign = config->vr_power_delivery_design; |
V Sowmya | 4be8d9e | 2022-07-05 20:49:57 +0530 | [diff] [blame] | 1063 | |
Sean Rhodes | 42f8b59 | 2023-08-08 13:46:53 +0100 | [diff] [blame] | 1064 | /* C state demotion must be disabled for Raptorlake J0 and Q0 SKUs */ |
| 1065 | assert(!(config->s0ix_enable && ((cpu_id == CPUID_RAPTORLAKE_J0) || |
| 1066 | (cpu_id == CPUID_RAPTORLAKE_Q0)) && |
| 1067 | !config->disable_package_c_state_demotion)); |
| 1068 | |
| 1069 | s_cfg->PkgCStateDemotion = !config->disable_package_c_state_demotion; |
Joey Peng | ea2a38b | 2023-04-25 15:18:00 +0800 | [diff] [blame] | 1070 | |
Michał Żygowski | d54a5b29 | 2023-07-03 17:17:32 +0200 | [diff] [blame] | 1071 | if (cpu_id == CPUID_RAPTORLAKE_J0 || cpu_id == CPUID_RAPTORLAKE_Q0) |
Joey Peng | ea2a38b | 2023-04-25 15:18:00 +0800 | [diff] [blame] | 1072 | s_cfg->C1e = 0; |
| 1073 | else |
| 1074 | s_cfg->C1e = 1; |
Michał Żygowski | 01025d3 | 2023-07-12 13:22:09 +0200 | [diff] [blame] | 1075 | #if CONFIG(SOC_INTEL_RAPTORLAKE) && !CONFIG(FSP_USE_REPO) |
Bora Guvendik | 6e64c01 | 2023-04-24 18:12:19 -0700 | [diff] [blame] | 1076 | s_cfg->EnableHwpScalabilityTracking = config->enable_hwp_scalability_tracking; |
| 1077 | #endif |
Subrata Banik | 6f1cb40 | 2021-06-09 22:11:12 +0530 | [diff] [blame] | 1078 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 1079 | |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 1080 | static void fill_fsps_irq_params(FSP_S_CONFIG *s_cfg, |
| 1081 | const struct soc_intel_alderlake_config *config) |
| 1082 | { |
Michał Żygowski | 72704be | 2022-06-20 18:10:14 +0200 | [diff] [blame] | 1083 | const struct slot_irq_constraints *constraints; |
| 1084 | size_t num_slots; |
| 1085 | |
| 1086 | if (CONFIG(SOC_INTEL_ALDERLAKE_PCH_S)) { |
| 1087 | constraints = irq_constraints_pch_s; |
| 1088 | num_slots = ARRAY_SIZE(irq_constraints_pch_s); |
| 1089 | } else { |
| 1090 | constraints = irq_constraints; |
| 1091 | num_slots = ARRAY_SIZE(irq_constraints); |
| 1092 | } |
| 1093 | |
| 1094 | if (!assign_pci_irqs(constraints, num_slots)) |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 1095 | die("ERROR: Unable to assign PCI IRQs, and no _PRT table available\n"); |
| 1096 | |
| 1097 | size_t pch_count = 0; |
| 1098 | const SI_PCH_DEVICE_INTERRUPT_CONFIG *upd_irqs = pci_irq_to_fsp(&pch_count); |
| 1099 | |
| 1100 | s_cfg->DevIntConfigPtr = (UINT32)((uintptr_t)upd_irqs); |
| 1101 | s_cfg->NumOfDevIntConfig = pch_count; |
| 1102 | printk(BIOS_INFO, "IRQ: Using dynamically assigned PCI IO-APIC IRQs\n"); |
| 1103 | } |
| 1104 | |
V Sowmya | 418d37e | 2021-06-21 08:47:17 +0530 | [diff] [blame] | 1105 | static void fill_fsps_fivr_params(FSP_S_CONFIG *s_cfg, |
| 1106 | const struct soc_intel_alderlake_config *config) |
| 1107 | { |
| 1108 | /* PCH FIVR settings override */ |
| 1109 | if (!config->ext_fivr_settings.configure_ext_fivr) |
| 1110 | return; |
| 1111 | |
| 1112 | s_cfg->PchFivrExtV1p05RailEnabledStates = |
| 1113 | config->ext_fivr_settings.v1p05_enable_bitmap; |
| 1114 | |
| 1115 | s_cfg->PchFivrExtV1p05RailSupportedVoltageStates = |
| 1116 | config->ext_fivr_settings.v1p05_supported_voltage_bitmap; |
| 1117 | |
| 1118 | s_cfg->PchFivrExtVnnRailEnabledStates = |
| 1119 | config->ext_fivr_settings.vnn_enable_bitmap; |
| 1120 | |
| 1121 | s_cfg->PchFivrExtVnnRailSupportedVoltageStates = |
| 1122 | config->ext_fivr_settings.vnn_supported_voltage_bitmap; |
| 1123 | |
| 1124 | s_cfg->PchFivrExtVnnRailSxEnabledStates = |
Bora Guvendik | fbf874f | 2021-10-18 14:17:41 -0700 | [diff] [blame] | 1125 | config->ext_fivr_settings.vnn_sx_enable_bitmap; |
V Sowmya | 418d37e | 2021-06-21 08:47:17 +0530 | [diff] [blame] | 1126 | |
| 1127 | /* Convert the voltages to increments of 2.5mv */ |
| 1128 | s_cfg->PchFivrExtV1p05RailVoltage = |
| 1129 | (config->ext_fivr_settings.v1p05_voltage_mv * 10) / 25; |
| 1130 | |
| 1131 | s_cfg->PchFivrExtVnnRailVoltage = |
| 1132 | (config->ext_fivr_settings.vnn_voltage_mv * 10) / 25; |
| 1133 | |
| 1134 | s_cfg->PchFivrExtVnnRailSxVoltage = |
| 1135 | (config->ext_fivr_settings.vnn_sx_voltage_mv * 10 / 25); |
| 1136 | |
| 1137 | s_cfg->PchFivrExtV1p05RailIccMaximum = |
| 1138 | config->ext_fivr_settings.v1p05_icc_max_ma; |
| 1139 | |
| 1140 | s_cfg->PchFivrExtVnnRailIccMaximum = |
| 1141 | config->ext_fivr_settings.vnn_icc_max_ma; |
V Sowmya | 036b16b | 2022-10-10 12:46:18 +0530 | [diff] [blame] | 1142 | |
| 1143 | #if CONFIG(SOC_INTEL_ALDERLAKE_PCH_N) |
| 1144 | /* Enable the FIVR VCCST ICCMax Control for ADL-N. |
| 1145 | * TODO:Right now the UPD is update in partial headers for only ADL-N and when its |
| 1146 | * updated for ADL-P then we will remove the config since this needs to be enabled for |
| 1147 | * all the Alderlake platforms. |
| 1148 | */ |
| 1149 | s_cfg->PchFivrVccstIccMaxControl = 1; |
| 1150 | #endif |
V Sowmya | 418d37e | 2021-06-21 08:47:17 +0530 | [diff] [blame] | 1151 | } |
| 1152 | |
Wisley Chen | d0cef2a | 2021-11-01 16:13:55 +0600 | [diff] [blame] | 1153 | static void fill_fsps_fivr_rfi_params(FSP_S_CONFIG *s_cfg, |
| 1154 | const struct soc_intel_alderlake_config *config) |
| 1155 | { |
| 1156 | /* transform from Hz to 100 KHz */ |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 1157 | s_cfg->FivrRfiFrequency = config->fivr_rfi_frequency / (100 * KHz); |
| 1158 | s_cfg->FivrSpreadSpectrum = config->fivr_spread_spectrum; |
Wisley Chen | d0cef2a | 2021-11-01 16:13:55 +0600 | [diff] [blame] | 1159 | } |
| 1160 | |
Wisley Chen | c510346 | 2021-11-04 18:12:58 +0600 | [diff] [blame] | 1161 | static void fill_fsps_acoustic_params(FSP_S_CONFIG *s_cfg, |
| 1162 | const struct soc_intel_alderlake_config *config) |
| 1163 | { |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 1164 | s_cfg->AcousticNoiseMitigation = config->acoustic_noise_mitigation; |
Wisley Chen | c510346 | 2021-11-04 18:12:58 +0600 | [diff] [blame] | 1165 | |
| 1166 | if (s_cfg->AcousticNoiseMitigation) { |
leo.chou | aef916a | 2022-05-13 10:41:03 +0800 | [diff] [blame] | 1167 | s_cfg->PreWake = config->PreWake; |
Wisley Chen | c510346 | 2021-11-04 18:12:58 +0600 | [diff] [blame] | 1168 | for (int i = 0; i < NUM_VR_DOMAINS; i++) { |
MAULIK V VAGHELA | 215a97e | 2022-03-07 18:39:17 +0530 | [diff] [blame] | 1169 | s_cfg->FastPkgCRampDisable[i] = config->fast_pkg_c_ramp_disable[i]; |
| 1170 | s_cfg->SlowSlewRate[i] = config->slow_slew_rate[i]; |
Wisley Chen | c510346 | 2021-11-04 18:12:58 +0600 | [diff] [blame] | 1171 | } |
| 1172 | } |
| 1173 | } |
| 1174 | |
Michał Żygowski | 46d7477 | 2022-04-25 12:15:55 +0200 | [diff] [blame] | 1175 | static void fill_fsps_pci_ssid_params(FSP_S_CONFIG *s_cfg, |
| 1176 | const struct soc_intel_alderlake_config *config) |
| 1177 | { |
| 1178 | struct device *dev; |
| 1179 | int i; |
| 1180 | /* |
| 1181 | * Prevent FSP from programming write-once subsystem IDs by providing |
| 1182 | * a custom SSID table. Must have at least one entry for the FSP to |
| 1183 | * use the table. |
| 1184 | */ |
| 1185 | struct svid_ssid_init_entry { |
| 1186 | union { |
| 1187 | struct { |
| 1188 | uint64_t reg:12; /* Register offset */ |
| 1189 | uint64_t function:3; |
| 1190 | uint64_t device:5; |
| 1191 | uint64_t bus:8; |
| 1192 | uint64_t :4; |
| 1193 | uint64_t segment:16; |
| 1194 | uint64_t :16; |
| 1195 | }; |
| 1196 | uint64_t segbusdevfuncregister; |
| 1197 | }; |
| 1198 | struct { |
| 1199 | uint16_t svid; |
| 1200 | uint16_t ssid; |
| 1201 | }; |
| 1202 | uint32_t reserved; |
| 1203 | }; |
| 1204 | |
| 1205 | /* |
| 1206 | * The xHCI and HDA devices have RW/L rather than RW/O registers for |
| 1207 | * subsystem IDs and so must be written before FspSiliconInit locks |
| 1208 | * them with their default values. |
| 1209 | */ |
| 1210 | const pci_devfn_t devfn_table[] = { PCH_DEVFN_XHCI, PCH_DEVFN_HDA }; |
| 1211 | static struct svid_ssid_init_entry ssid_table[ARRAY_SIZE(devfn_table)]; |
| 1212 | |
| 1213 | for (i = 0; i < ARRAY_SIZE(devfn_table); i++) { |
| 1214 | ssid_table[i].reg = PCI_SUBSYSTEM_VENDOR_ID; |
| 1215 | ssid_table[i].device = PCI_SLOT(devfn_table[i]); |
| 1216 | ssid_table[i].function = PCI_FUNC(devfn_table[i]); |
| 1217 | dev = pcidev_path_on_root(devfn_table[i]); |
| 1218 | if (dev) { |
| 1219 | ssid_table[i].svid = dev->subsystem_vendor; |
| 1220 | ssid_table[i].ssid = dev->subsystem_device; |
| 1221 | } |
| 1222 | } |
| 1223 | |
| 1224 | s_cfg->SiSsidTablePtr = (uintptr_t)ssid_table; |
| 1225 | s_cfg->SiNumberOfSsidTableEntry = ARRAY_SIZE(ssid_table); |
| 1226 | |
| 1227 | /* |
| 1228 | * Replace the default SVID:SSID value with the values specified in |
| 1229 | * the devicetree for the root device. |
| 1230 | */ |
| 1231 | dev = pcidev_path_on_root(SA_DEVFN_ROOT); |
| 1232 | s_cfg->SiCustomizedSvid = dev->subsystem_vendor; |
| 1233 | s_cfg->SiCustomizedSsid = dev->subsystem_device; |
| 1234 | |
| 1235 | /* Ensure FSP will program the registers */ |
| 1236 | s_cfg->SiSkipSsidProgramming = 0; |
| 1237 | } |
| 1238 | |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 1239 | static void soc_silicon_init_params(FSP_S_CONFIG *s_cfg, |
| 1240 | struct soc_intel_alderlake_config *config) |
| 1241 | { |
| 1242 | /* Override settings per board if required. */ |
| 1243 | mainboard_update_soc_chip_config(config); |
| 1244 | |
Arthur Heymans | 02967e6 | 2022-02-18 13:22:25 +0100 | [diff] [blame] | 1245 | void (*const fill_fsps_params[])(FSP_S_CONFIG *s_cfg, |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 1246 | const struct soc_intel_alderlake_config *config) = { |
| 1247 | fill_fsps_lpss_params, |
| 1248 | fill_fsps_cpu_params, |
| 1249 | fill_fsps_igd_params, |
| 1250 | fill_fsps_tcss_params, |
| 1251 | fill_fsps_chipset_lockdown_params, |
| 1252 | fill_fsps_xhci_params, |
| 1253 | fill_fsps_xdci_params, |
| 1254 | fill_fsps_uart_params, |
| 1255 | fill_fsps_sata_params, |
| 1256 | fill_fsps_thermal_params, |
Jeremy Soller | 9601b1e | 2022-05-26 10:21:36 -0600 | [diff] [blame] | 1257 | fill_fsps_gna_params, |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 1258 | fill_fsps_lan_params, |
| 1259 | fill_fsps_cnvi_params, |
| 1260 | fill_fsps_vmd_params, |
| 1261 | fill_fsps_thc_params, |
| 1262 | fill_fsps_tbt_params, |
| 1263 | fill_fsps_8254_params, |
Michael Niewöhner | 0e90580 | 2021-09-25 00:10:30 +0200 | [diff] [blame] | 1264 | fill_fsps_pm_timer_params, |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 1265 | fill_fsps_storage_params, |
| 1266 | fill_fsps_pcie_params, |
Tim Wawrzynczak | f944052 | 2021-12-16 15:07:15 -0700 | [diff] [blame] | 1267 | fill_fsps_cpu_pcie_params, |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 1268 | fill_fsps_misc_power_params, |
Tim Wawrzynczak | 43607e4 | 2021-05-18 09:04:42 -0600 | [diff] [blame] | 1269 | fill_fsps_irq_params, |
V Sowmya | 418d37e | 2021-06-21 08:47:17 +0530 | [diff] [blame] | 1270 | fill_fsps_fivr_params, |
Wisley Chen | d0cef2a | 2021-11-01 16:13:55 +0600 | [diff] [blame] | 1271 | fill_fsps_fivr_rfi_params, |
Wisley Chen | c510346 | 2021-11-04 18:12:58 +0600 | [diff] [blame] | 1272 | fill_fsps_acoustic_params, |
Michał Żygowski | 46d7477 | 2022-04-25 12:15:55 +0200 | [diff] [blame] | 1273 | fill_fsps_pci_ssid_params, |
Subrata Banik | b03cadf | 2021-06-09 22:19:04 +0530 | [diff] [blame] | 1274 | }; |
| 1275 | |
| 1276 | for (size_t i = 0; i < ARRAY_SIZE(fill_fsps_params); i++) |
| 1277 | fill_fsps_params[i](s_cfg, config); |
| 1278 | } |
| 1279 | |
Jeremy Compostella | a2a7fec | 2023-01-19 19:06:09 -0700 | [diff] [blame] | 1280 | /* |
| 1281 | * The Alder Lake PEIM graphics driver executed as part of the FSP does not wait |
| 1282 | * for the panel power cycle to complete before it initializes communication |
| 1283 | * with the display. It can result in AUX channel communication time out and |
| 1284 | * PEIM graphics driver failing to bring up graphics. |
| 1285 | * |
| 1286 | * If we have performed some graphics operations in romstage, it is possible |
| 1287 | * that a panel power cycle is still in progress. To prevent any issue with the |
| 1288 | * PEIM graphics driver it is preferable to ensure that panel power cycle is |
| 1289 | * complete. |
| 1290 | * |
| 1291 | * BUG:b:264526798 |
| 1292 | */ |
| 1293 | static void wait_for_panel_power_cycle_done(const struct soc_intel_alderlake_config *config) |
| 1294 | { |
| 1295 | const struct i915_gpu_panel_config *panel_cfg; |
| 1296 | uint32_t bar0; |
| 1297 | void *mmio; |
| 1298 | |
| 1299 | if (!CONFIG(RUN_FSP_GOP)) |
| 1300 | return; |
| 1301 | |
| 1302 | bar0 = pci_s_read_config32(SA_DEV_IGD, PCI_BASE_ADDRESS_0); |
| 1303 | mmio = (void *)(bar0 & ~PCI_BASE_ADDRESS_MEM_ATTR_MASK); |
| 1304 | if (!mmio) |
| 1305 | return; |
| 1306 | |
| 1307 | panel_cfg = &config->panel_cfg; |
| 1308 | for (size_t i = 0;; i++) { |
| 1309 | uint32_t status = read32(mmio + PCH_PP_STATUS); |
| 1310 | if (!(status & PANEL_POWER_CYCLE_ACTIVE)) |
| 1311 | break; |
| 1312 | if (i == panel_cfg->cycle_delay_ms) { |
| 1313 | printk(BIOS_ERR, "Panel power cycle is still active.\n"); |
| 1314 | break; |
| 1315 | } |
| 1316 | mdelay(1); |
| 1317 | } |
| 1318 | } |
| 1319 | |
Subrata Banik | 6f1cb40 | 2021-06-09 22:11:12 +0530 | [diff] [blame] | 1320 | /* UPD parameters to be initialized before SiliconInit */ |
| 1321 | void platform_fsp_silicon_init_params_cb(FSPS_UPD *supd) |
| 1322 | { |
| 1323 | struct soc_intel_alderlake_config *config; |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 1324 | FSP_S_CONFIG *s_cfg = &supd->FspsConfig; |
Subrata Banik | 6f1cb40 | 2021-06-09 22:11:12 +0530 | [diff] [blame] | 1325 | |
| 1326 | config = config_of_soc(); |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 1327 | soc_silicon_init_params(s_cfg, config); |
| 1328 | mainboard_silicon_init_params(s_cfg); |
Jeremy Compostella | a2a7fec | 2023-01-19 19:06:09 -0700 | [diff] [blame] | 1329 | |
| 1330 | wait_for_panel_power_cycle_done(config); |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 1331 | } |
| 1332 | |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 1333 | /* |
| 1334 | * Callbacks for SoC/Mainboard specific overrides for FspMultiPhaseSiInit |
| 1335 | * This platform supports below MultiPhaseSIInit Phase(s): |
| 1336 | * Phase | FSP return point | Purpose |
| 1337 | * ------- + ------------------------------------------------ + ------------------------------- |
| 1338 | * 1 | After TCSS initialization completed | for TCSS specific init |
Subrata Banik | b6c3a03 | 2022-06-05 22:39:34 +0530 | [diff] [blame] | 1339 | * 2 | Before BIOS Reset CPL is set by FSP-S | for CPU specific init |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 1340 | */ |
| 1341 | void platform_fsp_multi_phase_init_cb(uint32_t phase_index) |
| 1342 | { |
| 1343 | switch (phase_index) { |
| 1344 | case 1: |
| 1345 | /* TCSS specific initialization here */ |
Deepti Deshatty | 8e7facf | 2021-05-12 17:45:37 +0530 | [diff] [blame] | 1346 | printk(BIOS_DEBUG, "FSP MultiPhaseSiInit %s/%s called\n", |
| 1347 | __FILE__, __func__); |
| 1348 | |
| 1349 | if (CONFIG(SOC_INTEL_COMMON_BLOCK_TCSS)) { |
| 1350 | const config_t *config = config_of_soc(); |
| 1351 | tcss_configure(config->typec_aux_bias_pads); |
| 1352 | } |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 1353 | break; |
Subrata Banik | b6c3a03 | 2022-06-05 22:39:34 +0530 | [diff] [blame] | 1354 | case 2: |
| 1355 | /* CPU specific initialization here */ |
| 1356 | printk(BIOS_DEBUG, "FSP MultiPhaseSiInit %s/%s called\n", |
| 1357 | __FILE__, __func__); |
| 1358 | before_post_cpus_init(); |
| 1359 | /* Enable BIOS Reset CPL */ |
| 1360 | enable_bios_reset_cpl(); |
| 1361 | break; |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 1362 | default: |
| 1363 | break; |
| 1364 | } |
| 1365 | } |
| 1366 | |
| 1367 | /* Mainboard GPIO Configuration */ |
Subrata Banik | c0983c9 | 2021-06-15 13:02:01 +0530 | [diff] [blame] | 1368 | __weak void mainboard_silicon_init_params(FSP_S_CONFIG *s_cfg) |
Subrata Banik | 2871e0e | 2020-09-27 11:30:58 +0530 | [diff] [blame] | 1369 | { |
| 1370 | printk(BIOS_DEBUG, "WEAK: %s/%s called\n", __FILE__, __func__); |
| 1371 | } |
Subrata Banik | 0cf2674 | 2023-05-16 12:18:00 +0530 | [diff] [blame] | 1372 | |
| 1373 | /* Handle FSP logo params */ |
| 1374 | void soc_load_logo(FSPS_UPD *supd) |
| 1375 | { |
Subrata Banik | 03dfc21 | 2023-08-16 02:50:16 +0530 | [diff] [blame] | 1376 | fsp_convert_bmp_to_gop_blt(&supd->FspsConfig.LogoPtr, |
| 1377 | &supd->FspsConfig.LogoSize, |
| 1378 | &supd->FspsConfig.BltBufferAddress, |
| 1379 | &supd->FspsConfig.BltBufferSize, |
| 1380 | &supd->FspsConfig.LogoPixelHeight, |
| 1381 | &supd->FspsConfig.LogoPixelWidth); |
Subrata Banik | 0cf2674 | 2023-05-16 12:18:00 +0530 | [diff] [blame] | 1382 | } |