1/* SPDX-License-Identifier: GPL-2.0-only */ 2 3Device (TPSD) 4{ 5 /* 6 * TPSACPI01 is not a valid _HID but it is what the linux topstar 7 * laptop driver expects, use this indirection to let it compile. 8 */ 9 Name (BHID, "TPSACPI01") 10 Method (_HID) 11 { 12 Return (BHID) 13 } 14 Name (_UID, 0) 15 16 Method (FNCX, 1, NotSerialized) 17 { 18 If (Arg0 == 0x86) { 19 /* Enable topstar-laptop kernel driver handling */ 20 ^^EC.TPSE = 1 21 } ElseIf (Arg0 == 0x87) { 22 /* Disable topstar-laptop kernel driver handling */ 23 ^^EC.TPSE = 0 24 } 25 } 26} 27 28Device (EC) 29{ 30 Name (_HID, EisaId ("PNP0C09")) 31 Name (_UID, 0) 32 Name (_GPE, EC_SCI_GPI) 33 34 Name (_CRS, ResourceTemplate () { 35 IO (Decode16, 0x62, 0x62, 0, 1) 36 IO (Decode16, 0x66, 0x66, 0, 1) 37 }) 38 39 OperationRegion (ERAM, EmbeddedControl, 0, 0xFF) 40 Field (ERAM, ByteAcc, Lock, Preserve) 41 { 42 Offset (0x13), 43 RTMP, 8, 44 , 8, 45 BSTS, 2, /* Battery Status */ 46 , 3, 47 BTEX, 1, /* Battery Present */ 48 Offset (0x1D), 49 TPAD, 1, /* Touchpad Enable/Disable */ 50 WIFI, 1, /* WiFi Enable/Disable */ 51 , 3, 52 BTLE, 1, /* Bluetooth Enable/Disable */ 53 Offset (0x25), 54 , 5, 55 FANM, 2, 56 TPSE, 1, /* topstar-laptop driver enable/disable */ 57 Offset (0x31), 58 , 6, 59 LIDS, 1, /* LID Switch */ 60 ACEX, 1, /* AC present */ 61 Offset (0x8E), 62 BTDA, 16, /* Battery Design Capacity */ 63 Offset (0x92), 64 BTVO, 16, /* Battery Present Voltage */ 65 Offset (0x98), 66 BTRA, 16, /* Battery Remaining Capacity */ 67 BTDF, 16, /* Battery Last Full Charge Capacity */ 68 Offset (0x9E), 69 , 4, 70 BFCR, 1, /* Battery Level Critical */ 71 Offset (0xA0), 72 BTDV, 16, /* Battery Design Voltage */ 73 Offset (0xA4), 74 BTPR, 16, /* Battery Present Rate */ 75 Offset (0xE6), 76 TURB, 1, /* EC Requested Turbo Enable/Disable */ 77 EDTB, 1, /* Confirm Turbo Enable/Disable */ 78 } 79 80 Method (_REG, 2, NotSerialized) 81 { 82 /* Initialize AC power state */ 83 \PWRS = ACEX 84 85 /* Initialize LID switch state */ 86 \LIDS = LIDS 87 } 88 89 /* Notify topstar-laptop kernel driver */ 90 Method (TPSN, 1) 91 { 92 If (TPSE) { 93 Notify (^^TPSD, Arg0) 94 } 95 } 96 97 /* KEY_WWW */ 98 Method (_Q10) 99 { 100 TPSN (0x8A) 101 } 102 103 /* KEY_MAIL */ 104 Method (_Q11) 105 { 106 TPSN (0x8B) 107 } 108 109 /* KEY_MEDIA */ 110 Method (_Q12) 111 { 112 TPSN (0x8C) 113 } 114 115 /* AC Status Changed */ 116 Method (_Q20) 117 { 118 \PWRS = ACEX 119 Notify (AC, 0x80) 120 Notify (BAT, 0x80) 121 PNOT () 122 } 123 124 /* Lid Event */ 125 Method (_Q21) 126 { 127 \LIDS = LIDS 128 Notify (LID0, 0x80) 129 } 130 131 /* Battery Event */ 132 Method (_Q22) 133 { 134 Notify (BAT, 0x80) 135 } 136 137 /* KEY_SWITCHVIDEOMODE */ 138 Method (_Q25) 139 { 140 TPSN (0x86) 141 } 142 143 /* KEY_BRIGHTNESSUP */ 144 Method (_Q28) 145 { 146 TPSN (0x80) 147 } 148 149 /* KEY_BRIGHTNESSDOWN */ 150 Method (_Q29) 151 { 152 TPSN (0x81) 153 } 154 155 /* KEY_MUTE */ 156 Method (_Q2A) 157 { 158 TPSN (0x85) 159 } 160 161 /* KEY_VOLUMEUP */ 162 Method (_Q2B) 163 { 164 TPSN (0x83) 165 } 166 167 /* KEY_VOLUMEDOWN */ 168 Method (_Q2C) 169 { 170 TPSN (0x84) 171 } 172 173 /* KEY_SLEEP */ 174 Method (_Q2F) 175 { 176 Notify (\_SB.SLPB, 0x80) 177 } 178 179 /* KEY_F13 (Touchpad Enable/Disable) /* 180 /* Disabled since enabling breaks functionality 181 with Linux topstar driver */ 182 /* Method (_Q34) 183 { 184 TPSN (0x87) 185 ^TPAD ^= 1 186 } */ 187 188 /* KEY_WLAN */ 189 Method (_Q35) 190 { 191 TPSN (0x88) 192 ^WIFI ^= 1 193 } 194 195 /* KEY_BLUETOOTH */ 196 Method (_Q37) 197 { 198 ^BTLE ^= 1 199 } 200 201 /* Turbo Enable/Disable */ 202 Method (_Q50) 203 { 204 /* 205 * Limiting frequency via PPC doesn't do anything if the 206 * kernel is using intel_pstate instead of ACPI _PPC. 207 * 208 * If the state is not updated in EDTB the EC will 209 * repeatedly send this event several times a second 210 * when the system is charging. 211 */ 212 If (TURB) { 213 PPCM = PPCM_TURBO 214 PPCN () 215 EDTB = 1 216 } Else { 217 PPCM = PPCM_NOTURBO 218 PPCN () 219 EDTB = 0 220 } 221 } 222 223 #include "ac.asl" 224 #include "battery.asl" 225} 226 227Scope (\_TZ) 228{ 229 ThermalZone (TZ0) 230 { 231 /* _TMP: Temperature */ 232 Method (_TMP, 0, Serialized) 233 { 234 Local0 = (0x0AAC + (\_SB.PCI0.LPCB.EC.RTMP * 0x0A)) 235 Return (Local0) 236 } 237 238 /* _CRT: Critical Temperature */ 239 Method (_CRT, 0, Serialized) 240 { 241 /* defined in board ec.asl */ 242 Return (CRIT_TEMP) 243 } 244 } 245} 246