1/* SPDX-License-Identifier: GPL-2.0-only */ 2 3/* 4 * The mainboard must define a PNOT method to handle power 5 * state notifications and Notify CPU device objects to 6 * re-evaluate their _PPC and _CST tables. 7 */ 8 9Device (EC0) 10{ 11 Name (_HID, EISAID ("PNP0C09")) 12 Name (_UID, 1) 13 Name (_GPE, EC_GPE) // GPE for Runtime SCI 14 15 OperationRegion (ERAM, EmbeddedControl, 0x00, 0xff) 16 Field (ERAM, ByteAcc, Lock, Preserve) 17 { 18 Offset (0x80), 19 BTEX, 1, // Battery Exists 20 , 1, 21 ACEX, 1, // AC Exists 22 , 5, 23 Offset (0x83), 24 LIDS, 1, // Lid Switch State 25 , 7, 26 BTST, 8, // Battery State 27 Offset (0xA2), 28 BTRA, 16, // Battery Remaining Capacity 29 BTPR, 16, // Battery Present Rate 30 BTVO, 16, // Battery Present Voltage 31 Offset (0xB0), 32 BTDA, 16, // Battery Design Capacity 33 BTDF, 16, // Battery Last Full Charge Capacity 34 BTDV, 16, // Battery Design Voltage 35 BTDL, 16, // Battery Design Low 36 Offset (0xC0), 37 CPUT, 8, // CPU Temperature 38 Offset (0xCA), 39 FSL0, 1, // Fan Speed Level 0 40 FSL1, 1, // Fan Speed Level 1 41 FSL2, 1, // Fan Speed Level 2 42 FSL3, 1, // Fan Speed Level 3 43 FSL4, 1, // Fan Speed Level 4 44 , 2, 45 FCOS, 1, // Fan Speed OS Control 46 } 47 48 Method (_CRS, 0, Serialized) 49 { 50 Name (ECMD, ResourceTemplate() 51 { 52 IO (Decode16, 0x62, 0x62, 0, 1) 53 IO (Decode16, 0x66, 0x66, 0, 1) 54 }) 55 Return (ECMD) 56 } 57 58 Method (_REG, 2, NotSerialized) 59 { 60 // Initialize AC power state 61 \PWRS = ACEX 62 63 // Initialize LID switch state 64 \LIDS = LIDS 65 66 // Enable OS control of fan speed 67 FCOS = 1 68 69 // Force a read of CPU temperature 70 Local0 = CPUT 71 /* So that we don't get a warning that Local0 is unused. */ 72 Local0++ 73 } 74 75 PowerResource (FNP0, 0, 0) 76 { 77 Method (_STA) { 78 If (\FLVL <= 0) { 79 Return (1) 80 } Else { 81 Return (0) 82 } 83 } 84 Method (_ON) { 85 If (FCOS) { 86 FSL0 = 1 87 \FLVL = 0 88 Notify (\_TZ.THRM, 0x81) 89 } 90 } 91 Method (_OFF) { 92 If (FCOS) { 93 FSL0 = 0 94 \FLVL = 1 95 Notify (\_TZ.THRM, 0x81) 96 } 97 } 98 } 99 100 PowerResource (FNP1, 0, 0) 101 { 102 Method (_STA) { 103 If (\FLVL <= 1) { 104 Return (1) 105 } Else { 106 Return (0) 107 } 108 } 109 Method (_ON) { 110 If (FCOS) { 111 FSL1 = 1 112 \FLVL = 1 113 Notify (\_TZ.THRM, 0x81) 114 } 115 } 116 Method (_OFF) { 117 If (FCOS) { 118 FSL1 = 0 119 \FLVL = 2 120 Notify (\_TZ.THRM, 0x81) 121 } 122 } 123 } 124 125 PowerResource (FNP2, 0, 0) 126 { 127 Method (_STA) { 128 If (\FLVL <= 2) { 129 Return (1) 130 } Else { 131 Return (0) 132 } 133 } 134 Method (_ON) { 135 If (FCOS) { 136 FSL2 = 1 137 \FLVL = 2 138 Notify (\_TZ.THRM, 0x81) 139 } 140 } 141 Method (_OFF) { 142 If (FCOS) { 143 FSL2 = 0 144 \FLVL = 3 145 Notify (\_TZ.THRM, 0x81) 146 } 147 } 148 } 149 150 PowerResource (FNP3, 0, 0) 151 { 152 Method (_STA) { 153 If (\FLVL <= 3) { 154 Return (1) 155 } Else { 156 Return (0) 157 } 158 } 159 Method (_ON) { 160 If (FCOS) { 161 FSL3 = 1 162 \FLVL = 3 163 Notify (\_TZ.THRM, 0x81) 164 } 165 } 166 Method (_OFF) { 167 If (FCOS) { 168 FSL3 = 0 169 \FLVL = 4 170 Notify (\_TZ.THRM, 0x81) 171 } 172 } 173 } 174 175 PowerResource (FNP4, 0, 0) 176 { 177 Method (_STA) { 178 If (\FLVL <= 4) { 179 Return (1) 180 } Else { 181 Return (0) 182 } 183 } 184 Method (_ON) { 185 If (FCOS) { 186 FSL4 = 1 187 \FLVL = 4 188 Notify (\_TZ.THRM, 0x81) 189 } 190 } 191 Method (_OFF) { 192 If (FCOS) { 193 FSL4 = 0 194 \FLVL = 5 195 Notify (\_TZ.THRM, 0x81) 196 } 197 } 198 } 199 200 Device (FAN0) 201 { 202 Name (_HID, EISAID ("PNP0C0B")) 203 Name (_UID, 0) 204 Name (_PR0, Package () { FNP0 }) 205 } 206 207 Device (FAN1) 208 { 209 Name (_HID, EISAID ("PNP0C0B")) 210 Name (_UID, 1) 211 Name (_PR0, Package () { FNP1 }) 212 } 213 214 Device (FAN2) 215 { 216 Name (_HID, EISAID ("PNP0C0B")) 217 Name (_UID, 2) 218 Name (_PR0, Package () { FNP2 }) 219 } 220 221 Device (FAN3) 222 { 223 Name (_HID, EISAID ("PNP0C0B")) 224 Name (_UID, 3) 225 Name (_PR0, Package () { FNP3 }) 226 } 227 228 Device (FAN4) 229 { 230 Name (_HID, EISAID ("PNP0C0B")) 231 Name (_UID, 4) 232 Name (_PR0, Package () { FNP4 }) 233 } 234 235 // AC Power Connected 236 Method (_Q51, 0, NotSerialized) 237 { 238 \PWRS = 1 239 Notify (AC, 0x80) 240 \PNOT () 241 } 242 243 // AC Power Removed 244 Method (_Q52, 0, NotSerialized) 245 { 246 \PWRS = 0 247 Notify (AC, 0x80) 248 \PNOT () 249 } 250 251 // Battery State Change 252 Method (_Q53, 0, NotSerialized) 253 { 254 Notify (BAT0, 0x80) 255 Notify (BAT0, 0x81) 256 } 257 258 // Battery State Change 259 Method (_Q54, 0, NotSerialized) 260 { 261 Notify (BAT0, 0x80) 262 Notify (BAT0, 0x81) 263 } 264 265 // Power State Change 266 Method (_Q55, 0, NotSerialized) 267 { 268 \PNOT () 269 } 270 271 // Lid Switch Event 272 Method (_Q5E, 0, NotSerialized) 273 { 274 \LIDS = LIDS 275 Notify (\_SB.LID0, 0x80) 276 } 277 278 // Lid Switch Event 279 Method (_Q5F, 0, NotSerialized) 280 { 281 \LIDS = LIDS 282 Notify (\_SB.LID0, 0x80) 283 } 284 285 #include "ac.asl" 286 #include "battery.asl" 287} 288