Add EC component for SMSC MEC1308/1310
[coreboot.git] / src / ec / smsc / mec1308 / acpi / ec.asl
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2011 The Chromium OS Authors. All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program 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
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19
20 /*
21  * The mainboard must define a PNOT method to handle power
22  * state notifications and Notify CPU device objects to
23  * re-evaluate their _PPC and _CST tables.
24  */
25
26 Device (EC0)
27 {
28         Name (_HID, EISAID ("PNP0C09"))
29         Name (_UID, 1)
30         Name (_GPE, EC_GPE)     // GPE for Runtime SCI
31
32         OperationRegion (ERAM, EmbeddedControl, 0x00, 0xff)
33         Field (ERAM, ByteAcc, Lock, Preserve)
34         {
35                 Offset (0x80),
36                 BTEX, 1,                // Battery Exists
37                 , 1,
38                 ACEX, 1,                // AC Exists
39                 , 5,
40                 Offset (0x83),
41                 LIDS, 1,                // Lid Switch State
42                 , 7,
43                 BTST, 8,                // Battery State
44                 Offset (0xA2),
45                 BTRA, 16,               // Battery Remaining Capacity
46                 BTPR, 16,               // Battery Present Rate
47                 BTVO, 16,               // Battery Present Voltage
48                 Offset (0xB0),
49                 BTDA, 16,               // Battery Design Capacity
50                 BTDF, 16,               // Battery Last Full Charge Capacity
51                 BTDV, 16,               // Battery Design Voltage
52                 BTDL, 16,               // Battery Design Low
53                 Offset (0xC0),
54                 CPUT, 8,                // CPU Temperature
55                 Offset (0xCA),
56                 FSL0, 1,                // Fan Speed Level 0
57                 FSL1, 1,                // Fan Speed Level 1
58                 FSL2, 1,                // Fan Speed Level 2
59                 FSL3, 1,                // Fan Speed Level 3
60                 FSL4, 1,                // Fan Speed Level 4
61                 , 2,
62                 FCOS, 1,                // Fan Speed OS Control
63         }
64
65         Method (_CRS, 0, NotSerialized)
66         {
67                 Name (ECMD, ResourceTemplate()
68                 {
69                         IO (Decode16, 0x62, 0x62, 0, 1)
70                         IO (Decode16, 0x66, 0x66, 0, 1)
71                 })
72                 Return (ECMD)
73         }
74
75         Method (_REG, 2, NotSerialized)
76         {
77                 // Initialize AC power state
78                 Store (ACEX, \PWRS)
79
80                 // Initialize LID switch state
81                 Store (LIDS, \LIDS)
82
83                 // Enable OS control of fan speed
84                 Store (One, FCOS)
85
86                 // Force a read of CPU temperature
87                 Store (CPUT, Local0)
88         }
89
90         PowerResource (FNP0, 0, 0)
91         {
92                 Method (_STA) { Return (FSL0) }
93                 Method (_ON)  {
94                         If (FCOS) {
95                                 Store (One, FSL0)
96                                 Store (0, \FLVL)
97                                 Notify (\_TZ.THRM, 0x81)
98                         }
99                 }
100                 Method (_OFF) {
101                         If (FCOS) {
102                                 Store (Zero, FSL0)
103                                 Store (1, \FLVL)
104                                 Notify (\_TZ.THRM, 0x81)
105                         }
106                 }
107         }
108
109         PowerResource (FNP1, 0, 0)
110         {
111                 Method (_STA) { Return (FSL1) }
112                 Method (_ON)  {
113                         If (FCOS) {
114                                 Store (One, FSL1)
115                                 Store (1, \FLVL)
116                                 Notify (\_TZ.THRM, 0x81)
117                         }
118                 }
119                 Method (_OFF) {
120                         If (FCOS) {
121                                 Store (Zero, FSL1)
122                                 Store (2, \FLVL)
123                                 Notify (\_TZ.THRM, 0x81)
124                         }
125                 }
126         }
127
128         PowerResource (FNP2, 0, 0)
129         {
130                 Method (_STA) { Return (FSL2) }
131                 Method (_ON)  {
132                         If (FCOS) {
133                                 Store (One, FSL2)
134                                 Store (2, \FLVL)
135                                 Notify (\_TZ.THRM, 0x81)
136                         }
137                 }
138                 Method (_OFF) {
139                         If (FCOS) {
140                                 Store (Zero, FSL2)
141                                 Store (3, \FLVL)
142                                 Notify (\_TZ.THRM, 0x81)
143                         }
144                 }
145         }
146
147         PowerResource (FNP3, 0, 0)
148         {
149                 Method (_STA) { Return (FSL3) }
150                 Method (_ON)  {
151                         If (FCOS) {
152                                 Store (One, FSL3)
153                                 Store (3, \FLVL)
154                                 Notify (\_TZ.THRM, 0x81)
155                         }
156                 }
157                 Method (_OFF) {
158                         If (FCOS) {
159                                 Store (Zero, FSL3)
160                                 Store (4, \FLVL)
161                                 Notify (\_TZ.THRM, 0x81)
162                         }
163                 }
164         }
165
166         PowerResource (FNP4, 0, 0)
167         {
168                 Method (_STA) { Return (FSL4) }
169                 Method (_ON)  {
170                         If (FCOS) {
171                                 Store (One, FSL4)
172                                 Store (4, \FLVL)
173                                 Notify (\_TZ.THRM, 0x81)
174                         }
175                 }
176                 Method (_OFF) {
177                         If (FCOS) {
178                                 Store (Zero, FSL4)
179                                 Store (5, \FLVL)
180                                 Notify (\_TZ.THRM, 0x81)
181                         }
182                 }
183         }
184
185         Device (FAN0)
186         {
187                 Name (_HID, EISAID ("PNP0C0B"))
188                 Name (_UID, 0)
189                 Name (_PR0, Package () { FNP0 })
190         }
191
192         Device (FAN1)
193         {
194                 Name (_HID, EISAID ("PNP0C0B"))
195                 Name (_UID, 1)
196                 Name (_PR0, Package () { FNP1 })
197         }
198
199         Device (FAN2)
200         {
201                 Name (_HID, EISAID ("PNP0C0B"))
202                 Name (_UID, 2)
203                 Name (_PR0, Package () { FNP2 })
204         }
205
206         Device (FAN3)
207         {
208                 Name (_HID, EISAID ("PNP0C0B"))
209                 Name (_UID, 3)
210                 Name (_PR0, Package () { FNP3 })
211         }
212
213         Device (FAN4)
214         {
215                 Name (_HID, EISAID ("PNP0C0B"))
216                 Name (_UID, 4)
217                 Name (_PR0, Package () { FNP4 })
218         }
219
220         // AC Power Connected
221         Method (_Q51, 0, NotSerialized)
222         {
223                 Store (One, \PWRS)
224                 Notify (AC, 0x80)
225                 \PNOT ()
226         }
227
228         // AC Power Removed
229         Method (_Q52, 0, NotSerialized)
230         {
231                 Store (Zero, \PWRS)
232                 Notify (AC, 0x80)
233                 \PNOT ()
234         }
235
236         // Battery State Change
237         Method (_Q53, 0, NotSerialized)
238         {
239                 Notify (BAT0, 0x80)
240                 Notify (BAT0, 0x81)
241         }
242
243         // Battery State Change
244         Method (_Q54, 0, NotSerialized)
245         {
246                 Notify (BAT0, 0x80)
247                 Notify (BAT0, 0x81)
248         }
249
250         // Power State Change
251         Method (_Q55, 0, NotSerialized)
252         {
253                 \PNOT ()
254         }
255
256         // Lid Switch Event
257         Method (_Q5E, 0, NotSerialized)
258         {
259                 Store (LIDS, \LIDS)
260                 Notify (\_SB.LID0, 0x80)
261         }
262
263         // Lid Switch Event
264         Method (_Q5F, 0, NotSerialized)
265         {
266                 Store (LIDS, \LIDS)
267                 Notify (\_SB.LID0, 0x80)
268         }
269
270         #include "ac.asl"
271         #include "battery.asl"
272 }