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