blob: 62ca81a425199908341b2754b3636ba0619962d6 [file] [log] [blame]
Angel Pons4b429832020-04-02 23:48:50 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +01002
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +01003Name(_HID,EISAID("PNP0A08")) // PCIe
4Name(_CID,EISAID("PNP0A03")) // PCI
5
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +01006Name(_BBN, 0)
7
8Device (MCHC)
9{
10 Name(_ADR, 0x00000000) // 0:0.0
11
12 OperationRegion(MCHP, PCI_Config, 0x00, 0x100)
13 Field (MCHP, DWordAcc, NoLock, Preserve)
14 {
15 Offset (0x40), // EPBAR
16 EPEN, 1, // Enable
17 , 11, //
18 EPBR, 24, // EPBAR
19
20 Offset (0x48), // MCHBAR
21 MHEN, 1, // Enable
22 , 13, //
23 MHBR, 22, // MCHBAR
24
25 Offset (0x60), // PCIe BAR
26 PXEN, 1, // Enable
27 PXSZ, 2, // BAR size
28 , 23, //
29 PXBR, 10, // PCIe BAR
30
31 Offset (0x68), // DMIBAR
32 DMEN, 1, // Enable
33 , 11, //
34 DMBR, 24, // DMIBAR
35
36
37 Offset (0xa0),
38 TOM, 16,
39 TUUD, 16,
40
41 Offset (0xb0), // Top of Low Used Memory
42 TLUD, 16,
43 }
44
45 Mutex (CTCM, 1) /* CTDP Switch Mutex (sync level 1) */
46 Name (CTCC, 0) /* CTDP Current Selection */
47 Name (CTCN, 0) /* CTDP Nominal Select */
48 Name (CTCD, 1) /* CTDP Down Select */
49 Name (CTCU, 2) /* CTDP Up Select */
50
Angel Ponsa8df6cf2021-01-20 01:32:17 +010051 OperationRegion (MCHB, SystemMemory, CONFIG_FIXED_MCHBAR_MMIO_BASE, 0x8000)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +010052 Field (MCHB, DWordAcc, Lock, Preserve)
53 {
54 Offset (0x5930),
55 CTDN, 15, /* CTDP Nominal PL1 */
56 Offset (0x59a0),
57 PL1V, 15, /* Power Limit 1 Value */
58 PL1E, 1, /* Power Limit 1 Enable */
59 PL1C, 1, /* Power Limit 1 Clamp */
60 PL1T, 7, /* Power Limit 1 Time */
61 Offset (0x59a4),
62 PL2V, 15, /* Power Limit 2 Value */
63 PL2E, 1, /* Power Limit 2 Enable */
64 PL2C, 1, /* Power Limit 2 Clamp */
65 PL2T, 7, /* Power Limit 2 Time */
66 Offset (0x5f3c),
67 TARN, 8, /* CTDP Nominal Turbo Activation Ratio */
68 Offset (0x5f40),
69 CTDD, 15, /* CTDP Down PL1 */
70 , 1,
71 TARD, 8, /* CTDP Down Turbo Activation Ratio */
72 Offset (0x5f48),
73 CTDU, 15, /* CTDP Up PL1 */
74 , 1,
75 TARU, 8, /* CTDP Up Turbo Activation Ratio */
76 Offset (0x5f50),
77 CTCS, 2, /* CTDP Select */
78 Offset (0x5f54),
79 TARS, 8, /* Turbo Activation Ratio Select */
80 }
81
82 /*
83 * Search CPU0 _PSS looking for control=arg0 and then
84 * return previous P-state entry number for new _PPC
85 *
86 * Format of _PSS:
87 * Name (_PSS, Package () {
88 * Package (6) { freq, power, tlat, blat, control, status }
89 * }
90 */
Christian Walterbe3979c2019-12-18 15:07:59 +010091 External (\_SB.CP00._PSS)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +010092 Method (PSSS, 1, NotSerialized)
93 {
Angel Pons302a1432020-07-22 00:27:23 +020094 Local0 = 1 /* Start at P1 */
95 Local1 = SizeOf (\_SB.CP00._PSS)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +010096
Angel Pons302a1432020-07-22 00:27:23 +020097 While (Local0 < Local1) {
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +010098 /* Store _PSS entry Control value to Local2 */
Angel Pons302a1432020-07-22 00:27:23 +020099 Local2 = DeRefOf (Index (DeRefOf (Index (\_SB.CP00._PSS, Local0)), 4)) >> 8
100 If (Local2 == Arg0) {
101 Return (Local0 - 1)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100102 }
Angel Pons302a1432020-07-22 00:27:23 +0200103 Local0++
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100104 }
105
106 Return (0)
107 }
108
109 /* Set TDP Down */
110 Method (STND, 0, Serialized)
111 {
112 If (Acquire (CTCM, 100)) {
113 Return (0)
114 }
Angel Pons302a1432020-07-22 00:27:23 +0200115 If (CTCD == CTCC) {
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100116 Release (CTCM)
117 Return (0)
118 }
119
Angel Pons302a1432020-07-22 00:27:23 +0200120 Debug = "Set TDP Down"
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100121
122 /* Set CTC */
Angel Pons302a1432020-07-22 00:27:23 +0200123 CTCS = CTCD
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100124
125 /* Set TAR */
Angel Pons302a1432020-07-22 00:27:23 +0200126 TARS = TARD
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100127
128 /* Set PPC limit and notify OS */
Angel Pons302a1432020-07-22 00:27:23 +0200129 PPCM = PSSS (TARD)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100130 PPCN ()
131
132 /* Set PL2 to 1.25 * PL1 */
Angel Pons302a1432020-07-22 00:27:23 +0200133 PL2V = (CTDD * 125) / 100
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100134
135 /* Set PL1 */
Angel Pons302a1432020-07-22 00:27:23 +0200136 PL1V = CTDD
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100137
138 /* Store the new TDP Down setting */
Angel Pons302a1432020-07-22 00:27:23 +0200139 CTCC = CTCD
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100140
141 Release (CTCM)
142 Return (1)
143 }
144
145 /* Set TDP Nominal from Down */
146 Method (STDN, 0, Serialized)
147 {
148 If (Acquire (CTCM, 100)) {
149 Return (0)
150 }
Angel Pons302a1432020-07-22 00:27:23 +0200151 If (CTCN == CTCC) {
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100152 Release (CTCM)
153 Return (0)
154 }
155
Angel Pons302a1432020-07-22 00:27:23 +0200156 Debug = "Set TDP Nominal"
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100157
158 /* Set PL1 */
Angel Pons302a1432020-07-22 00:27:23 +0200159 PL1V = CTDN
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100160
161 /* Set PL2 to 1.25 * PL1 */
Angel Pons302a1432020-07-22 00:27:23 +0200162 PL2V = (CTDN * 125) / 100
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100163
164 /* Set PPC limit and notify OS */
Angel Pons302a1432020-07-22 00:27:23 +0200165 PPCM = PSSS (TARN)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100166 PPCN ()
167
168 /* Set TAR */
Angel Pons302a1432020-07-22 00:27:23 +0200169 TARS = TARN
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100170
171 /* Set CTC */
Angel Pons302a1432020-07-22 00:27:23 +0200172 CTCS = CTCN
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100173
174 /* Store the new TDP Nominal setting */
Angel Pons302a1432020-07-22 00:27:23 +0200175 CTCC = CTCN
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100176
177 Release (CTCM)
178 Return (1)
179 }
180}
181
182// Current Resource Settings
Martin Rothfc706432015-08-18 16:56:05 -0600183Name (MCRS, ResourceTemplate()
184{
185 // Bus Numbers
186 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
187 0x0000, 0x0000, 0x00ff, 0x0000, 0x0100,,, PB00)
188
189 // IO Region 0
190 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
191 0x0000, 0x0000, 0x0cf7, 0x0000, 0x0cf8,,, PI00)
192
193 // PCI Config Space
194 Io (Decode16, 0x0cf8, 0x0cf8, 0x0001, 0x0008)
195
196 // IO Region 1
197 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
198 0x0000, 0x0d00, 0xffff, 0x0000, 0xf300,,, PI01)
199
200 // VGA memory (0xa0000-0xbffff)
201 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
202 Cacheable, ReadWrite,
203 0x00000000, 0x000a0000, 0x000bffff, 0x00000000,
204 0x00020000,,, ASEG)
205
206 // OPROM reserved (0xc0000-0xc3fff)
207 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
208 Cacheable, ReadWrite,
209 0x00000000, 0x000c0000, 0x000c3fff, 0x00000000,
210 0x00004000,,, OPR0)
211
212 // OPROM reserved (0xc4000-0xc7fff)
213 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
214 Cacheable, ReadWrite,
215 0x00000000, 0x000c4000, 0x000c7fff, 0x00000000,
216 0x00004000,,, OPR1)
217
218 // OPROM reserved (0xc8000-0xcbfff)
219 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
220 Cacheable, ReadWrite,
221 0x00000000, 0x000c8000, 0x000cbfff, 0x00000000,
222 0x00004000,,, OPR2)
223
224 // OPROM reserved (0xcc000-0xcffff)
225 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
226 Cacheable, ReadWrite,
227 0x00000000, 0x000cc000, 0x000cffff, 0x00000000,
228 0x00004000,,, OPR3)
229
230 // OPROM reserved (0xd0000-0xd3fff)
231 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
232 Cacheable, ReadWrite,
233 0x00000000, 0x000d0000, 0x000d3fff, 0x00000000,
234 0x00004000,,, OPR4)
235
236 // OPROM reserved (0xd4000-0xd7fff)
237 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
238 Cacheable, ReadWrite,
239 0x00000000, 0x000d4000, 0x000d7fff, 0x00000000,
240 0x00004000,,, OPR5)
241
242 // OPROM reserved (0xd8000-0xdbfff)
243 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
244 Cacheable, ReadWrite,
245 0x00000000, 0x000d8000, 0x000dbfff, 0x00000000,
246 0x00004000,,, OPR6)
247
248 // OPROM reserved (0xdc000-0xdffff)
249 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
250 Cacheable, ReadWrite,
251 0x00000000, 0x000dc000, 0x000dffff, 0x00000000,
252 0x00004000,,, OPR7)
253
254 // BIOS Extension (0xe0000-0xe3fff)
255 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
256 Cacheable, ReadWrite,
257 0x00000000, 0x000e0000, 0x000e3fff, 0x00000000,
258 0x00004000,,, ESG0)
259
260 // BIOS Extension (0xe4000-0xe7fff)
261 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
262 Cacheable, ReadWrite,
263 0x00000000, 0x000e4000, 0x000e7fff, 0x00000000,
264 0x00004000,,, ESG1)
265
266 // BIOS Extension (0xe8000-0xebfff)
267 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
268 Cacheable, ReadWrite,
269 0x00000000, 0x000e8000, 0x000ebfff, 0x00000000,
270 0x00004000,,, ESG2)
271
272 // BIOS Extension (0xec000-0xeffff)
273 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
274 Cacheable, ReadWrite,
275 0x00000000, 0x000ec000, 0x000effff, 0x00000000,
276 0x00004000,,, ESG3)
277
278 // System BIOS (0xf0000-0xfffff)
279 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
280 Cacheable, ReadWrite,
281 0x00000000, 0x000f0000, 0x000fffff, 0x00000000,
282 0x00010000,,, FSEG)
283
284 // PCI Memory Region (Top of memory-0xfebfffff)
285 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
286 Cacheable, ReadWrite,
287 0x00000000, 0x00000000, 0xfebfffff, 0x00000000,
288 0xfec00000,,, PM01)
289
290 // TPM Area (0xfed40000-0xfed44fff)
291 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
292 Cacheable, ReadWrite,
293 0x00000000, 0xfed40000, 0xfed44fff, 0x00000000,
294 0x00005000,,, TPMR)
295})
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100296
297Method (_CRS, 0, Serialized)
298{
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100299 // Find PCI resource area in MCRS
Martin Rothfc706432015-08-18 16:56:05 -0600300 CreateDwordField(MCRS, ^PM01._MIN, PMIN)
301 CreateDwordField(MCRS, ^PM01._MAX, PMAX)
302 CreateDwordField(MCRS, ^PM01._LEN, PLEN)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100303
304 // Fix up PCI memory region
305 // Start with Top of Lower Usable DRAM
Angel Pons302a1432020-07-22 00:27:23 +0200306 Local0 = ^MCHC.TLUD
307 Local0 >>= 4
308 Local1 = ^MCHC.TUUD
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100309
310 // Check if ME base is equal
Angel Pons302a1432020-07-22 00:27:23 +0200311 If (Local0 == Local1) {
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100312 // Use Top Of Memory instead
Angel Pons302a1432020-07-22 00:27:23 +0200313 Local0 = ^MCHC.TOM
314 Local0 >>= 6
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100315 }
316
Angel Pons302a1432020-07-22 00:27:23 +0200317 Local0 <<= 20
318 PMIN = Local0
319 PLEN = PMAX - PMIN + 1
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100320
321 Return (MCRS)
322}