blob: 27c46611b332dac5c20232ac3c9f940e8081dc13 [file] [log] [blame]
Angel Ponsae593872020-04-04 18:50:57 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Martin Roth5c354b92019-04-22 14:55:16 -06002
3External(\_SB.ALIB, MethodObj)
4
5/* System Bus */
6/* _SB.PCI0 */
7
8/* Operating System Capabilities Method */
9Method(_OSC,4)
10{
11 /* Check for proper PCI/PCIe UUID */
12 If(LEqual(Arg0,ToUUID("33DB4D5B-1FF7-401C-9657-7441C03DD766")))
13 {
14 /* Let OS control everything */
15 Return (Arg3)
16 } Else {
17 CreateDWordField(Arg3,0,CDW1)
18 Or(CDW1,4,CDW1) // Unrecognized UUID
19 Return(Arg3)
20 }
21}
22
23/* Describe the Southbridge devices */
24
Martin Roth5c354b92019-04-22 14:55:16 -060025/* 0:14.0 - SMBUS */
26Device(SBUS) {
27 Name(_ADR, 0x00140000)
28} /* end SBUS */
29
30#include "usb.asl"
31
32/* 0:14.2 - I2S Audio */
33
34/* 0:14.3 - LPC */
35#include <soc/amd/common/acpi/lpc.asl>
36
Martin Roth5c354b92019-04-22 14:55:16 -060037Name(CRES, ResourceTemplate() {
38 /* Set the Bus number and Secondary Bus number for the PCI0 device
39 * The Secondary bus range for PCI0 lets the system
40 * know what bus values are allowed on the downstream
41 * side of this PCI bus if there is a PCI-PCI bridge.
42 * PCI busses can have 256 secondary busses which
43 * range from [0-0xFF] but they do not need to be
44 * sequential.
45 */
46 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
47 0x0000, /* address granularity */
48 0x0000, /* range minimum */
49 0x00ff, /* range maximum */
50 0x0000, /* translation */
51 0x0100, /* length */
52 ,, PSB0) /* ResourceSourceIndex, ResourceSource, DescriptorName */
53
54 IO(Decode16, 0x0cf8, 0x0cf8, 1, 8)
55
56 WORDIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
57 0x0000, /* address granularity */
58 0x0000, /* range minimum */
59 0x0cf7, /* range maximum */
60 0x0000, /* translation */
61 0x0cf8 /* length */
62 )
63 WORDIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
64 0x0000, /* address granularity */
65 0x03b0, /* range minimum */
66 0x03df, /* range maximum */
67 0x0000, /* translation */
68 0x0030 /* length */
69 )
70
71 WORDIO(ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
72 0x0000, /* address granularity */
73 0x0d00, /* range minimum */
74 0xffff, /* range maximum */
75 0x0000, /* translation */
76 0xf300 /* length */
77 )
78
79 Memory32Fixed(READONLY, 0x000a0000, 0x00020000, VGAM) /* VGA memory space */
80 Memory32Fixed(READONLY, 0x000c0000, 0x00020000, EMM1) /* Assume C0000-E0000 empty */
81
82 /* memory space for PCI BARs below 4GB */
83 Memory32Fixed(ReadOnly, 0x00000000, 0x00000000, MMIO)
84}) /* End Name(_SB.PCI0.CRES) */
85
86Method(_CRS, 0) {
87 /* DBGO("\\_SB\\PCI0\\_CRS\n") */
88 CreateDWordField(CRES, ^MMIO._BAS, MM1B)
89 CreateDWordField(CRES, ^MMIO._LEN, MM1L)
90
91 /*
92 * Declare memory between TOM1 and 4GB as available
93 * for PCI MMIO.
94 * Use ShiftLeft to avoid 64bit constant (for XP).
95 * This will work even if the OS does 32bit arithmetic, as
96 * 32bit (0x00000000 - TOM1) will wrap and give the same
97 * result as 64bit (0x100000000 - TOM1).
98 */
99 Store(TOM1, MM1B)
100 ShiftLeft(0x10000000, 4, Local0)
101 Subtract(Local0, TOM1, Local0)
102 Store(Local0, MM1L)
103
104 Return(CRES) /* note to change the Name buffer */
105} /* end of Method(_SB.PCI0._CRS) */
106
107/*
108 *
109 * FIRST METHOD CALLED UPON BOOT
110 *
111 * 1. If debugging, print current OS and ACPI interpreter.
112 * 2. Get PCI Interrupt routing from ACPI VSM, this
113 * value is based on user choice in BIOS setup.
114 */
115Method(_INI, 0, Serialized) {
116 /* DBGO("\\_SB\\_INI\n") */
117 /* DBGO(" DSDT.ASL code from ") */
118 /* DBGO(__DATE__) */
119 /* DBGO(" ") */
120 /* DBGO(__TIME__) */
121 /* DBGO("\n Sleep states supported: ") */
122 /* DBGO("\n") */
123 /* DBGO(" \\_OS=") */
124 /* DBGO(\_OS) */
125 /* DBGO("\n \\_REV=") */
126 /* DBGO(\_REV) */
127 /* DBGO("\n") */
128
129 /* Determine the OS we're running on */
130 OSFL()
Martin Roth5c354b92019-04-22 14:55:16 -0600131} /* End Method(_SB._INI) */
132
133Method(OSFL, 0){
134
135 if (LNotEqual(OSVR, Ones)) {Return(OSVR)} /* OS version was already detected */
136
137 if (CondRefOf(\_OSI))
138 {
139 Store(1, OSVR) /* Assume some form of XP */
140 if (\_OSI("Windows 2006")) /* Vista */
141 {
142 Store(2, OSVR)
143 }
144 } else {
145 If(WCMP(\_OS,"Linux")) {
146 Store(3, OSVR) /* Linux */
147 } Else {
148 Store(4, OSVR) /* Gotta be WinCE */
149 }
150 }
151 Return(OSVR)
152}
153
154OperationRegion(SMIC, SystemMemory, 0xfed80000, 0x80000)
155Field( SMIC, ByteAcc, NoLock, Preserve) {
156 /* MISC registers */
157 offset (0x03ee),
158 U3PS, 2, /* Usb3PowerSel */
159
160 offset (0x0e28),
161 ,29 ,
162 SARP, 1, /* Sata Ref Clock Powerdown */
163 U2RP, 1, /* Usb2 Ref Clock Powerdown */
164 U3RP, 1, /* Usb3 Ref Clock Powerdown */
165
Martin Roth5c354b92019-04-22 14:55:16 -0600166 /* AOAC Registers */
167 offset (0x1e4a), /* I2C0 D3 Control */
168 I0TD, 2,
169 , 1,
170 I0PD, 1,
171 offset (0x1e4b), /* I2C0 D3 State */
172 I0DS, 3,
173
174 offset (0x1e4c), /* I2C1 D3 Control */
175 I1TD, 2,
176 , 1,
177 I1PD, 1,
178 offset (0x1e4d), /* I2C1 D3 State */
179 I1DS, 3,
180
181 offset (0x1e4e), /* I2C2 D3 Control */
182 I2TD, 2,
183 , 1,
184 I2PD, 1,
185 offset (0x1e4f), /* I2C2 D3 State */
186 I2DS, 3,
187
188 offset (0x1e50), /* I2C3 D3 Control */
189 I3TD, 2,
190 , 1,
191 I3PD, 1,
192 offset (0x1e51), /* I2C3 D3 State */
193 I3DS, 3,
194
195 offset (0x1e56), /* UART0 D3 Control */
196 U0TD, 2,
197 , 1,
198 U0PD, 1,
199 offset (0x1e57), /* UART0 D3 State */
200 U0DS, 3,
201
202 offset (0x1e58), /* UART1 D3 Control */
203 U1TD, 2,
204 , 1,
205 U1PD, 1,
206 offset (0x1e59), /* UART1 D3 State */
207 U1DS, 3,
208
Marshall Dawsonc0b8d0d2019-06-20 10:29:29 -0600209 offset (0x1e60), /* UART2 D3 Control */
210 U2TD, 2,
211 , 1,
212 U2PD, 1,
213 offset (0x1e61), /* UART2 D3 State */
214 U2DS, 3,
215
Martin Roth5c354b92019-04-22 14:55:16 -0600216 offset (0x1e71), /* SD D3 State */
217 SDDS, 3,
218
Marshall Dawsonc0b8d0d2019-06-20 10:29:29 -0600219 offset (0x1e74), /* UART3 D3 Control */
220 U3TD, 2,
221 , 1,
222 U3PD, 1,
223 offset (0x1e75), /* UART3 D3 State */
224 U3DS, 3,
225
Martin Roth5c354b92019-04-22 14:55:16 -0600226 offset (0x1e80), /* Shadow Register Request */
227 , 15,
228 RQ15, 1,
229 , 2,
230 RQ18, 1,
231 , 4,
232 RQ23, 1,
233 RQ24, 1,
234 , 5,
235 RQTY, 1,
236 offset (0x1e84), /* Shadow Register Status */
237 , 15,
238 SASR, 1, /* SATA 15 Shadow Reg Request Status Register */
239 , 2,
240 U2SR, 1, /* USB2 18 Shadow Reg Request Status Register */
241 , 4,
242 U3SR, 1, /* USB3 23 Shadow Reg Request Status Register */
243 SDSR, 1, /* SD 24 Shadow Reg Request Status Register */
244
245 offset (0x1ea0), /* PwrGood Control */
246 PG1A, 1,
247 PG2_, 1,
248 ,1,
249 U3PG, 1, /* Usb3 Power Good BIT3 */
250
251 offset (0x1ea3), /* PwrGood Control b[31:24] */
252 PGA3, 8 ,
253}
254
255OperationRegion(FCFG, SystemMemory, PCBA, 0x01000000)
256Field(FCFG, DwordAcc, NoLock, Preserve)
257{
258 /* XHCI */
259 Offset(0x00080010), /* Base address */
260 XHBA, 32,
261 Offset(0x0008002c), /* Subsystem ID / Vendor ID */
262 XH2C, 32,
263
264 Offset(0x00080048), /* Indirect PCI Index Register */
265 IDEX, 32,
266 DATA, 32,
267 Offset(0x00080054), /* PME Control / Status */
268 U_PS, 2,
269
270 /* EHCI */
271 Offset(0x00090004), /* Control */
272 , 1,
273 EHME, 1,
274 Offset(0x00090010), /* Base address */
275 EHBA, 32,
276 Offset(0x0009002c), /* Subsystem ID / Vendor ID */
277 EH2C, 32,
278 Offset(0x00090054), /* EHCI Spare 1 */
279 EH54, 8,
280 Offset(0x00090064), /* Misc Control 2 */
281 EH64, 8,
282
283 Offset(0x000900c4), /* PME Control / Status */
284 E_PS, 2,
285
286 /* LPC Bridge */
287 Offset(0x000a30cb), /* ClientRomProtect[31:24] */
288 , 7,
289 AUSS, 1, /* AutoSizeStart */
290}
291
292/*
293 * Arg0:device:
294 * 5=I2C0, 6=I2C1, 7=I2C2, 8=I2C3, 11=UART0, 12=UART1,
Marshall Dawson5f3c4652019-09-17 11:22:31 -0600295 * 18=EHCI, 23=xHCI, 24=SD
Martin Roth5c354b92019-04-22 14:55:16 -0600296 * Arg1:D-state
297 */
298Mutex (FDAS, 0) /* FCH Device AOAC Semophore */
299Method(FDDC, 2, Serialized)
300{
301 Acquire(FDAS, 0xffff)
302
303 if(LEqual(Arg1, 0)) {
304 Switch(ToInteger(Arg0)) {
305 Case(Package() {5, 15, 24}) {
306 Store(One, PG1A)
307 }
308 Case(Package() {6, 7, 8, 11, 12, 18}) {
309 Store(One, PG2_)
310 }
311 }
312 /* put device into D0 */
313 Switch(ToInteger(Arg0))
314 {
315 Case(5) {
316 Store(0x00, I0TD)
317 Store(One, I0PD)
318 Store(I0DS, Local0)
319 while(LNotEqual(Local0,0x7)) {
320 Store(I0DS, Local0)
321 }
322 }
323 Case(6) {
324 Store(0x00, I1TD)
325 Store(One, I1PD)
326 Store(I1DS, Local0)
327 while(LNotEqual(Local0,0x7)) {
328 Store(I1DS, Local0)
329 }
330 }
331 Case(7) {
332 Store(0x00, I2TD)
333 Store(One, I2PD)
334 Store(I2DS, Local0)
335 while(LNotEqual(Local0,0x7)) {
336 Store(I2DS, Local0)
337 }
338 }
339 Case(8) {Store(0x00, I3TD)
340 Store(One, I3PD)
341 Store(I3DS, Local0)
342 while(LNotEqual(Local0,0x7)) {
343 Store(I3DS, Local0)
344 }
345 }
346 Case(11) {
347 Store(0x00, U0TD)
348 Store(One, U0PD)
349 Store(U0DS, Local0)
350 while(LNotEqual(Local0,0x7)) {
351 Store(U0DS, Local0)
352 }
353 }
354 Case(12) {
355 Store(0x00, U1TD)
356 Store(One, U1PD)
357 Store(U1DS, Local0)
358 while(LNotEqual(Local0,0x7)) {
359 Store(U1DS, Local0)
360 }
361 }
Marshall Dawsonc0b8d0d2019-06-20 10:29:29 -0600362 Case(16) {
363 Store(0x00, U2TD)
364 Store(One, U2PD)
365 Store(U2DS, Local0)
366 while(LNotEqual(Local0,0x7)) {
367 Store(U2DS, Local0)
368 }
369 }
370 Case(26) {
371 Store(0x00, U3TD)
372 Store(One, U3PD)
373 Store(U3DS, Local0)
374 while(LNotEqual(Local0,0x7)) {
375 Store(U3DS, Local0)
376 }
377 }
Martin Roth5c354b92019-04-22 14:55:16 -0600378 }
379 } else {
380 /* put device into D3cold */
381 Switch(ToInteger(Arg0))
382 {
383 Case(5) {
384 Store(Zero, I0PD)
385 Store(I0DS, Local0)
386 while(LNotEqual(Local0,0x0)) {
387 Store(I0DS, Local0)
388 }
389 Store(0x03, I0TD)
390 }
391 Case(6) {
392 Store(Zero, I1PD)
393 Store(I1DS, Local0)
394 while(LNotEqual(Local0,0x0)) {
395 Store(I1DS, Local0)
396 }
397 Store(0x03, I1TD)
398 }
399 Case(7) {
400 Store(Zero, I2PD)
401 Store(I2DS, Local0)
402 while(LNotEqual(Local0,0x0)) {
403 Store(I2DS, Local0)
404 }
405 Store(0x03, I2TD)}
406 Case(8) {
407 Store(Zero, I3PD)
408 Store(I3DS, Local0)
409 while(LNotEqual(Local0,0x0)) {
410 Store(I3DS, Local0)
411 }
412 Store(0x03, I3TD)
413 }
414 Case(11) {
415 Store(Zero, U0PD)
416 Store(U0DS, Local0)
417 while(LNotEqual(Local0,0x0)) {
418 Store(U0DS, Local0)
419 }
420 Store(0x03, U0TD)
421 }
422 Case(12) {
423 Store(Zero, U1PD)
424 Store(U1DS, Local0)
425 while(LNotEqual(Local0,0x0)) {
426 Store(U1DS, Local0)
427 }
428 Store(0x03, U1TD)
429 }
Marshall Dawsonc0b8d0d2019-06-20 10:29:29 -0600430 Case(16) {
431 Store(Zero, U2PD)
432 Store(U2DS, Local0)
433 while(LNotEqual(Local0,0x0)) {
434 Store(U2DS, Local0)
435 }
436 Store(0x03, U2TD)
437 }
438 Case(26) {
439 Store(Zero, U3PD)
440 Store(U3DS, Local0)
441 while(LNotEqual(Local0,0x0)) {
442 Store(U3DS, Local0)
443 }
444 Store(0x03, U3TD)
445 }
Martin Roth5c354b92019-04-22 14:55:16 -0600446 }
447 if(LEqual(I1TD, 3)) {
448 if(LEqual(I2TD, 3)) {
449 if(LEqual(I3TD, 3)) {
450 if(LEqual(U0TD, 3)) {
451 if(LEqual(U1TD, 3)) {
Marshall Dawsone0fd9a62019-07-09 18:12:03 -0500452 Store(Zero, PG2_)
Martin Roth5c354b92019-04-22 14:55:16 -0600453 }
454 }
455 }
456 }
457 }
458 }
459 Release(FDAS)
460}
461
462Method(FPTS,0, Serialized) /* FCH _PTS */
463{
Martin Roth5c354b92019-04-22 14:55:16 -0600464}
465
466Method(FWAK,0, Serialized) /* FCH _WAK */
467{
Martin Roth5c354b92019-04-22 14:55:16 -0600468 if(LEqual(\UT0E, zero)) {
469 if(LNotEqual(U0TD, 0x03)) {
470 FDDC(11, 3)
471 }
472 }
473 if(LEqual(\UT1E, zero)) {
474 if(LNotEqual(U1TD, 0x03)) {
475 FDDC(12, 3)
476 }
477 }
Martin Roth5c354b92019-04-22 14:55:16 -0600478 if(LEqual(\IC2E, zero)) {
479 if(LNotEqual(I2TD, 0x03)) {
480 FDDC(7, 3)
481 }
482 }
483 if(LEqual(\IC3E, zero)) {
484 if(LNotEqual(I3TD, 0x03)) {
485 FDDC(8, 3)
486 }
487 }
488}
489
490/*
491 * Helper for setting a bit in AOACxA0 PwrGood Control
492 * Arg0: bit to set or clear
493 * Arg1: 0 = clear bit[Arg0], non-zero = set bit[Arg0]
494 */
495Method(PWGC,2, Serialized)
496{
497 And (PGA3, 0xdf, Local0) /* do SwUsb3SlpShutdown below */
498 if(Arg1) {
499 Or(Arg0, Local0, Local0)
500 } else {
501 Not(Arg0, Local1)
502 And(Local1, Local0, Local0)
503 }
504 Store(Local0, PGA3)
505 if(LEqual(Arg0, 0x20)) { /* if SwUsb3SlpShutdown */
506 Store(PGA3, Local0)
507 And(Arg0, Local0, Local0)
508 while(LNot(Local0)) { /* wait SwUsb3SlpShutdown to complete */
509 Store(PGA3, Local0)
510 And(Arg0, Local0, Local0)
511 }
512 }
513}