Add DSDT node for AppleSMC
[qemu/ar7.git] / hw / i386 / q35-acpi-dsdt.dsl
blobee38fd658040a54ad5d9a914d51fc70d56835e74
1 /*
2  * Bochs/QEMU ACPI DSDT ASL definition
3  *
4  * Copyright (c) 2006 Fabrice Bellard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License version 2 as published by the Free Software Foundation.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  */
20  * Copyright (c) 2010 Isaku Yamahata
21  *                    yamahata at valinux co jp
22  * Based on acpi-dsdt.dsl, but heavily modified for q35 chipset.
23  */
25 ACPI_EXTRACT_ALL_CODE Q35AcpiDsdtAmlCode
27 DefinitionBlock (
28     "q35-acpi-dsdt.aml",// Output Filename
29     "DSDT",             // Signature
30     0x01,               // DSDT Compliance Revision
31     "BXPC",             // OEMID
32     "BXDSDT",           // TABLE ID
33     0x2                 // OEM Revision
34     )
37 #include "acpi-dsdt-dbug.dsl"
39     Scope(\_SB) {
40         OperationRegion(PCST, SystemIO, 0xae00, 0x0c)
41         OperationRegion(PCSB, SystemIO, 0xae0c, 0x01)
42         Field(PCSB, AnyAcc, NoLock, WriteAsZeros) {
43             PCIB, 8,
44         }
45     }
48 /****************************************************************
49  * PCI Bus definition
50  ****************************************************************/
52     Scope(\_SB) {
53         Device(PCI0) {
54             Name(_HID, EisaId("PNP0A08"))
55             Name(_CID, EisaId("PNP0A03"))
56             Name(_ADR, 0x00)
57             Name(_UID, 1)
59             // _OSC: based on sample of ACPI3.0b spec
60             Name(SUPP, 0) // PCI _OSC Support Field value
61             Name(CTRL, 0) // PCI _OSC Control Field value
62             Method(_OSC, 4) {
63                 // Create DWORD-addressable fields from the Capabilities Buffer
64                 CreateDWordField(Arg3, 0, CDW1)
66                 // Check for proper UUID
67                 If (LEqual(Arg0, ToUUID("33DB4D5B-1FF7-401C-9657-7441C03DD766"))) {
68                     // Create DWORD-addressable fields from the Capabilities Buffer
69                     CreateDWordField(Arg3, 4, CDW2)
70                     CreateDWordField(Arg3, 8, CDW3)
72                     // Save Capabilities DWORD2 & 3
73                     Store(CDW2, SUPP)
74                     Store(CDW3, CTRL)
76                     // Always allow native PME, AER (no dependencies)
77                     // Never allow SHPC (no SHPC controller in this system)
78                     And(CTRL, 0x1D, CTRL)
80 #if 0 // For now, nothing to do
81                     If (Not(And(CDW1, 1))) { // Query flag clear?
82                         // Disable GPEs for features granted native control.
83                         If (And(CTRL, 0x01)) { // Hot plug control granted?
84                             Store(0, HPCE) // clear the hot plug SCI enable bit
85                             Store(1, HPCS) // clear the hot plug SCI status bit
86                         }
87                         If (And(CTRL, 0x04)) { // PME control granted?
88                             Store(0, PMCE) // clear the PME SCI enable bit
89                             Store(1, PMCS) // clear the PME SCI status bit
90                         }
91                         If (And(CTRL, 0x10)) { // OS restoring PCI Express cap structure?
92                             // Set status to not restore PCI Express cap structure
93                             // upon resume from S3
94                             Store(1, S3CR)
95                         }
96                     }
97 #endif
98                     If (LNotEqual(Arg1, One)) {
99                         // Unknown revision
100                         Or(CDW1, 0x08, CDW1)
101                     }
102                     If (LNotEqual(CDW3, CTRL)) {
103                         // Capabilities bits were masked
104                         Or(CDW1, 0x10, CDW1)
105                     }
106                     // Update DWORD3 in the buffer
107                     Store(CTRL, CDW3)
108                 } Else {
109                     Or(CDW1, 4, CDW1) // Unrecognized UUID
110                 }
111                 Return (Arg3)
112             }
113         }
114     }
116 #include "acpi-dsdt-pci-crs.dsl"
117 #include "acpi-dsdt-hpet.dsl"
120 /****************************************************************
121  * VGA
122  ****************************************************************/
124     Scope(\_SB.PCI0) {
125         Device(VGA) {
126             Name(_ADR, 0x00010000)
127             Method(_S1D, 0, NotSerialized) {
128                 Return (0x00)
129             }
130             Method(_S2D, 0, NotSerialized) {
131                 Return (0x00)
132             }
133             Method(_S3D, 0, NotSerialized) {
134                 Return (0x00)
135             }
136         }
137     }
140 /****************************************************************
141  * LPC ISA bridge
142  ****************************************************************/
144     Scope(\_SB.PCI0) {
145         /* PCI D31:f0 LPC ISA bridge */
146         Device(ISA) {
147             /* PCI D31:f0 */
148             Name(_ADR, 0x001f0000)
150             /* ICH9 PCI to ISA irq remapping */
151             OperationRegion(PIRQ, PCI_Config, 0x60, 0x0C)
153             OperationRegion(LPCD, PCI_Config, 0x80, 0x2)
154             Field(LPCD, AnyAcc, NoLock, Preserve) {
155                 COMA,   3,
156                     ,   1,
157                 COMB,   3,
159                 Offset(0x01),
160                 LPTD,   2,
161                     ,   2,
162                 FDCD,   2
163             }
164             OperationRegion(LPCE, PCI_Config, 0x82, 0x2)
165             Field(LPCE, AnyAcc, NoLock, Preserve) {
166                 CAEN,   1,
167                 CBEN,   1,
168                 LPEN,   1,
169                 FDEN,   1
170             }
171         }
172     }
174 #define DSDT_APPLESMC_STA q35_dsdt_applesmc_sta
175 #include "acpi-dsdt-isa.dsl"
178 /****************************************************************
179  * PCI IRQs
180  ****************************************************************/
182     /* Zero => PIC mode, One => APIC Mode */
183     Name(\PICF, Zero)
184     Method(\_PIC, 1, NotSerialized) {
185         Store(Arg0, \PICF)
186     }
188     Scope(\_SB) {
189         Scope(PCI0) {
190 #define prt_slot_lnk(nr, lnk0, lnk1, lnk2, lnk3)  \
191     Package() { nr##ffff, 0, lnk0, 0 },           \
192     Package() { nr##ffff, 1, lnk1, 0 },           \
193     Package() { nr##ffff, 2, lnk2, 0 },           \
194     Package() { nr##ffff, 3, lnk3, 0 }
196 #define prt_slot_lnkA(nr) prt_slot_lnk(nr, LNKA, LNKB, LNKC, LNKD)
197 #define prt_slot_lnkB(nr) prt_slot_lnk(nr, LNKB, LNKC, LNKD, LNKA)
198 #define prt_slot_lnkC(nr) prt_slot_lnk(nr, LNKC, LNKD, LNKA, LNKB)
199 #define prt_slot_lnkD(nr) prt_slot_lnk(nr, LNKD, LNKA, LNKB, LNKC)
201 #define prt_slot_lnkE(nr) prt_slot_lnk(nr, LNKE, LNKF, LNKG, LNKH)
202 #define prt_slot_lnkF(nr) prt_slot_lnk(nr, LNKF, LNKG, LNKH, LNKE)
203 #define prt_slot_lnkG(nr) prt_slot_lnk(nr, LNKG, LNKH, LNKE, LNKF)
204 #define prt_slot_lnkH(nr) prt_slot_lnk(nr, LNKH, LNKE, LNKF, LNKG)
206             Name(PRTP, package() {
207                 prt_slot_lnkE(0x0000),
208                 prt_slot_lnkF(0x0001),
209                 prt_slot_lnkG(0x0002),
210                 prt_slot_lnkH(0x0003),
211                 prt_slot_lnkE(0x0004),
212                 prt_slot_lnkF(0x0005),
213                 prt_slot_lnkG(0x0006),
214                 prt_slot_lnkH(0x0007),
215                 prt_slot_lnkE(0x0008),
216                 prt_slot_lnkF(0x0009),
217                 prt_slot_lnkG(0x000a),
218                 prt_slot_lnkH(0x000b),
219                 prt_slot_lnkE(0x000c),
220                 prt_slot_lnkF(0x000d),
221                 prt_slot_lnkG(0x000e),
222                 prt_slot_lnkH(0x000f),
223                 prt_slot_lnkE(0x0010),
224                 prt_slot_lnkF(0x0011),
225                 prt_slot_lnkG(0x0012),
226                 prt_slot_lnkH(0x0013),
227                 prt_slot_lnkE(0x0014),
228                 prt_slot_lnkF(0x0015),
229                 prt_slot_lnkG(0x0016),
230                 prt_slot_lnkH(0x0017),
231                 prt_slot_lnkE(0x0018),
233                 /* INTA -> PIRQA for slot 25 - 31
234                    see the default value of D<N>IR */
235                 prt_slot_lnkA(0x0019),
236                 prt_slot_lnkA(0x001a),
237                 prt_slot_lnkA(0x001b),
238                 prt_slot_lnkA(0x001c),
239                 prt_slot_lnkA(0x001d),
241                 /* PCIe->PCI bridge. use PIRQ[E-H] */
242                 prt_slot_lnkE(0x001e),
244                 prt_slot_lnkA(0x001f)
245             })
247 #define prt_slot_gsi(nr, gsi0, gsi1, gsi2, gsi3)  \
248     Package() { nr##ffff, 0, gsi0, 0 },           \
249     Package() { nr##ffff, 1, gsi1, 0 },           \
250     Package() { nr##ffff, 2, gsi2, 0 },           \
251     Package() { nr##ffff, 3, gsi3, 0 }
253 #define prt_slot_gsiA(nr) prt_slot_gsi(nr, GSIA, GSIB, GSIC, GSID)
254 #define prt_slot_gsiB(nr) prt_slot_gsi(nr, GSIB, GSIC, GSID, GSIA)
255 #define prt_slot_gsiC(nr) prt_slot_gsi(nr, GSIC, GSID, GSIA, GSIB)
256 #define prt_slot_gsiD(nr) prt_slot_gsi(nr, GSID, GSIA, GSIB, GSIC)
258 #define prt_slot_gsiE(nr) prt_slot_gsi(nr, GSIE, GSIF, GSIG, GSIH)
259 #define prt_slot_gsiF(nr) prt_slot_gsi(nr, GSIF, GSIG, GSIH, GSIE)
260 #define prt_slot_gsiG(nr) prt_slot_gsi(nr, GSIG, GSIH, GSIE, GSIF)
261 #define prt_slot_gsiH(nr) prt_slot_gsi(nr, GSIH, GSIE, GSIF, GSIG)
263             Name(PRTA, package() {
264                 prt_slot_gsiE(0x0000),
265                 prt_slot_gsiF(0x0001),
266                 prt_slot_gsiG(0x0002),
267                 prt_slot_gsiH(0x0003),
268                 prt_slot_gsiE(0x0004),
269                 prt_slot_gsiF(0x0005),
270                 prt_slot_gsiG(0x0006),
271                 prt_slot_gsiH(0x0007),
272                 prt_slot_gsiE(0x0008),
273                 prt_slot_gsiF(0x0009),
274                 prt_slot_gsiG(0x000a),
275                 prt_slot_gsiH(0x000b),
276                 prt_slot_gsiE(0x000c),
277                 prt_slot_gsiF(0x000d),
278                 prt_slot_gsiG(0x000e),
279                 prt_slot_gsiH(0x000f),
280                 prt_slot_gsiE(0x0010),
281                 prt_slot_gsiF(0x0011),
282                 prt_slot_gsiG(0x0012),
283                 prt_slot_gsiH(0x0013),
284                 prt_slot_gsiE(0x0014),
285                 prt_slot_gsiF(0x0015),
286                 prt_slot_gsiG(0x0016),
287                 prt_slot_gsiH(0x0017),
288                 prt_slot_gsiE(0x0018),
290                 /* INTA -> PIRQA for slot 25 - 31, but 30
291                    see the default value of D<N>IR */
292                 prt_slot_gsiA(0x0019),
293                 prt_slot_gsiA(0x001a),
294                 prt_slot_gsiA(0x001b),
295                 prt_slot_gsiA(0x001c),
296                 prt_slot_gsiA(0x001d),
298                 /* PCIe->PCI bridge. use PIRQ[E-H] */
299                 prt_slot_gsiE(0x001e),
301                 prt_slot_gsiA(0x001f)
302             })
304             Method(_PRT, 0, NotSerialized) {
305                 /* PCI IRQ routing table, example from ACPI 2.0a specification,
306                    section 6.2.8.1 */
307                 /* Note: we provide the same info as the PCI routing
308                    table of the Bochs BIOS */
309                 If (LEqual(\PICF, Zero)) {
310                     Return (PRTP)
311                 } Else {
312                     Return (PRTA)
313                 }
314             }
315         }
317         Field(PCI0.ISA.PIRQ, ByteAcc, NoLock, Preserve) {
318             PRQA,   8,
319             PRQB,   8,
320             PRQC,   8,
321             PRQD,   8,
323             Offset(0x08),
324             PRQE,   8,
325             PRQF,   8,
326             PRQG,   8,
327             PRQH,   8
328         }
330         Method(IQST, 1, NotSerialized) {
331             // _STA method - get status
332             If (And(0x80, Arg0)) {
333                 Return (0x09)
334             }
335             Return (0x0B)
336         }
337         Method(IQCR, 1, Serialized) {
338             // _CRS method - get current settings
339             Name(PRR0, ResourceTemplate() {
340                 Interrupt(, Level, ActiveHigh, Shared) { 0 }
341             })
342             CreateDWordField(PRR0, 0x05, PRRI)
343             Store(And(Arg0, 0x0F), PRRI)
344             Return (PRR0)
345         }
347 #define define_link(link, uid, reg)                             \
348         Device(link) {                                          \
349             Name(_HID, EISAID("PNP0C0F"))                       \
350             Name(_UID, uid)                                     \
351             Name(_PRS, ResourceTemplate() {                     \
352                 Interrupt(, Level, ActiveHigh, Shared) {        \
353                     5, 10, 11                                   \
354                 }                                               \
355             })                                                  \
356             Method(_STA, 0, NotSerialized) {                    \
357                 Return (IQST(reg))                              \
358             }                                                   \
359             Method(_DIS, 0, NotSerialized) {                    \
360                 Or(reg, 0x80, reg)                              \
361             }                                                   \
362             Method(_CRS, 0, NotSerialized) {                    \
363                 Return (IQCR(reg))                              \
364             }                                                   \
365             Method(_SRS, 1, NotSerialized) {                    \
366                 CreateDWordField(Arg0, 0x05, PRRI)              \
367                 Store(PRRI, reg)                                \
368             }                                                   \
369         }
371         define_link(LNKA, 0, PRQA)
372         define_link(LNKB, 1, PRQB)
373         define_link(LNKC, 2, PRQC)
374         define_link(LNKD, 3, PRQD)
375         define_link(LNKE, 4, PRQE)
376         define_link(LNKF, 5, PRQF)
377         define_link(LNKG, 6, PRQG)
378         define_link(LNKH, 7, PRQH)
380 #define define_gsi_link(link, uid, gsi)                         \
381         Device(link) {                                          \
382             Name(_HID, EISAID("PNP0C0F"))                       \
383             Name(_UID, uid)                                     \
384             Name(_PRS, ResourceTemplate() {                     \
385                 Interrupt(, Level, ActiveHigh, Shared) {        \
386                     gsi                                         \
387                 }                                               \
388             })                                                  \
389             Name(_CRS, ResourceTemplate() {                     \
390                 Interrupt(, Level, ActiveHigh, Shared) {        \
391                     gsi                                         \
392                 }                                               \
393             })                                                  \
394             Method(_SRS, 1, NotSerialized) {                    \
395             }                                                   \
396         }
398         define_gsi_link(GSIA, 0, 0x10)
399         define_gsi_link(GSIB, 0, 0x11)
400         define_gsi_link(GSIC, 0, 0x12)
401         define_gsi_link(GSID, 0, 0x13)
402         define_gsi_link(GSIE, 0, 0x14)
403         define_gsi_link(GSIF, 0, 0x15)
404         define_gsi_link(GSIG, 0, 0x16)
405         define_gsi_link(GSIH, 0, 0x17)
406     }
408 #include "acpi-dsdt-cpu-hotplug.dsl"
411 /****************************************************************
412  * General purpose events
413  ****************************************************************/
415     Scope(\_GPE) {
416         Name(_HID, "ACPI0006")
418         Method(_L00) {
419         }
420         Method(_L01) {
421         }
422         Method(_E02) {
423             // CPU hotplug event
424             \_SB.PRSC()
425         }
426         Method(_L03) {
427         }
428         Method(_L04) {
429         }
430         Method(_L05) {
431         }
432         Method(_L06) {
433         }
434         Method(_L07) {
435         }
436         Method(_L08) {
437         }
438         Method(_L09) {
439         }
440         Method(_L0A) {
441         }
442         Method(_L0B) {
443         }
444         Method(_L0C) {
445         }
446         Method(_L0D) {
447         }
448         Method(_L0E) {
449         }
450         Method(_L0F) {
451         }
452     }