Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | Scope (\_SB) { |
| 4 | #include "ac.asl" |
| 5 | #include "battery.asl" |
| 6 | #include "buttons.asl" |
| 7 | #include "hid.asl" |
| 8 | #include "lid.asl" |
| 9 | #include "librem-ec.asl" |
| 10 | } |
| 11 | |
| 12 | Device (\_SB.PCI0.LPCB.EC0) |
| 13 | { |
| 14 | Name (_HID, EisaId ("PNP0C09") /* Embedded Controller Device */) // _HID: Hardware ID |
| 15 | Name (_GPE, EC_GPE_SCI) // _GPE: General Purpose Events |
| 16 | Name (_CRS, ResourceTemplate () // _CRS: Current Resource Settings |
| 17 | { |
| 18 | IO (Decode16, |
| 19 | 0x0062, // Range Minimum |
| 20 | 0x0062, // Range Maximum |
| 21 | 0x00, // Alignment |
| 22 | 0x01, // Length |
| 23 | ) |
| 24 | IO (Decode16, |
| 25 | 0x0066, // Range Minimum |
| 26 | 0x0066, // Range Maximum |
| 27 | 0x00, // Alignment |
| 28 | 0x01, // Length |
| 29 | ) |
| 30 | }) |
| 31 | |
| 32 | #include "ec_ram.asl" |
| 33 | |
Felix Singer | 42efd7f | 2022-12-26 09:38:45 +0100 | [diff] [blame^] | 34 | Name (ECOK, 0) |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 35 | Method (_REG, 2, Serialized) // _REG: Region Availability |
| 36 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 37 | Printf ("EC: _REG %o %o", ToHexString(Arg0), ToHexString(Arg1)) |
Felix Singer | ca4b587 | 2022-12-26 08:17:06 +0100 | [diff] [blame] | 38 | If ((Arg0 == 0x03) && (Arg1 == 1)) { |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 39 | // Enable hardware touchpad lock, airplane mode, and keyboard backlight keys |
| 40 | ECOS = 1 |
| 41 | |
| 42 | // Enable software display brightness keys |
| 43 | WINF = 1 |
| 44 | |
| 45 | // Set current AC state |
| 46 | ^^^^AC.ACFG = ADP |
| 47 | // Update battery information and status |
| 48 | ^^^^BAT0.UPBI() |
| 49 | ^^^^BAT0.UPBS() |
| 50 | |
| 51 | // Notify of changes |
Felix Singer | 42efd7f | 2022-12-26 09:38:45 +0100 | [diff] [blame^] | 52 | Notify(^^^^AC, 0) |
| 53 | Notify(^^^^BAT0, 0) |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 54 | |
| 55 | PNOT () |
| 56 | |
| 57 | // EC is now available |
| 58 | ECOK = Arg1 |
| 59 | |
Nicole Faerber | e00ea2f | 2021-04-15 05:59:37 -0500 | [diff] [blame] | 60 | // Reset Librem EC Device |
| 61 | ^^^^LIEC.RSET() |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 62 | } |
| 63 | } |
| 64 | |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 65 | Method (PTS, 1, Serialized) { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 66 | Printf ("EC: PTS: %o", ToHexString(Arg0)) |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 67 | If (ECOK) { |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 68 | // Clear wake cause |
Felix Singer | 42efd7f | 2022-12-26 09:38:45 +0100 | [diff] [blame^] | 69 | WFNO = 0 |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 70 | } |
| 71 | } |
| 72 | |
| 73 | Method (WAK, 1, Serialized) { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 74 | Printf ("EC: WAK: %o", ToHexString(Arg0)) |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 75 | If (ECOK) { |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 76 | // Set current AC state |
| 77 | ^^^^AC.ACFG = ADP |
| 78 | |
| 79 | // Update battery information and status |
| 80 | ^^^^BAT0.UPBI() |
| 81 | ^^^^BAT0.UPBS() |
| 82 | |
| 83 | // Notify of changes |
Felix Singer | 42efd7f | 2022-12-26 09:38:45 +0100 | [diff] [blame^] | 84 | Notify(^^^^AC, 0) |
| 85 | Notify(^^^^BAT0, 0) |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 86 | |
Nicole Faerber | e00ea2f | 2021-04-15 05:59:37 -0500 | [diff] [blame] | 87 | // Reset Librem EC Device |
| 88 | ^^^^LIEC.RSET() |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 89 | } |
| 90 | } |
| 91 | |
| 92 | Method (_Q0A, 0, NotSerialized) // Touchpad Toggle |
| 93 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 94 | Printf ("EC: Touchpad Toggle") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | Method (_Q0B, 0, NotSerialized) // Screen Toggle |
| 98 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 99 | Printf ("EC: Screen Toggle") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | Method (_Q0C, 0, NotSerialized) // Mute |
| 103 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 104 | Printf ("EC: Mute") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | Method (_Q0D, 0, NotSerialized) // Keyboard Backlight |
| 108 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 109 | Printf ("EC: Keyboard Backlight") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | Method (_Q0E, 0, NotSerialized) // Volume Down |
| 113 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 114 | Printf ("EC: Volume Down") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | Method (_Q0F, 0, NotSerialized) // Volume Up |
| 118 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 119 | Printf ("EC: Volume Up") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | Method (_Q10, 0, NotSerialized) // Switch Video Mode |
| 123 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 124 | Printf ("EC: Switch Video Mode") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | Method (_Q11, 0, NotSerialized) // Brightness Down |
| 128 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 129 | Printf ("EC: Brightness Down") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 130 | if (^^^^HIDD.HRDY) { |
| 131 | ^^^^HIDD.HPEM (20) |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | Method (_Q12, 0, NotSerialized) // Brightness Up |
| 136 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 137 | Printf ("EC: Brightness Up") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 138 | if (^^^^HIDD.HRDY) { |
| 139 | ^^^^HIDD.HPEM (19) |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | Method (_Q13, 0, NotSerialized) // Camera Toggle |
| 144 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 145 | Printf ("EC: Camera Toggle") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | Method (_Q14, 0, NotSerialized) // Airplane Mode |
| 149 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 150 | Printf ("EC: Airplane Mode") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 151 | if (^^^^HIDD.HRDY) { |
| 152 | ^^^^HIDD.HPEM (8) |
| 153 | } |
| 154 | // TODO: hardware airplane mode |
| 155 | } |
| 156 | |
| 157 | Method (_Q15, 0, NotSerialized) // Suspend Button |
| 158 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 159 | Printf ("EC: Suspend Button") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 160 | Notify (SLPB, 0x80) |
| 161 | } |
| 162 | |
| 163 | Method (_Q16, 0, NotSerialized) // AC Detect |
| 164 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 165 | Printf ("EC: AC Detect") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 166 | ^^^^AC.ACFG = ADP |
| 167 | Notify (AC, 0x80) // Status Change |
| 168 | If (BAT0) |
| 169 | { |
| 170 | Notify (^^^^BAT0, 0x81) // Information Change |
| 171 | Notify (^^^^BAT0, 0x80) // Status Change |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | Method (_Q17, 0, NotSerialized) // BAT0 Update |
| 176 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 177 | Printf ("EC: BAT0 Update (17)") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 178 | Notify (^^^^BAT0, 0x81) // Information Change |
| 179 | } |
| 180 | |
| 181 | Method (_Q19, 0, NotSerialized) // BAT0 Update |
| 182 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 183 | Printf ("EC: BAT0 Update (19)") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 184 | Notify (^^^^BAT0, 0x81) // Information Change |
| 185 | } |
| 186 | |
| 187 | Method (_Q1B, 0, NotSerialized) // Lid Close |
| 188 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 189 | Printf ("EC: Lid Close") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 190 | Notify (LID0, 0x80) |
| 191 | } |
| 192 | |
| 193 | Method (_Q1C, 0, NotSerialized) // Thermal Trip |
| 194 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 195 | Printf ("EC: Thermal Trip") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 196 | /* TODO |
| 197 | Notify (\_TZ.TZ0, 0x81) // Thermal Trip Point Change |
| 198 | Notify (\_TZ.TZ0, 0x80) // Thermal Status Change |
| 199 | */ |
| 200 | } |
| 201 | |
| 202 | Method (_Q1D, 0, NotSerialized) // Power Button |
| 203 | { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 204 | Printf ("EC: Power Button") |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 205 | Notify (PWRB, 0x80) |
| 206 | } |
| 207 | |
| 208 | Method (_Q50, 0, NotSerialized) // Other Events |
| 209 | { |
| 210 | Local0 = OEM4 |
| 211 | If (Local0 == 0x8A) { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 212 | Printf ("EC: White Keyboard Backlight") |
Nicole Faerber | e00ea2f | 2021-04-15 05:59:37 -0500 | [diff] [blame] | 213 | Notify (^^^^LIEC, 0x80) |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 214 | } ElseIf (Local0 == 0x9F) { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 215 | Printf ("EC: Color Keyboard Toggle") |
Nicole Faerber | e00ea2f | 2021-04-15 05:59:37 -0500 | [diff] [blame] | 216 | Notify (^^^^LIEC, 0x81) |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 217 | } ElseIf (Local0 == 0x81) { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 218 | Printf ("EC: Color Keyboard Down") |
Nicole Faerber | e00ea2f | 2021-04-15 05:59:37 -0500 | [diff] [blame] | 219 | Notify (^^^^LIEC, 0x82) |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 220 | } ElseIf (Local0 == 0x82) { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 221 | Printf ("EC: Color Keyboard Up") |
Nicole Faerber | e00ea2f | 2021-04-15 05:59:37 -0500 | [diff] [blame] | 222 | Notify (^^^^LIEC, 0x83) |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 223 | } ElseIf (Local0 == 0x80) { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 224 | Printf ("EC: Color Keyboard Color Change") |
Nicole Faerber | e00ea2f | 2021-04-15 05:59:37 -0500 | [diff] [blame] | 225 | Notify (^^^^LIEC, 0x84) |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 226 | } Else { |
Felix Singer | dcebf6c | 2021-12-26 15:24:25 +0100 | [diff] [blame] | 227 | Printf ("EC: Other: %o", ToHexString(Local0)) |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 228 | } |
| 229 | } |
| 230 | |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 231 | #include "battery_thresholds.asl" |
Matt DeVillier | 7d57d56 | 2021-04-14 13:15:43 -0500 | [diff] [blame] | 232 | } |