Angel Pons | 89ab250 | 2020-04-03 01:22:28 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 2 | |
| 3 | Device (EC0) |
| 4 | { |
| 5 | Name (_HID, EISAID ("PNP0C09")) |
| 6 | Name (_UID, 0) |
| 7 | |
| 8 | Name (_GPE, THINKPAD_EC_GPE) |
| 9 | Mutex (ECLK, 0x07) |
| 10 | |
| 11 | /* EmbeddedControl should work as well, but memory mapped is faster. */ |
| 12 | OperationRegion (ERAM, SystemMemory, (CONFIG_EC_BASE_ADDRESS + 0x100), 0x100) |
| 13 | Field (ERAM, ByteAcc, Lock, Preserve) |
| 14 | { |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 15 | , 1, |
| 16 | , 1, |
| 17 | HKFA, 1, // FN lock (Hotkey / FN row toggle) |
| 18 | , 1, |
| 19 | , 1, |
| 20 | , 1, |
| 21 | , 1, |
| 22 | |
| 23 | Offset(0x0c), |
| 24 | HLCL, 8, // LED control |
| 25 | |
| 26 | Offset(0x46), |
| 27 | , 4, |
| 28 | ONAC, 1, |
| 29 | , 3, |
| 30 | |
| 31 | Offset(0x81), |
| 32 | PAGE, 8, |
| 33 | } |
| 34 | |
| 35 | /* Battery info page 0 */ |
| 36 | Field (ERAM, ByteAcc, NoLock, Preserve) |
| 37 | { |
| 38 | Offset(0xA0), |
| 39 | SBRC, 16, /* Remaining capacity */ |
| 40 | SBFC, 16, /* Full-charge capacity */ |
| 41 | SBAE, 16, |
| 42 | SBRS, 16, |
| 43 | SBAC, 16, /* Present rate */ |
| 44 | SBVO, 16, /* Present voltage */ |
| 45 | SBAF, 16, |
| 46 | SBBS, 16, |
| 47 | } |
| 48 | |
| 49 | /* Battery info page 1 */ |
| 50 | Field (ERAM, ByteAcc, NoLock, Preserve) |
| 51 | { |
| 52 | Offset (0xA0), |
| 53 | , 15, |
| 54 | SBCM, 1, /* Power unit (0 == mA/mAh, 1 == mW/mWh) */ |
| 55 | SBMD, 16, |
| 56 | SBCC, 16, |
| 57 | } |
| 58 | |
| 59 | /* Battery info page 2 */ |
| 60 | Field (ERAM, ByteAcc, NoLock, Preserve) |
| 61 | { |
| 62 | Offset (0xA0), |
| 63 | SBDC, 16, /* Design Capacity */ |
| 64 | SBDV, 16, /* Design Voltage */ |
| 65 | SBOM, 16, |
| 66 | SBSI, 16, |
| 67 | SBDT, 16, |
| 68 | SBSN, 16, /* Serial number */ |
| 69 | } |
| 70 | |
| 71 | /* Battery info page 4 */ |
| 72 | Field (ERAM, ByteAcc, NoLock, Preserve) |
| 73 | { |
| 74 | Offset (0xA0), |
| 75 | SBCH, 32, /* Type (LiON) */ |
| 76 | } |
| 77 | |
| 78 | /* Battery info page 5 */ |
| 79 | Field (ERAM, ByteAcc, NoLock, Preserve) |
| 80 | { |
| 81 | Offset (0xA0), |
| 82 | SBMN, 128, /* Manufacturer */ |
| 83 | } |
| 84 | |
| 85 | /* Battery info page 6 */ |
| 86 | Field (ERAM, ByteAcc, NoLock, Preserve) |
| 87 | { |
| 88 | Offset (0xA0), |
| 89 | SBDN, 128, /* Model */ |
| 90 | } |
| 91 | |
| 92 | Method (_CRS, 0, Serialized) |
| 93 | { |
| 94 | Name (ECMD, ResourceTemplate() |
| 95 | { |
| 96 | IO (Decode16, 0x62, 0x62, 0, 1) |
| 97 | IO (Decode16, 0x66, 0x66, 0, 1) |
| 98 | IO (Decode16, 0x700, 0x700, 0, 8) |
| 99 | Memory32Fixed(ReadOnly, CONFIG_EC_BASE_ADDRESS, 0x1000, FF00) |
| 100 | }) |
| 101 | Return (ECMD) |
| 102 | } |
| 103 | |
| 104 | /* Increase brightness hotkey */ |
| 105 | Method (_Q14, 0, NotSerialized) { |
| 106 | BRIGHTNESS_UP() |
| 107 | ^HKEY.MHKQ (0x1010) |
| 108 | } |
| 109 | |
| 110 | /* Decrease brightness hotkey */ |
| 111 | Method (_Q15, 0, NotSerialized) { |
| 112 | BRIGHTNESS_DOWN() |
| 113 | ^HKEY.MHKQ (0x1011) |
| 114 | } |
| 115 | |
| 116 | /* Video output switch hotkey */ |
| 117 | Method (_Q16, 0, NotSerialized) { |
Angel Pons | 822148c | 2020-04-29 22:58:39 +0200 | [diff] [blame] | 118 | Notify (\_SB.PCI0.GFX0, 0x82) |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 119 | ^HKEY.MHKQ (0x1007) |
| 120 | } |
| 121 | |
| 122 | Method (_Q19, 0, NotSerialized) |
| 123 | { |
| 124 | ^HKEY.MHKQ (0x1018) |
| 125 | } |
| 126 | |
| 127 | /* Switched to AC power */ |
| 128 | Method (_Q26, 0, NotSerialized) |
| 129 | { |
Elyes HAOUAS | c23ec64 | 2020-10-08 09:52:35 +0200 | [diff] [blame] | 130 | PWRS = 1 |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 131 | Notify (^AC, 0x80) |
| 132 | Notify (^BAT0, 0x80) |
| 133 | \PNOT () |
| 134 | ^HKEY.MHKQ (0x6040) |
| 135 | } |
| 136 | |
| 137 | /* Switched to battery power */ |
| 138 | Method (_Q27, 0, NotSerialized) |
| 139 | { |
Elyes HAOUAS | c23ec64 | 2020-10-08 09:52:35 +0200 | [diff] [blame] | 140 | PWRS = 0 |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 141 | Notify (^AC, 0x80) |
| 142 | Notify (^BAT0, 0x80) |
| 143 | \PNOT () |
| 144 | ^HKEY.MHKQ (0x6040) |
| 145 | } |
| 146 | |
| 147 | /* Lid openend */ |
| 148 | Method (_Q2A, 0, NotSerialized) |
| 149 | { |
Elyes HAOUAS | c23ec64 | 2020-10-08 09:52:35 +0200 | [diff] [blame] | 150 | LIDS = 1 |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 151 | Notify(^LID, 0x80) |
| 152 | ^HKEY.MHKQ (0x5002) |
| 153 | } |
| 154 | |
| 155 | /* Lid closed */ |
| 156 | Method (_Q2B, 0, NotSerialized) |
| 157 | { |
Elyes HAOUAS | c23ec64 | 2020-10-08 09:52:35 +0200 | [diff] [blame] | 158 | LIDS = 0 |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 159 | Notify(^LID, 0x80) |
| 160 | ^HKEY.MHKQ (0x5001) |
| 161 | } |
| 162 | |
| 163 | /* Tablet swivel down */ |
| 164 | Method (_Q35, 0, NotSerialized) |
| 165 | { |
| 166 | ^HKEY.MHKQ (0x60c0) |
| 167 | ^HKEY.MHKQ (0x500a) |
| 168 | } |
| 169 | |
| 170 | /* Tablet swivel up */ |
| 171 | Method (_Q36, 0, NotSerialized) |
| 172 | { |
| 173 | ^HKEY.MHKQ (0x60c0) |
| 174 | ^HKEY.MHKQ (0x5009) |
| 175 | } |
| 176 | |
| 177 | /* Tablet rotate lock button */ |
| 178 | Method (_Q37, 0, NotSerialized) |
| 179 | { |
| 180 | ^HKEY.MHKQ (0x6020) |
| 181 | } |
| 182 | |
| 183 | /* Numlock pressed */ |
| 184 | Method (_Q3F, 0, NotSerialized) |
| 185 | { |
| 186 | ^HKEY.MHKQ (0x6000) |
| 187 | } |
| 188 | |
| 189 | /* RFKill status changed */ |
| 190 | Method (_Q41, 0, NotSerialized) { |
| 191 | ^HKEY.MHKQ (0x7000) |
| 192 | } |
| 193 | |
| 194 | /* Mute hotkey */ |
| 195 | Method (_Q43, 0, NotSerialized) { |
| 196 | ^HKEY.MHKQ (0x1017) |
| 197 | } |
| 198 | |
| 199 | /* Settings hotkey */ |
| 200 | Method (_Q5A, 0, NotSerialized) |
| 201 | { |
| 202 | ^HKEY.MHKQ (0x101D) |
| 203 | } |
| 204 | |
| 205 | /* Search hotkey */ |
| 206 | Method (_Q5B, 0, NotSerialized) |
| 207 | { |
| 208 | ^HKEY.MHKQ (0x101E) |
| 209 | } |
| 210 | |
| 211 | /* Scale hotkey */ |
| 212 | Method (_Q5C, 0, NotSerialized) |
| 213 | { |
| 214 | ^HKEY.MHKQ (0x101F) |
| 215 | } |
| 216 | |
| 217 | /* File hotkey */ |
| 218 | Method (_Q5D, 0, NotSerialized) |
| 219 | { |
| 220 | ^HKEY.MHKQ (0x1020) |
| 221 | } |
| 222 | |
| 223 | /* RFkill hotkey */ |
| 224 | Method (_Q64, 0, NotSerialized) { |
| 225 | ^HKEY.MHKQ (0x1005) |
| 226 | } |
| 227 | |
| 228 | /* Mic mute hotkey */ |
| 229 | Method (_Q6A, 0, NotSerialized) |
| 230 | { |
| 231 | ^HKEY.MHKQ (0x101B) |
| 232 | } |
| 233 | |
| 234 | /* FN key pressed */ |
| 235 | Method (_Q70, 0, NotSerialized) { } |
| 236 | |
| 237 | /* FN+Esc pressed / FN row mode switch */ |
| 238 | Method (_Q74, 0, NotSerialized) { |
Elyes HAOUAS | c23ec64 | 2020-10-08 09:52:35 +0200 | [diff] [blame] | 239 | HKFA = 1 ^ HKFA |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 240 | ^HKEY.MHKQ (0x6060) |
| 241 | } |
| 242 | |
| 243 | /* Implements enough of the Lenovo hotkey device for |
| 244 | * thinkpad-acpi to work, no real support for hotkey masking */ |
| 245 | Device (HKEY) |
| 246 | { |
| 247 | Name (_HID, EisaId ("LEN0068")) |
| 248 | |
| 249 | Name (DHKC, Zero) |
| 250 | Name (DHKV, Zero) |
| 251 | Name (DHKN, 0xFC018070) // Hotkey mask |
| 252 | Mutex (XDHK, 0x07) |
| 253 | |
| 254 | Method (_STA, 0, NotSerialized) |
| 255 | { |
| 256 | Return (0x0F) |
| 257 | } |
| 258 | |
| 259 | Method (MHKV, 0, NotSerialized) |
| 260 | { |
| 261 | Return (0x0100) // Interface version 1.0 |
| 262 | } |
| 263 | |
| 264 | Method (MHKA, 0, NotSerialized) // Hotkey all mask |
| 265 | { |
| 266 | Return (0xFFFFFFFF) |
| 267 | } |
| 268 | |
| 269 | Method (MHKM, 2, NotSerialized) // Set hotkey mask |
| 270 | { |
| 271 | Acquire (XDHK, 0xFFFF) |
| 272 | |
Elyes HAOUAS | c23ec64 | 2020-10-08 09:52:35 +0200 | [diff] [blame] | 273 | Local0 = 1 << Arg0-- |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 274 | If (Arg1) { |
Elyes HAOUAS | c23ec64 | 2020-10-08 09:52:35 +0200 | [diff] [blame] | 275 | DHKN |= Local0 |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 276 | } Else { |
Elyes HAOUAS | c23ec64 | 2020-10-08 09:52:35 +0200 | [diff] [blame] | 277 | DHKN &= ~Local0 |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | Release (XDHK) |
| 281 | } |
| 282 | |
| 283 | Method (MHKC, 1, NotSerialized) // Hotkey disable? |
| 284 | { |
| 285 | Acquire (XDHK, 0xFFFF) |
| 286 | |
Elyes HAOUAS | c23ec64 | 2020-10-08 09:52:35 +0200 | [diff] [blame] | 287 | DHKC = Arg0 |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 288 | |
| 289 | Release (XDHK) |
| 290 | } |
| 291 | |
| 292 | Method (MHKP, 0, NotSerialized) // Hotkey poll |
| 293 | { |
| 294 | Acquire (XDHK, 0xFFFF) |
| 295 | |
Elyes HAOUAS | c23ec64 | 2020-10-08 09:52:35 +0200 | [diff] [blame] | 296 | Local0 = 0 |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 297 | |
| 298 | if (DHKV) { |
Elyes HAOUAS | c23ec64 | 2020-10-08 09:52:35 +0200 | [diff] [blame] | 299 | Local0 = DHKV |
| 300 | DHKV = 0 |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | Release (XDHK) |
| 304 | |
| 305 | Return (Local0) |
| 306 | } |
| 307 | |
| 308 | Method (MHKQ, 1, NotSerialized) // Send hotkey event |
| 309 | { |
| 310 | Acquire (XDHK, 0xFFFF) |
| 311 | |
Elyes HAOUAS | c23ec64 | 2020-10-08 09:52:35 +0200 | [diff] [blame] | 312 | DHKV = Arg0 |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 313 | |
| 314 | Release (XDHK) |
| 315 | |
| 316 | Notify (HKEY, 0x80) // Status Change |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | /* LED support for thinkpad-acpi */ |
| 321 | Method (LED, 2, NotSerialized) |
| 322 | { |
Elyes HAOUAS | c23ec64 | 2020-10-08 09:52:35 +0200 | [diff] [blame] | 323 | HLCL = Arg0 | Arg1 |
Tobias Diedrich | cee930a | 2017-02-12 14:09:06 +0100 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | Device (AC) |
| 327 | { |
| 328 | Name (_HID, "ACPI0003") |
| 329 | Name (_PCL, Package (1) { \_SB }) |
| 330 | |
| 331 | Method (_PSR, 0, NotSerialized) |
| 332 | { |
| 333 | Return (ONAC) |
| 334 | } |
| 335 | Method (_STA, 0, NotSerialized) |
| 336 | { |
| 337 | Return (0x0F) |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | /* Battery is H8 compatible, but requires an explicit delay */ |
| 342 | #define BATTERY_PAGE_DELAY_MS 20 |
| 343 | #include <ec/lenovo/h8/acpi/battery.asl> |
| 344 | |
| 345 | /* LID is H8 compatible */ |
| 346 | #include <ec/lenovo/h8/acpi/lid.asl> |
| 347 | } |