Since some people disapprove of white space cleanups mixed in regular commits
[coreboot.git] / src / mainboard / roda / rk886ex / acpi / superio.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 /* SMSC LPC47N227 */
23
24 Device (SIO1)
25 {
26         Name (_HID, EISAID("PNP0A05"))
27         Name (_UID, 1)
28
29         OperationRegion(SIOR, SystemIO, 0x2e, 0x02)
30         Field (SIOR, ByteAcc, Nolock, Preserve)
31         {
32                 INDX,   8,
33                 DATA,   8
34         }
35
36         Mutex (SIOM, 0x00)
37
38         Method (READ, 3)
39         {
40                 Acquire (SIOM, 0xffff)
41                 If (LEqual(Arg0, 0)) {
42                         Store (0x55, INDX)
43                         Store (Arg1, INDX)
44                         Store (DATA, Local1)
45                         Store (0xaa, INDX)
46                 }
47                 And (Local1, Arg2, Local1)
48                 Release(SIOM)
49                 Return(Local1)
50         }
51
52         Method (WRIT, 3)
53         {
54                 Acquire (SIOM, 0xffff)
55                 If (LEqual(Arg0, 0)) {
56                         Store (0x55, INDX)
57                         Store (Arg1, INDX)
58                         Store (Arg2, DATA)
59                         Store (0xaa, INDX)
60                 }
61                 Release(SIOM)
62         }
63
64         Device (COMA)
65         {
66                 Name(_HID, EISAID("PNP0501"))
67                 Name(_UID, 1)
68                 Name(_PRW, Package() { 0x08, 0x03 })
69
70                 /* Device Status */
71                 Method (_STA, 0)
72                 {
73                         // Device disabled by coreboot?
74                         If (LEqual(CMAP, 0)) {
75                                 Return (0)
76                         }
77
78                         // Is the hardware enabled?
79                         Store (READ(0, 0x24, 0xff), Local0)
80                         If (LEqual(Local0, 0)) {
81                                 Return (0xd)
82                         } Else {
83                                 // Power Enabled?
84                                 Store (READ(0, 0x02, 0x08), Local0)
85                                 If (LEqual(Local0, 0)) {
86                                         Return (0x0d)
87                                 } Else {
88                                         Return (0x0f)
89                                 }
90                         }
91                 }
92
93                 /* Device Disable */
94                 Method (_DIS, 0)
95                 {
96                         WRIT(0, 0x24, 0x00)
97
98                         Store(READ(0, 0x28, 0x0f), Local0)
99                         WRIT(0, 0x28, Local0)
100
101                         Store(READ(0, 0x02, 0xff), Local0)
102                         Not(0x08, Local1)
103                         And(Local0, Local1, Local0)
104                         WRIT(0, 0x02, Local0)
105                 }
106
107                 /* Possible Resource Settings */
108                 Name(_PRS, ResourceTemplate() {
109                         StartDependentFn(0, 1) {
110                                 IO(Decode16, 0x3f8, 0x3f8, 0x8, 0x8)
111                                 IRQNoFlags() { 4 }
112                         } EndDependentFn()
113                 })
114
115                 /* Current Resource Settings */
116                 Method(_CRS, 0)
117                 {
118                         Name(NONE, ResourceTemplate() {
119                                 IO(Decode16, 0x000, 0x000, 0x0, 0x0)
120                                 IRQNoFlags() { }
121                         })
122
123                         Name(RSRC, ResourceTemplate() {
124                                 IO(Decode16, 0x3f8, 0x3f8, 0x8, 0x8, _IOA)
125                                 IRQNoFlags(_IRA) { 4 }
126                         })
127
128                         And (_STA(), 0x02, Local0)
129                         If (LEqual(Local0, 0)) {
130                                 Return(NONE)
131                         }
132
133                         CreateByteField(RSRC,
134                                 \_SB.PCI0.LPCB.SIO1.COMA._CRS._IOA._MIN, IOLO)
135                         CreateByteField(RSRC, 0x03, IOHI) // Why?
136                         CreateByteField(RSRC,
137                                 \_SB.PCI0.LPCB.SIO1.COMA._CRS._IOA._MAX, IORL)
138                         CreateByteField(RSRC, 0x05, IORH) // Why?
139                         CreateByteField(RSRC,
140                                 \_SB.PCI0.LPCB.SIO1.COMA._CRS._IRA._INT, IRQL)
141
142                         Store (READ(0, 0x24, 0xff), Local0)
143                         And (Local0, 0xc0, Local1)
144                         ShiftRight(Local1, 0x06, Local1)
145                         ShiftLeft(Local0, 0x02, Local0)
146                         Store(Local0, IOLO)
147                         Store(Local1, IOHI)
148                         Store(IOLO, IORL)
149                         Store(IOHI, IORH)
150
151                         /* Interrupt */
152                         Store(READ(0, 0x28, 0xf0), Local0)
153                         ShiftRight(Local0, 4, Local0)
154                         ShiftLeft(1, Local0, IRQL)
155                         Return(RSRC)
156                 }
157
158                 /* Set Resource Settings */
159                 Method(_SRS, 1)
160                 {
161                         CreateByteField(Arg0, 0x02, IOLO)
162                         CreateByteField(Arg0, 0x03, IOHI)
163                         CreateByteField(Arg0, 0x09, IRQL)
164
165                         WRIT(0, 0x24, 0)
166                         FindSetRightBit(IRQL, Local0)
167                         Decrement(Local0)
168                         ShiftLeft(Local0, 4, Local0)
169
170                         Store(READ(0, 0x28, 0x0f), Local1)
171                         Or(Local0, Local1, Local0)
172                         WRIT(0, 0x28, Local0)
173
174                         Store(IOLO, Local0)
175                         ShiftRight(Local0, 2, Local0)
176                         And(Local0, 0xfe, Local0)
177
178                         Store(IOHI, Local1)
179                         ShiftLeft(Local1, 6, Local1)
180                         Or (Local0, Local1, Local0)
181                         WRIT(0, 0x24, Local0)
182
183                         Store(READ(0, 0x02, 0xff), Local0)
184                         Or(Local0, 0x08, Local0)
185                         WRIT(0, 0x02, Local0)
186
187                         Store(READ(0, 0x07, 0xff), Local0)
188                         Not(0x40, Local1)
189                         And (Local0, Local1, Local0)
190                         WRIT(0, 0x07, Local0)
191                 }
192
193
194                 /* D0 state - Line drivers are on */
195                 Method (_PS0, 0)
196                 {
197                         Store(READ(0, 0x02, 0xff), Local0)
198                         Or(Local0, 0x08, Local0)
199                         WRIT(0, 0x02, Local0)
200
201                         Store (READ(0, 0x07, 0xff), Local0)
202                         Not(0x40, Local1)
203                         And(Local0, Local1, Local0)
204                         WRIT(0, 0x07, Local0)
205                 }
206
207                 /* D3 State - Line drivers are off */
208                 Method(_PS3, 0)
209                 {
210                         Store(READ(0, 0x02, 0xff), Local0)
211                         Not(0x08, Local1)
212                         And(Local0, Local1, Local0)
213                         WRIT(0, 0x02, Local0)
214                 }
215         }
216
217         Device (COMB)
218         {
219                 Name(_HID, EISAID("PNP0501"))
220                 Name(_UID, 2)
221                 Name(_PRW, Package() { 0x08, 0x03 })
222
223                 /* Device Status */
224                 Method (_STA, 0)
225                 {
226                         // Device disabled by coreboot?
227                         If (LEqual(CMBP, 0)) {
228                                 Return (0)
229                         }
230
231                         /* IRDA? */
232                         Store(READ(0, 0x0c, 0x38), Local0)
233                         If (LNotEqual(Local0, Zero)) {
234                                 Return (0)
235                         }
236
237                         // Is the hardware enabled?
238                         Store (READ(0, 0x25, 0xff), Local0)
239                         If (LEqual(Local0, 0)) {
240                                 Return (0xd)
241                         } Else {
242                                 // Power Enabled?
243                                 Store (READ(0, 0x02, 0x80), Local0)
244                                 If (LEqual(Local0, 0)) {
245                                         Return (0x0d)
246                                 } Else {
247                                         Return (0x0f)
248                                 }
249                         }
250                 }
251
252                 /* Device Disable */
253                 Method (_DIS, 0)
254                 {
255                         WRIT(0, 0x25, 0x00)
256
257                         Store(READ(0, 0x28, 0xf0), Local0)
258                         WRIT(0, 0x28, Local0)
259
260                         Store(READ(0, 0x02, 0xff), Local0)
261                         Not(0x80, Local1)
262                         And(Local0, Local1, Local0)
263                         WRIT(0, 0x02, Local0)
264                 }
265
266                 /* Possible Resource Settings */
267                 Name(_PRS, ResourceTemplate() {
268                         StartDependentFn(0, 1) {
269                                 IO(Decode16, 0x2f8, 0x2f8, 0x8, 0x8)
270                                 IRQNoFlags() { 3 }
271                         } EndDependentFn()
272                 })
273
274                 /* Current Resource Settings */
275                 Method(_CRS, 0)
276                 {
277                         Name(NONE, ResourceTemplate() {
278                                 IO(Decode16, 0x000, 0x000, 0x0, 0x0)
279                                 IRQNoFlags() { }
280                         })
281
282                         Name(RSRC, ResourceTemplate() {
283                                 IO(Decode16, 0x2f8, 0x2f8, 0x8, 0x8, _IOB)
284                                 IRQNoFlags(_IRB) { 3 }
285                         })
286
287                         And (_STA(), 0x02, Local0)
288                         If (LEqual(Local0, 0)) {
289                                 Return(NONE)
290                         }
291
292                         CreateByteField(RSRC,
293                                 \_SB.PCI0.LPCB.SIO1.COMB._CRS._IOB._MIN, IOLO)
294                         CreateByteField(RSRC, 0x03, IOHI)
295                         CreateByteField(RSRC,
296                                 \_SB.PCI0.LPCB.SIO1.COMB._CRS._IOB._MAX, IORL)
297                         CreateByteField(RSRC, 0x05, IORH)
298                         CreateByteField(RSRC,
299                                 \_SB.PCI0.LPCB.SIO1.COMB._CRS._IRB._INT, IRQL)
300
301                         Store (READ(0, 0x25, 0xff), Local0)
302                         And (Local0, 0xc0, Local1)
303                         ShiftRight(Local1, 0x06, Local1)
304                         ShiftLeft(Local0, 0x02, Local0)
305                         Store(Local0, IOLO)
306                         Store(Local1, IOHI)
307                         Store(IOLO, IORL)
308                         Store(IOHI, IORH)
309
310                         /* Interrupt */
311                         Store(READ(0, 0x28, 0x0f), Local0)
312                         ShiftRight(Local0, 4, Local0)
313                         ShiftLeft(1, Local0, IRQL)
314                         Return(RSRC)
315                 }
316
317                 /* Set Resource Settings */
318                 Method(_SRS, 1)
319                 {
320                         CreateByteField(Arg0, 0x02, IOLO)
321                         CreateByteField(Arg0, 0x03, IOHI)
322                         CreateByteField(Arg0, 0x09, IRQL)
323
324                         WRIT(0, 0x25, 0)
325                         FindSetRightBit(IRQL, Local0)
326                         Decrement(Local0)
327
328                         Store(READ(0, 0x28, 0xf0), Local1)
329                         Or(Local0, Local1, Local0)
330                         WRIT(0, 0x28, Local0)
331
332                         Store(IOLO, Local0)
333                         ShiftRight(Local0, 2, Local0)
334                         And(Local0, 0xfe, Local0)
335
336                         Store(IOHI, Local1)
337                         ShiftLeft(Local1, 6, Local1)
338                         Or (Local0, Local1, Local0)
339                         WRIT(0, 0x25, Local0)
340
341                         Store(READ(0, 0x0c, 0xff), Local0)
342                         Not(0x38, Local1)
343                         And(Local0, Local1, Local0)
344                         WRIT(0, 0x0c, Local0)
345
346                         Store(READ(0, 0x02, 0xff), Local0)
347                         Or(Local0, 0x80, Local0)
348                         WRIT(0, 0x02, Local0)
349
350                         Store(READ(0, 0x07, 0xff), Local0)
351                         Not(0x20, Local1)
352                         And (Local0, Local1, Local0)
353                         WRIT(0, 0x07, Local0)
354                 }
355
356                 /* D0 state - Line drivers are on */
357                 Method (_PS0, 0)
358                 {
359                         Store(READ(0, 0x02, 0xff), Local0)
360                         Or(Local0, 0x80, Local0)
361                         WRIT(0, 0x02, Local0)
362
363                         Store (READ(0, 0x07, 0xff), Local0)
364                         Not(0x20, Local1)
365                         And(Local0, Local1, Local0)
366                         WRIT(0, 0x07, Local0)
367                 }
368
369                 /* D3 State - Line drivers are off */
370                 Method(_PS3, 0)
371                 {
372                         Store(READ(0, 0x02, 0xff), Local0)
373                         Not(0x80, Local1)
374                         And(Local0, Local1, Local0)
375                         WRIT(0, 0x02, Local0)
376                 }
377         }
378 }
379