Since some people disapprove of white space cleanups mixed in regular commits
[coreboot.git] / src / mainboard / roda / rk886ex / acpi / platform.asl
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2007-2009 coresystems GmbH
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; version 2 of
9  * the License.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
19  * MA 02110-1301 USA
20  */
21
22 /* These come from the dynamically created CPU SSDT */
23 External(PDC0)
24 External(PDC1)
25
26 /* The APM port can be used for generating software SMIs */
27
28 OperationRegion (APMP, SystemIO, 0xb2, 2)
29 Field (APMP, ByteAcc, NoLock, Preserve)
30 {
31         APMC, 8,        // APM command
32         APMS, 8         // APM status
33 }
34
35 /* Port 80 POST */
36
37 OperationRegion (POST, SystemIO, 0x80, 1)
38 Field (POST, ByteAcc, Lock, Preserve)
39 {
40         DBG0, 8
41 }
42
43 /* SMI I/O Trap */
44 Method(TRAP, 1, Serialized)
45 {
46         Store (Arg0, SMIF)      // SMI Function
47         Store (0, TRP0)         // Generate trap
48         Return (SMIF)           // Return value of SMI handler
49 }
50
51 /* The _PIC method is called by the OS to choose between interrupt
52  * routing via the i8259 interrupt controller or the APIC.
53  *
54  * _PIC is called with a parameter of 0 for i8259 configuration and
55  * with a parameter of 1 for Local Apic/IOAPIC configuration.
56  */
57
58 Method(_PIC, 1)
59 {
60         // Remember the OS' IRQ routing choice.
61         Store(Arg0, PICM)
62 }
63
64 /* The _PTS method (Prepare To Sleep) is called before the OS is
65  * entering a sleep state. The sleep state number is passed in Arg0
66  */
67
68 Method(_PTS,1)
69 {
70         // Call a trap so SMI can prepare for Sleep as well.
71         // TRAP(0x55)
72 }
73
74 /* The _WAK method is called on system wakeup */
75
76 Method(_WAK,1)
77 {
78         // CPU specific part
79
80         // Notify PCI Express slots in case a card
81         // was inserted while a sleep state was active.
82
83         // Are we going to S3?
84         If (LEqual(Arg0, 3)) {
85                 // ..
86         }
87
88         // Are we going to S4?
89         If (LEqual(Arg0, 4)) {
90                 // ..
91         }
92
93         // TODO: Windows XP SP2 P-State restore
94
95         Return(Package(){0,0})
96 }
97
98 // Power notification
99
100 External (\_PR_.CPU0, DeviceObj)
101 External (\_PR_.CPU1, DeviceObj)
102
103 Method (PNOT)
104 {
105         If (MPEN) {
106                 If(And(PDC0, 0x08)) {
107                         Notify (\_PR_.CPU0, 0x80)        // _PPC
108
109                         If (And(PDC0, 0x10)) {
110                                 Sleep(100)
111                                 Notify(\_PR_.CPU0, 0x81) // _CST
112                         }
113                 }
114
115                 If(And(PDC1, 0x08)) {
116                         Notify (\_PR_.CPU1, 0x80)        // _PPC
117                         If (And(PDC1, 0x10)) {
118                                 Sleep(100)
119                                 Notify(\_PR_.CPU1, 0x81) // _CST
120                         }
121                 }
122
123         } Else { // UP
124                 Notify (\_PR_.CPU0, 0x80)
125                 Sleep(0x64)
126                 Notify(\_PR_.CPU0, 0x81)
127         }
128
129         // Notify the Batteries
130         Notify(BAT1, 0x80) // Execute BAT1 _BST
131         Notify(BAT2, 0x80) // Execute BAT2 _BST
132 }
133
134 /* System Bus */
135
136 Scope(\_SB)
137 {
138         /* This method is placed on the top level, so we can make sure it's the
139          * first executed _INI method.
140          */
141         Method(_INI, 0)
142         {
143                 /* The DTS data in NVS is probably not up to date.
144                  * Update temperature values and make sure AP thermal
145                  * interrupts can happen
146                  */
147
148                 // TRAP(71) // TODO
149
150                 /* Determine the Operating System and save the value in OSYS.
151                  * We have to do this in order to be able to work around
152                  * certain windows bugs.
153                  *
154                  *    OSYS value | Operating System
155                  *    -----------+------------------
156                  *       2000    | Windows 2000
157                  *       2001    | Windows XP(+SP1)
158                  *       2002    | Windows XP SP2
159                  *       2006    | Windows Vista
160                  *       ????    | Windows 7
161                  */
162
163                 /* Let's assume we're running at least Windows 2000 */
164                 Store (2000, OSYS)
165
166                 If (CondRefOf(_OSI, Local0)) {
167                         /* Linux answers _OSI with "True" for a couple of
168                          * Windows version queries. But unlike Windows it
169                          * needs a Video repost, so let's determine whether
170                          * we're running Linux.
171                          */
172
173                         If (_OSI("Linux")) {
174                                 Store (1, LINX)
175                         }
176
177                         If (_OSI("Windows 2001")) {
178                                 Store (2001, OSYS)
179                         }
180
181                         If (_OSI("Windows 2001 SP1")) {
182                                 Store (2001, OSYS)
183                         }
184
185                         If (_OSI("Windows 2001 SP2")) {
186                                 Store (2002, OSYS)
187                         }
188
189                         If (_OSI("Windows 2006")) {
190                                 Store (2006, OSYS)
191                         }
192                 }
193
194                 /* And the OS workarounds start right after we know what we're
195                  * running: Windows XP SP1 needs to have C-State coordination
196                  * enabled in SMM.
197                  */
198                 If (LAnd(LEqual(OSYS, 2001), MPEN)) {
199                         // TRAP(61) // TODO
200                 }
201
202                 /* SMM power state and C4-on-C3 settings need to be updated */
203                 // TRAP(43) // TODO
204         }
205 }
206