payloads/edk2: Disable the CPU Timer Lib unless supported
[coreboot.git] / src / mainboard / roda / rk9 / acpi / superio.asl
blobd9f6ac0a8aa8b7a70eb0f30e457fda5144508fe2
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 /* SMSC LPC47N227 */
5 Device (SIO1)
7         Name (_HID, EISAID("PNP0A05"))
8         Name (_UID, 1)
10         OperationRegion(SIOR, SystemIO, 0x2e, 0x02)
11         Field (SIOR, ByteAcc, Nolock, Preserve)
12         {
13                 INDX,   8,
14                 DATA,   8
15         }
17         Mutex (SIOM, 0x00)
19         Method (READ, 3)
20         {
21                 Acquire (SIOM, 0xffff)
22                 If (Arg0 == 0) {
23                         INDX = 0x55
24                         INDX = Arg1
25                         Local1 = DATA
26                         INDX = 0xaa
27                 }
28                 Local1 &= Arg2
29                 Release(SIOM)
30                 Return(Local1)
31         }
33         Method (WRIT, 3)
34         {
35                 Acquire (SIOM, 0xffff)
36                 If (Arg0 == 0) {
37                         INDX = 0x55
38                         INDX = Arg1
39                         DATA = Arg2
40                         INDX = 0xaa
41                 }
42                 Release(SIOM)
43         }
45         Device (COMA)
46         {
47                 Name(_HID, EISAID("PNP0501"))
48                 Name(_UID, 1)
49                 Name(_PRW, Package() { 0x08, 0x03 })
51                 /* Device Status */
52                 Method (_STA, 0)
53                 {
54                         // Device disabled by coreboot?
55                         If (CMAP == 0) {
56                                 Return (0)
57                         }
59                         // Is the hardware enabled?
60                         Local0 = READ (0, 0x24, 0xff)
61                         If (Local0 == 0) {
62                                 Return (0xd)
63                         } Else {
64                                 // Power Enabled?
65                                 Local0 = READ (0, 0x02, 0x08)
66                                 If (Local0 == 0) {
67                                         Return (0x0d)
68                                 } Else {
69                                         Return (0x0f)
70                                 }
71                         }
72                 }
74                 /* Device Disable */
75                 Method (_DIS, 0)
76                 {
77                         WRIT(0, 0x24, 0x00)
79                         Local0 = READ (0, 0x28, 0x0f)
80                         WRIT(0, 0x28, Local0)
82                         Local0 = READ(0, 0x02, 0xff)
83                         Local1 = ~0x08
84                         Local0 &= Local1
85                         WRIT(0, 0x02, Local0)
86                 }
88                 /* Possible Resource Settings */
89                 Name(_PRS, ResourceTemplate() {
90                         StartDependentFn(0, 1) {
91                                 IO(Decode16, 0x3f8, 0x3f8, 0x8, 0x8)
92                                 IRQNoFlags() { 4 }
93                         } EndDependentFn()
94                 })
96                 /* Current Resource Settings */
97                 Method(_CRS, 0)
98                 {
99                         Name(NONE, ResourceTemplate() {
100                                 IO(Decode16, 0x000, 0x000, 0x0, 0x1)
101                                 IRQNoFlags() { }
102                         })
104                         Name(RSRC, ResourceTemplate() {
105                                 IO(Decode16, 0x3f8, 0x3f8, 0x8, 0x8, _IOA)
106                                 IRQNoFlags(_IRA) { 4 }
107                         })
109                         Local0 = _STA() & 0x02
110                         If (Local0 == 0) {
111                                 Return(NONE)
112                         }
114                         CreateWordField(RSRC,
115                                 \_SB.PCI0.LPCB.SIO1.COMA._CRS._IOA._MIN, IOMN)
116                         CreateWordField(RSRC,
117                                 \_SB.PCI0.LPCB.SIO1.COMA._CRS._IOA._MAX, IOMX)
118                         CreateWordField(RSRC,
119                                 \_SB.PCI0.LPCB.SIO1.COMA._CRS._IRA._INT, IRQ)
121                         /* I/O Base */
122                         Local0 = READ (0, 0x24, 0xfe)
123                         Local0 <<= 2
124                         IOMN = Local0
125                         IOMX = Local0
127                         /* Interrupt */
128                         Local0 = READ (0, 0x28, 0xf0)
129                         Local0 >>= 4
130                         IRQ = 1 << Local0
131                         Return(RSRC)
132                 }
134                 /* Set Resource Settings */
135                 Method(_SRS, 1)
136                 {
137                         CreateByteField(Arg0, 0x02, IOLO)
138                         CreateByteField(Arg0, 0x03, IOHI)
139                         CreateByteField(Arg0, 0x09, IRQL)
141                         WRIT(0, 0x24, 0)
142                         FindSetRightBit(IRQL, Local0)
143                         Local0--
144                         Local0 <<= 4
146                         Local1 = READ (0, 0x28, 0x0f)
147                         Local0 |= Local1
148                         WRIT(0, 0x28, Local0)
150                         Local0 = IOLO
151                         Local0 >>= 2
152                         Local0 &= 0xfe
154                         Local1 = IOHI
155                         Local1 <<= 6
156                         Local0 |= Local1
157                         WRIT(0, 0x24, Local0)
159                         Local0 = READ(0, 0x02, 0xff)
160                         Local0 |= 0x08
161                         WRIT(0, 0x02, Local0)
163                         Local0 = READ (0, 0x07, 0xff)
164                         Local1 = ~0x40
165                         Local0 &= Local1
166                         WRIT(0, 0x07, Local0)
167                 }
170                 /* D0 state - Line drivers are on */
171                 Method (_PS0, 0)
172                 {
173                         Local0 = READ(0, 0x02, 0xff)
174                         Local0 |= 0x08
175                         WRIT(0, 0x02, Local0)
177                         Local0 = READ (0, 0x07, 0xff)
178                         Local1 = ~0x40
179                         Local0 &= Local1
180                         WRIT(0, 0x07, Local0)
181                 }
183                 /* D3 State - Line drivers are off */
184                 Method(_PS3, 0)
185                 {
186                         Local0 = READ(0, 0x02, 0xff)
187                         Local1 = ~0x08
188                         Local0 &= Local1
189                         WRIT(0, 0x02, Local0)
190                 }
191         }
193         Device (COMB)
194         {
195                 Name(_HID, EISAID("PNP0501"))
196                 Name(_UID, 2)
197                 Name(_PRW, Package() { 0x08, 0x03 })
199                 /* Device Status */
200                 Method (_STA, 0)
201                 {
202                         // Device disabled by coreboot?
203                         If (CMBP == 0) {
204                                 Return (0)
205                         }
207                         /* IRDA? */
208                         Local0 = READ (0, 0x0c, 0x38)
209                         If (Local0 != 0) {
210                                 Return (0)
211                         }
213                         // Is the hardware enabled?
214                         Local0 = READ (0, 0x25, 0xff)
215                         If (Local0 == 0) {
216                                 Return (0xd)
217                         } Else {
218                                 // Power Enabled?
219                                 Local0 = READ (0, 0x02, 0x80)
220                                 If (Local0 == 0) {
221                                         Return (0x0d)
222                                 } Else {
223                                         Return (0x0f)
224                                 }
225                         }
226                 }
228                 /* Device Disable */
229                 Method (_DIS, 0)
230                 {
231                         WRIT(0, 0x25, 0x00)
233                         Local0 = READ (0, 0x28, 0xf0)
234                         WRIT(0, 0x28, Local0)
236                         Local0 = READ(0, 0x02, 0xff)
237                         Local1 = ~0x80
238                         Local0 &= Local1
239                         WRIT(0, 0x02, Local0)
240                 }
242                 /* Possible Resource Settings */
243                 Name(_PRS, ResourceTemplate() {
244                         StartDependentFn(0, 1) {
245                                 IO(Decode16, 0x2f8, 0x2f8, 0x8, 0x8)
246                                 IRQNoFlags() { 3 }
247                         } EndDependentFn()
248                 })
250                 /* Current Resource Settings */
251                 Method(_CRS, 0)
252                 {
253                         Name(NONE, ResourceTemplate() {
254                                 IO(Decode16, 0x000, 0x000, 0x0, 0x1)
255                                 IRQNoFlags() { }
256                         })
258                         Name(RSRC, ResourceTemplate() {
259                                 IO(Decode16, 0x2f8, 0x2f8, 0x8, 0x8, _IOB)
260                                 IRQNoFlags(_IRB) { 3 }
261                         })
263                         Local0 = _STA() & 0x02
264                         If (Local0 == 0) {
265                                 Return(NONE)
266                         }
268                         CreateWordField(RSRC,
269                                 \_SB.PCI0.LPCB.SIO1.COMB._CRS._IOB._MIN, IOMN)
270                         CreateWordField(RSRC,
271                                 \_SB.PCI0.LPCB.SIO1.COMB._CRS._IOB._MAX, IOMX)
272                         CreateWordField(RSRC,
273                                 \_SB.PCI0.LPCB.SIO1.COMB._CRS._IRB._INT, IRQ)
275                         /* I/O Base */
276                         Local0 = READ (0, 0x25, 0xfe)
277                         Local0 <<= 2
278                         IOMN = Local0
279                         IOMX = Local0
281                         /* Interrupt */
282                         Local0 = READ (0, 0x28, 0x0f)
283                         IRQ = 1 << Local0
284                         Return(RSRC)
285                 }
287                 /* Set Resource Settings */
288                 Method(_SRS, 1)
289                 {
290                         CreateByteField(Arg0, 0x02, IOLO)
291                         CreateByteField(Arg0, 0x03, IOHI)
292                         CreateByteField(Arg0, 0x09, IRQL)
294                         WRIT(0, 0x25, 0)
295                         FindSetRightBit(IRQL, Local0)
296                         Local0--
298                         Local1 = READ (0, 0x28, 0xf0)
299                         Local0 |= Local1
300                         WRIT(0, 0x28, Local0)
302                         Local0 = IOLO
303                         Local0 >>= 2
304                         Local0 &= 0xfe
306                         Local1 = IOHI
307                         Local1 <<= 6
308                         Local0 |= Local1
309                         WRIT(0, 0x25, Local0)
311                         Local0 = READ (0, 0x0c, 0xff)
312                         Local1 = ~0x38
313                         Local0 &= Local1
314                         WRIT(0, 0x0c, Local0)
316                         Local0 = READ(0, 0x02, 0xff)
317                         Local0 |= 0x80
318                         WRIT(0, 0x02, Local0)
320                         Local0 = READ (0, 0x07, 0xff)
321                         Local1 = ~0x20
322                         Local0 &= Local1
323                         WRIT(0, 0x07, Local0)
324                 }
326                 /* D0 state - Line drivers are on */
327                 Method (_PS0, 0)
328                 {
329                         Local0 = READ(0, 0x02, 0xff)
330                         Local0 |= 0x80
331                         WRIT(0, 0x02, Local0)
333                         Local0 = READ (0, 0x07, 0xff)
334                         Local1 = ~0x20
335                         Local0 &= Local1
336                         WRIT(0, 0x07, Local0)
337                 }
339                 /* D3 State - Line drivers are off */
340                 Method(_PS3, 0)
341                 {
342                         Local0 = READ(0, 0x02, 0xff)
343                         Local1 = ~0x80
344                         Local0 &= Local1
345                         WRIT(0, 0x02, Local0)
346                 }
347         }