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