Duncan Laurie | e52840a | 2018-10-15 15:19:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright 2018 Google LLC |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation; version 2 of |
| 9 | * 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 | */ |
| 16 | |
| 17 | /* ACPI_POWER_RECORD */ |
| 18 | Name (ECPR, 0) |
| 19 | |
| 20 | Method (ECQP, 0, Serialized) |
| 21 | { |
| 22 | Local0 = R (APWR) |
| 23 | Local1 = Local0 ^ ECPR |
| 24 | ECPR = Local0 |
| 25 | |
| 26 | If (EBIT (APAC, Local1)) { |
| 27 | Printf ("AC Power Status Changed") |
| 28 | Notify (AC, 0x80) |
| 29 | } |
| 30 | |
| 31 | If (EBIT (APB1, Local1)) { |
| 32 | If (EBIT (APB1, Local0)) { |
| 33 | Printf ("BAT0 Inserted") |
| 34 | Notify (BAT0, 0x81) |
| 35 | } Else { |
| 36 | Printf ("BAT0 Removed") |
| 37 | Notify (BAT0, 0x80) |
| 38 | Notify (BAT0, 0x81) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | If (EBIT (APC1, Local1)) { |
| 43 | Printf ("BAT0 Status Change") |
| 44 | Notify (BAT0, 0x80) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | /* Handle events in PmEv1 */ |
| 49 | Method (ECQ1, 1, Serialized) |
| 50 | { |
| 51 | /* Power button pressed */ |
| 52 | If (EBIT (E1PB, Arg0)) { |
| 53 | Printf ("Power Button Event") |
| 54 | /* Do not notify \_SB.PWRB here to prevent double event */ |
| 55 | } |
| 56 | |
| 57 | /* LID state changed */ |
| 58 | If (EBIT (E1LD, Arg0)) { |
| 59 | Printf ("Lid State Changed") |
| 60 | Notify (^LID, 0x80) |
| 61 | } |
| 62 | |
| 63 | /* Power Event */ |
| 64 | If (EBIT (E1PW, Arg0)) { |
| 65 | Printf ("Power Event") |
| 66 | ECQP () |
| 67 | } |
| 68 | |
| 69 | /* Sleep Button */ |
| 70 | If (EBIT (E1SB, Arg0)) { |
| 71 | Printf ("Sleep Button") |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | /* Handle events in PmEv2 */ |
| 76 | Method (ECQ2, 1, Serialized) |
| 77 | { |
| 78 | Printf ("EVT2: %o", Arg0) |
Duncan Laurie | 45b8465 | 2018-11-17 12:18:20 -0700 | [diff] [blame] | 79 | |
| 80 | If (EBIT (E2QS, Arg0)) { |
| 81 | Printf ("QS EVENT") |
Duncan Laurie | aaac678 | 2019-02-01 09:37:34 -0800 | [diff] [blame] | 82 | Notify (^WEVT, 0x90) |
Duncan Laurie | 45b8465 | 2018-11-17 12:18:20 -0700 | [diff] [blame] | 83 | } |
Duncan Laurie | 4a2558b | 2019-02-01 11:44:14 -0800 | [diff] [blame^] | 84 | |
| 85 | If (EBIT (E2OR, Arg0)) { |
| 86 | If (R (OTBL)) { |
| 87 | Printf ("EC event indicates tablet mode") |
| 88 | Notify (^VBTN, ^VTBL) |
| 89 | } Else { |
| 90 | Printf ("EC event indicates laptop mode") |
| 91 | Notify (^VBTN, ^VLAP) |
| 92 | } |
| 93 | } |
Duncan Laurie | e52840a | 2018-10-15 15:19:18 -0700 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | /* Handle events in PmEv3 */ |
| 97 | Method (ECQ3, 1, Serialized) |
| 98 | { |
| 99 | Printf ("EVT3: %o", Arg0) |
Duncan Laurie | 98d7de7 | 2018-11-20 17:30:47 -0800 | [diff] [blame] | 100 | |
Duncan Laurie | 4a2558b | 2019-02-01 11:44:14 -0800 | [diff] [blame^] | 101 | If (EBIT (E3CP, Arg0)) { |
| 102 | If (R (P2PB)) { |
| 103 | Printf ("Power button pressed") |
| 104 | Notify (^VBTN, ^VPPB) |
| 105 | } Else { |
| 106 | Printf ("Power button released") |
| 107 | Notify (^VBTN, ^VRPB) |
| 108 | } |
| 109 | } |
| 110 | |
Duncan Laurie | bfb001d | 2018-12-04 10:13:25 -0800 | [diff] [blame] | 111 | #ifdef EC_ENABLE_DPTF |
Duncan Laurie | 98d7de7 | 2018-11-20 17:30:47 -0800 | [diff] [blame] | 112 | /* Theraml Events */ |
| 113 | If (EBIT (E3TH, Arg0)) { |
| 114 | ^PATX () |
| 115 | } |
Duncan Laurie | bfb001d | 2018-12-04 10:13:25 -0800 | [diff] [blame] | 116 | #endif |
Duncan Laurie | e52840a | 2018-10-15 15:19:18 -0700 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | /* Handle events in PmEv4 */ |
| 120 | Method (ECQ4, 1, Serialized) |
| 121 | { |
| 122 | Printf ("EVT4: %o", Arg0) |
| 123 | } |
| 124 | |
Duncan Laurie | e52840a | 2018-10-15 15:19:18 -0700 | [diff] [blame] | 125 | /* Process all events */ |
| 126 | Method (_Q66, 0, Serialized) |
| 127 | { |
| 128 | Local0 = R (EVT1) |
| 129 | If (Local0) { |
| 130 | ECQ1 (Local0) |
| 131 | } |
| 132 | |
| 133 | Local0 = R (EVT2) |
| 134 | If (Local0) { |
| 135 | ECQ2 (Local0) |
| 136 | } |
| 137 | |
| 138 | Local0 = R (EVT3) |
| 139 | If (Local0) { |
| 140 | ECQ3 (Local0) |
| 141 | } |
| 142 | |
| 143 | Local0 = R (EVT4) |
| 144 | If (Local0) { |
| 145 | ECQ4 (Local0) |
| 146 | } |
Duncan Laurie | 45b8465 | 2018-11-17 12:18:20 -0700 | [diff] [blame] | 147 | } |