Angel Pons | 210a008 | 2020-04-02 23:48:24 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Duncan Laurie | e52840a | 2018-10-15 15:19:18 -0700 | [diff] [blame] | 2 | |
| 3 | /* ACPI_POWER_RECORD */ |
| 4 | Name (ECPR, 0) |
| 5 | |
| 6 | Method (ECQP, 0, Serialized) |
| 7 | { |
Duncan Laurie | a213ed6 | 2019-02-21 17:38:03 -0800 | [diff] [blame] | 8 | Local0 = R (PWSR) |
Duncan Laurie | e52840a | 2018-10-15 15:19:18 -0700 | [diff] [blame] | 9 | Local1 = Local0 ^ ECPR |
| 10 | ECPR = Local0 |
| 11 | |
Duncan Laurie | a213ed6 | 2019-02-21 17:38:03 -0800 | [diff] [blame] | 12 | If (EBIT (ACEX, Local1)) { |
Duncan Laurie | e52840a | 2018-10-15 15:19:18 -0700 | [diff] [blame] | 13 | Printf ("AC Power Status Changed") |
| 14 | Notify (AC, 0x80) |
| 15 | } |
| 16 | |
Duncan Laurie | a213ed6 | 2019-02-21 17:38:03 -0800 | [diff] [blame] | 17 | If (EBIT (BTEX, Local1)) { |
| 18 | If (EBIT (BTEX, Local0)) { |
Duncan Laurie | e52840a | 2018-10-15 15:19:18 -0700 | [diff] [blame] | 19 | Printf ("BAT0 Inserted") |
| 20 | Notify (BAT0, 0x81) |
| 21 | } Else { |
| 22 | Printf ("BAT0 Removed") |
| 23 | Notify (BAT0, 0x80) |
| 24 | Notify (BAT0, 0x81) |
| 25 | } |
| 26 | } |
| 27 | |
Mathew King | 071182a | 2020-06-02 12:27:06 -0600 | [diff] [blame] | 28 | /* |
| 29 | * Battery status is cleared when read so always use the value from |
| 30 | * PWSR directly regardless of the previous value stored in ECPR. |
| 31 | */ |
| 32 | If (EBIT (BTSC, Local0)) { |
Duncan Laurie | e52840a | 2018-10-15 15:19:18 -0700 | [diff] [blame] | 33 | Printf ("BAT0 Status Change") |
| 34 | Notify (BAT0, 0x80) |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | /* Handle events in PmEv1 */ |
| 39 | Method (ECQ1, 1, Serialized) |
| 40 | { |
| 41 | /* Power button pressed */ |
| 42 | If (EBIT (E1PB, Arg0)) { |
| 43 | Printf ("Power Button Event") |
| 44 | /* Do not notify \_SB.PWRB here to prevent double event */ |
| 45 | } |
| 46 | |
| 47 | /* LID state changed */ |
| 48 | If (EBIT (E1LD, Arg0)) { |
| 49 | Printf ("Lid State Changed") |
Eric Lai | 5ddce58 | 2020-03-13 17:42:03 +0800 | [diff] [blame] | 50 | Notify (^LID0, 0x80) |
Duncan Laurie | e52840a | 2018-10-15 15:19:18 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | /* Power Event */ |
| 54 | If (EBIT (E1PW, Arg0)) { |
| 55 | Printf ("Power Event") |
| 56 | ECQP () |
| 57 | } |
| 58 | |
| 59 | /* Sleep Button */ |
| 60 | If (EBIT (E1SB, Arg0)) { |
| 61 | Printf ("Sleep Button") |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | /* Handle events in PmEv2 */ |
| 66 | Method (ECQ2, 1, Serialized) |
| 67 | { |
| 68 | Printf ("EVT2: %o", Arg0) |
Duncan Laurie | 45b8465 | 2018-11-17 12:18:20 -0700 | [diff] [blame] | 69 | |
| 70 | If (EBIT (E2QS, Arg0)) { |
| 71 | Printf ("QS EVENT") |
Duncan Laurie | aaac678 | 2019-02-01 09:37:34 -0800 | [diff] [blame] | 72 | Notify (^WEVT, 0x90) |
Duncan Laurie | 45b8465 | 2018-11-17 12:18:20 -0700 | [diff] [blame] | 73 | } |
Duncan Laurie | 4a2558b | 2019-02-01 11:44:14 -0800 | [diff] [blame] | 74 | |
| 75 | If (EBIT (E2OR, Arg0)) { |
| 76 | If (R (OTBL)) { |
| 77 | Printf ("EC event indicates tablet mode") |
| 78 | Notify (^VBTN, ^VTBL) |
| 79 | } Else { |
| 80 | Printf ("EC event indicates laptop mode") |
| 81 | Notify (^VBTN, ^VLAP) |
| 82 | } |
| 83 | } |
Duncan Laurie | e52840a | 2018-10-15 15:19:18 -0700 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | /* Handle events in PmEv3 */ |
| 87 | Method (ECQ3, 1, Serialized) |
| 88 | { |
| 89 | Printf ("EVT3: %o", Arg0) |
Duncan Laurie | 98d7de7 | 2018-11-20 17:30:47 -0800 | [diff] [blame] | 90 | |
Duncan Laurie | 4a2558b | 2019-02-01 11:44:14 -0800 | [diff] [blame] | 91 | If (EBIT (E3CP, Arg0)) { |
| 92 | If (R (P2PB)) { |
| 93 | Printf ("Power button pressed") |
| 94 | Notify (^VBTN, ^VPPB) |
| 95 | } Else { |
| 96 | Printf ("Power button released") |
| 97 | Notify (^VBTN, ^VRPB) |
| 98 | } |
| 99 | } |
| 100 | |
Duncan Laurie | bfb001d | 2018-12-04 10:13:25 -0800 | [diff] [blame] | 101 | #ifdef EC_ENABLE_DPTF |
Duncan Laurie | 98d7de7 | 2018-11-20 17:30:47 -0800 | [diff] [blame] | 102 | /* Theraml Events */ |
| 103 | If (EBIT (E3TH, Arg0)) { |
| 104 | ^PATX () |
| 105 | } |
Duncan Laurie | bfb001d | 2018-12-04 10:13:25 -0800 | [diff] [blame] | 106 | #endif |
Duncan Laurie | e52840a | 2018-10-15 15:19:18 -0700 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | /* Handle events in PmEv4 */ |
| 110 | Method (ECQ4, 1, Serialized) |
| 111 | { |
| 112 | Printf ("EVT4: %o", Arg0) |
| 113 | } |
| 114 | |
Duncan Laurie | e52840a | 2018-10-15 15:19:18 -0700 | [diff] [blame] | 115 | /* Process all events */ |
| 116 | Method (_Q66, 0, Serialized) |
| 117 | { |
| 118 | Local0 = R (EVT1) |
| 119 | If (Local0) { |
| 120 | ECQ1 (Local0) |
| 121 | } |
| 122 | |
| 123 | Local0 = R (EVT2) |
| 124 | If (Local0) { |
| 125 | ECQ2 (Local0) |
| 126 | } |
| 127 | |
| 128 | Local0 = R (EVT3) |
| 129 | If (Local0) { |
| 130 | ECQ3 (Local0) |
| 131 | } |
| 132 | |
| 133 | Local0 = R (EVT4) |
| 134 | If (Local0) { |
| 135 | ECQ4 (Local0) |
| 136 | } |
Duncan Laurie | 45b8465 | 2018-11-17 12:18:20 -0700 | [diff] [blame] | 137 | } |
Duncan Laurie | c145e54 | 2019-04-18 16:37:50 -0700 | [diff] [blame] | 138 | |
| 139 | /* UCSI SCI uses a unique event code */ |
| 140 | Method (_Q79, 0, Serialized) |
| 141 | { |
Duncan Laurie | 3cd3cb6 | 2020-06-09 15:13:15 -0700 | [diff] [blame] | 142 | If (ISSX == Zero) { |
| 143 | Printf ("EC _Q79 UCSI Event") |
| 144 | Notify (^UCSI, 0x80) |
| 145 | ^UCEP = Zero |
| 146 | } Else { |
| 147 | Printf ("EC _Q79 UCSI Event Masked in S0ix") |
Felix Singer | ca4b587 | 2022-12-26 08:17:06 +0100 | [diff] [blame^] | 148 | ^UCEP = 1 |
Duncan Laurie | 3cd3cb6 | 2020-06-09 15:13:15 -0700 | [diff] [blame] | 149 | } |
Duncan Laurie | c145e54 | 2019-04-18 16:37:50 -0700 | [diff] [blame] | 150 | } |