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