85a987bae09ee7f36207d9a8a447e6c61564820f
[coreboot.git] / src / mainboard / lenovo / t60 / 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         \_SB.PCI0.LPCB.EC.MUTE(1)
71 }
72
73 /* The _WAK method is called on system wakeup */
74
75 Method(_WAK,1)
76 {
77         // CPU specific part
78
79         // Notify PCI Express slots in case a card
80         // was inserted while a sleep state was active.
81
82         // Are we going to S3?
83         If (LEqual(Arg0, 3)) {
84                 // ..
85         }
86
87         // Are we going to S4?
88         If (LEqual(Arg0, 4)) {
89                 // ..
90         }
91
92         // TODO: Windows XP SP2 P-State restore
93
94         Return(Package(){0,0})
95 }
96
97 // Power notification
98
99 External (\_PR_.CPU0, DeviceObj)
100 External (\_PR_.CPU1, DeviceObj)
101
102 Method (PNOT)
103 {
104         If (MPEN) {
105                 If(And(PDC0, 0x08)) {
106                         Notify (\_PR_.CPU0, 0x80)        // _PPC
107
108                         If (And(PDC0, 0x10)) {
109                                 Sleep(100)
110                                 Notify(\_PR_.CPU0, 0x81) // _CST
111                         }
112                 }
113
114                 If(And(PDC1, 0x08)) {
115                         Notify (\_PR_.CPU1, 0x80)        // _PPC
116                         If (And(PDC1, 0x10)) {
117                                 Sleep(100)
118                                 Notify(\_PR_.CPU1, 0x81) // _CST
119                         }
120                 }
121
122         } Else { // UP
123                 Notify (\_PR_.CPU0, 0x80)
124                 Sleep(0x64)
125                 Notify(\_PR_.CPU0, 0x81)
126         }
127
128         // Notify the Batteries
129         Notify(\_SB.PCI0.LPCB.EC.BAT0, 0x80) // Execute BAT1 _BST
130         Notify(\_SB.PCI0.LPCB.EC.BAT1, 0x80) // Execute BAT2 _BST
131 }
132
133 /* System Bus */
134
135 Scope(\_SB)
136 {
137         /* This method is placed on the top level, so we can make sure it's the
138          * first executed _INI method.
139          */
140         Method(_INI, 0)
141         {
142                 /* The DTS data in NVS is probably not up to date.
143                  * Update temperature values and make sure AP thermal
144                  * interrupts can happen
145                  */
146
147                 // TRAP(71) // TODO
148
149                 /* Determine the Operating System and save the value in OSYS.
150                  * We have to do this in order to be able to work around
151                  * certain windows bugs.
152                  *
153                  *    OSYS value | Operating System
154                  *    -----------+------------------
155                  *       2000    | Windows 2000
156                  *       2001    | Windows XP(+SP1)
157                  *       2002    | Windows XP SP2
158                  *       2006    | Windows Vista
159                  *       ????    | Windows 7
160                  */
161
162                 /* Let's assume we're running at least Windows 2000 */
163                 Store (2000, OSYS)
164
165                 If (CondRefOf(_OSI, Local0)) {
166                         /* Linux answers _OSI with "True" for a couple of
167                          * Windows version queries. But unlike Windows it
168                          * needs a Video repost, so let's determine whether
169                          * we're running Linux.
170                          */
171
172                         If (_OSI("Linux")) {
173                                 Store (1, LINX)
174                         }
175
176                         If (_OSI("Windows 2001")) {
177                                 Store (2001, OSYS)
178                         }
179
180                         If (_OSI("Windows 2001 SP1")) {
181                                 Store (2001, OSYS)
182                         }
183
184                         If (_OSI("Windows 2001 SP2")) {
185                                 Store (2002, OSYS)
186                         }
187
188                         If (_OSI("Windows 2006")) {
189                                 Store (2006, OSYS)
190                         }
191                 }
192
193                 /* And the OS workarounds start right after we know what we're
194                  * running: Windows XP SP1 needs to have C-State coordination
195                  * enabled in SMM.
196                  */
197                 If (LAnd(LEqual(OSYS, 2001), MPEN)) {
198                         // TRAP(61) // TODO
199                 }
200
201                 /* SMM power state and C4-on-C3 settings need to be updated */
202                 // TRAP(43) // TODO
203         }
204 }
205