blob: dfef304885e74399c0396fe64e77056b38fed314 [file] [log] [blame]
Angel Pons4b429832020-04-02 23:48:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +01003
4
5Name(_HID,EISAID("PNP0A08")) // PCIe
6Name(_CID,EISAID("PNP0A03")) // PCI
7
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +01008Name(_BBN, 0)
9
10Device (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
53 OperationRegion (MCHB, SystemMemory, DEFAULT_MCHBAR, 0x8000)
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 Walterbe3979c2019-12-18 15:07:59 +010093 External (\_SB.CP00._PSS)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +010094 Method (PSSS, 1, NotSerialized)
95 {
96 Store (One, Local0) /* Start at P1 */
Christian Walterbe3979c2019-12-18 15:07:59 +010097 Store (SizeOf (\_SB.CP00._PSS), Local1)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +010098
99 While (LLess (Local0, Local1)) {
100 /* Store _PSS entry Control value to Local2 */
101 ShiftRight (DeRefOf (Index (DeRefOf (Index
Christian Walterbe3979c2019-12-18 15:07:59 +0100102 (\_SB.CP00._PSS, Local0)), 4)), 8, Local2)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100103 If (LEqual (Local2, Arg0)) {
104 Return (Subtract (Local0, 1))
105 }
106 Increment (Local0)
107 }
108
109 Return (0)
110 }
111
112 /* Set TDP Down */
113 Method (STND, 0, Serialized)
114 {
115 If (Acquire (CTCM, 100)) {
116 Return (0)
117 }
118 If (LEqual (CTCD, CTCC)) {
119 Release (CTCM)
120 Return (0)
121 }
122
123 Store ("Set TDP Down", Debug)
124
125 /* Set CTC */
126 Store (CTCD, CTCS)
127
128 /* Set TAR */
129 Store (TARD, TARS)
130
131 /* Set PPC limit and notify OS */
132 Store (PSSS (TARD), PPCM)
133 PPCN ()
134
135 /* Set PL2 to 1.25 * PL1 */
Martin Roth35272fd2015-12-10 08:28:53 -0700136 Divide (Multiply (CTDD, 125), 100, , PL2V)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100137
138 /* Set PL1 */
139 Store (CTDD, PL1V)
140
141 /* Store the new TDP Down setting */
142 Store (CTCD, CTCC)
143
144 Release (CTCM)
145 Return (1)
146 }
147
148 /* Set TDP Nominal from Down */
149 Method (STDN, 0, Serialized)
150 {
151 If (Acquire (CTCM, 100)) {
152 Return (0)
153 }
154 If (LEqual (CTCN, CTCC)) {
155 Release (CTCM)
156 Return (0)
157 }
158
159 Store ("Set TDP Nominal", Debug)
160
161 /* Set PL1 */
162 Store (CTDN, PL1V)
163
164 /* Set PL2 to 1.25 * PL1 */
Martin Roth35272fd2015-12-10 08:28:53 -0700165 Divide (Multiply (CTDN, 125), 100, , PL2V)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100166
167 /* Set PPC limit and notify OS */
168 Store (PSSS (TARN), PPCM)
169 PPCN ()
170
171 /* Set TAR */
172 Store (TARN, TARS)
173
174 /* Set CTC */
175 Store (CTCN, CTCS)
176
177 /* Store the new TDP Nominal setting */
178 Store (CTCN, CTCC)
179
180 Release (CTCM)
181 Return (1)
182 }
183}
184
185// Current Resource Settings
Martin Rothfc706432015-08-18 16:56:05 -0600186Name (MCRS, ResourceTemplate()
187{
188 // Bus Numbers
189 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
190 0x0000, 0x0000, 0x00ff, 0x0000, 0x0100,,, PB00)
191
192 // IO Region 0
193 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
194 0x0000, 0x0000, 0x0cf7, 0x0000, 0x0cf8,,, PI00)
195
196 // PCI Config Space
197 Io (Decode16, 0x0cf8, 0x0cf8, 0x0001, 0x0008)
198
199 // IO Region 1
200 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
201 0x0000, 0x0d00, 0xffff, 0x0000, 0xf300,,, PI01)
202
203 // VGA memory (0xa0000-0xbffff)
204 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
205 Cacheable, ReadWrite,
206 0x00000000, 0x000a0000, 0x000bffff, 0x00000000,
207 0x00020000,,, ASEG)
208
209 // OPROM reserved (0xc0000-0xc3fff)
210 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
211 Cacheable, ReadWrite,
212 0x00000000, 0x000c0000, 0x000c3fff, 0x00000000,
213 0x00004000,,, OPR0)
214
215 // OPROM reserved (0xc4000-0xc7fff)
216 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
217 Cacheable, ReadWrite,
218 0x00000000, 0x000c4000, 0x000c7fff, 0x00000000,
219 0x00004000,,, OPR1)
220
221 // OPROM reserved (0xc8000-0xcbfff)
222 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
223 Cacheable, ReadWrite,
224 0x00000000, 0x000c8000, 0x000cbfff, 0x00000000,
225 0x00004000,,, OPR2)
226
227 // OPROM reserved (0xcc000-0xcffff)
228 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
229 Cacheable, ReadWrite,
230 0x00000000, 0x000cc000, 0x000cffff, 0x00000000,
231 0x00004000,,, OPR3)
232
233 // OPROM reserved (0xd0000-0xd3fff)
234 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
235 Cacheable, ReadWrite,
236 0x00000000, 0x000d0000, 0x000d3fff, 0x00000000,
237 0x00004000,,, OPR4)
238
239 // OPROM reserved (0xd4000-0xd7fff)
240 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
241 Cacheable, ReadWrite,
242 0x00000000, 0x000d4000, 0x000d7fff, 0x00000000,
243 0x00004000,,, OPR5)
244
245 // OPROM reserved (0xd8000-0xdbfff)
246 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
247 Cacheable, ReadWrite,
248 0x00000000, 0x000d8000, 0x000dbfff, 0x00000000,
249 0x00004000,,, OPR6)
250
251 // OPROM reserved (0xdc000-0xdffff)
252 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
253 Cacheable, ReadWrite,
254 0x00000000, 0x000dc000, 0x000dffff, 0x00000000,
255 0x00004000,,, OPR7)
256
257 // BIOS Extension (0xe0000-0xe3fff)
258 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
259 Cacheable, ReadWrite,
260 0x00000000, 0x000e0000, 0x000e3fff, 0x00000000,
261 0x00004000,,, ESG0)
262
263 // BIOS Extension (0xe4000-0xe7fff)
264 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
265 Cacheable, ReadWrite,
266 0x00000000, 0x000e4000, 0x000e7fff, 0x00000000,
267 0x00004000,,, ESG1)
268
269 // BIOS Extension (0xe8000-0xebfff)
270 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
271 Cacheable, ReadWrite,
272 0x00000000, 0x000e8000, 0x000ebfff, 0x00000000,
273 0x00004000,,, ESG2)
274
275 // BIOS Extension (0xec000-0xeffff)
276 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
277 Cacheable, ReadWrite,
278 0x00000000, 0x000ec000, 0x000effff, 0x00000000,
279 0x00004000,,, ESG3)
280
281 // System BIOS (0xf0000-0xfffff)
282 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
283 Cacheable, ReadWrite,
284 0x00000000, 0x000f0000, 0x000fffff, 0x00000000,
285 0x00010000,,, FSEG)
286
287 // PCI Memory Region (Top of memory-0xfebfffff)
288 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
289 Cacheable, ReadWrite,
290 0x00000000, 0x00000000, 0xfebfffff, 0x00000000,
291 0xfec00000,,, PM01)
292
293 // TPM Area (0xfed40000-0xfed44fff)
294 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
295 Cacheable, ReadWrite,
296 0x00000000, 0xfed40000, 0xfed44fff, 0x00000000,
297 0x00005000,,, TPMR)
298})
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100299
300Method (_CRS, 0, Serialized)
301{
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100302 // Find PCI resource area in MCRS
Martin Rothfc706432015-08-18 16:56:05 -0600303 CreateDwordField(MCRS, ^PM01._MIN, PMIN)
304 CreateDwordField(MCRS, ^PM01._MAX, PMAX)
305 CreateDwordField(MCRS, ^PM01._LEN, PLEN)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100306
307 // Fix up PCI memory region
308 // Start with Top of Lower Usable DRAM
309 Store (^MCHC.TLUD, Local0)
310 ShiftRight (Local0, 4, Local0)
311 Store (^MCHC.TUUD, Local1)
312
313 // Check if ME base is equal
314 If (LEqual (Local0, Local1)) {
315 // Use Top Of Memory instead
316 Store (^MCHC.TOM, Local0)
317 ShiftRight (Local0, 6, Local0)
318 }
319
320 ShiftLeft (Local0, 20, Local0)
321 Store (Local0, PMIN)
322 Add(Subtract(PMAX, PMIN), 1, PLEN)
323
324 Return (MCRS)
325}