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 | |
| 3 | |
| 4 | Name(_HID,EISAID("PNP0A08")) // PCIe |
| 5 | Name(_CID,EISAID("PNP0A03")) // PCI |
| 6 | |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 7 | Name(_BBN, 0) |
| 8 | |
| 9 | Device (MCHC) |
| 10 | { |
| 11 | Name(_ADR, 0x00000000) // 0:0.0 |
| 12 | |
| 13 | OperationRegion(MCHP, PCI_Config, 0x00, 0x100) |
| 14 | Field (MCHP, DWordAcc, NoLock, Preserve) |
| 15 | { |
| 16 | Offset (0x40), // EPBAR |
| 17 | EPEN, 1, // Enable |
| 18 | , 11, // |
| 19 | EPBR, 24, // EPBAR |
| 20 | |
| 21 | Offset (0x48), // MCHBAR |
| 22 | MHEN, 1, // Enable |
| 23 | , 13, // |
| 24 | MHBR, 22, // MCHBAR |
| 25 | |
| 26 | Offset (0x60), // PCIe BAR |
| 27 | PXEN, 1, // Enable |
| 28 | PXSZ, 2, // BAR size |
| 29 | , 23, // |
| 30 | PXBR, 10, // PCIe BAR |
| 31 | |
| 32 | Offset (0x68), // DMIBAR |
| 33 | DMEN, 1, // Enable |
| 34 | , 11, // |
| 35 | DMBR, 24, // DMIBAR |
| 36 | |
| 37 | |
| 38 | Offset (0xa0), |
| 39 | TOM, 16, |
| 40 | TUUD, 16, |
| 41 | |
| 42 | Offset (0xb0), // Top of Low Used Memory |
| 43 | TLUD, 16, |
| 44 | } |
| 45 | |
| 46 | Mutex (CTCM, 1) /* CTDP Switch Mutex (sync level 1) */ |
| 47 | Name (CTCC, 0) /* CTDP Current Selection */ |
| 48 | Name (CTCN, 0) /* CTDP Nominal Select */ |
| 49 | Name (CTCD, 1) /* CTDP Down Select */ |
| 50 | Name (CTCU, 2) /* CTDP Up Select */ |
| 51 | |
| 52 | OperationRegion (MCHB, SystemMemory, DEFAULT_MCHBAR, 0x8000) |
| 53 | Field (MCHB, DWordAcc, Lock, Preserve) |
| 54 | { |
| 55 | Offset (0x5930), |
| 56 | CTDN, 15, /* CTDP Nominal PL1 */ |
| 57 | Offset (0x59a0), |
| 58 | PL1V, 15, /* Power Limit 1 Value */ |
| 59 | PL1E, 1, /* Power Limit 1 Enable */ |
| 60 | PL1C, 1, /* Power Limit 1 Clamp */ |
| 61 | PL1T, 7, /* Power Limit 1 Time */ |
| 62 | Offset (0x59a4), |
| 63 | PL2V, 15, /* Power Limit 2 Value */ |
| 64 | PL2E, 1, /* Power Limit 2 Enable */ |
| 65 | PL2C, 1, /* Power Limit 2 Clamp */ |
| 66 | PL2T, 7, /* Power Limit 2 Time */ |
| 67 | Offset (0x5f3c), |
| 68 | TARN, 8, /* CTDP Nominal Turbo Activation Ratio */ |
| 69 | Offset (0x5f40), |
| 70 | CTDD, 15, /* CTDP Down PL1 */ |
| 71 | , 1, |
| 72 | TARD, 8, /* CTDP Down Turbo Activation Ratio */ |
| 73 | Offset (0x5f48), |
| 74 | CTDU, 15, /* CTDP Up PL1 */ |
| 75 | , 1, |
| 76 | TARU, 8, /* CTDP Up Turbo Activation Ratio */ |
| 77 | Offset (0x5f50), |
| 78 | CTCS, 2, /* CTDP Select */ |
| 79 | Offset (0x5f54), |
| 80 | TARS, 8, /* Turbo Activation Ratio Select */ |
| 81 | } |
| 82 | |
| 83 | /* |
| 84 | * Search CPU0 _PSS looking for control=arg0 and then |
| 85 | * return previous P-state entry number for new _PPC |
| 86 | * |
| 87 | * Format of _PSS: |
| 88 | * Name (_PSS, Package () { |
| 89 | * Package (6) { freq, power, tlat, blat, control, status } |
| 90 | * } |
| 91 | */ |
Christian Walter | be3979c | 2019-12-18 15:07:59 +0100 | [diff] [blame] | 92 | External (\_SB.CP00._PSS) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 93 | Method (PSSS, 1, NotSerialized) |
| 94 | { |
| 95 | Store (One, Local0) /* Start at P1 */ |
Christian Walter | be3979c | 2019-12-18 15:07:59 +0100 | [diff] [blame] | 96 | Store (SizeOf (\_SB.CP00._PSS), Local1) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 97 | |
| 98 | While (LLess (Local0, Local1)) { |
| 99 | /* Store _PSS entry Control value to Local2 */ |
| 100 | ShiftRight (DeRefOf (Index (DeRefOf (Index |
Christian Walter | be3979c | 2019-12-18 15:07:59 +0100 | [diff] [blame] | 101 | (\_SB.CP00._PSS, Local0)), 4)), 8, Local2) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 102 | If (LEqual (Local2, Arg0)) { |
| 103 | Return (Subtract (Local0, 1)) |
| 104 | } |
| 105 | Increment (Local0) |
| 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 | } |
| 117 | If (LEqual (CTCD, CTCC)) { |
| 118 | Release (CTCM) |
| 119 | Return (0) |
| 120 | } |
| 121 | |
| 122 | Store ("Set TDP Down", Debug) |
| 123 | |
| 124 | /* Set CTC */ |
| 125 | Store (CTCD, CTCS) |
| 126 | |
| 127 | /* Set TAR */ |
| 128 | Store (TARD, TARS) |
| 129 | |
| 130 | /* Set PPC limit and notify OS */ |
| 131 | Store (PSSS (TARD), PPCM) |
| 132 | PPCN () |
| 133 | |
| 134 | /* Set PL2 to 1.25 * PL1 */ |
Martin Roth | 35272fd | 2015-12-10 08:28:53 -0700 | [diff] [blame] | 135 | Divide (Multiply (CTDD, 125), 100, , PL2V) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 136 | |
| 137 | /* Set PL1 */ |
| 138 | Store (CTDD, PL1V) |
| 139 | |
| 140 | /* Store the new TDP Down setting */ |
| 141 | Store (CTCD, CTCC) |
| 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 | } |
| 153 | If (LEqual (CTCN, CTCC)) { |
| 154 | Release (CTCM) |
| 155 | Return (0) |
| 156 | } |
| 157 | |
| 158 | Store ("Set TDP Nominal", Debug) |
| 159 | |
| 160 | /* Set PL1 */ |
| 161 | Store (CTDN, PL1V) |
| 162 | |
| 163 | /* Set PL2 to 1.25 * PL1 */ |
Martin Roth | 35272fd | 2015-12-10 08:28:53 -0700 | [diff] [blame] | 164 | Divide (Multiply (CTDN, 125), 100, , PL2V) |
Vladimir Serbinenko | c6f6be0 | 2013-11-12 22:32:08 +0100 | [diff] [blame] | 165 | |
| 166 | /* Set PPC limit and notify OS */ |
| 167 | Store (PSSS (TARN), PPCM) |
| 168 | PPCN () |
| 169 | |
| 170 | /* Set TAR */ |
| 171 | Store (TARN, TARS) |
| 172 | |
| 173 | /* Set CTC */ |
| 174 | Store (CTCN, CTCS) |
| 175 | |
| 176 | /* Store the new TDP Nominal setting */ |
| 177 | Store (CTCN, CTCC) |
| 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 |
| 308 | Store (^MCHC.TLUD, Local0) |
| 309 | ShiftRight (Local0, 4, Local0) |
| 310 | Store (^MCHC.TUUD, Local1) |
| 311 | |
| 312 | // Check if ME base is equal |
| 313 | If (LEqual (Local0, Local1)) { |
| 314 | // Use Top Of Memory instead |
| 315 | Store (^MCHC.TOM, Local0) |
| 316 | ShiftRight (Local0, 6, Local0) |
| 317 | } |
| 318 | |
| 319 | ShiftLeft (Local0, 20, Local0) |
| 320 | Store (Local0, PMIN) |
| 321 | Add(Subtract(PMAX, PMIN), 1, PLEN) |
| 322 | |
| 323 | Return (MCRS) |
| 324 | } |