| 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 */) |
| 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 |
|
| 34 |
Name (ECOK, 0) |
| 35 |
Method (_REG, 2, Serialized) // _REG: Region Availability |
| 36 |
{ |
| 37 |
Printf ("EC: _REG %o %o", ToHexString(Arg0), ToHexString(Arg1)) |
| 38 |
If ((Arg0 == 0x03) && (Arg1 == 1)) { |
| 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 |
| 52 |
Notify(^^^^AC, 0) |
| 53 |
Notify(^^^^BAT0, 0) |
| 54 |
|
| 55 |
PNOT () |
| 56 |
|
| 57 |
// EC is now available |
| 58 |
ECOK = Arg1 |
| 59 |
|
| 60 |
// Reset Librem EC Device |
| 61 |
^^^^LIEC.RSET() |
| 62 |
} |
| 63 |
} |
| 64 |
|
| 65 |
Method (PTS, 1, Serialized) { |
| 66 |
Printf ("EC: PTS: %o", ToHexString(Arg0)) |
| 67 |
If (ECOK) { |
| 68 |
// Clear wake cause |
| 69 |
WFNO = 0 |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
Method (WAK, 1, Serialized) { |
| 74 |
Printf ("EC: WAK: %o", ToHexString(Arg0)) |
| 75 |
If (ECOK) { |
| 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 |
| 84 |
Notify(^^^^AC, 0) |
| 85 |
Notify(^^^^BAT0, 0) |
| 86 |
|
| 87 |
// Reset Librem EC Device |
| 88 |
^^^^LIEC.RSET() |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
Method (_Q0A, 0, NotSerialized) // Touchpad Toggle |
| 93 |
{ |
| 94 |
Printf ("EC: Touchpad Toggle") |
| 95 |
} |
| 96 |
|
| 97 |
Method (_Q0B, 0, NotSerialized) // Screen Toggle |
| 98 |
{ |
| 99 |
Printf ("EC: Screen Toggle") |
| 100 |
} |
| 101 |
|
| 102 |
Method (_Q0C, 0, NotSerialized) // Mute |
| 103 |
{ |
| 104 |
Printf ("EC: Mute") |
| 105 |
} |
| 106 |
|
| 107 |
Method (_Q0D, 0, NotSerialized) // Keyboard Backlight |
| 108 |
{ |
| 109 |
Printf ("EC: Keyboard Backlight") |
| 110 |
} |
| 111 |
|
| 112 |
Method (_Q0E, 0, NotSerialized) // Volume Down |
| 113 |
{ |
| 114 |
Printf ("EC: Volume Down") |
| 115 |
} |
| 116 |
|
| 117 |
Method (_Q0F, 0, NotSerialized) // Volume Up |
| 118 |
{ |
| 119 |
Printf ("EC: Volume Up") |
| 120 |
} |
| 121 |
|
| 122 |
Method (_Q10, 0, NotSerialized) // Switch Video Mode |
| 123 |
{ |
| 124 |
Printf ("EC: Switch Video Mode") |
| 125 |
} |
| 126 |
|
| 127 |
Method (_Q11, 0, NotSerialized) // Brightness Down |
| 128 |
{ |
| 129 |
Printf ("EC: Brightness Down") |
| 130 |
if (^^^^HIDD.HRDY) { |
| 131 |
^^^^HIDD.HPEM (20) |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
Method (_Q12, 0, NotSerialized) // Brightness Up |
| 136 |
{ |
| 137 |
Printf ("EC: Brightness Up") |
| 138 |
if (^^^^HIDD.HRDY) { |
| 139 |
^^^^HIDD.HPEM (19) |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
Method (_Q13, 0, NotSerialized) // Camera Toggle |
| 144 |
{ |
| 145 |
Printf ("EC: Camera Toggle") |
| 146 |
} |
| 147 |
|
| 148 |
Method (_Q14, 0, NotSerialized) // Airplane Mode |
| 149 |
{ |
| 150 |
Printf ("EC: Airplane Mode") |
| 151 |
if (^^^^HIDD.HRDY) { |
| 152 |
^^^^HIDD.HPEM (8) |
| 153 |
} |
| 154 |
// TODO: hardware airplane mode |
| 155 |
} |
| 156 |
|
| 157 |
Method (_Q15, 0, NotSerialized) // Suspend Button |
| 158 |
{ |
| 159 |
Printf ("EC: Suspend Button") |
| 160 |
Notify (SLPB, 0x80) |
| 161 |
} |
| 162 |
|
| 163 |
Method (_Q16, 0, NotSerialized) // AC Detect |
| 164 |
{ |
| 165 |
Printf ("EC: AC Detect") |
| 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 |
{ |
| 177 |
Printf ("EC: BAT0 Update (17)") |
| 178 |
Notify (^^^^BAT0, 0x81) // Information Change |
| 179 |
} |
| 180 |
|
| 181 |
Method (_Q19, 0, NotSerialized) // BAT0 Update |
| 182 |
{ |
| 183 |
Printf ("EC: BAT0 Update (19)") |
| 184 |
Notify (^^^^BAT0, 0x81) // Information Change |
| 185 |
} |
| 186 |
|
| 187 |
Method (_Q1B, 0, NotSerialized) // Lid Close |
| 188 |
{ |
| 189 |
Printf ("EC: Lid Close") |
| 190 |
Notify (LID0, 0x80) |
| 191 |
} |
| 192 |
|
| 193 |
Method (_Q1C, 0, NotSerialized) // Thermal Trip |
| 194 |
{ |
| 195 |
Printf ("EC: Thermal Trip") |
| 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 |
{ |
| 204 |
Printf ("EC: Power Button") |
| 205 |
Notify (PWRB, 0x80) |
| 206 |
} |
| 207 |
|
| 208 |
Method (_Q50, 0, NotSerialized) // Other Events |
| 209 |
{ |
| 210 |
Local0 = OEM4 |
| 211 |
If (Local0 == 0x8A) { |
| 212 |
Printf ("EC: White Keyboard Backlight") |
| 213 |
Notify (^^^^LIEC, 0x80) |
| 214 |
} ElseIf (Local0 == 0x9F) { |
| 215 |
Printf ("EC: Color Keyboard Toggle") |
| 216 |
Notify (^^^^LIEC, 0x81) |
| 217 |
} ElseIf (Local0 == 0x81) { |
| 218 |
Printf ("EC: Color Keyboard Down") |
| 219 |
Notify (^^^^LIEC, 0x82) |
| 220 |
} ElseIf (Local0 == 0x82) { |
| 221 |
Printf ("EC: Color Keyboard Up") |
| 222 |
Notify (^^^^LIEC, 0x83) |
| 223 |
} ElseIf (Local0 == 0x80) { |
| 224 |
Printf ("EC: Color Keyboard Color Change") |
| 225 |
Notify (^^^^LIEC, 0x84) |
| 226 |
} Else { |
| 227 |
Printf ("EC: Other: %o", ToHexString(Local0)) |
| 228 |
} |
| 229 |
} |
| 230 |
|
| 231 |
#include "battery_thresholds.asl" |
| 232 |
} |