Angel Pons | 4b42983 | 2020-04-02 23:48:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 2 | |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 3 | Name(_HID,EISAID("PNP0A08")) // PCIe |
| 4 | Name(_CID,EISAID("PNP0A03")) // PCI |
| 5 | |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 6 | Name(_BBN, 0) |
| 7 | |
Angel Pons | ffdf1f9 | 2021-01-10 16:30:40 +0100 | [diff] [blame] | 8 | Name(\PPCM, 0) |
| 9 | |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 10 | Device (MCHC) |
| 11 | { |
| 12 | Name(_ADR, 0x00000000) // 0:0.0 |
| 13 | |
| 14 | OperationRegion(MCHP, PCI_Config, 0x00, 0x100) |
| 15 | Field (MCHP, DWordAcc, NoLock, Preserve) |
| 16 | { |
| 17 | Offset (0x40), // EPBAR |
| 18 | EPEN, 1, // Enable |
| 19 | , 11, // |
| 20 | EPBR, 24, // EPBAR |
| 21 | |
| 22 | Offset (0x48), // MCHBAR |
| 23 | MHEN, 1, // Enable |
| 24 | , 13, // |
| 25 | MHBR, 22, // MCHBAR |
| 26 | |
| 27 | Offset (0x60), // PCIe BAR |
| 28 | PXEN, 1, // Enable |
| 29 | PXSZ, 2, // BAR size |
| 30 | , 23, // |
| 31 | PXBR, 10, // PCIe BAR |
| 32 | |
| 33 | Offset (0x68), // DMIBAR |
| 34 | DMEN, 1, // Enable |
| 35 | , 11, // |
| 36 | DMBR, 24, // DMIBAR |
| 37 | |
| 38 | |
| 39 | Offset (0xa0), |
| 40 | TOM, 16, |
| 41 | TUUD, 16, |
| 42 | |
| 43 | Offset (0xb0), // Top of Low Used Memory |
| 44 | TLUD, 16, |
| 45 | } |
| 46 | |
| 47 | Mutex (CTCM, 1) /* CTDP Switch Mutex (sync level 1) */ |
| 48 | Name (CTCC, 0) /* CTDP Current Selection */ |
| 49 | Name (CTCN, 0) /* CTDP Nominal Select */ |
| 50 | Name (CTCD, 1) /* CTDP Down Select */ |
| 51 | Name (CTCU, 2) /* CTDP Up Select */ |
| 52 | |
Angel Pons | a8df6cf | 2021-01-20 01:32:17 +0100 | [diff] [blame] | 53 | OperationRegion (MCHB, SystemMemory, CONFIG_FIXED_MCHBAR_MMIO_BASE, 0x8000) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 54 | Field (MCHB, DWordAcc, Lock, Preserve) |
| 55 | { |
| 56 | Offset (0x5930), |
| 57 | CTDN, 15, /* CTDP Nominal PL1 */ |
| 58 | Offset (0x59a0), |
| 59 | PL1V, 15, /* Power Limit 1 Value */ |
| 60 | PL1E, 1, /* Power Limit 1 Enable */ |
| 61 | PL1C, 1, /* Power Limit 1 Clamp */ |
| 62 | PL1T, 7, /* Power Limit 1 Time */ |
| 63 | Offset (0x59a4), |
| 64 | PL2V, 15, /* Power Limit 2 Value */ |
| 65 | PL2E, 1, /* Power Limit 2 Enable */ |
| 66 | PL2C, 1, /* Power Limit 2 Clamp */ |
| 67 | PL2T, 7, /* Power Limit 2 Time */ |
| 68 | Offset (0x5f3c), |
| 69 | TARN, 8, /* CTDP Nominal Turbo Activation Ratio */ |
| 70 | Offset (0x5f40), |
| 71 | CTDD, 15, /* CTDP Down PL1 */ |
| 72 | , 1, |
| 73 | TARD, 8, /* CTDP Down Turbo Activation Ratio */ |
| 74 | Offset (0x5f48), |
| 75 | CTDU, 15, /* CTDP Up PL1 */ |
| 76 | , 1, |
| 77 | TARU, 8, /* CTDP Up Turbo Activation Ratio */ |
| 78 | Offset (0x5f50), |
| 79 | CTCS, 2, /* CTDP Select */ |
| 80 | Offset (0x5f54), |
| 81 | TARS, 8, /* Turbo Activation Ratio Select */ |
| 82 | } |
| 83 | |
| 84 | /* |
| 85 | * Search CPU0 _PSS looking for control=arg0 and then |
| 86 | * return previous P-state entry number for new _PPC |
| 87 | * |
| 88 | * Format of _PSS: |
| 89 | * Name (_PSS, Package () { |
| 90 | * Package (6) { freq, power, tlat, blat, control, status } |
| 91 | * } |
| 92 | */ |
Christian Walter | be3979c | 2019-12-18 15:07:59 +0100 | [diff] [blame] | 93 | External (\_SB.CP00._PSS) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 94 | Method (PSSS, 1, NotSerialized) |
| 95 | { |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 96 | Local0 = 1 /* Start at P1 */ |
| 97 | Local1 = SizeOf (\_SB.CP00._PSS) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 98 | |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 99 | While (Local0 < Local1) { |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 100 | /* Store _PSS entry Control value to Local2 */ |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 101 | Local2 = DeRefOf (Index (DeRefOf (Index (\_SB.CP00._PSS, Local0)), 4)) >> 8 |
| 102 | If (Local2 == Arg0) { |
| 103 | Return (Local0 - 1) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 104 | } |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 105 | Local0++ |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | Return (0) |
| 109 | } |
| 110 | |
| 111 | /* Set TDP Down */ |
| 112 | Method (STND, 0, Serialized) |
| 113 | { |
| 114 | If (Acquire (CTCM, 100)) { |
| 115 | Return (0) |
| 116 | } |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 117 | If (CTCD == CTCC) { |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 118 | Release (CTCM) |
| 119 | Return (0) |
| 120 | } |
| 121 | |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 122 | Debug = "Set TDP Down" |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 123 | |
| 124 | /* Set CTC */ |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 125 | CTCS = CTCD |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 126 | |
| 127 | /* Set TAR */ |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 128 | TARS = TARD |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 129 | |
| 130 | /* Set PPC limit and notify OS */ |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 131 | PPCM = PSSS (TARD) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 132 | PPCN () |
| 133 | |
| 134 | /* Set PL2 to 1.25 * PL1 */ |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 135 | PL2V = (CTDD * 125) / 100 |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 136 | |
| 137 | /* Set PL1 */ |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 138 | PL1V = CTDD |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 139 | |
| 140 | /* Store the new TDP Down setting */ |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 141 | CTCC = CTCD |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 142 | |
| 143 | Release (CTCM) |
| 144 | Return (1) |
| 145 | } |
| 146 | |
| 147 | /* Set TDP Nominal from Down */ |
| 148 | Method (STDN, 0, Serialized) |
| 149 | { |
| 150 | If (Acquire (CTCM, 100)) { |
| 151 | Return (0) |
| 152 | } |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 153 | If (CTCN == CTCC) { |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 154 | Release (CTCM) |
| 155 | Return (0) |
| 156 | } |
| 157 | |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 158 | Debug = "Set TDP Nominal" |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 159 | |
| 160 | /* Set PL1 */ |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 161 | PL1V = CTDN |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 162 | |
| 163 | /* Set PL2 to 1.25 * PL1 */ |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 164 | PL2V = (CTDN * 125) / 100 |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 165 | |
| 166 | /* Set PPC limit and notify OS */ |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 167 | PPCM = PSSS (TARN) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 168 | PPCN () |
| 169 | |
| 170 | /* Set TAR */ |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 171 | TARS = TARN |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 172 | |
| 173 | /* Set CTC */ |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 174 | CTCS = CTCN |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 175 | |
| 176 | /* Store the new TDP Nominal setting */ |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 177 | CTCC = CTCN |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 178 | |
| 179 | Release (CTCM) |
| 180 | Return (1) |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | // Current Resource Settings |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 185 | Name (MCRS, ResourceTemplate() |
| 186 | { |
| 187 | // Bus Numbers |
| 188 | WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode, |
| 189 | 0x0000, 0x0000, 0x00ff, 0x0000, 0x0100,,, PB00) |
| 190 | |
| 191 | // IO Region 0 |
| 192 | DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, |
| 193 | 0x0000, 0x0000, 0x0cf7, 0x0000, 0x0cf8,,, PI00) |
| 194 | |
| 195 | // PCI Config Space |
| 196 | Io (Decode16, 0x0cf8, 0x0cf8, 0x0001, 0x0008) |
| 197 | |
| 198 | // IO Region 1 |
| 199 | DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange, |
| 200 | 0x0000, 0x0d00, 0xffff, 0x0000, 0xf300,,, PI01) |
| 201 | |
| 202 | // VGA memory (0xa0000-0xbffff) |
| 203 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 204 | Cacheable, ReadWrite, |
| 205 | 0x00000000, 0x000a0000, 0x000bffff, 0x00000000, |
| 206 | 0x00020000,,, ASEG) |
| 207 | |
| 208 | // OPROM reserved (0xc0000-0xc3fff) |
| 209 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 210 | Cacheable, ReadWrite, |
| 211 | 0x00000000, 0x000c0000, 0x000c3fff, 0x00000000, |
| 212 | 0x00004000,,, OPR0) |
| 213 | |
| 214 | // OPROM reserved (0xc4000-0xc7fff) |
| 215 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 216 | Cacheable, ReadWrite, |
| 217 | 0x00000000, 0x000c4000, 0x000c7fff, 0x00000000, |
| 218 | 0x00004000,,, OPR1) |
| 219 | |
| 220 | // OPROM reserved (0xc8000-0xcbfff) |
| 221 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 222 | Cacheable, ReadWrite, |
| 223 | 0x00000000, 0x000c8000, 0x000cbfff, 0x00000000, |
| 224 | 0x00004000,,, OPR2) |
| 225 | |
| 226 | // OPROM reserved (0xcc000-0xcffff) |
| 227 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 228 | Cacheable, ReadWrite, |
| 229 | 0x00000000, 0x000cc000, 0x000cffff, 0x00000000, |
| 230 | 0x00004000,,, OPR3) |
| 231 | |
| 232 | // OPROM reserved (0xd0000-0xd3fff) |
| 233 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 234 | Cacheable, ReadWrite, |
| 235 | 0x00000000, 0x000d0000, 0x000d3fff, 0x00000000, |
| 236 | 0x00004000,,, OPR4) |
| 237 | |
| 238 | // OPROM reserved (0xd4000-0xd7fff) |
| 239 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 240 | Cacheable, ReadWrite, |
| 241 | 0x00000000, 0x000d4000, 0x000d7fff, 0x00000000, |
| 242 | 0x00004000,,, OPR5) |
| 243 | |
| 244 | // OPROM reserved (0xd8000-0xdbfff) |
| 245 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 246 | Cacheable, ReadWrite, |
| 247 | 0x00000000, 0x000d8000, 0x000dbfff, 0x00000000, |
| 248 | 0x00004000,,, OPR6) |
| 249 | |
| 250 | // OPROM reserved (0xdc000-0xdffff) |
| 251 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 252 | Cacheable, ReadWrite, |
| 253 | 0x00000000, 0x000dc000, 0x000dffff, 0x00000000, |
| 254 | 0x00004000,,, OPR7) |
| 255 | |
| 256 | // BIOS Extension (0xe0000-0xe3fff) |
| 257 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 258 | Cacheable, ReadWrite, |
| 259 | 0x00000000, 0x000e0000, 0x000e3fff, 0x00000000, |
| 260 | 0x00004000,,, ESG0) |
| 261 | |
| 262 | // BIOS Extension (0xe4000-0xe7fff) |
| 263 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 264 | Cacheable, ReadWrite, |
| 265 | 0x00000000, 0x000e4000, 0x000e7fff, 0x00000000, |
| 266 | 0x00004000,,, ESG1) |
| 267 | |
| 268 | // BIOS Extension (0xe8000-0xebfff) |
| 269 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 270 | Cacheable, ReadWrite, |
| 271 | 0x00000000, 0x000e8000, 0x000ebfff, 0x00000000, |
| 272 | 0x00004000,,, ESG2) |
| 273 | |
| 274 | // BIOS Extension (0xec000-0xeffff) |
| 275 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 276 | Cacheable, ReadWrite, |
| 277 | 0x00000000, 0x000ec000, 0x000effff, 0x00000000, |
| 278 | 0x00004000,,, ESG3) |
| 279 | |
| 280 | // System BIOS (0xf0000-0xfffff) |
| 281 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 282 | Cacheable, ReadWrite, |
| 283 | 0x00000000, 0x000f0000, 0x000fffff, 0x00000000, |
| 284 | 0x00010000,,, FSEG) |
| 285 | |
| 286 | // PCI Memory Region (Top of memory-0xfebfffff) |
| 287 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 288 | Cacheable, ReadWrite, |
| 289 | 0x00000000, 0x00000000, 0xfebfffff, 0x00000000, |
| 290 | 0xfec00000,,, PM01) |
| 291 | |
| 292 | // TPM Area (0xfed40000-0xfed44fff) |
| 293 | DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, |
| 294 | Cacheable, ReadWrite, |
| 295 | 0x00000000, 0xfed40000, 0xfed44fff, 0x00000000, |
| 296 | 0x00005000,,, TPMR) |
| 297 | }) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 298 | |
| 299 | Method (_CRS, 0, Serialized) |
| 300 | { |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 301 | // Find PCI resource area in MCRS |
Martin Roth | fc70643 | 2015-08-18 16:56:05 -0600 | [diff] [blame] | 302 | CreateDwordField(MCRS, ^PM01._MIN, PMIN) |
| 303 | CreateDwordField(MCRS, ^PM01._MAX, PMAX) |
| 304 | CreateDwordField(MCRS, ^PM01._LEN, PLEN) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 305 | |
| 306 | // Fix up PCI memory region |
| 307 | // Start with Top of Lower Usable DRAM |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 308 | Local0 = ^MCHC.TLUD |
| 309 | Local0 >>= 4 |
| 310 | Local1 = ^MCHC.TUUD |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 311 | |
| 312 | // Check if ME base is equal |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 313 | If (Local0 == Local1) { |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 314 | // Use Top Of Memory instead |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 315 | Local0 = ^MCHC.TOM |
| 316 | Local0 >>= 6 |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 317 | } |
| 318 | |
Angel Pons | 302a143 | 2020-07-22 00:27:23 +0200 | [diff] [blame] | 319 | Local0 <<= 20 |
| 320 | PMIN = Local0 |
| 321 | PLEN = PMAX - PMIN + 1 |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 322 | |
| 323 | Return (MCRS) |
| 324 | } |