Remove whitespace.
[coreboot.git] / src / mainboard / getac / p470 / 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 /* The APM port can be used for generating software SMIs */
23
24 OperationRegion (APMP, SystemIO, 0xb2, 2)
25 Field (APMP, ByteAcc, NoLock, Preserve)
26 {
27         APMC, 8,        // APM command
28         APMS, 8         // APM status
29 }
30
31 /* Port 80 POST */
32
33 OperationRegion (POST, SystemIO, 0x80, 1)
34 Field (POST, ByteAcc, Lock, Preserve)
35 {
36         DBG0, 8
37 }
38
39 /* SMI I/O Trap */
40 Method(TRAP, 1, Serialized)
41 {
42         Store (Arg0, SMIF)      // SMI Function
43         Store (0, TRP0)         // Generate trap
44         Return (SMIF)           // Return value of SMI handler
45 }
46
47 /* SMI Function Trap */
48 OperationRegion(SMI1, SystemMemory, 0xC0DEDEAD, 0x100)
49 Field(SMI1, AnyAcc, NoLock, Preserve)
50 {
51         BCMD,  8,
52         DID,  32,
53         INFO, 1024
54 }
55
56 /* The _PIC method is called by the OS to choose between interrupt
57  * routing via the i8259 interrupt controller or the APIC.
58  *
59  * _PIC is called with a parameter of 0 for i8259 configuration and
60  * with a parameter of 1 for Local Apic/IOAPIC configuration.
61  */
62
63 Method(_PIC, 1)
64 {
65         // Remember the OS' IRQ routing choice.
66         Store(Arg0, PICM)
67 }
68
69 /* The _PTS method (Prepare To Sleep) is called before the OS is
70  * entering a sleep state. The sleep state number is passed in Arg0
71  */
72
73 Method(_PTS,1)
74 {
75         TRAP(0xed)
76         Sleep(1000)
77
78         Store(0, \_SB.ACFG)
79
80         // Are we going to S3?
81         If (LEqual(Arg0, 3)) {
82                 Store (0x4c, BCMD)
83         }
84
85         // Are we going to S4?
86         If (Lequal(Arg0, 4)) {
87                 TRAP(0xe7)
88                 TRAP(0xea)
89         }
90
91         // Are we going to S5?
92         If (Lequal(Arg0, 5)) {
93                 Store (0x4b, BCMD)
94                 TRAP(0xde)
95         }
96
97         // The 2.6.12.5 ACPI engine seems to optimize the
98         // If(LEqual(Arg0, 5)) path away. This keeps it from doing so:
99         TRAP(Arg0)
100         Store(Arg0, DBG0)
101         // End of ugly OS bug workaround
102 }
103
104 /* The _WAK method is called on system wakeup */
105
106 Method(_WAK,1)
107 {
108         // Enable GPS
109         Store (1, GP11) // GPSE
110
111         // Wake from S3 or S4?
112         If (LOr(LEqual(Arg0, 3), LEqual(Arg0, 4))) {
113                 If (And(CFGD, 0x01000000)) {
114                         If (LAnd(And(CFGD, 0xf0), LEqual(OSYS, 2001))) {
115                                 TRAP(0x3d)
116                         }
117                 }
118         }
119
120         // Notify PCI Express slots in case a card
121         // was inserted while a sleep state was active.
122
123         If (LEqual(RP1D, 0)) {
124                 Notify(\_SB.PCI0.RP01, 0)
125         }
126
127         If (LEqual(RP3D, 0)) {
128                 Notify(\_SB.PCI0.RP03, 0)
129         }
130
131         If (LEqual(RP4D, 0)) {
132                 Notify(\_SB.PCI0.RP04, 0)
133         }
134
135         // Are we coming from S3?
136         If (LEqual(Arg0, 3)) {
137                 TRAP(0xeb)
138                 TRAP(0x46)
139         }
140
141         // Are we coming from S4?
142         If (LEqual(Arg0, 4)) {
143                 Notify(SLPB, 0x02)
144                 If (DTSE) {
145                         TRAP(0x47)
146                 }
147         }
148
149         // Windows XP SP2 P-State restore
150         If (LAnd(LEqual(OSYS, 2002), And(CFGD, 1))) {
151                 If (LGreater(\_PR.CPU0._PPC, 0)) {
152                         Subtract(\_PR.CPU0._PPC, 1, \_PR.CPU0._PPC)
153                         PNOT()
154                         Add(\_PR.CPU0._PPC, 1, \_PR.CPU0._PPC)
155                         PNOT()
156                 } Else {
157                         Add(\_PR.CPU0._PPC, 1, \_PR.CPU0._PPC)
158                         PNOT()
159                         Subtract(\_PR.CPU0._PPC, 1, \_PR.CPU0._PPC)
160                         PNOT()
161                 }
162         }
163
164         Return(Package(){0,0})
165 }
166
167 // Power notification
168
169 External (\_PR_.CPU0, DeviceObj)
170 External (\_PR_.CPU1, DeviceObj)
171 External (\_PR_.CPU0._PPC)
172 External (\_PR_.CPU1._PPC)
173 /* These come from the dynamically created CPU SSDT */
174 External(PDC0)
175 External(PDC1)
176
177 Method (PNOT)
178 {
179         If (MPEN) {
180                 If(And(PDC0, 0x08)) {
181                         Notify (\_PR_.CPU0, 0x80)        // _PPC
182
183                         If (And(PDC0, 0x10)) {
184                                 Sleep(100)
185                                 Notify(\_PR_.CPU0, 0x81) // _CST
186                         }
187                 }
188
189                 If(And(PDC1, 0x08)) {
190                         Notify (\_PR_.CPU1, 0x80)        // _PPC
191                         If (And(PDC1, 0x10)) {
192                                 Sleep(100)
193                                 Notify(\_PR_.CPU1, 0x81) // _CST
194                         }
195                 }
196
197         } Else { // UP
198                 Notify (\_PR_.CPU0, 0x80)
199                 Sleep(0x64)
200                 Notify(\_PR_.CPU0, 0x81)
201         }
202
203         // Notify the Batteries
204         Notify(\_SB.BAT0, 0x80) // Execute BAT0 _BST
205         Notify(\_SB.BAT1, 0x80) // Execute BAT1 _BST
206 }
207
208 // Hardcoded for now..
209 Name (CFGD, 0x113B69F1)
210
211 /* System Bus */
212
213 Scope(\_SB)
214 {
215         /* This method is placed on the top level, so we can make sure it's the
216          * first executed _INI method.
217          */
218         Method(_INI, 0)
219         {
220                 /* The DTS data in NVS is probably not up to date.
221                  * Update temperature values and make sure AP thermal
222                  * interrupts can happen
223                  */
224                 If (DTSE) {
225                         TRAP(0x47)
226                 }
227
228                 /* Determine the Operating System and save the value in OSYS.
229                  * We have to do this in order to be able to work around
230                  * certain windows bugs.
231                  *
232                  *    OSYS value | Operating System
233                  *    -----------+------------------
234                  *       2000    | Windows 2000
235                  *       2001    | Windows XP(+SP1)
236                  *       2002    | Windows XP SP2
237                  *       2006    | Windows Vista
238                  *       ????    | Windows 7
239                  */
240
241                 /* Let's assume we're running at least Windows 2000 */
242                 Store (2000, OSYS)
243
244                 If (CondRefOf(_OSI, Local0)) {
245                         /* Linux answers _OSI with "True" for a couple of
246                          * Windows version queries. But unlike Windows it
247                          * needs a Video repost, so let's determine whether
248                          * we're running Linux.
249                          */
250
251                         If (_OSI("Linux")) {
252                                 Store (1, LINX)
253                         }
254
255                         If (_OSI("Windows 2001")) {
256                                 Store (2001, OSYS)
257                         }
258
259                         If (_OSI("Windows 2001 SP1")) {
260                                 Store (2001, OSYS)
261                         }
262
263                         If (_OSI("Windows 2001 SP2")) {
264                                 Store (2002, OSYS)
265                         }
266
267                         If (_OSI("Windows 2006")) {
268                                 Store (2006, OSYS)
269                         }
270                 }
271
272                 /* And the OS workarounds start right after we know what we're
273                  * running: Windows XP SP1 needs to have C-State coordination
274                  * enabled in SMM.
275                  */
276                 If (LAnd(LEqual(OSYS, 2001), MPEN)) {
277                         TRAP(0x3d)
278                 }
279
280                 /* SMM power state and C4-on-C3 settings need to be updated */
281                 // TRAP(43)
282
283                 /* OS Init */
284                 TRAP(0x32)
285         }
286 }
287