blob: 4fd5ab0607ff2b97b48bcf2a61e6d13103d40f42 [file] [log] [blame]
Felix Held3f3eca92020-01-23 17:12:32 +01001/* SPDX-License-Identifier: GPL-2.0-only */
Nico Huberae7c9682013-05-23 18:13:23 +02002
3/* =================== Keyboard Controller ================== */
4
5/*
6 * Just uses the default i/o ports 0x60/0x64, irq 1 (and 12 for PS/2
7 * mouse). Do we have any system that needs this configurable?
8 *
9 * Controlled by the following preprocessor defines:
10 *
Elyes HAOUAS495bb662019-09-23 13:15:41 +020011 * SUPERIO_CHIP_NAME The name of the Super I/O chip (unique, required)
12 * SUPERIO_KBC_LDN The logical device number on the Super I/O
Nico Huberae7c9682013-05-23 18:13:23 +020013 * chip for this keyboard controller (required)
14 * SUPERIO_KBC_PS2M If defined, PS/2 mouse support is included in
15 * the KBC_LDN. Mouse irq is set at IRQ1 of the
16 * KBC_LDN.
17 * SUPERIO_KBC_PS2LDN If defined, specifies a second LDN to configure
18 * PS/2 mouse support. Mouse irq is set at IRQ0 of
19 * this LDN.
20 * SUPERIO_KBC_PS2M and SUPERIO_KBC_PS2LDN are mutually exclusive.
21 */
22
23#include "pnp.asl"
24
25#ifndef SUPERIO_CHIP_NAME
26# error "SUPERIO_CHIP_NAME is not defined."
27#endif
28
29#ifndef SUPERIO_KBC_LDN
30# error "SUPERIO_KBC_LDN is not defined."
31#endif
32
33#if defined(SUPERIO_KBC_PS2M) && defined(SUPERIO_KBC_PS2LDN)
34# error "SUPERIO_KBC_PS2M and SUPERIO_KBC_PS2LDN are mutually exclusive."
35#endif
36
37Device (SUPERIO_ID(KBD, SUPERIO_KBC_LDN)) {
38 Name (_HID, EisaId ("PNP0303"))
39 Name (_UID, SUPERIO_UID(KBD, SUPERIO_KBC_LDN))
40
41 Method (_STA)
42 {
43 PNP_GENERIC_STA(SUPERIO_KBC_LDN)
44 }
45
46 Method (_DIS)
47 {
48 ENTER_CONFIG_MODE (SUPERIO_KBC_LDN)
Felix Singerfacf7d02022-12-12 02:34:43 +010049 PNP_DEVICE_ACTIVE = Zero
Nico Huberae7c9682013-05-23 18:13:23 +020050 EXIT_CONFIG_MODE ()
51 #if defined(SUPERIO_KBC_PS2LDN)
52 Notify (SUPERIO_ID(PS2, SUPERIO_KBC_PS2LDN), 1)
53 #elif defined(SUPERIO_KBC_PS2M)
54 Notify (SUPERIO_ID(PS2, SUPERIO_KBC_LDN), 1)
55 #endif
56 }
57
58 Method (_PSC) {
59 PNP_DEFAULT_PSC
60 }
61
Tristan Corrick8f731b82018-08-01 03:08:53 +120062 Method (_CRS, 0, Serialized)
Nico Huberae7c9682013-05-23 18:13:23 +020063 {
64 Name (CRS, ResourceTemplate () {
65 IO (Decode16, 0x0000, 0x0000, 0x01, 0x01, IO0)
66 IO (Decode16, 0x0000, 0x0000, 0x01, 0x01, IO1)
67 IRQNoFlags (IR0) {}
68 })
69 ENTER_CONFIG_MODE (SUPERIO_KBC_LDN)
70 PNP_READ_IO(PNP_IO0, CRS, IO0)
71 PNP_READ_IO(PNP_IO1, CRS, IO1)
72 PNP_READ_IRQ(PNP_IRQ0, CRS, IR0)
73 EXIT_CONFIG_MODE ()
74 Return (CRS)
75 }
76
77 Name (_PRS, ResourceTemplate ()
78 {
79 StartDependentFn (0,0) {
80 IO (Decode16, 0x0060, 0x0060, 0x01, 0x01)
81 IO (Decode16, 0x0064, 0x0064, 0x01, 0x01)
82 IRQNoFlags () {1}
83 }
84 EndDependentFn()
85 })
86
87 Method (_SRS, 1, Serialized)
88 {
89 Name (TMPL, ResourceTemplate () {
90 IO (Decode16, 0x0000, 0x0000, 0x01, 0x01, IO0)
91 IO (Decode16, 0x0000, 0x0000, 0x01, 0x01, IO1)
92 IRQNoFlags (IR0) {}
93 })
94 ENTER_CONFIG_MODE (SUPERIO_KBC_LDN)
95 PNP_WRITE_IO(PNP_IO0, Arg0, IO0)
96 PNP_WRITE_IO(PNP_IO1, Arg0, IO1)
97 PNP_WRITE_IRQ(PNP_IRQ0, Arg0, IR0)
Felix Singerca4b5872022-12-26 08:17:06 +010098 PNP_DEVICE_ACTIVE = 1
Nico Huberae7c9682013-05-23 18:13:23 +020099 EXIT_CONFIG_MODE ()
100 #if defined(SUPERIO_KBC_PS2LDN)
101 Notify (SUPERIO_ID(PS2, SUPERIO_KBC_PS2LDN), 1)
102 #elif defined(SUPERIO_KBC_PS2M)
103 Notify (SUPERIO_ID(PS2, SUPERIO_KBC_LDN), 1)
104 #endif
105 }
106}
107
108#if defined(SUPERIO_KBC_PS2M)
109Device (SUPERIO_ID(PS2, SUPERIO_KBC_LDN)) {
110 Name (_HID, EisaId ("PNP0F13"))
111 Name (_UID, SUPERIO_UID(PS2, SUPERIO_KBC_LDN))
112
113 Method (_STA)
114 {
115 Return (^^SUPERIO_ID(KBD, SUPERIO_KBC_LDN)._STA ())
116 }
117
118 Method (_PSC) {
119 Return (^^SUPERIO_ID(KBD, SUPERIO_KBC_LDN)._PSC ())
120 }
121
Tristan Corrick8f731b82018-08-01 03:08:53 +1200122 Method (_CRS, 0, Serialized)
Nico Huberae7c9682013-05-23 18:13:23 +0200123 {
124 Name (CRS, ResourceTemplate () {
125 IRQNoFlags (IR1) {}
126 })
127 ENTER_CONFIG_MODE (SUPERIO_KBC_LDN)
128 PNP_READ_IRQ(PNP_IRQ1, CRS, IR1)
129 EXIT_CONFIG_MODE ()
130 Return (CRS)
131 }
132
133 Name (_PRS, ResourceTemplate ()
134 {
135 StartDependentFn (0,0) {
136 IRQNoFlags () {12}
137 }
138 EndDependentFn()
139 })
140
141 Method (_SRS, 1, Serialized)
142 {
143 Name (TMPL, ResourceTemplate () {
144 IRQNoFlags (IR1) {}
145 })
146 ENTER_CONFIG_MODE (SUPERIO_KBC_LDN)
147 PNP_WRITE_IRQ(PNP_IRQ1, Arg0, IR1)
148 EXIT_CONFIG_MODE ()
149 }
150}
151#elif defined(SUPERIO_KBC_PS2LDN)
152Device (SUPERIO_ID(PS2, SUPERIO_KBC_PS2LDN)) {
153 Name (_HID, EisaId ("PNP0F13"))
154 Name (_UID, SUPERIO_UID(PS2, SUPERIO_KBC_PS2LDN))
155
156 Method (_STA)
157 {
Felix Singerfacf7d02022-12-12 02:34:43 +0100158 Local0 = ^^SUPERIO_ID(KBD, SUPERIO_KBC_LDN)._STA ()
Felix Singer8ef8a3e2022-01-02 00:29:41 +0100159 If (Local0 == DEVICE_PRESENT_ACTIVE) {
Nico Huberae7c9682013-05-23 18:13:23 +0200160 PNP_GENERIC_STA(SUPERIO_KBC_PS2LDN)
161 } Else {
162 Return (Local0)
163 }
164 }
165
166 Method (_DIS)
167 {
168 ENTER_CONFIG_MODE (SUPERIO_KBC_PS2LDN)
Felix Singerfacf7d02022-12-12 02:34:43 +0100169 PNP_DEVICE_ACTIVE = Zero
Nico Huberae7c9682013-05-23 18:13:23 +0200170 EXIT_CONFIG_MODE ()
171 }
172
173 Method (_PSC) {
174 PNP_DEFAULT_PSC
175 }
176
Tristan Corrick8f731b82018-08-01 03:08:53 +1200177 Method (_CRS, 0, Serialized)
Nico Huberae7c9682013-05-23 18:13:23 +0200178 {
179 Name (CRS, ResourceTemplate () {
180 IRQNoFlags (IR1) {}
181 })
182 ENTER_CONFIG_MODE (SUPERIO_KBC_PS2LDN)
183 PNP_READ_IRQ(PNP_IRQ0, CRS, IR1)
184 EXIT_CONFIG_MODE ()
185 Return (CRS)
186 }
187
188 Name (_PRS, ResourceTemplate ()
189 {
190 StartDependentFn (0,0) {
191 IRQNoFlags () {12}
192 }
193 EndDependentFn()
194 })
195
196 Method (_SRS, 1, Serialized)
197 {
198 Name (TMPL, ResourceTemplate () {
199 IRQNoFlags (IR1) {}
200 })
201 ENTER_CONFIG_MODE (SUPERIO_KBC_PS2LDN)
202 PNP_WRITE_IRQ(PNP_IRQ0, Arg0, IR1)
Felix Singerca4b5872022-12-26 08:17:06 +0100203 PNP_DEVICE_ACTIVE = 1
Nico Huberae7c9682013-05-23 18:13:23 +0200204 EXIT_CONFIG_MODE ()
205 }
206}
207#endif