libpayload: Add Timer for sdm845
[coreboot.git] / src / superio / acpi / pnp_kbc.asl
blobdb81ea21851bcdfb80024526c825182b41fd4a14
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2011 Christoph Grenz <christophg+cb@grenz-bonn.de>
5  * Copyright (C) 2013 secunet Security Networks AG
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; version 2 of 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  */
17 /* =================== Keyboard Controller ================== */
20  * Just uses the default i/o ports 0x60/0x64, irq 1 (and 12 for PS/2
21  * mouse). Do we have any system that needs this configurable?
22  *
23  * Controlled by the following preprocessor defines:
24  *
25  * SUPERIO_CHIP_NAME    The name of the super i/o chip (unique, required)
26  * SUPERIO_KBC_LDN      The logical device number on the super i/o
27  *                      chip for this keyboard controller (required)
28  * SUPERIO_KBC_PS2M     If defined, PS/2 mouse support is included in
29  *                      the KBC_LDN. Mouse irq is set at IRQ1 of the
30  *                      KBC_LDN.
31  * SUPERIO_KBC_PS2LDN   If defined, specifies a second LDN to configure
32  *                      PS/2 mouse support. Mouse irq is set at IRQ0 of
33  *                      this LDN.
34  * SUPERIO_KBC_PS2M and SUPERIO_KBC_PS2LDN are mutually exclusive.
35  */
37 #include "pnp.asl"
39 #ifndef SUPERIO_CHIP_NAME
40 # error "SUPERIO_CHIP_NAME is not defined."
41 #endif
43 #ifndef SUPERIO_KBC_LDN
44 # error "SUPERIO_KBC_LDN is not defined."
45 #endif
47 #if defined(SUPERIO_KBC_PS2M) && defined(SUPERIO_KBC_PS2LDN)
48 # error "SUPERIO_KBC_PS2M and SUPERIO_KBC_PS2LDN are mutually exclusive."
49 #endif
51 Device (SUPERIO_ID(KBD, SUPERIO_KBC_LDN)) {
52         Name (_HID, EisaId ("PNP0303"))
53         Name (_UID, SUPERIO_UID(KBD, SUPERIO_KBC_LDN))
55         Method (_STA)
56         {
57                 PNP_GENERIC_STA(SUPERIO_KBC_LDN)
58         }
60         Method (_DIS)
61         {
62                 ENTER_CONFIG_MODE (SUPERIO_KBC_LDN)
63                   Store (Zero, PNP_DEVICE_ACTIVE)
64                 EXIT_CONFIG_MODE ()
65                 #if defined(SUPERIO_KBC_PS2LDN)
66                 Notify (SUPERIO_ID(PS2, SUPERIO_KBC_PS2LDN), 1)
67                 #elif defined(SUPERIO_KBC_PS2M)
68                 Notify (SUPERIO_ID(PS2, SUPERIO_KBC_LDN), 1)
69                 #endif
70         }
72         Method (_PSC) {
73                 PNP_DEFAULT_PSC
74         }
76         Method (_CRS)
77         {
78                 Name (CRS, ResourceTemplate () {
79                         IO (Decode16, 0x0000, 0x0000, 0x01, 0x01, IO0)
80                         IO (Decode16, 0x0000, 0x0000, 0x01, 0x01, IO1)
81                         IRQNoFlags (IR0) {}
82                 })
83                 ENTER_CONFIG_MODE (SUPERIO_KBC_LDN)
84                   PNP_READ_IO(PNP_IO0, CRS, IO0)
85                   PNP_READ_IO(PNP_IO1, CRS, IO1)
86                   PNP_READ_IRQ(PNP_IRQ0, CRS, IR0)
87                 EXIT_CONFIG_MODE ()
88                 Return (CRS)
89         }
91         Name (_PRS, ResourceTemplate ()
92         {
93                 StartDependentFn (0,0) {
94                         IO (Decode16, 0x0060, 0x0060, 0x01, 0x01)
95                         IO (Decode16, 0x0064, 0x0064, 0x01, 0x01)
96                         IRQNoFlags () {1}
97                 }
98                 EndDependentFn()
99         })
101         Method (_SRS, 1, Serialized)
102         {
103                 Name (TMPL, ResourceTemplate () {
104                         IO (Decode16, 0x0000, 0x0000, 0x01, 0x01, IO0)
105                         IO (Decode16, 0x0000, 0x0000, 0x01, 0x01, IO1)
106                         IRQNoFlags (IR0) {}
107                 })
108                 ENTER_CONFIG_MODE (SUPERIO_KBC_LDN)
109                   PNP_WRITE_IO(PNP_IO0, Arg0, IO0)
110                   PNP_WRITE_IO(PNP_IO1, Arg0, IO1)
111                   PNP_WRITE_IRQ(PNP_IRQ0, Arg0, IR0)
112                   Store (One, PNP_DEVICE_ACTIVE)
113                 EXIT_CONFIG_MODE ()
114                 #if defined(SUPERIO_KBC_PS2LDN)
115                 Notify (SUPERIO_ID(PS2, SUPERIO_KBC_PS2LDN), 1)
116                 #elif defined(SUPERIO_KBC_PS2M)
117                 Notify (SUPERIO_ID(PS2, SUPERIO_KBC_LDN), 1)
118                 #endif
119         }
122 #if defined(SUPERIO_KBC_PS2M)
123 Device (SUPERIO_ID(PS2, SUPERIO_KBC_LDN)) {
124         Name (_HID, EisaId ("PNP0F13"))
125         Name (_UID, SUPERIO_UID(PS2, SUPERIO_KBC_LDN))
127         Method (_STA)
128         {
129                 Return (^^SUPERIO_ID(KBD, SUPERIO_KBC_LDN)._STA ())
130         }
132         Method (_PSC) {
133                 Return (^^SUPERIO_ID(KBD, SUPERIO_KBC_LDN)._PSC ())
134         }
136         Method (_CRS)
137         {
138                 Name (CRS, ResourceTemplate () {
139                         IRQNoFlags (IR1) {}
140                 })
141                 ENTER_CONFIG_MODE (SUPERIO_KBC_LDN)
142                   PNP_READ_IRQ(PNP_IRQ1, CRS, IR1)
143                 EXIT_CONFIG_MODE ()
144                 Return (CRS)
145         }
147         Name (_PRS, ResourceTemplate ()
148         {
149                 StartDependentFn (0,0) {
150                         IRQNoFlags () {12}
151                 }
152                 EndDependentFn()
153         })
155         Method (_SRS, 1, Serialized)
156         {
157                 Name (TMPL, ResourceTemplate () {
158                         IRQNoFlags (IR1) {}
159                 })
160                 ENTER_CONFIG_MODE (SUPERIO_KBC_LDN)
161                   PNP_WRITE_IRQ(PNP_IRQ1, Arg0, IR1)
162                 EXIT_CONFIG_MODE ()
163         }
165 #elif defined(SUPERIO_KBC_PS2LDN)
166 Device (SUPERIO_ID(PS2, SUPERIO_KBC_PS2LDN)) {
167         Name (_HID, EisaId ("PNP0F13"))
168         Name (_UID, SUPERIO_UID(PS2, SUPERIO_KBC_PS2LDN))
170         Method (_STA)
171         {
172                 Store (^^SUPERIO_ID(KBD, SUPERIO_KBC_LDN)._STA (), Local0)
173                 If (LEqual (Local0, DEVICE_PRESENT_ACTIVE)) {
174                         PNP_GENERIC_STA(SUPERIO_KBC_PS2LDN)
175                 } Else {
176                         Return (Local0)
177                 }
178         }
180         Method (_DIS)
181         {
182                 ENTER_CONFIG_MODE (SUPERIO_KBC_PS2LDN)
183                   Store (Zero, PNP_DEVICE_ACTIVE)
184                 EXIT_CONFIG_MODE ()
185         }
187         Method (_PSC) {
188                 PNP_DEFAULT_PSC
189         }
191         Method (_CRS)
192         {
193                 Name (CRS, ResourceTemplate () {
194                         IRQNoFlags (IR1) {}
195                 })
196                 ENTER_CONFIG_MODE (SUPERIO_KBC_PS2LDN)
197                   PNP_READ_IRQ(PNP_IRQ0, CRS, IR1)
198                 EXIT_CONFIG_MODE ()
199                 Return (CRS)
200         }
202         Name (_PRS, ResourceTemplate ()
203         {
204                 StartDependentFn (0,0) {
205                         IRQNoFlags () {12}
206                 }
207                 EndDependentFn()
208         })
210         Method (_SRS, 1, Serialized)
211         {
212                 Name (TMPL, ResourceTemplate () {
213                         IRQNoFlags (IR1) {}
214                 })
215                 ENTER_CONFIG_MODE (SUPERIO_KBC_PS2LDN)
216                   PNP_WRITE_IRQ(PNP_IRQ0, Arg0, IR1)
217                   Store (One, PNP_DEVICE_ACTIVE)
218                 EXIT_CONFIG_MODE ()
219         }
221 #endif