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