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