| 1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 |
|
| 3 |
/* |
| 4 |
* Global TODO: (externally: Optimus GC6 and GPS) |
| 5 |
* - TRPS: This is SMI 0xDD, likely in SmmOemDriver. This SW SMI adds to and executes |
| 6 |
* a table of function pointers produced throughout the OEM 'value-add' stack. |
| 7 |
* - Arg0 - "SFUN" - is index into "$FNC" pointer table? It's easier to |
| 8 |
* correlate *CommonService use: Offset 13 creates TRPS handlers. |
| 9 |
* - Known functions: |
| 10 |
* - 0x80 calls offset 0 in ACER_BOOT_DEVICE_SERVICE_PROTOCOL_GUID. |
| 11 |
* - NB: efiXplorer can miss InstallProtocolInterface() when Interface is local |
| 12 |
* - 0x81 toggles Intel Dynamic Acceleration in IA32_MISC_ENABLE MSR. |
| 13 |
* - 0x82 does switch on "OSYS" to set EC byte. Suspect this is for OS features. |
| 14 |
* (A CVE exists in the vendor code only if it never sets the offset in the buffer.) |
| 15 |
* - RBEC/WBEC/MBEC: This is SMI 0xDD, "functions" 0x10, 0x11 and 0x12 in SmmKbcDriver, |
| 16 |
* added into SmmCommonService table at its protocol notify. Performs read, write |
| 17 |
* and read-modify-write from buffer. We will use ACPI instead. |
| 18 |
* - WMI: This is likely SMI 0xD0 in A01WMISmmCallback. This SW SMI likely uses the WMI |
| 19 |
* object and consumes the OEM 'value-add' stack for EC and presumably the A01* |
| 20 |
* OEM/ODM 'value-add' stack. An SSDT contains the device and EC0 provides "GCMS" |
| 21 |
* and "GOTS" method helpers. |
| 22 |
* |
| 23 |
* Generally, more information is needed. |
| 24 |
* TODO: Implement more board features: lid and touchpad trigger wake from S3, |
| 25 |
* Fn-Ctrl swap, sticky Fn keys and always-on USB charger. |
| 26 |
*/ |
| 27 |
|
| 28 |
Device (EC0) |
| 29 |
{ |
| 30 |
Name (_HID, EisaId ("PNP0C09") /* Embedded Controller Device */) |
| 31 |
Name (_GPE, 0x50) // _GPE: General Purpose Events |
| 32 |
Name (\ECOK, 0) |
| 33 |
#if CONFIG(EC_USE_LGMR) |
| 34 |
Name (LGMR, 0xFE800000) // Static, may depend on EC configuration. Unsure which register. |
| 35 |
#endif |
| 36 |
|
| 37 |
Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings |
| 38 |
{ |
| 39 |
IO (Decode16, 0x62, 0x62, 0, 1) |
| 40 |
IO (Decode16, 0x66, 0x66, 0, 1) |
| 41 |
}) |
| 42 |
|
| 43 |
#define EC_SC_IO 0x66 |
| 44 |
#define EC_DATA_IO 0x62 |
| 45 |
#include <ec/acpi/ec.asl> |
| 46 |
|
| 47 |
#if CONFIG(EC_USE_LGMR) |
| 48 |
OperationRegion (ECMB, SystemMemory, LGMR, 0x200) |
| 49 |
#endif |
| 50 |
OperationRegion (RAM, EmbeddedControl, 0, 0xFF) |
| 51 |
Field (RAM, ByteAcc, Lock, Preserve) |
| 52 |
{ |
| 53 |
CMDB, 8, /* EC commands */ |
| 54 |
ETID, 8, /* Thermal page selector */ |
| 55 |
EBID, 8, /* Battery page selector */ |
| 56 |
Offset (0x06), |
| 57 |
CMD2, 8, /* param 2: UNUSED */ |
| 58 |
CMD1, 8, /* param 1: UNUSED */ |
| 59 |
CMD0, 8, /* param 0 to EC command */ |
| 60 |
Offset (0x0A), |
| 61 |
, 1, |
| 62 |
, 1, |
| 63 |
Offset (0x10), |
| 64 |
EQEN, 1, /* EQ enable */ |
| 65 |
ETEE, 1, /* TODO */ |
| 66 |
Offset (0x4E), |
| 67 |
ISEN, 1, /* TODO */ |
| 68 |
Offset (0x4F), |
| 69 |
ECTP, 8, /* Touchpad ID */ |
| 70 |
Offset (0x51), |
| 71 |
, 3, |
| 72 |
TPEN, 1, /* Touchpad enable */ |
| 73 |
Offset (0x52), |
| 74 |
WLEX, 1, /* WLAN present */ |
| 75 |
BTEX, 1, /* Bluetooth present */ |
| 76 |
EX3G, 1, /* 3G */ |
| 77 |
, 3, |
| 78 |
RFEX, 1, /* RF present */ |
| 79 |
/* |
| 80 |
* NOTE: Some reverse engineering, as well as corroborating vendor's hidden SetupUtility |
| 81 |
* options with the EC's memory space, suggests that offset 0x55 might be the battery |
| 82 |
* threshold |
| 83 |
* - TODO: Actually diff changes in modified vendor FW |
| 84 |
*/ |
| 85 |
Offset (0x57), |
| 86 |
, 7, |
| 87 |
AHKB, 1, /* Hotkey triggered */ |
| 88 |
AHKE, 8, /* Hotkey data */ |
| 89 |
Offset (0x5C), |
| 90 |
Offset (0x5D), |
| 91 |
Offset (0x6C), |
| 92 |
PWLT, 1, /* NVIDIA GPS: Panel? */ |
| 93 |
, 3, |
| 94 |
GCON, 1, /* Enter Optimus GC6 */ |
| 95 |
Offset (0x70), |
| 96 |
, 1, |
| 97 |
ELID, 1, /* Lid state */ |
| 98 |
, 3, |
| 99 |
EACS, 1, /* AC state */ |
| 100 |
Offset (0x71), |
| 101 |
WLEN, 1, /* WLAN enable */ |
| 102 |
BTEN, 1, /* Bluetooth enable */ |
| 103 |
, 3, |
| 104 |
ISS3, 1, |
| 105 |
ISS4, 1, |
| 106 |
ISS5, 1, |
| 107 |
, 4, |
| 108 |
EIDW, 1, /* Device wake */ |
| 109 |
Offset (0x74), |
| 110 |
, 2, |
| 111 |
, 1, |
| 112 |
TPEX, 1, /* Touchpad present */ |
| 113 |
Offset (0x75), |
| 114 |
BLST, 1, /* Bluetooth state */ |
| 115 |
LMIB, 1, /* TODO */ |
| 116 |
Offset (0x76), |
| 117 |
ECSS, 4, /* EC Notify of power state */ |
| 118 |
EOSS, 4, /* EC Notify of power state */ |
| 119 |
Offset (0x88), /* TODO: Aliased to "EB0S" */ |
| 120 |
EB0A, 1, |
| 121 |
, 2, |
| 122 |
EB0R, 1, |
| 123 |
EB0L, 1, |
| 124 |
EB0F, 1, |
| 125 |
EB0N, 1, |
| 126 |
Offset (0x90), |
| 127 |
SCPM, 1, /* Set cooling policy */ |
| 128 |
Offset (0x92), /* TODO: Aliased to "ETAF" */ |
| 129 |
ESSF, 1, |
| 130 |
ECTT, 1, |
| 131 |
EDTT, 1, |
| 132 |
EOSD, 1, /* Trip */ |
| 133 |
EVTP, 1, |
| 134 |
ECP1, 1, |
| 135 |
, 1, |
| 136 |
ECP2, 1, |
| 137 |
Offset (0xA8), |
| 138 |
ES0T, 8, /* Temperature */ |
| 139 |
ES1T, 8, /* Temperature */ |
| 140 |
Offset (0xD0), |
| 141 |
ESP0, 8, /* Passive temp */ |
| 142 |
ESC0, 8, /* Critical temp */ |
| 143 |
ESP1, 8, /* Passive temp */ |
| 144 |
ESC1, 8, /* Critical temp */ |
| 145 |
} |
| 146 |
/* Aliases several battery registers */ |
| 147 |
Field (RAM, ByteAcc, Lock, Preserve) |
| 148 |
{ |
| 149 |
Offset (0x88), |
| 150 |
EB0S, 8, /* Battery 0 state */ |
| 151 |
} |
| 152 |
/* Aliases several thermal registers */ |
| 153 |
Field (RAM, ByteAcc, Lock, Preserve) |
| 154 |
{ |
| 155 |
Offset (0x92), |
| 156 |
ETAF, 8, |
| 157 |
} |
| 158 |
|
| 159 |
#if CONFIG(EC_USE_LGMR) |
| 160 |
Field (ECMB, ByteAcc, Lock, Preserve) |
| 161 |
{ |
| 162 |
Offset (0x02), |
| 163 |
, 1, |
| 164 |
MLID, 1, |
| 165 |
, 3, |
| 166 |
MACS, 1, |
| 167 |
Offset (0x06), |
| 168 |
MBTP, 8, |
| 169 |
Offset (0x08), |
| 170 |
MB0S, 8, |
| 171 |
Offset (0x20), |
| 172 |
MS0T, 8, |
| 173 |
MS1T, 8, |
| 174 |
MS2T, 8, |
| 175 |
MS3T, 8, |
| 176 |
MS4T, 8, |
| 177 |
MS5T, 8, |
| 178 |
Offset (0x53), |
| 179 |
MCSS, 1, |
| 180 |
MCTT, 1, |
| 181 |
MDTT, 1, |
| 182 |
MOSD, 1, |
| 183 |
MVTP, 1, |
| 184 |
Offset (0x54), |
| 185 |
MSP0, 8, |
| 186 |
MSC0, 8, |
| 187 |
MCC0, 8, |
| 188 |
MSC1, 8, |
| 189 |
} |
| 190 |
#endif |
| 191 |
|
| 192 |
Method (_REG, 2, NotSerialized) // _REG: Region Availability |
| 193 |
{ |
| 194 |
If (Arg0 == 3) |
| 195 |
{ |
| 196 |
ECOK = Arg1 // OS can clear region availability |
| 197 |
If (Arg1 == 1) // On initialise |
| 198 |
{ |
| 199 |
TINI () |
| 200 |
EOSS = 0x05 |
| 201 |
/* OSYS retrieved by SMM, Arg3 is unused */ |
| 202 |
// TRPS (0x82, 1, 0) |
| 203 |
|
| 204 |
/* |
| 205 |
* Other pages return valid data too, but this seems to be |
| 206 |
* the page we are expecting - persistently in ectool dump |
| 207 |
* with vendor firmware |
| 208 |
* FIXME: Contents of other pages? |
| 209 |
*/ |
| 210 |
ETID = 0x20 |
| 211 |
} |
| 212 |
} |
| 213 |
|
| 214 |
/* iGFX RC method call stripped */ |
| 215 |
} |
| 216 |
|
| 217 |
Method (TINI, 0, NotSerialized) |
| 218 |
{ |
| 219 |
If (ECOK) |
| 220 |
{ |
| 221 |
ETAF = 0 |
| 222 |
ETEE = 1 |
| 223 |
} |
| 224 |
Else |
| 225 |
{ |
| 226 |
EC_WRITE (0x92, 0) // ETAF = 0 |
| 227 |
MBEC (0x10, 0xFD, 0x02) // ETEE = 1 |
| 228 |
} |
| 229 |
} |
| 230 |
|
| 231 |
Name (RFST, 0) /* RF state */ |
| 232 |
Method (ECPS, 1, NotSerialized) // _PTS: Prepare To Sleep |
| 233 |
{ |
| 234 |
ECSS = Arg0 |
| 235 |
/* OSYS retrieved by SMM */ |
| 236 |
// TRPS (0x82, 0x02, Arg0) |
| 237 |
If ((Arg0 == 3) || (Arg0 == 4)) |
| 238 |
{ |
| 239 |
RFST = RFEX |
| 240 |
} |
| 241 |
} |
| 242 |
|
| 243 |
Method (ECWK, 1, NotSerialized) // _WAK: Wake |
| 244 |
{ |
| 245 |
EQEN = 1 |
| 246 |
EOSS = Arg0 |
| 247 |
TINI () |
| 248 |
Notify (BAT0, 0x81) // Information Change |
| 249 |
/* OSYS retrieved by SMM */ |
| 250 |
// TRPS (0x82, 0x03, Arg0) |
| 251 |
If ((Arg0 == 3) || (Arg0 == 4)) |
| 252 |
{ |
| 253 |
RFEX = RFST |
| 254 |
Notify (SLPB, 0x02) // Device Wake |
| 255 |
} |
| 256 |
/* iGFX RC method call stripped */ |
| 257 |
} |
| 258 |
|
| 259 |
Method (MBEC, 3, Serialized) |
| 260 |
{ |
| 261 |
Local0 = EC_READ (Arg0) |
| 262 |
Local0 &= Arg1 |
| 263 |
Local0 |= Arg2 |
| 264 |
EC_WRITE (Arg0, Local0) |
| 265 |
} |
| 266 |
|
| 267 |
/* Graphical hotkey */ |
| 268 |
Method (_Q19, 0, NotSerialized) |
| 269 |
{ |
| 270 |
Printf ("Graphical hotkey display switching not implemented in coreboot!") |
| 271 |
} |
| 272 |
|
| 273 |
/* Increase brightness */ |
| 274 |
Method (_Q1C, 0, NotSerialized) |
| 275 |
{ |
| 276 |
^^^GFX0.INCB () |
| 277 |
} |
| 278 |
|
| 279 |
/* Decrease brightness */ |
| 280 |
Method (_Q1D, 0, NotSerialized) |
| 281 |
{ |
| 282 |
^^^GFX0.DECB () |
| 283 |
} |
| 284 |
|
| 285 |
/* Hotkeys */ |
| 286 |
Method (_Q2C, 0, NotSerialized) |
| 287 |
{ |
| 288 |
If (LMIB) |
| 289 |
{ |
| 290 |
If (!AHKB) /* Else, WMI clears its buffer? */ |
| 291 |
{ |
| 292 |
Local1 = AHKE |
| 293 |
If ((Local1 > 0) && (Local1 < 0x80)) |
| 294 |
{ |
| 295 |
Printf ("Hotkeys - TODO: Airplane mode?") |
| 296 |
/* WMI -> "GCMS" method */ |
| 297 |
} |
| 298 |
ElseIf ((Local1 > 0x80) && (Local1 < 0xA0)) |
| 299 |
{ |
| 300 |
/* TODO: Not working when called by HID mode. What does WMI do here? */ |
| 301 |
TPEN ^= 1 |
| 302 |
} |
| 303 |
} |
| 304 |
} |
| 305 |
} |
| 306 |
|
| 307 |
Method (_Q36, 0, NotSerialized) |
| 308 |
{ |
| 309 |
If (ECOK) |
| 310 |
{ |
| 311 |
EOSD = 1 // Thermal trip |
| 312 |
} |
| 313 |
Else |
| 314 |
{ |
| 315 |
MBEC (0x92, 0xF7, 0x08) // EOSD = 1 |
| 316 |
} |
| 317 |
|
| 318 |
Sleep (500) |
| 319 |
Notify (\_TZ.TZ01, 0x80) // Thermal Status Change |
| 320 |
Notify (\_TZ.TZ00, 0x80) // Thermal Status Change |
| 321 |
} |
| 322 |
|
| 323 |
Method (_Q3F, 0, NotSerialized) |
| 324 |
{ |
| 325 |
/* Arg3 is unused */ |
| 326 |
// TRPS (0x80, 0, 0) |
| 327 |
} |
| 328 |
|
| 329 |
Method (_Q40, 0, NotSerialized) |
| 330 |
{ |
| 331 |
Notify (BAT0, 0x81) // Information Change |
| 332 |
} |
| 333 |
|
| 334 |
Method (_Q41, 0, NotSerialized) |
| 335 |
{ |
| 336 |
Notify (BAT0, 0x81) // Information Change |
| 337 |
} |
| 338 |
|
| 339 |
/* Battery status change */ |
| 340 |
Method (_Q48, 0, NotSerialized) |
| 341 |
{ |
| 342 |
Notify (BAT0, 0x80) |
| 343 |
} |
| 344 |
|
| 345 |
/* Battery critical? */ |
| 346 |
Method (_Q4C, 0, NotSerialized) |
| 347 |
{ |
| 348 |
If (B0ST) |
| 349 |
{ |
| 350 |
Notify (BAT0, 0x80) // Status Change |
| 351 |
} |
| 352 |
} |
| 353 |
|
| 354 |
/* AC status change: present */ |
| 355 |
Method (_Q50, 0, NotSerialized) |
| 356 |
{ |
| 357 |
Notify (ADP1, 0x80) |
| 358 |
} |
| 359 |
|
| 360 |
/* AC status change: not present */ |
| 361 |
Method (_Q51, 0, NotSerialized) |
| 362 |
{ |
| 363 |
Notify (ADP1, 0x80) |
| 364 |
} |
| 365 |
|
| 366 |
/* Lid status change: open */ |
| 367 |
Method (_Q52, 0, NotSerialized) |
| 368 |
{ |
| 369 |
Notify (LID0, 0x80) |
| 370 |
} |
| 371 |
|
| 372 |
/* Lid status change: close */ |
| 373 |
Method (_Q53, 0, NotSerialized) |
| 374 |
{ |
| 375 |
Notify (LID0, 0x80) |
| 376 |
} |
| 377 |
|
| 378 |
Method (_Q60, 0, NotSerialized) |
| 379 |
{ |
| 380 |
Printf ("EC Query (0x60): WMI") |
| 381 |
} |
| 382 |
|
| 383 |
Method (_Q61, 0, NotSerialized) |
| 384 |
{ |
| 385 |
Printf ("EC Query (0x61): WMI") |
| 386 |
} |
| 387 |
|
| 388 |
Method (_Q62, 0, NotSerialized) |
| 389 |
{ |
| 390 |
Printf ("EC Query (0x62): Optimus GC6 or NVIDIA GPS") |
| 391 |
} |
| 392 |
|
| 393 |
Method (_Q63, 0, NotSerialized) |
| 394 |
{ |
| 395 |
Printf ("EC Query (0x63): Optimus GC6 or NVIDIA GPS") |
| 396 |
} |
| 397 |
|
| 398 |
Method (_Q67, 0, NotSerialized) |
| 399 |
{ |
| 400 |
Printf ("EC Query (0x67): NVIDIA GPS") |
| 401 |
} |
| 402 |
|
| 403 |
Method (_Q68, 0, NotSerialized) |
| 404 |
{ |
| 405 |
Printf ("EC Query (0x68): NVIDIA GPS") |
| 406 |
} |
| 407 |
|
| 408 |
Method (_Q6C, 0, NotSerialized) |
| 409 |
{ |
| 410 |
/* Arg3 is unused */ |
| 411 |
// TRPS (0x81, 0, 0) |
| 412 |
} |
| 413 |
|
| 414 |
Method (_Q6D, 0, NotSerialized) |
| 415 |
{ |
| 416 |
/* Arg3 is unused */ |
| 417 |
// TRPS (0x81, 1, 0) |
| 418 |
} |
| 419 |
|
| 420 |
#include "ac.asl" |
| 421 |
#include "battery.asl" |
| 422 |
} |