1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
|
/*++
This file contains an 'Intel Peripheral Driver' and uniquely
identified as "Intel Reference Module" and is
licensed for Intel CPUs and chipsets under the terms of your
license agreement with Intel or your vendor. This file may
be modified by the user, subject to additional terms of the
license agreement
--*/
/*++
Copyright (c) 1999 - 2013 Intel Corporation. All rights reserved
This software and associated documentation (if any) is furnished
under a license and may only be used or copied in accordance
with the terms of the license. Except as permitted by such
license, no part of this software or documentation may be
reproduced, stored in a retrieval system, or transmitted in any
form or by any means without the express written consent of
Intel Corporation.
Module Name:
Sa.ASL
Abstract:
Devices definition of SystemAgent ACPI reference code.
--*/
//AMI_OVERRIDE -->>
#if !defined(ASL_Remove_SaSsdt_Data_To_Dsdt) || (ASL_Remove_SaSsdt_Data_To_Dsdt == 0)
#if defined(ASL_RC_PEG_0) && (ASL_RC_PEG_0 == 1)
External(AR02)
External(PR02)
#endif
#if defined(ASL_RC_PEG_1) && (ASL_RC_PEG_1 == 1)
External(AR0A)
External(PR0A)
#endif
#if defined(ASL_RC_PEG_2) && (ASL_RC_PEG_2 == 1)
External(AR0B)
External(PR0B)
#endif
External(PICM)
External(\GPRW, MethodObj)
External(\_SB.PCI0, DeviceObj)
#endif
//AMI_OVERRIDE --<<
Scope (\_SB.PCI0) {
Name(LTRS, 0)
Name(OBFS, 0)
//AMI_OVERRIDE -->>
#if defined(ASL_RC_PEG_0) && (ASL_RC_PEG_0 == 1)
Device(PEG0) { // P.E.G. Root Port D1F0
Name(_ADR, 0x00010000)
OperationRegion(PEGR,PCI_Config,0xC0,0x30)
Field(PEGR,DWordAcc,NoLock,Preserve)
{
,16,
PSTS, 1, // PME Status
offset (44),
GENG, 1, // General Message GPE Enable
,1, // Reserved
PMEG, 1, // PME GPE Enable
}
Method(_PRW, 0) { Return(GPRW(0x09, 4)) } // can wakeup from S4 state
Method(_PSW,1)
{
If(Arg0)
{
Store(1,GENG)
Store(1,PMEG)
}
Else
{
Store(0,GENG)
Store(0,PMEG)
}
}
Method(HPME,0,Serialized)
{
//
// Clear PME status bit
//
Store(1,PSTS)
}
Method(_PRT,0) {
If(PICM) { Return(AR02) }// APIC mode
Return (PR02) // PIC Mode
} // end _PRT
//
// Pass LTRx to LTRS so SaPcieDsm.asl can be reused for PEGs.
//
Method(_INI)
{
Store (LTRA, LTRS)
Store (OBFA, OBFS)
}
include("SaPcieDsm.ASL")
Device(PEGP) { // P.E.G. Port Slot x16
Name(_ADR, 0x00000000)
Method(_PRW, 0) { Return(GPRW(0x09, 4)) } // can wakeup from S4 state
} // end "P.E.G. Port Slot x16"
} // end "P.E.G. Root Port D1F0"
#endif
#if defined(ASL_RC_PEG_1) && (ASL_RC_PEG_1 == 1)
Device(PEG1) { // P.E.G. Root Port D1F1
Name(_ADR, 0x00010001)
OperationRegion(PEGR,PCI_Config,0xC0,0x30)
Field(PEGR,DWordAcc,NoLock,Preserve)
{
,16,
PSTS, 1, // PME Status
offset (44),
GENG, 1, // General Message GPE Enable
,1, // Reserved
PMEG, 1, // PME GPE Enable
}
Method(_PRW, 0) { Return(GPRW(0x09, 4)) } // can wakeup from S4 state
Method(_PSW,1)
{
If(Arg0)
{
Store(1,GENG)
Store(1,PMEG)
}
Else
{
Store(0,GENG)
Store(0,PMEG)
}
}
Method(HPME,0,Serialized)
{
//
// Clear PME status bit
//
Store(1,PSTS)
}
Method(_PRT,0) {
If(PICM) { Return(AR0A) }// APIC mode
Return (PR0A) // PIC Mode
} // end _PRT
Method(_INI)
{
Store (LTRB, LTRS)
Store (OBFB, OBFS)
}
include("SaPcieDsm.ASL")
} // end "P.E.G. Root Port D1F1"
#endif
#if defined(ASL_RC_PEG_2) && (ASL_RC_PEG_2 == 1)
Device(PEG2) { // P.E.G. Root Port D1F2
Name(_ADR, 0x00010002)
OperationRegion(PEGR,PCI_Config,0xC0,0x30)
Field(PEGR,DWordAcc,NoLock,Preserve)
{
,16,
PSTS, 1, // PME Status
offset (44),
GENG, 1, // General Message GPE Enable
,1, // Reserved
PMEG, 1, // PME GPE Enable
}
Method(_PRW, 0) { Return(GPRW(0x09, 4)) } // can wakeup from S4 state
Method(_PSW,1)
{
If(Arg0)
{
Store(1,GENG)
Store(1,PMEG)
}
Else
{
Store(0,GENG)
Store(0,PMEG)
}
}
Method(HPME,0,Serialized)
{
//
// Clear PME status bit
//
Store(1,PSTS)
}
Method(_PRT,0) {
If(PICM) { Return(AR0B) }// APIC mode
Return (PR0B) // PIC Mode
} // end _PRT
Method(_INI)
{
Store (LTRC, LTRS)
Store (OBFC, OBFS)
}
include("SaPcieDsm.ASL")
} // end "P.E.G. Root Port D1F2"
#endif
//AMI_OVERRIDE --<<
Device(B0D3) { // SA Audio Device
Name(_ADR, 0x00030000)
Name (BARA, 0x80000000)
Name (TBAR, 0x0)
Name (TCMD, 0x0)
Name (MODB, 0x0)
Name (MODC, 0x0)
Method(_STA,0)
{
If(LNotEqual(AUVD, 0xFFFF))
{
Return(0xF) // then enabled
}
Return(0) // then disabled
}
Method(_INI) {
//
// Save a valid Audio BAR for the ABWA W/A
//
If (LAnd (LNotEqual (And(ABAR, 0xFFFFC004), 0xFFFFC004), LNotEqual (And (ABAR, 0xFFFFC000), 0))) {
Store (ABAR, BARA)
}
}
OperationRegion(RPCS,SystemMemory,\XBAS,0x18040)
Field(RPCS,AnyAcc,NoLock,Preserve)
{
Offset (0x18004),
ACMD, 8,
Offset (0x18010),
ABAR, 32,
}
OperationRegion(RPCZ,PCI_Config,0x00,0x40)
Field(RPCZ,DWordAcc,Lock,Preserve)
{
AUVD, 16,
}
///
/// Restore Audio WAs
///
Method (ASTR, 0, Serialized) {
If (LAnd (LNotEqual (And(ABAR, 0xFFFFC004), 0xFFFFC004), LNotEqual (And (ABAR, 0xFFFFC000), 0))) {
And (ABAR, 0xFFFFFFF0, BBAR)
Add (BBAR, 0x1000, BBAR)
OperationRegion(RPCY,SystemMemory,BBAR, 0x25)
Field(RPCY,DWordAcc,NoLock,Preserve)
{
Offset(0xC),
EM4W, 32,
Offset(0x10),
EMWA, 32,
Offset(0x1C),
ADWA, 32,
}
Store(AUDA, EMWA)
Store(AUDB, ADWA)
Store(AUDC, EM4W)
}
}
///
/// Send the command to the codec via the Immediate Command
///
Method (VSTR, 1, Serialized) {
Name (CONT, 1000)
Name (ADDR, 0x80000000)
Store (Arg0, ADDR)
OperationRegion(CCDC,SystemMemory,ADDR,4)
Field(CCDC,ByteAcc,NoLock,Preserve)
{
Offset(0x0),
CDEC, 32,
}
If (LAnd (LNotEqual (And(ABAR, 0xFFFFC004), 0xFFFFC004), LNotEqual (And (ABAR, 0xFFFFC000), 0))) {
If (LNotEqual (CDEC, 0)) {
And (ABAR, 0xFFFFFFF0, BBAR)
OperationRegion(IPCV,SystemMemory,BBAR,0x70)
Field(IPCV,DWordAcc,NoLock,Preserve)
{
Offset(0x60),
AVIC, 32,
Offset(0x68),
AIRS, 16,
}
Store (1000, CONT)
While (LAnd (LEqual(And(AIRS, 0x1), 1), LNotEqual(CONT,0)))
{
Stall(1)
Decrement(CONT)
}
Or (AIRS, 2, AIRS)
Store (CDEC, AVIC)
Or (AIRS, 1, AIRS)
Store (1000, CONT)
While (LAnd (LEqual(And(AIRS, 0x1), 1), LNotEqual(CONT,0)))
{
Stall(1)
Decrement(CONT)
}
}
}
}
///
/// Restore Verb Table
///
Method (CXDC, 0, Serialized)
{
Name(IDDX, 0x80000000)
//AMI_OVERRIDE --- Change name from CADR to CCSA to fix that the system has BsOD issue. It is due to the name(CADR) is conflict with AMI Aptio definition name. >>
If (LAnd (LNotEqual (CCSA, 0), LNotEqual (CCNT, 0))) {
Store (CCSA, IDDX)
While (LLess (IDDX, Add (CCSA, Multiply (CCNT, 4))))
// If (LAnd (LNotEqual (CADR, 0), LNotEqual (CCNT, 0))) {
// Store (CADR, IDDX)
// While (LLess (IDDX, Add (CADR, Multiply (CCNT, 4))))
//AMI_OVERRIDE --- <<
{
VSTR (IDDX)
Add (IDDX, 4, IDDX)
}
}
}
///
/// Reset Audio Controller
///
Method (ARST, 0, Serialized)
{
If (LAnd (LNotEqual (And(ABAR, 0xFFFFC004), 0xFFFFC004), LNotEqual (And (ABAR, 0xFFFFC000), 0))) {
And (ABAR, 0xFFFFFFF0, BBAR)
OperationRegion(IPCV,SystemMemory,BBAR,0xBF)
Field(IPCV,AnyAcc,NoLock,Preserve)
{
Offset(0x08),
CRST, 32,
Offset(0x4C),
CORB, 32,
Offset(0x5C),
RIRB, 32,
Offset(0x80),
OSD1, 32,
Offset(0xA0),
OSD2, 32,
}
AND (CORB, 0xFFFFFFFD, CORB)
AND (RIRB, 0xFFFFFFFD, RIRB)
AND (OSD1, 0xFFFFFFFD, OSD1)
AND (OSD2, 0xFFFFFFFD, OSD2)
AND (CRST, 0xFFFFFFFE, CRST)
}
}
///
/// Codec Initialization Programming Sequence
///
Method (AINI, 0, Serialized)
{
Name (CONT, 1000)
If (LAnd (LNotEqual (And(ABAR, 0xFFFFC004), 0xFFFFC004), LNotEqual (And (ABAR, 0xFFFFC000), 0))) {
And (ABAR, 0xFFFFFFF0, BBAR)
OperationRegion(IPCV,SystemMemory,BBAR,0x70)
Field(IPCV,DWordAcc,NoLock,Preserve)
{
Offset(0x0),
GCAP, 16,
Offset(0x08),
GCTL, 32,
Offset(0x0E),
SSTS, 8,
Offset(0x60),
AVIC, 32,
Offset(0x68),
AIRS, 16,
}
///
/// Step1/2:Reset Controller and wait for reset complete
///
Or (GCTL, 1, GCTL)
Store (1000, CONT)
While (LAnd (LEqual (And (GCTL , 1), 0), LNotEqual (CONT, 0)))
{
Stall (1)
Decrement (CONT)
}
///
/// Step3:
/// Read GCAP and write the same value back to
/// the register once after Controller Reset# bit is set
///
And (GCAP, 0xFFFF, GCAP)
///
/// Step4:
/// Clear the "State Change Status Register" STATESTS bits for
/// each of the "SDIN Stat Change Status Flag"
///
Or (SSTS, 0xF, SSTS)
///
/// Step5:
/// Turn off the link and poll RESET# bit until it reads back
/// as 0 to get hardware reset report
///
And (GCTL, 0xFFFFFFFE, GCTL)
Store (1000, CONT)
While (LAnd (LEqual(And(GCTL,1), 1), LNotEqual(CONT,0)))
{
Stall (1)
Decrement (CONT)
}
///
/// Step6:
/// Turn on the link and poll RESET# bit until it reads back as 1
///
Or (GCTL, 1, GCTL)
Store (1000, CONT)
While (LAnd (LEqual(And(GCTL,1), 0), LNotEqual(CONT,0)))
{
Stall (1)
Decrement (CONT)
}
}
}
///
/// W/A for Audio CdClk restore issue with HDMI hotplug after S3/S4 resume
/// Store ABAR temporarily and restore it at the end of Call Back SF 21h
///
Method (ABWA, 1, Serialized)
{
If (Arg0) {
If (LOr (LEqual (And(ABAR, 0xFFFFC004), 0xFFFFC004), LEqual (And (ABAR, 0xFFFFC000), 0))) {
///
/// if Audio BAR does not have a valid value
///
If (LNotEqual (BARA, 0x80000000)) { // but a vaid value has been saved by the _INI or _WAK earlier
Store (ABAR, TBAR) // temporarily assign Audio Bar to restore mmio registers
Store (ACMD, TCMD)
Store (BARA, ABAR)
Store (0x06, ACMD)
Store (0x01, MODB)
}
} Else { // Audio BAR has a valid value
If (LNotEqual (And (ACMD, 0x06), 0x06)) { // but CMD register is not set to allow writes to mmio registers
Store (ACMD, TCMD) // temporarily set CMD register to allow mmio writes
Store (0x06, ACMD)
Store (0x01, MODC)
}
}
} Else { // Restore the original Audio Bar and Cmd Register
If (MODB) {
If(LEqual(ABAR, BARA)) {
Store (TBAR, ABAR)
Store (TCMD, ACMD)
}
}
If (MODC) { // Restore only the Cmd Register
Store (TCMD, ACMD)
}
}
}
} // end "SA Audio Device"
Device(GFX0) { // I.G.D
Name(_ADR, 0x00020000)
include("IntelGfx.ASL")
} // end I.G.D
}
|