blob: a2bc2ba46b6c7226dd185d0865f176540e203467 [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
Angel Ponsffdf1f92021-01-10 16:30:40 +01008Name(\PPCM, 0)
9
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +010010Device (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
Angel Ponsa8df6cf2021-01-20 01:32:17 +010053 OperationRegion (MCHB, SystemMemory, CONFIG_FIXED_MCHBAR_MMIO_BASE, 0x8000)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +010054 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 {
Angel Pons302a1432020-07-22 00:27:23 +020096 Local0 = 1 /* Start at P1 */
97 Local1 = SizeOf (\_SB.CP00._PSS)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +010098
Angel Pons302a1432020-07-22 00:27:23 +020099 While (Local0 < Local1) {
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100100 /* Store _PSS entry Control value to Local2 */
Elyes Haouase0078932022-12-25 06:45:03 +0100101 Local2 = DeRefOf (DeRefOf (\_SB.CP00._PSS[Local0])[4]) >> 8
Angel Pons302a1432020-07-22 00:27:23 +0200102 If (Local2 == Arg0) {
103 Return (Local0 - 1)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100104 }
Angel Pons302a1432020-07-22 00:27:23 +0200105 Local0++
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100106 }
107
108 Return (0)
109 }
110
111 /* Set TDP Down */
112 Method (STND, 0, Serialized)
113 {
114 If (Acquire (CTCM, 100)) {
115 Return (0)
116 }
Angel Pons302a1432020-07-22 00:27:23 +0200117 If (CTCD == CTCC) {
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100118 Release (CTCM)
119 Return (0)
120 }
121
Felix Singerf64ad5e2021-12-29 13:13:04 +0100122 Printf ("Set TDP Down")
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100123
124 /* Set CTC */
Angel Pons302a1432020-07-22 00:27:23 +0200125 CTCS = CTCD
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100126
127 /* Set TAR */
Angel Pons302a1432020-07-22 00:27:23 +0200128 TARS = TARD
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100129
130 /* Set PPC limit and notify OS */
Angel Pons302a1432020-07-22 00:27:23 +0200131 PPCM = PSSS (TARD)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100132 PPCN ()
133
134 /* Set PL2 to 1.25 * PL1 */
Angel Pons302a1432020-07-22 00:27:23 +0200135 PL2V = (CTDD * 125) / 100
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100136
137 /* Set PL1 */
Angel Pons302a1432020-07-22 00:27:23 +0200138 PL1V = CTDD
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100139
140 /* Store the new TDP Down setting */
Angel Pons302a1432020-07-22 00:27:23 +0200141 CTCC = CTCD
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100142
143 Release (CTCM)
144 Return (1)
145 }
146
147 /* Set TDP Nominal from Down */
148 Method (STDN, 0, Serialized)
149 {
150 If (Acquire (CTCM, 100)) {
151 Return (0)
152 }
Angel Pons302a1432020-07-22 00:27:23 +0200153 If (CTCN == CTCC) {
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100154 Release (CTCM)
155 Return (0)
156 }
157
Felix Singerf64ad5e2021-12-29 13:13:04 +0100158 Printf ("Set TDP Nominal")
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100159
160 /* Set PL1 */
Angel Pons302a1432020-07-22 00:27:23 +0200161 PL1V = CTDN
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100162
163 /* Set PL2 to 1.25 * PL1 */
Angel Pons302a1432020-07-22 00:27:23 +0200164 PL2V = (CTDN * 125) / 100
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100165
166 /* Set PPC limit and notify OS */
Angel Pons302a1432020-07-22 00:27:23 +0200167 PPCM = PSSS (TARN)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100168 PPCN ()
169
170 /* Set TAR */
Angel Pons302a1432020-07-22 00:27:23 +0200171 TARS = TARN
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100172
173 /* Set CTC */
Angel Pons302a1432020-07-22 00:27:23 +0200174 CTCS = CTCN
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100175
176 /* Store the new TDP Nominal setting */
Angel Pons302a1432020-07-22 00:27:23 +0200177 CTCC = CTCN
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100178
179 Release (CTCM)
180 Return (1)
181 }
182}
183
184// Current Resource Settings
Martin Rothfc706432015-08-18 16:56:05 -0600185Name (MCRS, ResourceTemplate()
186{
187 // Bus Numbers
188 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
189 0x0000, 0x0000, 0x00ff, 0x0000, 0x0100,,, PB00)
190
191 // IO Region 0
192 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
193 0x0000, 0x0000, 0x0cf7, 0x0000, 0x0cf8,,, PI00)
194
195 // PCI Config Space
196 Io (Decode16, 0x0cf8, 0x0cf8, 0x0001, 0x0008)
197
198 // IO Region 1
199 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
200 0x0000, 0x0d00, 0xffff, 0x0000, 0xf300,,, PI01)
201
202 // VGA memory (0xa0000-0xbffff)
203 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
204 Cacheable, ReadWrite,
205 0x00000000, 0x000a0000, 0x000bffff, 0x00000000,
206 0x00020000,,, ASEG)
207
208 // OPROM reserved (0xc0000-0xc3fff)
209 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
210 Cacheable, ReadWrite,
211 0x00000000, 0x000c0000, 0x000c3fff, 0x00000000,
212 0x00004000,,, OPR0)
213
214 // OPROM reserved (0xc4000-0xc7fff)
215 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
216 Cacheable, ReadWrite,
217 0x00000000, 0x000c4000, 0x000c7fff, 0x00000000,
218 0x00004000,,, OPR1)
219
220 // OPROM reserved (0xc8000-0xcbfff)
221 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
222 Cacheable, ReadWrite,
223 0x00000000, 0x000c8000, 0x000cbfff, 0x00000000,
224 0x00004000,,, OPR2)
225
226 // OPROM reserved (0xcc000-0xcffff)
227 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
228 Cacheable, ReadWrite,
229 0x00000000, 0x000cc000, 0x000cffff, 0x00000000,
230 0x00004000,,, OPR3)
231
232 // OPROM reserved (0xd0000-0xd3fff)
233 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
234 Cacheable, ReadWrite,
235 0x00000000, 0x000d0000, 0x000d3fff, 0x00000000,
236 0x00004000,,, OPR4)
237
238 // OPROM reserved (0xd4000-0xd7fff)
239 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
240 Cacheable, ReadWrite,
241 0x00000000, 0x000d4000, 0x000d7fff, 0x00000000,
242 0x00004000,,, OPR5)
243
244 // OPROM reserved (0xd8000-0xdbfff)
245 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
246 Cacheable, ReadWrite,
247 0x00000000, 0x000d8000, 0x000dbfff, 0x00000000,
248 0x00004000,,, OPR6)
249
250 // OPROM reserved (0xdc000-0xdffff)
251 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
252 Cacheable, ReadWrite,
253 0x00000000, 0x000dc000, 0x000dffff, 0x00000000,
254 0x00004000,,, OPR7)
255
256 // BIOS Extension (0xe0000-0xe3fff)
257 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
258 Cacheable, ReadWrite,
259 0x00000000, 0x000e0000, 0x000e3fff, 0x00000000,
260 0x00004000,,, ESG0)
261
262 // BIOS Extension (0xe4000-0xe7fff)
263 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
264 Cacheable, ReadWrite,
265 0x00000000, 0x000e4000, 0x000e7fff, 0x00000000,
266 0x00004000,,, ESG1)
267
268 // BIOS Extension (0xe8000-0xebfff)
269 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
270 Cacheable, ReadWrite,
271 0x00000000, 0x000e8000, 0x000ebfff, 0x00000000,
272 0x00004000,,, ESG2)
273
274 // BIOS Extension (0xec000-0xeffff)
275 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
276 Cacheable, ReadWrite,
277 0x00000000, 0x000ec000, 0x000effff, 0x00000000,
278 0x00004000,,, ESG3)
279
280 // System BIOS (0xf0000-0xfffff)
281 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
282 Cacheable, ReadWrite,
283 0x00000000, 0x000f0000, 0x000fffff, 0x00000000,
284 0x00010000,,, FSEG)
285
286 // PCI Memory Region (Top of memory-0xfebfffff)
287 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
288 Cacheable, ReadWrite,
289 0x00000000, 0x00000000, 0xfebfffff, 0x00000000,
290 0xfec00000,,, PM01)
291
292 // TPM Area (0xfed40000-0xfed44fff)
293 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
294 Cacheable, ReadWrite,
295 0x00000000, 0xfed40000, 0xfed44fff, 0x00000000,
296 0x00005000,,, TPMR)
297})
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100298
299Method (_CRS, 0, Serialized)
300{
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100301 // Find PCI resource area in MCRS
Martin Rothfc706432015-08-18 16:56:05 -0600302 CreateDwordField(MCRS, ^PM01._MIN, PMIN)
303 CreateDwordField(MCRS, ^PM01._MAX, PMAX)
304 CreateDwordField(MCRS, ^PM01._LEN, PLEN)
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100305
306 // Fix up PCI memory region
307 // Start with Top of Lower Usable DRAM
Angel Pons302a1432020-07-22 00:27:23 +0200308 Local0 = ^MCHC.TLUD
309 Local0 >>= 4
310 Local1 = ^MCHC.TUUD
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100311
312 // Check if ME base is equal
Angel Pons302a1432020-07-22 00:27:23 +0200313 If (Local0 == Local1) {
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100314 // Use Top Of Memory instead
Angel Pons302a1432020-07-22 00:27:23 +0200315 Local0 = ^MCHC.TOM
316 Local0 >>= 6
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100317 }
318
Angel Pons302a1432020-07-22 00:27:23 +0200319 Local0 <<= 20
320 PMIN = Local0
321 PLEN = PMAX - PMIN + 1
Vladimir Serbinenkoc6f6be02013-11-12 22:32:08 +0100322
323 Return (MCRS)
324}