blob: 4ce4cb6ce7b351e99af812fc65813ecf50cd474a [file] [log] [blame]
Angel Pons6e5aabd2020-03-23 23:44:42 +01001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauer00636b02012-04-04 00:08:51 +02002
3Name(_HID,EISAID("PNP0A08")) // PCIe
4Name(_CID,EISAID("PNP0A03")) // PCI
5
Stefan Reinauer00636b02012-04-04 00:08:51 +02006Name(_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, //
Patrick Rudolph2af2f2c2019-03-26 14:33:16 +010018 EPBR, 27, // EPBAR
Stefan Reinauer00636b02012-04-04 00:08:51 +020019
20 Offset (0x48), // MCHBAR
21 MHEN, 1, // Enable
Patrick Rudolph2af2f2c2019-03-26 14:33:16 +010022 , 14, //
23 MHBR, 24, // MCHBAR
Patrick Rudolph0b643d22017-07-05 20:07:06 +020024 Offset (0x54),
25 DVEN, 32,
Stefan Reinauer00636b02012-04-04 00:08:51 +020026 Offset (0x60), // PCIe BAR
27 PXEN, 1, // Enable
28 PXSZ, 2, // BAR size
29 , 23, //
Patrick Rudolph2af2f2c2019-03-26 14:33:16 +010030 PXBR, 13, // PCIe BAR
Stefan Reinauer00636b02012-04-04 00:08:51 +020031
32 Offset (0x68), // DMIBAR
33 DMEN, 1, // Enable
34 , 11, //
Patrick Rudolph2af2f2c2019-03-26 14:33:16 +010035 DMBR, 27, // DMIBAR
Stefan Reinauer00636b02012-04-04 00:08:51 +020036
37 Offset (0x70), // ME Base Address
38 MEBA, 64,
39
40 // ...
41
42 Offset (0x80), // PAM0
43 , 4,
44 PM0H, 2,
45 , 2,
46 Offset (0x81), // PAM1
47 PM1L, 2,
48 , 2,
49 PM1H, 2,
50 , 2,
51 Offset (0x82), // PAM2
52 PM2L, 2,
53 , 2,
54 PM2H, 2,
55 , 2,
56 Offset (0x83), // PAM3
57 PM3L, 2,
58 , 2,
59 PM3H, 2,
60 , 2,
61 Offset (0x84), // PAM4
62 PM4L, 2,
63 , 2,
64 PM4H, 2,
65 , 2,
66 Offset (0x85), // PAM5
67 PM5L, 2,
68 , 2,
69 PM5H, 2,
70 , 2,
71 Offset (0x86), // PAM6
72 PM6L, 2,
73 , 2,
74 PM6H, 2,
75 , 2,
76
77 Offset (0xa0), // Top of Used Memory
78 TOM, 64,
79
80 Offset (0xbc), // Top of Low Used Memory
81 TLUD, 32,
82 }
83
Duncan Laurie1b3207e2012-07-18 15:33:45 -070084 Mutex (CTCM, 1) /* CTDP Switch Mutex (sync level 1) */
85 Name (CTCC, 0) /* CTDP Current Selection */
Duncan Laurie55864ef2012-07-16 12:27:42 -070086 Name (CTCN, 0) /* CTDP Nominal Select */
87 Name (CTCD, 1) /* CTDP Down Select */
88 Name (CTCU, 2) /* CTDP Up Select */
Stefan Reinauer00636b02012-04-04 00:08:51 +020089
Patrick Rudolph2af2f2c2019-03-26 14:33:16 +010090 OperationRegion (MCHB, SystemMemory, \_SB.PCI0.MCHC.MHBR << 15, 0x8000)
Duncan Laurie55864ef2012-07-16 12:27:42 -070091 Field (MCHB, DWordAcc, Lock, Preserve)
92 {
93 Offset (0x5930),
94 CTDN, 15, /* CTDP Nominal PL1 */
95 Offset (0x59a0),
96 PL1V, 15, /* Power Limit 1 Value */
97 PL1E, 1, /* Power Limit 1 Enable */
98 PL1C, 1, /* Power Limit 1 Clamp */
99 PL1T, 7, /* Power Limit 1 Time */
100 Offset (0x59a4),
101 PL2V, 15, /* Power Limit 2 Value */
102 PL2E, 1, /* Power Limit 2 Enable */
103 PL2C, 1, /* Power Limit 2 Clamp */
104 PL2T, 7, /* Power Limit 2 Time */
105 Offset (0x5f3c),
106 TARN, 8, /* CTDP Nominal Turbo Activation Ratio */
107 Offset (0x5f40),
108 CTDD, 15, /* CTDP Down PL1 */
109 , 1,
110 TARD, 8, /* CTDP Down Turbo Activation Ratio */
111 Offset (0x5f48),
112 CTDU, 15, /* CTDP Up PL1 */
113 , 1,
114 TARU, 8, /* CTDP Up Turbo Activation Ratio */
115 Offset (0x5f50),
116 CTCS, 2, /* CTDP Select */
117 Offset (0x5f54),
118 TARS, 8, /* Turbo Activation Ratio Select */
119 }
120
121 /*
122 * Search CPU0 _PSS looking for control=arg0 and then
123 * return previous P-state entry number for new _PPC
124 *
125 * Format of _PSS:
126 * Name (_PSS, Package () {
127 * Package (6) { freq, power, tlat, blat, control, status }
128 * }
129 */
Christian Walterbe3979c2019-12-18 15:07:59 +0100130 External (\_SB.CP00._PSS)
Duncan Laurie55864ef2012-07-16 12:27:42 -0700131 Method (PSSS, 1, NotSerialized)
132 {
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700133 Local0 = 1 /* Start at P1 */
134 Local1 = SizeOf (\_SB.CP00._PSS)
Duncan Laurie55864ef2012-07-16 12:27:42 -0700135
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700136 While (Local0 < Local1) {
Duncan Laurie55864ef2012-07-16 12:27:42 -0700137 /* Store _PSS entry Control value to Local2 */
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700138 Local2 = DeRefOf (Index (DeRefOf (Index (\_SB.CP00._PSS, Local0)), 4)) >> 8
139 If (Local2 == Arg0) {
140 Return (Local0 - 1)
Duncan Laurie55864ef2012-07-16 12:27:42 -0700141 }
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700142 Local0++
Duncan Laurie55864ef2012-07-16 12:27:42 -0700143 }
144
145 Return (0)
146 }
147
148 /* Set TDP Down */
149 Method (STND, 0, Serialized)
150 {
Duncan Laurie1b3207e2012-07-18 15:33:45 -0700151 If (Acquire (CTCM, 100)) {
Duncan Laurie55864ef2012-07-16 12:27:42 -0700152 Return (0)
153 }
Angel Pons5cd8c7c2020-08-03 19:26:45 +0200154 If (CTCD == CTCC) {
Duncan Laurie1b3207e2012-07-18 15:33:45 -0700155 Release (CTCM)
156 Return (0)
157 }
158
Angel Pons5cd8c7c2020-08-03 19:26:45 +0200159 Debug = "Set TDP Down"
Duncan Laurie55864ef2012-07-16 12:27:42 -0700160
161 /* Set CTC */
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700162 CTCS = CTCD
Duncan Laurie55864ef2012-07-16 12:27:42 -0700163
164 /* Set TAR */
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700165 TARS = TARD
Duncan Laurie55864ef2012-07-16 12:27:42 -0700166
167 /* Set PPC limit and notify OS */
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700168 PPCM = PSSS (TARD)
Duncan Laurie55864ef2012-07-16 12:27:42 -0700169 PPCN ()
170
171 /* Set PL2 to 1.25 * PL1 */
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700172 PL2V = (CTDD * 125) / 100
Duncan Laurie55864ef2012-07-16 12:27:42 -0700173
174 /* Set PL1 */
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700175 PL1V = CTDD
Duncan Laurie55864ef2012-07-16 12:27:42 -0700176
Duncan Laurie1b3207e2012-07-18 15:33:45 -0700177 /* Store the new TDP Down setting */
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700178 CTCC = CTCD
Duncan Laurie1b3207e2012-07-18 15:33:45 -0700179
180 Release (CTCM)
Duncan Laurie55864ef2012-07-16 12:27:42 -0700181 Return (1)
182 }
183
184 /* Set TDP Nominal from Down */
185 Method (STDN, 0, Serialized)
186 {
Duncan Laurie1b3207e2012-07-18 15:33:45 -0700187 If (Acquire (CTCM, 100)) {
Duncan Laurie55864ef2012-07-16 12:27:42 -0700188 Return (0)
189 }
Angel Pons5cd8c7c2020-08-03 19:26:45 +0200190 If (CTCN == CTCC) {
Duncan Laurie1b3207e2012-07-18 15:33:45 -0700191 Release (CTCM)
192 Return (0)
193 }
194
Angel Pons5cd8c7c2020-08-03 19:26:45 +0200195 Debug = "Set TDP Nominal"
Duncan Laurie55864ef2012-07-16 12:27:42 -0700196
197 /* Set PL1 */
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700198 PL1V = CTDN
Duncan Laurie55864ef2012-07-16 12:27:42 -0700199
200 /* Set PL2 to 1.25 * PL1 */
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700201 PL2V = (CTDN * 125) / 100
Duncan Laurie55864ef2012-07-16 12:27:42 -0700202
203 /* Set PPC limit and notify OS */
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700204 PPCM = PSSS (TARN)
Duncan Laurie55864ef2012-07-16 12:27:42 -0700205 PPCN ()
206
207 /* Set TAR */
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700208 TARS = TARN
Duncan Laurie55864ef2012-07-16 12:27:42 -0700209
210 /* Set CTC */
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700211 CTCS = CTCN
Duncan Laurie55864ef2012-07-16 12:27:42 -0700212
Duncan Laurie1b3207e2012-07-18 15:33:45 -0700213 /* Store the new TDP Nominal setting */
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700214 CTCC = CTCN
Duncan Laurie1b3207e2012-07-18 15:33:45 -0700215
216 Release (CTCM)
Duncan Laurie55864ef2012-07-16 12:27:42 -0700217 Return (1)
218 }
219}
Stefan Reinauer00636b02012-04-04 00:08:51 +0200220
221// Current Resource Settings
Martin Rothfc706432015-08-18 16:56:05 -0600222Name (MCRS, ResourceTemplate()
223{
224 // Bus Numbers
225 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
226 0x0000, 0x0000, 0x00ff, 0x0000, 0x0100,,, PB00)
227
228 // IO Region 0
229 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
230 0x0000, 0x0000, 0x0cf7, 0x0000, 0x0cf8,,, PI00)
231
232 // PCI Config Space
233 Io (Decode16, 0x0cf8, 0x0cf8, 0x0001, 0x0008)
234
235 // IO Region 1
236 DWordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
237 0x0000, 0x0d00, 0xffff, 0x0000, 0xf300,,, PI01)
238
239 // VGA memory (0xa0000-0xbffff)
240 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
241 Cacheable, ReadWrite,
242 0x00000000, 0x000a0000, 0x000bffff, 0x00000000,
243 0x00020000,,, ASEG)
244
245 // OPROM reserved (0xc0000-0xc3fff)
246 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
247 Cacheable, ReadWrite,
248 0x00000000, 0x000c0000, 0x000c3fff, 0x00000000,
249 0x00004000,,, OPR0)
250
251 // OPROM reserved (0xc4000-0xc7fff)
252 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
253 Cacheable, ReadWrite,
254 0x00000000, 0x000c4000, 0x000c7fff, 0x00000000,
255 0x00004000,,, OPR1)
256
257 // OPROM reserved (0xc8000-0xcbfff)
258 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
259 Cacheable, ReadWrite,
260 0x00000000, 0x000c8000, 0x000cbfff, 0x00000000,
261 0x00004000,,, OPR2)
262
263 // OPROM reserved (0xcc000-0xcffff)
264 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
265 Cacheable, ReadWrite,
266 0x00000000, 0x000cc000, 0x000cffff, 0x00000000,
267 0x00004000,,, OPR3)
268
269 // OPROM reserved (0xd0000-0xd3fff)
270 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
271 Cacheable, ReadWrite,
272 0x00000000, 0x000d0000, 0x000d3fff, 0x00000000,
273 0x00004000,,, OPR4)
274
275 // OPROM reserved (0xd4000-0xd7fff)
276 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
277 Cacheable, ReadWrite,
278 0x00000000, 0x000d4000, 0x000d7fff, 0x00000000,
279 0x00004000,,, OPR5)
280
281 // OPROM reserved (0xd8000-0xdbfff)
282 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
283 Cacheable, ReadWrite,
284 0x00000000, 0x000d8000, 0x000dbfff, 0x00000000,
285 0x00004000,,, OPR6)
286
287 // OPROM reserved (0xdc000-0xdffff)
288 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
289 Cacheable, ReadWrite,
290 0x00000000, 0x000dc000, 0x000dffff, 0x00000000,
291 0x00004000,,, OPR7)
292
293 // BIOS Extension (0xe0000-0xe3fff)
294 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
295 Cacheable, ReadWrite,
296 0x00000000, 0x000e0000, 0x000e3fff, 0x00000000,
297 0x00004000,,, ESG0)
298
299 // BIOS Extension (0xe4000-0xe7fff)
300 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
301 Cacheable, ReadWrite,
302 0x00000000, 0x000e4000, 0x000e7fff, 0x00000000,
303 0x00004000,,, ESG1)
304
305 // BIOS Extension (0xe8000-0xebfff)
306 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
307 Cacheable, ReadWrite,
308 0x00000000, 0x000e8000, 0x000ebfff, 0x00000000,
309 0x00004000,,, ESG2)
310
311 // BIOS Extension (0xec000-0xeffff)
312 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
313 Cacheable, ReadWrite,
314 0x00000000, 0x000ec000, 0x000effff, 0x00000000,
315 0x00004000,,, ESG3)
316
317 // System BIOS (0xf0000-0xfffff)
318 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
319 Cacheable, ReadWrite,
320 0x00000000, 0x000f0000, 0x000fffff, 0x00000000,
321 0x00010000,,, FSEG)
322
Shelley Chen4e9bb332021-10-20 15:43:45 -0700323 // PCI Memory Region (Top of memory-CONFIG_ECAM_MMCONF_BASE_ADDRESS)
Martin Rothfc706432015-08-18 16:56:05 -0600324 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
325 Cacheable, ReadWrite,
326 0x00000000, 0x00000000, 0x00000000, 0x00000000,
327 0x00000000,,, PM01)
328
329 // TPM Area (0xfed40000-0xfed44fff)
330 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed,
331 Cacheable, ReadWrite,
332 0x00000000, 0xfed40000, 0xfed44fff, 0x00000000,
333 0x00005000,,, TPMR)
334})
Stefan Reinauer00636b02012-04-04 00:08:51 +0200335
336Method (_CRS, 0, Serialized)
337{
Stefan Reinauer00636b02012-04-04 00:08:51 +0200338 // Find PCI resource area in MCRS
Martin Rothfc706432015-08-18 16:56:05 -0600339 CreateDwordField(MCRS, ^PM01._MIN, PMIN)
340 CreateDwordField(MCRS, ^PM01._MAX, PMAX)
341 CreateDwordField(MCRS, ^PM01._LEN, PLEN)
Stefan Reinauer00636b02012-04-04 00:08:51 +0200342
343 // Fix up PCI memory region
344 // Start with Top of Lower Usable DRAM
Furquan Shaikh4b4c0c62020-06-01 13:47:28 -0700345 // Lower 20 bits of TOLUD register need to be masked since they contain lock and
346 // reserved bits.
347 Local0 = ^MCHC.TLUD & (0xfff << 20)
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700348 Local1 = ^MCHC.MEBA
Stefan Reinauer00636b02012-04-04 00:08:51 +0200349
350 // Check if ME base is equal
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700351 If (Local0 == Local1) {
Stefan Reinauer00636b02012-04-04 00:08:51 +0200352 // Use Top Of Memory instead
Furquan Shaikh4b4c0c62020-06-01 13:47:28 -0700353 // Lower 20 bits of TOM register need to be masked since they contain lock and
354 // reserved bits.
355 Local0 = ^MCHC.TOM & (0x7ffff << 20)
Stefan Reinauer00636b02012-04-04 00:08:51 +0200356 }
357
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700358 PMIN = Local0
Shelley Chen4e9bb332021-10-20 15:43:45 -0700359 PMAX = CONFIG_ECAM_MMCONF_BASE_ADDRESS - 1
Furquan Shaikh9e94cce2020-06-01 13:44:57 -0700360 PLEN = PMAX - PMIN + 1
Stefan Reinauer00636b02012-04-04 00:08:51 +0200361
362 Return (MCRS)
363}