Clock cleanups.
[seabios.git] / src / acpi-dsdt.dsl
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19 DefinitionBlock (
20     "acpi-dsdt.aml",    // Output Filename
21     "DSDT",             // Signature
22     0x01,               // DSDT Compliance Revision
23     "BXPC",             // OEMID
24     "BXDSDT",           // TABLE ID
25     0x1                 // OEM Revision
26     )
27 {
28     Scope (\)
29     {
30         /* Debug Output */
31         OperationRegion (DBG, SystemIO, 0xb044, 0x04)
32         Field (DBG, DWordAcc, NoLock, Preserve)
33         {
34             DBGL,   32,
35         }
36     }
37
38
39     /* PCI Bus definition */
40     Scope(\_SB) {
41         Device(PCI0) {
42             Name (_HID, EisaId ("PNP0A03"))
43             Name (_ADR, 0x00)
44             Name (_UID, 1)
45             Name(_PRT, Package() {
46                 /* PCI IRQ routing table, example from ACPI 2.0a specification,
47                    section 6.2.8.1 */
48                 /* Note: we provide the same info as the PCI routing
49                    table of the Bochs BIOS */
50
51                 // PCI Slot 0
52                 Package() {0x0000ffff, 0, LNKD, 0},
53                 Package() {0x0000ffff, 1, LNKA, 0},
54                 Package() {0x0000ffff, 2, LNKB, 0},
55                 Package() {0x0000ffff, 3, LNKC, 0},
56
57                 // PCI Slot 1
58                 Package() {0x0001ffff, 0, LNKA, 0},
59                 Package() {0x0001ffff, 1, LNKB, 0},
60                 Package() {0x0001ffff, 2, LNKC, 0},
61                 Package() {0x0001ffff, 3, LNKD, 0},
62
63                 // PCI Slot 2
64                 Package() {0x0002ffff, 0, LNKB, 0},
65                 Package() {0x0002ffff, 1, LNKC, 0},
66                 Package() {0x0002ffff, 2, LNKD, 0},
67                 Package() {0x0002ffff, 3, LNKA, 0},
68
69                 // PCI Slot 3
70                 Package() {0x0003ffff, 0, LNKC, 0},
71                 Package() {0x0003ffff, 1, LNKD, 0},
72                 Package() {0x0003ffff, 2, LNKA, 0},
73                 Package() {0x0003ffff, 3, LNKB, 0},
74
75                 // PCI Slot 4
76                 Package() {0x0004ffff, 0, LNKD, 0},
77                 Package() {0x0004ffff, 1, LNKA, 0},
78                 Package() {0x0004ffff, 2, LNKB, 0},
79                 Package() {0x0004ffff, 3, LNKC, 0},
80
81                 // PCI Slot 5
82                 Package() {0x0005ffff, 0, LNKA, 0},
83                 Package() {0x0005ffff, 1, LNKB, 0},
84                 Package() {0x0005ffff, 2, LNKC, 0},
85                 Package() {0x0005ffff, 3, LNKD, 0},
86             })
87
88             Name (_CRS, ResourceTemplate ()
89             {
90                 WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
91                     0x0000,             // Address Space Granularity
92                     0x0000,             // Address Range Minimum
93                     0x00FF,             // Address Range Maximum
94                     0x0000,             // Address Translation Offset
95                     0x0100,             // Address Length
96                     ,, )
97                 IO (Decode16,
98                     0x0CF8,             // Address Range Minimum
99                     0x0CF8,             // Address Range Maximum
100                     0x01,               // Address Alignment
101                     0x08,               // Address Length
102                     )
103                 WordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
104                     0x0000,             // Address Space Granularity
105                     0x0000,             // Address Range Minimum
106                     0x0CF7,             // Address Range Maximum
107                     0x0000,             // Address Translation Offset
108                     0x0CF8,             // Address Length
109                     ,, , TypeStatic)
110                 WordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
111                     0x0000,             // Address Space Granularity
112                     0x0D00,             // Address Range Minimum
113                     0xFFFF,             // Address Range Maximum
114                     0x0000,             // Address Translation Offset
115                     0xF300,             // Address Length
116                     ,, , TypeStatic)
117                 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite,
118                     0x00000000,         // Address Space Granularity
119                     0x000A0000,         // Address Range Minimum
120                     0x000BFFFF,         // Address Range Maximum
121                     0x00000000,         // Address Translation Offset
122                     0x00020000,         // Address Length
123                     ,, , AddressRangeMemory, TypeStatic)
124                 DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
125                     0x00000000,         // Address Space Granularity
126                     0xE0000000,         // Address Range Minimum
127                     0xFEBFFFFF,         // Address Range Maximum
128                     0x00000000,         // Address Translation Offset
129                     0x1EC00000,         // Address Length
130                     ,, , AddressRangeMemory, TypeStatic)
131             })
132         }
133     }
134
135     Scope(\_SB.PCI0) {
136         Device (VGA) {
137                  Name (_ADR, 0x00020000)
138                  Method (_S1D, 0, NotSerialized)
139                  {
140                          Return (0x00)
141                  }
142                  Method (_S2D, 0, NotSerialized)
143                  {
144                          Return (0x00)
145                  }
146                  Method (_S3D, 0, NotSerialized)
147                  {
148                          Return (0x00)
149                  }
150         }
151
152         /* PIIX3 ISA bridge */
153         Device (ISA) {
154             Name (_ADR, 0x00010000)
155
156             /* PIIX PCI to ISA irq remapping */
157             OperationRegion (P40C, PCI_Config, 0x60, 0x04)
158
159             /* Real-time clock */
160             Device (RTC)
161             {
162                 Name (_HID, EisaId ("PNP0B00"))
163                 Name (_CRS, ResourceTemplate ()
164                 {
165                     IO (Decode16, 0x0070, 0x0070, 0x10, 0x02)
166                     IRQNoFlags () {8}
167                     IO (Decode16, 0x0072, 0x0072, 0x02, 0x06)
168                 })
169             }
170
171             /* Keyboard seems to be important for WinXP install */
172             Device (KBD)
173             {
174                 Name (_HID, EisaId ("PNP0303"))
175                 Method (_STA, 0, NotSerialized)
176                 {
177                     Return (0x0f)
178                 }
179
180                 Method (_CRS, 0, NotSerialized)
181                 {
182                      Name (TMP, ResourceTemplate ()
183                      {
184                     IO (Decode16,
185                         0x0060,             // Address Range Minimum
186                         0x0060,             // Address Range Maximum
187                         0x01,               // Address Alignment
188                         0x01,               // Address Length
189                         )
190                     IO (Decode16,
191                         0x0064,             // Address Range Minimum
192                         0x0064,             // Address Range Maximum
193                         0x01,               // Address Alignment
194                         0x01,               // Address Length
195                         )
196                     IRQNoFlags ()
197                         {1}
198                     })
199                     Return (TMP)
200                 }
201             }
202
203             /* PS/2 mouse */
204             Device (MOU)
205             {
206                 Name (_HID, EisaId ("PNP0F13"))
207                 Method (_STA, 0, NotSerialized)
208                 {
209                     Return (0x0f)
210                 }
211
212                 Method (_CRS, 0, NotSerialized)
213                 {
214                     Name (TMP, ResourceTemplate ()
215                     {
216                          IRQNoFlags () {12}
217                     })
218                     Return (TMP)
219                 }
220             }
221
222             /* PS/2 floppy controller */
223             Device (FDC0)
224             {
225                 Name (_HID, EisaId ("PNP0700"))
226                 Method (_STA, 0, NotSerialized)
227                 {
228                     Return (0x0F)
229                 }
230                 Method (_CRS, 0, NotSerialized)
231                 {
232                     Name (BUF0, ResourceTemplate ()
233                     {
234                         IO (Decode16, 0x03F2, 0x03F2, 0x00, 0x04)
235                         IO (Decode16, 0x03F7, 0x03F7, 0x00, 0x01)
236                         IRQNoFlags () {6}
237                         DMA (Compatibility, NotBusMaster, Transfer8) {2}
238                     })
239                     Return (BUF0)
240                 }
241             }
242
243             /* Parallel port */
244             Device (LPT)
245             {
246                 Name (_HID, EisaId ("PNP0400"))
247                 Method (_STA, 0, NotSerialized)
248                 {
249                     Store (\_SB.PCI0.PX13.DRSA, Local0)
250                     And (Local0, 0x80000000, Local0)
251                     If (LEqual (Local0, 0))
252                     {
253                         Return (0x00)
254                     }
255                     Else
256                     {
257                         Return (0x0F)
258                     }
259                 }
260                 Method (_CRS, 0, NotSerialized)
261                 {
262                     Name (BUF0, ResourceTemplate ()
263                     {
264                         IO (Decode16, 0x0378, 0x0378, 0x08, 0x08)
265                         IRQNoFlags () {7}
266                     })
267                     Return (BUF0)
268                 }
269             }
270
271             /* Serial Ports */
272             Device (COM1)
273             {
274                 Name (_HID, EisaId ("PNP0501"))
275                 Name (_UID, 0x01)
276                 Method (_STA, 0, NotSerialized)
277                 {
278                     Store (\_SB.PCI0.PX13.DRSC, Local0)
279                     And (Local0, 0x08000000, Local0)
280                     If (LEqual (Local0, 0))
281                     {
282                         Return (0x00)
283                     }
284                     Else
285                     {
286                         Return (0x0F)
287                     }
288                 }
289                 Method (_CRS, 0, NotSerialized)
290                 {
291                     Name (BUF0, ResourceTemplate ()
292                     {
293                         IO (Decode16, 0x03F8, 0x03F8, 0x00, 0x08)
294                         IRQNoFlags () {4}
295                     })
296                     Return (BUF0)
297                 }
298             }
299
300             Device (COM2)
301             {
302                 Name (_HID, EisaId ("PNP0501"))
303                 Name (_UID, 0x02)
304                 Method (_STA, 0, NotSerialized)
305                 {
306                     Store (\_SB.PCI0.PX13.DRSC, Local0)
307                     And (Local0, 0x80000000, Local0)
308                     If (LEqual (Local0, 0))
309                     {
310                         Return (0x00)
311                     }
312                     Else
313                     {
314                         Return (0x0F)
315                     }
316                 }
317                 Method (_CRS, 0, NotSerialized)
318                 {
319                     Name (BUF0, ResourceTemplate ()
320                     {
321                         IO (Decode16, 0x02F8, 0x02F8, 0x00, 0x08)
322                         IRQNoFlags () {3}
323                     })
324                     Return (BUF0)
325                 }
326             }
327         }
328
329         /* PIIX4 PM */
330         Device (PX13) {
331             Name (_ADR, 0x00010003)
332
333             OperationRegion (P13C, PCI_Config, 0x5c, 0x24)
334             Field (P13C, DWordAcc, NoLock, Preserve)
335             {
336                 DRSA, 32,
337                 DRSB, 32,
338                 DRSC, 32,
339                 DRSE, 32,
340                 DRSF, 32,
341                 DRSG, 32,
342                 DRSH, 32,
343                 DRSI, 32,
344                 DRSJ, 32
345             }
346         }
347     }
348
349     /* PCI IRQs */
350     Scope(\_SB) {
351          Field (\_SB.PCI0.ISA.P40C, ByteAcc, NoLock, Preserve)
352          {
353              PRQ0,   8,
354              PRQ1,   8,
355              PRQ2,   8,
356              PRQ3,   8
357          }
358
359         Device(LNKA){
360                 Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
361                 Name(_UID, 1)
362                 Name(_PRS, ResourceTemplate(){
363                     IRQ (Level, ActiveLow, Shared)
364                         {3,4,5,6,7,9,10,11,12}
365                 })
366                 Method (_STA, 0, NotSerialized)
367                 {
368                     Store (0x0B, Local0)
369                     If (And (0x80, PRQ0, Local1))
370                     {
371                          Store (0x09, Local0)
372                     }
373                     Return (Local0)
374                 }
375                 Method (_DIS, 0, NotSerialized)
376                 {
377                     Or (PRQ0, 0x80, PRQ0)
378                 }
379                 Method (_CRS, 0, NotSerialized)
380                 {
381                     Name (PRR0, ResourceTemplate ()
382                     {
383                         IRQ (Level, ActiveLow, Shared)
384                             {1}
385                     })
386                     CreateWordField (PRR0, 0x01, TMP)
387                     Store (PRQ0, Local0)
388                     If (LLess (Local0, 0x80))
389                     {
390                         ShiftLeft (One, Local0, TMP)
391                     }
392                     Else
393                     {
394                         Store (Zero, TMP)
395                     }
396                     Return (PRR0)
397                 }
398                 Method (_SRS, 1, NotSerialized)
399                 {
400                     CreateWordField (Arg0, 0x01, TMP)
401                     FindSetRightBit (TMP, Local0)
402                     Decrement (Local0)
403                     Store (Local0, PRQ0)
404                 }
405         }
406         Device(LNKB){
407                 Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
408                 Name(_UID, 2)
409                 Name(_PRS, ResourceTemplate(){
410                     IRQ (Level, ActiveLow, Shared)
411                         {3,4,5,6,7,9,10,11,12}
412                 })
413                 Method (_STA, 0, NotSerialized)
414                 {
415                     Store (0x0B, Local0)
416                     If (And (0x80, PRQ1, Local1))
417                     {
418                          Store (0x09, Local0)
419                     }
420                     Return (Local0)
421                 }
422                 Method (_DIS, 0, NotSerialized)
423                 {
424                     Or (PRQ1, 0x80, PRQ1)
425                 }
426                 Method (_CRS, 0, NotSerialized)
427                 {
428                     Name (PRR0, ResourceTemplate ()
429                     {
430                         IRQ (Level, ActiveLow, Shared)
431                             {1}
432                     })
433                     CreateWordField (PRR0, 0x01, TMP)
434                     Store (PRQ1, Local0)
435                     If (LLess (Local0, 0x80))
436                     {
437                         ShiftLeft (One, Local0, TMP)
438                     }
439                     Else
440                     {
441                         Store (Zero, TMP)
442                     }
443                     Return (PRR0)
444                 }
445                 Method (_SRS, 1, NotSerialized)
446                 {
447                     CreateWordField (Arg0, 0x01, TMP)
448                     FindSetRightBit (TMP, Local0)
449                     Decrement (Local0)
450                     Store (Local0, PRQ1)
451                 }
452         }
453         Device(LNKC){
454                 Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
455                 Name(_UID, 3)
456                 Name(_PRS, ResourceTemplate(){
457                     IRQ (Level, ActiveLow, Shared)
458                         {3,4,5,6,7,9,10,11,12}
459                 })
460                 Method (_STA, 0, NotSerialized)
461                 {
462                     Store (0x0B, Local0)
463                     If (And (0x80, PRQ2, Local1))
464                     {
465                          Store (0x09, Local0)
466                     }
467                     Return (Local0)
468                 }
469                 Method (_DIS, 0, NotSerialized)
470                 {
471                     Or (PRQ2, 0x80, PRQ2)
472                 }
473                 Method (_CRS, 0, NotSerialized)
474                 {
475                     Name (PRR0, ResourceTemplate ()
476                     {
477                         IRQ (Level, ActiveLow, Shared)
478                             {1}
479                     })
480                     CreateWordField (PRR0, 0x01, TMP)
481                     Store (PRQ2, Local0)
482                     If (LLess (Local0, 0x80))
483                     {
484                         ShiftLeft (One, Local0, TMP)
485                     }
486                     Else
487                     {
488                         Store (Zero, TMP)
489                     }
490                     Return (PRR0)
491                 }
492                 Method (_SRS, 1, NotSerialized)
493                 {
494                     CreateWordField (Arg0, 0x01, TMP)
495                     FindSetRightBit (TMP, Local0)
496                     Decrement (Local0)
497                     Store (Local0, PRQ2)
498                 }
499         }
500         Device(LNKD){
501                 Name(_HID, EISAID("PNP0C0F"))     // PCI interrupt link
502                 Name(_UID, 4)
503                 Name(_PRS, ResourceTemplate(){
504                     IRQ (Level, ActiveLow, Shared)
505                         {3,4,5,6,7,9,10,11,12}
506                 })
507                 Method (_STA, 0, NotSerialized)
508                 {
509                     Store (0x0B, Local0)
510                     If (And (0x80, PRQ3, Local1))
511                     {
512                          Store (0x09, Local0)
513                     }
514                     Return (Local0)
515                 }
516                 Method (_DIS, 0, NotSerialized)
517                 {
518                     Or (PRQ3, 0x80, PRQ3)
519                 }
520                 Method (_CRS, 0, NotSerialized)
521                 {
522                     Name (PRR0, ResourceTemplate ()
523                     {
524                         IRQ (Level, ActiveLow, Shared)
525                             {1}
526                     })
527                     CreateWordField (PRR0, 0x01, TMP)
528                     Store (PRQ3, Local0)
529                     If (LLess (Local0, 0x80))
530                     {
531                         ShiftLeft (One, Local0, TMP)
532                     }
533                     Else
534                     {
535                         Store (Zero, TMP)
536                     }
537                     Return (PRR0)
538                 }
539                 Method (_SRS, 1, NotSerialized)
540                 {
541                     CreateWordField (Arg0, 0x01, TMP)
542                     FindSetRightBit (TMP, Local0)
543                     Decrement (Local0)
544                     Store (Local0, PRQ3)
545                 }
546         }
547     }
548
549     /*
550      * S3 (suspend-to-ram), S4 (suspend-to-disk) and S5 (power-off) type codes:
551      * must match piix4 emulation.
552      */
553     Name (\_S3, Package (0x04)
554     {
555         0x01,  /* PM1a_CNT.SLP_TYP */
556         0x01,  /* PM1b_CNT.SLP_TYP */
557         Zero,  /* reserved */
558         Zero   /* reserved */
559     })
560     Name (\_S4, Package (0x04)
561     {
562         Zero,  /* PM1a_CNT.SLP_TYP */
563         Zero,  /* PM1b_CNT.SLP_TYP */
564         Zero,  /* reserved */
565         Zero   /* reserved */
566     })
567     Name (\_S5, Package (0x04)
568     {
569         Zero,  /* PM1a_CNT.SLP_TYP */
570         Zero,  /* PM1b_CNT.SLP_TYP */
571         Zero,  /* reserved */
572         Zero   /* reserved */
573     })
574 }