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