blob: 1a4f33d011cfc45c87abafdc33b6295dd51534d2 [file] [log] [blame]
Aaron Durbin76c37002012-10-30 09:03:43 -05001/*
2 * This file is part of the coreboot project.
3 *
Aaron Durbin76c37002012-10-30 09:03:43 -05004 *
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.
Aaron Durbin76c37002012-10-30 09:03:43 -050014 */
15
16
17Name(_HID,EISAID("PNP0A08")) // PCIe
18Name(_CID,EISAID("PNP0A03")) // PCI
19
Aaron Durbin76c37002012-10-30 09:03:43 -050020Name(_BBN, 0)
21
22Device (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
Chris Morgan5e5e7892020-02-07 09:40:42 -060038 Offset (0x54),
39 DVEN, 32,
Aaron Durbin76c37002012-10-30 09:03:43 -050040 Offset (0x60), // PCIe BAR
41 PXEN, 1, // Enable
42 PXSZ, 2, // BAR size
43 , 23, //
44 PXBR, 10, // PCIe BAR
45
46 Offset (0x68), // DMIBAR
47 DMEN, 1, // Enable
48 , 11, //
49 DMBR, 24, // DMIBAR
50
51 Offset (0x70), // ME Base Address
52 MEBA, 64,
53
54 // ...
55
56 Offset (0x80), // PAM0
57 , 4,
58 PM0H, 2,
59 , 2,
60 Offset (0x81), // PAM1
61 PM1L, 2,
62 , 2,
63 PM1H, 2,
64 , 2,
65 Offset (0x82), // PAM2
66 PM2L, 2,
67 , 2,
68 PM2H, 2,
69 , 2,
70 Offset (0x83), // PAM3
71 PM3L, 2,
72 , 2,
73 PM3H, 2,
74 , 2,
75 Offset (0x84), // PAM4
76 PM4L, 2,
77 , 2,
78 PM4H, 2,
79 , 2,
80 Offset (0x85), // PAM5
81 PM5L, 2,
82 , 2,
83 PM5H, 2,
84 , 2,
85 Offset (0x86), // PAM6
86 PM6L, 2,
87 , 2,
88 PM6H, 2,
89 , 2,
90
91 Offset (0xa0), // Top of Used Memory
92 TOM, 64,
93
94 Offset (0xbc), // Top of Low Used Memory
95 TLUD, 32,
96 }
97
98 Mutex (CTCM, 1) /* CTDP Switch Mutex (sync level 1) */
99 Name (CTCC, 0) /* CTDP Current Selection */
100 Name (CTCN, 0) /* CTDP Nominal Select */
101 Name (CTCD, 1) /* CTDP Down Select */
102 Name (CTCU, 2) /* CTDP Up Select */
Duncan Laurieb1711792013-06-28 16:01:53 -0700103 Name (SPL1, 0) /* Saved PL1 value */
Aaron Durbin76c37002012-10-30 09:03:43 -0500104
Duncan Laurieb1711792013-06-28 16:01:53 -0700105 OperationRegion (MCHB, SystemMemory, Add(DEFAULT_MCHBAR,0x5000), 0x1000)
Aaron Durbin76c37002012-10-30 09:03:43 -0500106 Field (MCHB, DWordAcc, Lock, Preserve)
107 {
Duncan Laurieb1711792013-06-28 16:01:53 -0700108 Offset (0x930), /* PACKAGE_POWER_SKU */
Aaron Durbin76c37002012-10-30 09:03:43 -0500109 CTDN, 15, /* CTDP Nominal PL1 */
Duncan Laurieb1711792013-06-28 16:01:53 -0700110 Offset (0x938), /* PACKAGE_POWER_SKU_UNIT */
111 PUNI, 4, /* Power Units */
112 , 4,
113 EUNI, 5, /* Energy Units */
114 , 3,
115 TUNI, 4, /* Time Units */
116 Offset (0x958), /* PLATFORM_INFO */
117 , 40,
118 LFM_, 8, /* Maximum Efficiency Ratio (LFM) */
119 Offset (0x9a0), /* TURBO_POWER_LIMIT1 */
Aaron Durbin76c37002012-10-30 09:03:43 -0500120 PL1V, 15, /* Power Limit 1 Value */
121 PL1E, 1, /* Power Limit 1 Enable */
122 PL1C, 1, /* Power Limit 1 Clamp */
123 PL1T, 7, /* Power Limit 1 Time */
Duncan Laurieb1711792013-06-28 16:01:53 -0700124 Offset (0x9a4), /* TURBO_POWER_LIMIT2 */
Aaron Durbin76c37002012-10-30 09:03:43 -0500125 PL2V, 15, /* Power Limit 2 Value */
126 PL2E, 1, /* Power Limit 2 Enable */
127 PL2C, 1, /* Power Limit 2 Clamp */
128 PL2T, 7, /* Power Limit 2 Time */
Duncan Laurieb1711792013-06-28 16:01:53 -0700129 Offset (0xf3c), /* CONFIG_TDP_NOMINAL */
Aaron Durbin76c37002012-10-30 09:03:43 -0500130 TARN, 8, /* CTDP Nominal Turbo Activation Ratio */
Duncan Laurieb1711792013-06-28 16:01:53 -0700131 Offset (0xf40), /* CONFIG_TDP_LEVEL1 */
Aaron Durbin76c37002012-10-30 09:03:43 -0500132 CTDD, 15, /* CTDP Down PL1 */
Duncan Laurieb1711792013-06-28 16:01:53 -0700133 , 1,
Aaron Durbin76c37002012-10-30 09:03:43 -0500134 TARD, 8, /* CTDP Down Turbo Activation Ratio */
Duncan Laurieb1711792013-06-28 16:01:53 -0700135 Offset (0xf48), /* MSR_CONFIG_TDP_LEVEL2 */
Aaron Durbin76c37002012-10-30 09:03:43 -0500136 CTDU, 15, /* CTDP Up PL1 */
Duncan Laurieb1711792013-06-28 16:01:53 -0700137 , 1,
Aaron Durbin76c37002012-10-30 09:03:43 -0500138 TARU, 8, /* CTDP Up Turbo Activation Ratio */
Duncan Laurieb1711792013-06-28 16:01:53 -0700139 Offset (0xf50), /* CONFIG_TDP_CONTROL */
Aaron Durbin76c37002012-10-30 09:03:43 -0500140 CTCS, 2, /* CTDP Select */
Duncan Laurieb1711792013-06-28 16:01:53 -0700141 Offset (0xf54), /* TURBO_ACTIVATION_RATIO */
Aaron Durbin76c37002012-10-30 09:03:43 -0500142 TARS, 8, /* Turbo Activation Ratio Select */
143 }
144
145 /*
Elyes HAOUAS69d658f2016-09-17 20:32:07 +0200146 * Search CPU0 _PSS looking for control = arg0 and then
Aaron Durbin76c37002012-10-30 09:03:43 -0500147 * return previous P-state entry number for new _PPC
148 *
149 * Format of _PSS:
150 * Name (_PSS, Package () {
151 * Package (6) { freq, power, tlat, blat, control, status }
152 * }
153 */
Christian Walterbe3979c2019-12-18 15:07:59 +0100154 External (\_SB.CP00._PSS)
Aaron Durbin76c37002012-10-30 09:03:43 -0500155 Method (PSSS, 1, NotSerialized)
156 {
157 Store (One, Local0) /* Start at P1 */
Christian Walterbe3979c2019-12-18 15:07:59 +0100158 Store (SizeOf (\_SB.CP00._PSS), Local1)
Aaron Durbin76c37002012-10-30 09:03:43 -0500159
160 While (LLess (Local0, Local1)) {
161 /* Store _PSS entry Control value to Local2 */
162 ShiftRight (DeRefOf (Index (DeRefOf (Index
Christian Walterbe3979c2019-12-18 15:07:59 +0100163 (\_SB.CP00._PSS, Local0)), 4)), 8, Local2)
Aaron Durbin76c37002012-10-30 09:03:43 -0500164 If (LEqual (Local2, Arg0)) {
165 Return (Subtract (Local0, 1))
166 }
167 Increment (Local0)
168 }
169
170 Return (0)
171 }
172
Duncan Laurieb1711792013-06-28 16:01:53 -0700173 /* Calculate PL2 based on chip type */
174 Method (CPL2, 1, NotSerialized)
175 {
176 If (\ISLP ()) {
177 /* Haswell ULT PL2 = 25W */
178 Return (Multiply (25, 8))
179 } Else {
180 /* Haswell Mobile PL2 = 1.25 * PL1 */
181 Return (Divide (Multiply (Arg0, 125), 100))
182 }
183 }
184
185 /* Set Config TDP Down */
Aaron Durbin76c37002012-10-30 09:03:43 -0500186 Method (STND, 0, Serialized)
187 {
188 If (Acquire (CTCM, 100)) {
189 Return (0)
190 }
191 If (LEqual (CTCD, CTCC)) {
192 Release (CTCM)
193 Return (0)
194 }
195
196 Store ("Set TDP Down", Debug)
197
198 /* Set CTC */
199 Store (CTCD, CTCS)
200
201 /* Set TAR */
202 Store (TARD, TARS)
203
204 /* Set PPC limit and notify OS */
205 Store (PSSS (TARD), PPCM)
206 PPCN ()
207
Duncan Laurieb1711792013-06-28 16:01:53 -0700208 /* Set PL2 */
209 Store (CPL2 (CTDD), PL2V)
Aaron Durbin76c37002012-10-30 09:03:43 -0500210
211 /* Set PL1 */
212 Store (CTDD, PL1V)
213
214 /* Store the new TDP Down setting */
215 Store (CTCD, CTCC)
216
217 Release (CTCM)
218 Return (1)
219 }
220
Duncan Laurieb1711792013-06-28 16:01:53 -0700221 /* Set Config TDP Nominal from Down */
Aaron Durbin76c37002012-10-30 09:03:43 -0500222 Method (STDN, 0, Serialized)
223 {
224 If (Acquire (CTCM, 100)) {
225 Return (0)
226 }
227 If (LEqual (CTCN, CTCC)) {
228 Release (CTCM)
229 Return (0)
230 }
231
232 Store ("Set TDP Nominal", Debug)
233
234 /* Set PL1 */
235 Store (CTDN, PL1V)
236
Duncan Laurieb1711792013-06-28 16:01:53 -0700237 /* Set PL2 */
238 Store (CPL2 (CTDN), PL2V)
Aaron Durbin76c37002012-10-30 09:03:43 -0500239
240 /* Set PPC limit and notify OS */
241 Store (PSSS (TARN), PPCM)
242 PPCN ()
243
244 /* Set TAR */
245 Store (TARN, TARS)
246
247 /* Set CTC */
248 Store (CTCN, CTCS)
249
250 /* Store the new TDP Nominal setting */
251 Store (CTCN, CTCC)
252
253 Release (CTCM)
254 Return (1)
255 }
Duncan Laurieb1711792013-06-28 16:01:53 -0700256
257 /* Calculate PL1 value based on requested TDP */
258 Method (TDPP, 1, NotSerialized)
259 {
260 Return (Multiply (ShiftLeft (Subtract (PUNI, 1), 2), Arg0))
261 }
262
263 /* Enable Controllable TDP to limit PL1 to requested value */
264 Method (CTLE, 1, Serialized)
265 {
266 If (Acquire (CTCM, 100)) {
267 Return (0)
268 }
269
270 Store ("Enable PL1 Limit", Debug)
271
272 /* Set _PPC to LFM */
273 Store (PSSS (LFM_), Local0)
274 Add (Local0, 1, PPCM)
275 \PPCN ()
276
277 /* Set TAR to LFM-1 */
278 Subtract (LFM_, 1, TARS)
279
280 /* Set PL1 to desired value */
281 Store (PL1V, SPL1)
282 Store (TDPP (Arg0), PL1V)
283
284 /* Set PL1 CLAMP bit */
285 Store (One, PL1C)
286
287 Release (CTCM)
288 Return (1)
289 }
290
291 /* Disable Controllable TDP */
292 Method (CTLD, 0, Serialized)
293 {
294 If (Acquire (CTCM, 100)) {
295 Return (0)
296 }
297
298 Store ("Disable PL1 Limit", Debug)
299
300 /* Clear PL1 CLAMP bit */
301 Store (Zero, PL1C)
302
303 /* Set PL1 to normal value */
304 Store (SPL1, PL1V)
305
306 /* Set TAR to 0 */
307 Store (Zero, TARS)
308
309 /* Set _PPC to 0 */
310 Store (Zero, PPCM)
311 \PPCN ()
312
313 Release (CTCM)
314 Return (1)
315 }
Aaron Durbin76c37002012-10-30 09:03:43 -0500316}
317
318// Current Resource Settings
Martin Rothfc706432015-08-18 16:56:05 -0600319Name (MCRS, ResourceTemplate()
320{
321 // Bus Numbers
322 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
323 0x0000, 0x0000, 0x00ff, 0x0000, 0x0100,,, PB00)
324
325 // IO Region 0
326 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
327 0x0000, 0x0000, 0x0cf7, 0x0000, 0x0cf8,,, PI00)
328
329 // PCI Config Space
330 Io (Decode16, 0x0cf8, 0x0cf8, 0x0001, 0x0008)
331
332 // IO Region 1
333 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
334 0x0000, 0x0d00, 0xffff, 0x0000, 0xf300,,, PI01)
335
336 // VGA memory (0xa0000-0xbffff)
337 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
338 Cacheable, ReadWrite,
339 0x00000000, 0x000a0000, 0x000bffff, 0x00000000,
340 0x00020000,,, ASEG)
341
342 // OPROM reserved (0xc0000-0xc3fff)
343 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
344 Cacheable, ReadWrite,
345 0x00000000, 0x000c0000, 0x000c3fff, 0x00000000,
346 0x00004000,,, OPR0)
347
348 // OPROM reserved (0xc4000-0xc7fff)
349 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
350 Cacheable, ReadWrite,
351 0x00000000, 0x000c4000, 0x000c7fff, 0x00000000,
352 0x00004000,,, OPR1)
353
354 // OPROM reserved (0xc8000-0xcbfff)
355 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
356 Cacheable, ReadWrite,
357 0x00000000, 0x000c8000, 0x000cbfff, 0x00000000,
358 0x00004000,,, OPR2)
359
360 // OPROM reserved (0xcc000-0xcffff)
361 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
362 Cacheable, ReadWrite,
363 0x00000000, 0x000cc000, 0x000cffff, 0x00000000,
364 0x00004000,,, OPR3)
365
366 // OPROM reserved (0xd0000-0xd3fff)
367 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
368 Cacheable, ReadWrite,
369 0x00000000, 0x000d0000, 0x000d3fff, 0x00000000,
370 0x00004000,,, OPR4)
371
372 // OPROM reserved (0xd4000-0xd7fff)
373 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
374 Cacheable, ReadWrite,
375 0x00000000, 0x000d4000, 0x000d7fff, 0x00000000,
376 0x00004000,,, OPR5)
377
378 // OPROM reserved (0xd8000-0xdbfff)
379 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
380 Cacheable, ReadWrite,
381 0x00000000, 0x000d8000, 0x000dbfff, 0x00000000,
382 0x00004000,,, OPR6)
383
384 // OPROM reserved (0xdc000-0xdffff)
385 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
386 Cacheable, ReadWrite,
387 0x00000000, 0x000dc000, 0x000dffff, 0x00000000,
388 0x00004000,,, OPR7)
389
390 // BIOS Extension (0xe0000-0xe3fff)
391 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
392 Cacheable, ReadWrite,
393 0x00000000, 0x000e0000, 0x000e3fff, 0x00000000,
394 0x00004000,,, ESG0)
395
396 // BIOS Extension (0xe4000-0xe7fff)
397 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
398 Cacheable, ReadWrite,
399 0x00000000, 0x000e4000, 0x000e7fff, 0x00000000,
400 0x00004000,,, ESG1)
401
402 // BIOS Extension (0xe8000-0xebfff)
403 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
404 Cacheable, ReadWrite,
405 0x00000000, 0x000e8000, 0x000ebfff, 0x00000000,
406 0x00004000,,, ESG2)
407
408 // BIOS Extension (0xec000-0xeffff)
409 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
410 Cacheable, ReadWrite,
411 0x00000000, 0x000ec000, 0x000effff, 0x00000000,
412 0x00004000,,, ESG3)
413
414 // System BIOS (0xf0000-0xfffff)
415 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
416 Cacheable, ReadWrite,
417 0x00000000, 0x000f0000, 0x000fffff, 0x00000000,
418 0x00010000,,, FSEG)
419
420 // PCI Memory Region (Top of memory-CONFIG_MMCONF_BASE_ADDRESS)
421 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
422 Cacheable, ReadWrite,
423 0x00000000, 0x00000000, 0x00000000, 0x00000000,
424 0x00000000,,, PM01)
425
426 // TPM Area (0xfed40000-0xfed44fff)
427 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
428 Cacheable, ReadWrite,
429 0x00000000, 0xfed40000, 0xfed44fff, 0x00000000,
430 0x00005000,,, TPMR)
431})
Aaron Durbin76c37002012-10-30 09:03:43 -0500432
433Method (_CRS, 0, Serialized)
434{
Aaron Durbin76c37002012-10-30 09:03:43 -0500435 // Find PCI resource area in MCRS
Martin Rothfc706432015-08-18 16:56:05 -0600436 CreateDwordField(MCRS, ^PM01._MIN, PMIN)
437 CreateDwordField(MCRS, ^PM01._MAX, PMAX)
438 CreateDwordField(MCRS, ^PM01._LEN, PLEN)
Aaron Durbin76c37002012-10-30 09:03:43 -0500439
440 // Fix up PCI memory region
441 // Start with Top of Lower Usable DRAM
442 Store (^MCHC.TLUD, Local0)
443 Store (^MCHC.MEBA, Local1)
444
445 // Check if ME base is equal
446 If (LEqual (Local0, Local1)) {
447 // Use Top Of Memory instead
448 Store (^MCHC.TOM, Local0)
449 }
450
451 Store (Local0, PMIN)
Dave Frodin2eaa0d42015-04-23 06:04:46 -0600452 Store (Subtract(CONFIG_MMCONF_BASE_ADDRESS, 1), PMAX)
Aaron Durbin76c37002012-10-30 09:03:43 -0500453 Add(Subtract(PMAX, PMIN), 1, PLEN)
454
455 Return (MCRS)
456}