Angel Pons | 210a008 | 2020-04-02 23:48:24 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 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 | |
Duncan Laurie | d338b46 | 2013-07-31 15:30:41 -0700 | [diff] [blame] | 9 | // Mainboard specific throttle handler |
Freddy Paul | e8cc52f | 2015-10-02 19:06:57 -0700 | [diff] [blame] | 10 | #ifdef DPTF_ENABLE_CHARGER |
Duncan Laurie | 3f1500f | 2014-03-06 08:37:49 -0800 | [diff] [blame] | 11 | External (\_SB.DPTF.TCHG, DeviceObj) |
Freddy Paul | e8cc52f | 2015-10-02 19:06:57 -0700 | [diff] [blame] | 12 | #endif |
Chris Wang | e019bd9 | 2020-08-06 16:38:04 +0800 | [diff] [blame] | 13 | /* Enable DPTC interface with AMD ALIB */ |
| 14 | #ifdef EC_ENABLE_AMD_DPTC_SUPPORT |
| 15 | External(\_SB.DPTC, MethodObj) |
| 16 | #endif |
Duncan Laurie | d338b46 | 2013-07-31 15:30:41 -0700 | [diff] [blame] | 17 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 18 | Device (EC0) |
| 19 | { |
| 20 | Name (_HID, EISAID ("PNP0C09")) |
| 21 | Name (_UID, 1) |
Duncan Laurie | 045222f | 2013-05-21 07:49:11 -0700 | [diff] [blame] | 22 | Name (_GPE, EC_SCI_GPI) |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 23 | Name (TOFS, EC_TEMP_SENSOR_OFFSET) |
Duncan Laurie | 433432b | 2013-06-03 10:38:22 -0700 | [diff] [blame] | 24 | Name (TNCA, EC_TEMP_SENSOR_NOT_CALIBRATED) |
| 25 | Name (TNOP, EC_TEMP_SENSOR_NOT_POWERED) |
| 26 | Name (TBAD, EC_TEMP_SENSOR_ERROR) |
| 27 | Name (TNPR, EC_TEMP_SENSOR_NOT_PRESENT) |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 28 | Name (DWRN, 15) // Battery capacity warning at 15% |
| 29 | Name (DLOW, 10) // Battery capacity low at 10% |
| 30 | |
Shawn Nematbakhsh | 37b7a66 | 2015-03-24 11:07:51 -0700 | [diff] [blame] | 31 | OperationRegion (ERAM, EmbeddedControl, 0x00, EC_ACPI_MEM_MAPPED_BEGIN) |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 32 | Field (ERAM, ByteAcc, Lock, Preserve) |
| 33 | { |
| 34 | Offset (0x00), |
| 35 | RAMV, 8, // EC RAM Version |
| 36 | TSTB, 8, // Test Byte |
| 37 | TSTC, 8, // Complement of Test Byte |
Patrick Georgi | f9267f9 | 2017-08-24 23:12:55 +0200 | [diff] [blame] | 38 | KBLV, 8, // Keyboard Backlight value |
Duncan Laurie | ad8d913 | 2013-12-10 07:41:33 -0800 | [diff] [blame] | 39 | FAND, 8, // Set Fan Duty Cycle |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 40 | PATI, 8, // Programmable Auxiliary Trip Sensor ID |
| 41 | PATT, 8, // Programmable Auxiliary Trip Threshold |
| 42 | PATC, 8, // Programmable Auxiliary Trip Commit |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 43 | CHGL, 8, // Charger Current Limit |
jiazi Yang | 51fc93f | 2016-07-28 05:15:01 -0400 | [diff] [blame] | 44 | TBMD, 1, // Tablet mode |
Karthikeyan Ramasubramanian | 036ccd7 | 2018-10-23 22:16:36 -0600 | [diff] [blame] | 45 | DDPN, 3, // Device DPTF Profile Number |
Patrick Georgi | f9267f9 | 2017-08-24 23:12:55 +0200 | [diff] [blame] | 46 | // DFUD must be 0 for the other 31 values to be valid |
Patrick Georgi | 4bd68b8 | 2017-08-18 21:06:24 +0200 | [diff] [blame] | 47 | Offset (0x0a), |
Patrick Georgi | f9267f9 | 2017-08-24 23:12:55 +0200 | [diff] [blame] | 48 | DFUD, 1, // Device Features Undefined |
| 49 | FLSH, 1, // Flash commands present |
| 50 | PFAN, 1, // PWM Fan control present |
| 51 | KBLE, 1, // Keyboard Backlight present |
| 52 | LTBR, 1, // Lightbar present |
| 53 | LEDC, 1, // LED control |
| 54 | MTNS, 1, // Motion sensors present |
| 55 | KEYB, 1, // EC is keyboard controller |
| 56 | PSTR, 1, // Persistent storage |
| 57 | P80P, 1, // EC serves I/O Port 80h |
| 58 | THRM, 1, // EC supports thermal management |
| 59 | SBKL, 1, // Screen backlight switch present |
| 60 | WIFI, 1, // WIFI switch present |
| 61 | HOST, 1, // EC monitors host events (eg SCI, SMI) |
| 62 | GPIO, 1, // EC provides GPIO commands |
| 63 | I2CB, 1, // EC provides I2C controller access |
| 64 | CHRG, 1, // EC provides commands for charger control |
| 65 | BATT, 1, // Simply Battery support |
| 66 | SBAT, 1, // Smart Battery support |
| 67 | HANG, 1, // EC can detect host hang |
| 68 | PMUI, 1, // Power Information |
| 69 | DSEC, 1, // another EC exists downstream |
| 70 | UPDC, 1, // supports USB Power Delivery |
| 71 | UMUX, 1, // supports USB Mux |
| 72 | MSFF, 1, // Motion Sense has FIFO |
| 73 | TVST, 1, // supports temporary secure vstore |
| 74 | TCMV, 1, // USB Type C Muxing is virtual (host assisted) |
| 75 | RTCD, 1, // EC provides an RTC device |
| 76 | FPRD, 1, // EC provides a fingerprint reader device |
| 77 | TPAD, 1, // EC provides a touchpad device |
| 78 | RWSG, 1, // EC has RWSIG task enabled |
| 79 | DEVE, 1, // EC supports device events |
| 80 | // make sure we're within our space envelope |
| 81 | Offset (0x0e), |
Nicolas Boichat | 07fe618 | 2018-01-26 14:37:16 +0800 | [diff] [blame] | 82 | Offset (0x12), |
| 83 | BTID, 8, // Battery index that host wants to read |
Emil Lundmark | 9d5f9f2 | 2018-05-22 19:31:37 +0200 | [diff] [blame] | 84 | USPP, 8, // USB Port Power |
Subrata Banik | f5c3e29 | 2020-11-30 16:10:34 +0530 | [diff] [blame^] | 85 | } |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 86 | |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 87 | #if CONFIG(EC_GOOGLE_CHROMEEC_ACPI_MEMMAP) |
Shawn Nematbakhsh | 37b7a66 | 2015-03-24 11:07:51 -0700 | [diff] [blame] | 88 | OperationRegion (EMEM, EmbeddedControl, |
| 89 | EC_ACPI_MEM_MAPPED_BEGIN, EC_ACPI_MEM_MAPPED_SIZE) |
| 90 | Field (EMEM, ByteAcc, Lock, Preserve) |
| 91 | #else |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 92 | OperationRegion (EMEM, SystemIO, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE) |
| 93 | Field (EMEM, ByteAcc, NoLock, Preserve) |
Shawn Nematbakhsh | 37b7a66 | 2015-03-24 11:07:51 -0700 | [diff] [blame] | 94 | #endif |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 95 | { |
Shawn Nematbakhsh | 37b7a66 | 2015-03-24 11:07:51 -0700 | [diff] [blame] | 96 | #include "emem.asl" |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 97 | } |
| 98 | |
Aaron Durbin | 05201d7 | 2016-09-23 16:06:14 -0500 | [diff] [blame] | 99 | #ifdef EC_ENABLE_LID_SWITCH |
| 100 | /* LID Switch */ |
| 101 | Device (LID0) |
| 102 | { |
| 103 | Name (_HID, EisaId ("PNP0C0D")) |
| 104 | Method (_LID, 0) |
| 105 | { |
| 106 | Return (^^LIDS) |
| 107 | } |
| 108 | |
| 109 | #ifdef EC_ENABLE_WAKE_PIN |
| 110 | Name (_PRW, Package () { EC_ENABLE_WAKE_PIN, 0x5 }) |
| 111 | #endif |
| 112 | } |
| 113 | #endif |
| 114 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 115 | Method (TINS, 1, Serialized) |
| 116 | { |
| 117 | Switch (ToInteger (Arg0)) |
| 118 | { |
| 119 | Case (0) { Return (TIN0) } |
| 120 | Case (1) { Return (TIN1) } |
| 121 | Case (2) { Return (TIN2) } |
| 122 | Case (3) { Return (TIN3) } |
| 123 | Case (4) { Return (TIN4) } |
| 124 | Case (5) { Return (TIN5) } |
| 125 | Case (6) { Return (TIN6) } |
| 126 | Case (7) { Return (TIN7) } |
| 127 | Case (8) { Return (TIN8) } |
| 128 | Case (9) { Return (TIN9) } |
| 129 | Default { Return (TIN0) } |
| 130 | } |
| 131 | } |
| 132 | |
Duncan Laurie | 20373c0 | 2015-09-22 09:40:37 -0700 | [diff] [blame] | 133 | Method (_CRS, 0, Serialized) |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 134 | { |
| 135 | Name (ECMD, ResourceTemplate() |
| 136 | { |
| 137 | IO (Decode16, |
| 138 | EC_LPC_ADDR_ACPI_DATA, |
| 139 | EC_LPC_ADDR_ACPI_DATA, |
| 140 | 0, 1) |
| 141 | IO (Decode16, |
| 142 | EC_LPC_ADDR_ACPI_CMD, |
| 143 | EC_LPC_ADDR_ACPI_CMD, |
| 144 | 0, 1) |
| 145 | }) |
| 146 | Return (ECMD) |
| 147 | } |
| 148 | |
| 149 | Method (_REG, 2, NotSerialized) |
| 150 | { |
| 151 | // Initialize AC power state |
| 152 | Store (ACEX, \PWRS) |
Furquan Shaikh | 80c555d | 2020-06-12 10:01:20 -0700 | [diff] [blame] | 153 | /* |
| 154 | * Inform platform code about the current AC power state. |
| 155 | * This allows the platform to take any action based on the initialized state. |
| 156 | * PWRS isn't valid before this point. |
| 157 | */ |
| 158 | \PNOT () |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 159 | |
| 160 | // Initialize LID switch state |
| 161 | Store (LIDS, \LIDS) |
Kevin Chiu | 83f0c69 | 2020-09-22 00:48:36 +0800 | [diff] [blame] | 162 | |
| 163 | #ifdef EC_ENABLE_AMD_DPTC_SUPPORT |
| 164 | /* |
| 165 | * Per the device mode (clamshell or tablet) to initialize |
| 166 | * the thermal setting on OS startup. |
| 167 | */ |
| 168 | If (CondRefOf (\_SB.DPTC)) { |
| 169 | \_SB.DPTC() |
| 170 | } |
| 171 | #endif |
| 172 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 173 | } |
| 174 | |
Duncan Laurie | ad8d913 | 2013-12-10 07:41:33 -0800 | [diff] [blame] | 175 | /* Read requested temperature and check against EC error values */ |
| 176 | Method (TSRD, 1, Serialized) |
| 177 | { |
| 178 | Store (\_SB.PCI0.LPCB.EC0.TINS (Arg0), Local0) |
| 179 | |
| 180 | /* Check for sensor not calibrated */ |
| 181 | If (LEqual (Local0, \_SB.PCI0.LPCB.EC0.TNCA)) { |
| 182 | Return (Zero) |
| 183 | } |
| 184 | |
| 185 | /* Check for sensor not present */ |
| 186 | If (LEqual (Local0, \_SB.PCI0.LPCB.EC0.TNPR)) { |
| 187 | Return (Zero) |
| 188 | } |
| 189 | |
| 190 | /* Check for sensor not powered */ |
| 191 | If (LEqual (Local0, \_SB.PCI0.LPCB.EC0.TNOP)) { |
| 192 | Return (Zero) |
| 193 | } |
| 194 | |
| 195 | /* Check for sensor bad reading */ |
| 196 | If (LEqual (Local0, \_SB.PCI0.LPCB.EC0.TBAD)) { |
| 197 | Return (Zero) |
| 198 | } |
| 199 | |
| 200 | /* Adjust by offset to get Kelvin */ |
| 201 | Add (\_SB.PCI0.LPCB.EC0.TOFS, Local0, Local0) |
| 202 | |
| 203 | /* Convert to 1/10 Kelvin */ |
| 204 | Multiply (Local0, 10, Local0) |
| 205 | |
| 206 | Return (Local0) |
| 207 | } |
| 208 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 209 | // Lid Closed Event |
| 210 | Method (_Q01, 0, NotSerialized) |
| 211 | { |
| 212 | Store ("EC: LID CLOSE", Debug) |
| 213 | Store (LIDS, \LIDS) |
Aaron Durbin | 05201d7 | 2016-09-23 16:06:14 -0500 | [diff] [blame] | 214 | #ifdef EC_ENABLE_LID_SWITCH |
| 215 | Notify (LID0, 0x80) |
Aaron Durbin | 05201d7 | 2016-09-23 16:06:14 -0500 | [diff] [blame] | 216 | #endif |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | // Lid Open Event |
| 220 | Method (_Q02, 0, NotSerialized) |
| 221 | { |
| 222 | Store ("EC: LID OPEN", Debug) |
| 223 | Store (LIDS, \LIDS) |
Furquan Shaikh | a3a8456 | 2017-11-28 14:32:17 -0800 | [diff] [blame] | 224 | Notify (CREC, 0x2) |
Aaron Durbin | 05201d7 | 2016-09-23 16:06:14 -0500 | [diff] [blame] | 225 | #ifdef EC_ENABLE_LID_SWITCH |
| 226 | Notify (LID0, 0x80) |
Aaron Durbin | 05201d7 | 2016-09-23 16:06:14 -0500 | [diff] [blame] | 227 | #endif |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | // Power Button |
| 231 | Method (_Q03, 0, NotSerialized) |
| 232 | { |
| 233 | Store ("EC: POWER BUTTON", Debug) |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | // AC Connected |
| 237 | Method (_Q04, 0, NotSerialized) |
| 238 | { |
| 239 | Store ("EC: AC CONNECTED", Debug) |
| 240 | Store (ACEX, \PWRS) |
| 241 | Notify (AC, 0x80) |
Freddy Paul | e8cc52f | 2015-10-02 19:06:57 -0700 | [diff] [blame] | 242 | #ifdef DPTF_ENABLE_CHARGER |
Duncan Laurie | 3f1500f | 2014-03-06 08:37:49 -0800 | [diff] [blame] | 243 | If (CondRefOf (\_SB.DPTF.TCHG)) { |
| 244 | Notify (\_SB.DPTF.TCHG, 0x80) |
| 245 | } |
Freddy Paul | e8cc52f | 2015-10-02 19:06:57 -0700 | [diff] [blame] | 246 | #endif |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 247 | \PNOT () |
| 248 | } |
| 249 | |
| 250 | // AC Disconnected |
| 251 | Method (_Q05, 0, NotSerialized) |
| 252 | { |
| 253 | Store ("EC: AC DISCONNECTED", Debug) |
| 254 | Store (ACEX, \PWRS) |
| 255 | Notify (AC, 0x80) |
Freddy Paul | e8cc52f | 2015-10-02 19:06:57 -0700 | [diff] [blame] | 256 | #ifdef DPTF_ENABLE_CHARGER |
Duncan Laurie | 3f1500f | 2014-03-06 08:37:49 -0800 | [diff] [blame] | 257 | If (CondRefOf (\_SB.DPTF.TCHG)) { |
| 258 | Notify (\_SB.DPTF.TCHG, 0x80) |
| 259 | } |
Freddy Paul | e8cc52f | 2015-10-02 19:06:57 -0700 | [diff] [blame] | 260 | #endif |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 261 | \PNOT () |
| 262 | } |
| 263 | |
| 264 | // Battery Low Event |
| 265 | Method (_Q06, 0, NotSerialized) |
| 266 | { |
| 267 | Store ("EC: BATTERY LOW", Debug) |
| 268 | Notify (BAT0, 0x80) |
| 269 | } |
| 270 | |
| 271 | // Battery Critical Event |
| 272 | Method (_Q07, 0, NotSerialized) |
| 273 | { |
| 274 | Store ("EC: BATTERY CRITICAL", Debug) |
| 275 | Notify (BAT0, 0x80) |
| 276 | } |
| 277 | |
| 278 | // Battery Info Event |
| 279 | Method (_Q08, 0, NotSerialized) |
| 280 | { |
| 281 | Store ("EC: BATTERY INFO", Debug) |
| 282 | Notify (BAT0, 0x81) |
Nicolas Boichat | 07fe618 | 2018-01-26 14:37:16 +0800 | [diff] [blame] | 283 | #ifdef EC_ENABLE_SECOND_BATTERY_DEVICE |
| 284 | If (CondRefOf (BAT1)) { |
| 285 | Notify (BAT1, 0x81) |
| 286 | } |
| 287 | #endif |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 288 | } |
| 289 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 290 | // Thermal Overload Event |
| 291 | Method (_Q0A, 0, NotSerialized) |
| 292 | { |
| 293 | Store ("EC: THERMAL OVERLOAD", Debug) |
| 294 | Notify (\_TZ, 0x80) |
| 295 | } |
| 296 | |
| 297 | // Thermal Event |
| 298 | Method (_Q0B, 0, NotSerialized) |
| 299 | { |
| 300 | Store ("EC: THERMAL", Debug) |
| 301 | Notify (\_TZ, 0x80) |
| 302 | } |
| 303 | |
| 304 | // USB Charger |
| 305 | Method (_Q0C, 0, NotSerialized) |
| 306 | { |
| 307 | Store ("EC: USB CHARGER", Debug) |
| 308 | } |
| 309 | |
| 310 | // Key Pressed |
| 311 | Method (_Q0D, 0, NotSerialized) |
| 312 | { |
| 313 | Store ("EC: KEY PRESSED", Debug) |
Furquan Shaikh | a3a8456 | 2017-11-28 14:32:17 -0800 | [diff] [blame] | 314 | Notify (CREC, 0x2) |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 315 | } |
| 316 | |
Duncan Laurie | 18d9899b | 2013-08-28 09:54:04 -0700 | [diff] [blame] | 317 | // Thermal Shutdown Imminent |
| 318 | Method (_Q10, 0, NotSerialized) |
| 319 | { |
| 320 | Store ("EC: THERMAL SHUTDOWN", Debug) |
| 321 | Notify (\_TZ, 0x80) |
| 322 | } |
| 323 | |
| 324 | // Battery Shutdown Imminent |
| 325 | Method (_Q11, 0, NotSerialized) |
| 326 | { |
| 327 | Store ("EC: BATTERY SHUTDOWN", Debug) |
| 328 | Notify (BAT0, 0x80) |
| 329 | } |
| 330 | |
Duncan Laurie | d338b46 | 2013-07-31 15:30:41 -0700 | [diff] [blame] | 331 | // Throttle Start |
| 332 | Method (_Q12, 0, NotSerialized) |
| 333 | { |
Martin Roth | 6b1ceac | 2018-05-06 17:58:36 -0500 | [diff] [blame] | 334 | #ifdef EC_ENABLE_THROTTLING_HANDLER |
Duncan Laurie | d338b46 | 2013-07-31 15:30:41 -0700 | [diff] [blame] | 335 | Store ("EC: THROTTLE START", Debug) |
Martin Roth | 6b1ceac | 2018-05-06 17:58:36 -0500 | [diff] [blame] | 336 | \_TZ.THRT (1) |
| 337 | #endif |
Duncan Laurie | d338b46 | 2013-07-31 15:30:41 -0700 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | // Throttle Stop |
| 341 | Method (_Q13, 0, NotSerialized) |
| 342 | { |
Martin Roth | 6b1ceac | 2018-05-06 17:58:36 -0500 | [diff] [blame] | 343 | #ifdef EC_ENABLE_THROTTLING_HANDLER |
Duncan Laurie | d338b46 | 2013-07-31 15:30:41 -0700 | [diff] [blame] | 344 | Store ("EC: THROTTLE STOP", Debug) |
Martin Roth | 6b1ceac | 2018-05-06 17:58:36 -0500 | [diff] [blame] | 345 | \_TZ.THRT (0) |
| 346 | #endif |
Duncan Laurie | d338b46 | 2013-07-31 15:30:41 -0700 | [diff] [blame] | 347 | } |
| 348 | |
Shawn Nematbakhsh | 98cc94c | 2014-08-28 11:33:41 -0700 | [diff] [blame] | 349 | #ifdef EC_ENABLE_PD_MCU_DEVICE |
| 350 | // PD event |
| 351 | Method (_Q16, 0, NotSerialized) |
| 352 | { |
| 353 | Store ("EC: GOT PD EVENT", Debug) |
Prashant Malani | dabc0ad | 2020-03-10 15:42:54 -0700 | [diff] [blame] | 354 | Notify (\_SB.PCI0.LPCB.EC0.CREC.ECPD, 0x80) |
Shawn Nematbakhsh | 98cc94c | 2014-08-28 11:33:41 -0700 | [diff] [blame] | 355 | } |
| 356 | #endif |
| 357 | |
Duncan Laurie | d840118 | 2014-09-29 08:32:19 -0700 | [diff] [blame] | 358 | // Battery Status |
| 359 | Method (_Q17, 0, NotSerialized) |
| 360 | { |
| 361 | Store ("EC: BATTERY STATUS", Debug) |
| 362 | Notify (BAT0, 0x80) |
Nicolas Boichat | 07fe618 | 2018-01-26 14:37:16 +0800 | [diff] [blame] | 363 | #ifdef EC_ENABLE_SECOND_BATTERY_DEVICE |
| 364 | If (CondRefOf (BAT1)) { |
| 365 | Notify (BAT1, 0x80) |
| 366 | } |
| 367 | #endif |
Duncan Laurie | d840118 | 2014-09-29 08:32:19 -0700 | [diff] [blame] | 368 | } |
| 369 | |
Gwendal Grignou | 95b7a6c | 2016-05-03 23:53:23 -0700 | [diff] [blame] | 370 | // MKBP interrupt. |
Gwendal Grignou | 880b458 | 2016-06-20 08:49:25 -0700 | [diff] [blame] | 371 | Method (_Q1B, 0, NotSerialized) |
Gwendal Grignou | 95b7a6c | 2016-05-03 23:53:23 -0700 | [diff] [blame] | 372 | { |
| 373 | Store ("EC: MKBP", Debug) |
| 374 | Notify (CREC, 0x80) |
| 375 | } |
| 376 | |
Brandon Breitenstein | bc885c1 | 2020-04-01 13:30:37 -0700 | [diff] [blame] | 377 | #ifdef EC_ENABLE_PD_MCU_DEVICE |
| 378 | // USB MUX Interrupt |
| 379 | Method (_Q1C, 0, NotSerialized) |
| 380 | { |
| 381 | Store ("EC: USB MUX", Debug) |
| 382 | Notify (\_SB.PCI0.LPCB.EC0.CREC.ECPD, 0x80) |
| 383 | } |
| 384 | #endif |
| 385 | |
jiazi Yang | 51fc93f | 2016-07-28 05:15:01 -0400 | [diff] [blame] | 386 | // TABLET mode switch Event |
| 387 | Method (_Q1D, 0, NotSerialized) |
| 388 | { |
| 389 | Store ("EC: TABLET mode switch Event", Debug) |
Furquan Shaikh | a3a8456 | 2017-11-28 14:32:17 -0800 | [diff] [blame] | 390 | Notify (CREC, 0x2) |
Karthikeyan Ramasubramanian | 017b5c4 | 2018-11-14 08:53:01 -0700 | [diff] [blame] | 391 | #ifdef EC_ENABLE_MULTIPLE_DPTF_PROFILES |
Martin Roth | 9c05598 | 2018-05-01 21:52:42 -0500 | [diff] [blame] | 392 | \_SB.DPTF.TPET() |
Furquan Shaikh | c96ad86 | 2018-01-26 10:40:09 -0800 | [diff] [blame] | 393 | #endif |
| 394 | #ifdef EC_ENABLE_TBMC_DEVICE |
Gwendal Grignou | 87d5fb8 | 2017-01-19 18:30:21 -0800 | [diff] [blame] | 395 | Notify (TBMC, 0x80) |
Gwendal Grignou | 87d5fb8 | 2017-01-19 18:30:21 -0800 | [diff] [blame] | 396 | #endif |
Chris Wang | e019bd9 | 2020-08-06 16:38:04 +0800 | [diff] [blame] | 397 | #ifdef EC_ENABLE_AMD_DPTC_SUPPORT |
| 398 | If (CondRefOf (\_SB.DPTC)) { |
| 399 | \_SB.DPTC() |
| 400 | } |
| 401 | #endif |
Furquan Shaikh | a3a8456 | 2017-11-28 14:32:17 -0800 | [diff] [blame] | 402 | } |
jiazi Yang | 51fc93f | 2016-07-28 05:15:01 -0400 | [diff] [blame] | 403 | |
Duncan Laurie | ad8d913 | 2013-12-10 07:41:33 -0800 | [diff] [blame] | 404 | /* |
| 405 | * Dynamic Platform Thermal Framework support |
| 406 | */ |
| 407 | |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 408 | /* Mutex for EC PAT interface */ |
| 409 | Mutex (PATM, 1) |
| 410 | |
Duncan Laurie | ad8d913 | 2013-12-10 07:41:33 -0800 | [diff] [blame] | 411 | /* |
| 412 | * Set Aux Trip Point 0 |
| 413 | * Arg0 = Temp Sensor ID |
| 414 | * Arg1 = Value to set |
| 415 | */ |
| 416 | Method (PAT0, 2, Serialized) |
| 417 | { |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 418 | If (Acquire (^PATM, 1000)) { |
| 419 | Return (0) |
| 420 | } |
| 421 | |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 422 | /* Set sensor ID */ |
| 423 | Store (ToInteger (Arg0), ^PATI) |
| 424 | |
Duncan Laurie | 8be6759 | 2014-01-09 10:01:05 -0800 | [diff] [blame] | 425 | /* Temperature is passed in 1/10 Kelvin */ |
Duncan Laurie | 20373c0 | 2015-09-22 09:40:37 -0700 | [diff] [blame] | 426 | Divide (ToInteger (Arg1), 10, , Local1) |
Duncan Laurie | 8be6759 | 2014-01-09 10:01:05 -0800 | [diff] [blame] | 427 | |
| 428 | /* Adjust by EC temperature offset */ |
| 429 | Subtract (Local1, ^TOFS, ^PATT) |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 430 | |
| 431 | /* Set commit value with SELECT=0 and ENABLE=1 */ |
| 432 | Store (0x02, ^PATC) |
| 433 | |
| 434 | Release (^PATM) |
| 435 | Return (1) |
Duncan Laurie | ad8d913 | 2013-12-10 07:41:33 -0800 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | /* |
| 439 | * Set Aux Trip Point 1 |
| 440 | * Arg0 = Temp Sensor ID |
| 441 | * Arg1 = Value to set |
| 442 | */ |
| 443 | Method (PAT1, 2, Serialized) |
| 444 | { |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 445 | If (Acquire (^PATM, 1000)) { |
| 446 | Return (0) |
| 447 | } |
| 448 | |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 449 | /* Set sensor ID */ |
| 450 | Store (ToInteger (Arg0), ^PATI) |
| 451 | |
Duncan Laurie | 8be6759 | 2014-01-09 10:01:05 -0800 | [diff] [blame] | 452 | /* Temperature is passed in 1/10 Kelvin */ |
Duncan Laurie | 20373c0 | 2015-09-22 09:40:37 -0700 | [diff] [blame] | 453 | Divide (ToInteger (Arg1), 10, , Local1) |
Duncan Laurie | 8be6759 | 2014-01-09 10:01:05 -0800 | [diff] [blame] | 454 | |
| 455 | /* Adjust by EC temperature offset */ |
| 456 | Subtract (Local1, ^TOFS, ^PATT) |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 457 | |
| 458 | /* Set commit value with SELECT=1 and ENABLE=1 */ |
| 459 | Store (0x03, ^PATC) |
| 460 | |
| 461 | Release (^PATM) |
| 462 | Return (1) |
| 463 | } |
| 464 | |
Duncan Laurie | 8be6759 | 2014-01-09 10:01:05 -0800 | [diff] [blame] | 465 | /* Disable Aux Trip Points |
| 466 | * Arg0 = Temp Sensor ID |
| 467 | */ |
| 468 | Method (PATD, 1, Serialized) |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 469 | { |
| 470 | If (Acquire (^PATM, 1000)) { |
| 471 | Return (0) |
| 472 | } |
| 473 | |
Duncan Laurie | 8be6759 | 2014-01-09 10:01:05 -0800 | [diff] [blame] | 474 | Store (ToInteger (Arg0), ^PATI) |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 475 | Store (0x00, ^PATT) |
| 476 | |
| 477 | /* Disable PAT0 */ |
| 478 | Store (0x00, ^PATC) |
| 479 | |
| 480 | /* Disable PAT1 */ |
| 481 | Store (0x01, ^PATC) |
| 482 | |
| 483 | Release (^PATM) |
| 484 | Return (1) |
Duncan Laurie | ad8d913 | 2013-12-10 07:41:33 -0800 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | /* |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 488 | * Thermal Threshold Event |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 489 | */ |
Duncan Laurie | 8be6759 | 2014-01-09 10:01:05 -0800 | [diff] [blame] | 490 | Method (_Q09, 0, NotSerialized) |
Duncan Laurie | ad8d913 | 2013-12-10 07:41:33 -0800 | [diff] [blame] | 491 | { |
Marc Jones | e17ec3e | 2018-08-15 22:53:34 -0600 | [diff] [blame] | 492 | If (LNot(Acquire (^PATM, 1000))) { |
| 493 | /* Read sensor ID for event */ |
| 494 | Store (^PATI, Local0) |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 495 | |
Marc Jones | e17ec3e | 2018-08-15 22:53:34 -0600 | [diff] [blame] | 496 | /* When sensor ID returns 0xFF then no more events */ |
| 497 | While (LNotEqual (Local0, EC_TEMP_SENSOR_NOT_PRESENT)) |
| 498 | { |
Martin Roth | 15f232d | 2018-04-29 22:41:58 -0500 | [diff] [blame] | 499 | #ifdef HAVE_THERM_EVENT_HANDLER |
Marc Jones | e17ec3e | 2018-08-15 22:53:34 -0600 | [diff] [blame] | 500 | \_SB.DPTF.TEVT (Local0) |
Martin Roth | 15f232d | 2018-04-29 22:41:58 -0500 | [diff] [blame] | 501 | #endif |
Aaron Durbin | b3ce658 | 2014-05-13 09:23:10 -0500 | [diff] [blame] | 502 | |
Marc Jones | e17ec3e | 2018-08-15 22:53:34 -0600 | [diff] [blame] | 503 | /* Keep reaading sensor ID for event */ |
| 504 | Store (^PATI, Local0) |
| 505 | } |
Duncan Laurie | 93e2444 | 2014-01-06 12:30:52 -0800 | [diff] [blame] | 506 | |
Marc Jones | e17ec3e | 2018-08-15 22:53:34 -0600 | [diff] [blame] | 507 | Release (^PATM) |
| 508 | } |
Duncan Laurie | ad8d913 | 2013-12-10 07:41:33 -0800 | [diff] [blame] | 509 | } |
| 510 | |
Duncan Laurie | e6b280e | 2014-02-10 16:21:05 -0800 | [diff] [blame] | 511 | /* |
| 512 | * Set Charger Current Limit |
| 513 | * Arg0 = Current Limit in 64mA steps |
| 514 | */ |
| 515 | Method (CHGS, 1, Serialized) |
| 516 | { |
| 517 | Store (ToInteger (Arg0), ^CHGL) |
| 518 | } |
| 519 | |
| 520 | /* |
| 521 | * Disable Charger Current Limit |
| 522 | */ |
| 523 | Method (CHGD, 0, Serialized) |
| 524 | { |
| 525 | Store (0xFF, ^CHGL) |
| 526 | } |
| 527 | |
jiazi Yang | 51fc93f | 2016-07-28 05:15:01 -0400 | [diff] [blame] | 528 | /* Read current Tablet mode */ |
| 529 | Method (RCTM, 0, NotSerialized) |
| 530 | { |
| 531 | Return (^TBMD) |
| 532 | } |
| 533 | |
Wim Vervoorn | 8629b49 | 2020-01-15 09:16:46 +0100 | [diff] [blame] | 534 | #ifdef EC_ENABLE_MULTIPLE_DPTF_PROFILES |
Karthikeyan Ramasubramanian | 036ccd7 | 2018-10-23 22:16:36 -0600 | [diff] [blame] | 535 | /* Read current Device DPTF Profile Number */ |
| 536 | Method (RCDP, 0, NotSerialized) |
| 537 | { |
| 538 | /* |
| 539 | * DDPN = 0 is reserved for backwards compatibility. |
| 540 | * If DDPN == 0 use TBMD to load appropriate DPTF table. |
| 541 | */ |
| 542 | If (LEqual (^DDPN, 0)) { |
| 543 | Return (^TBMD) |
| 544 | } Else { |
| 545 | Subtract (^DDPN, 1, Local0) |
| 546 | Return (Local0) |
| 547 | } |
| 548 | } |
Wim Vervoorn | 8629b49 | 2020-01-15 09:16:46 +0100 | [diff] [blame] | 549 | #endif |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 550 | #if CONFIG(EC_GOOGLE_CHROMEEC_ACPI_USB_PORT_POWER) |
Emil Lundmark | 9d5f9f2 | 2018-05-22 19:31:37 +0200 | [diff] [blame] | 551 | /* |
| 552 | * Enable USB Port Power |
| 553 | * Arg0 = USB port ID |
| 554 | */ |
| 555 | Method (UPPS, 1, Serialized) |
| 556 | { |
| 557 | Or (USPP, ShiftLeft (1, Arg0), USPP) |
| 558 | } |
| 559 | |
| 560 | /* |
| 561 | * Disable USB Port Power |
| 562 | * Arg0 = USB port ID |
| 563 | */ |
| 564 | Method (UPPC, 1, Serialized) |
| 565 | { |
| 566 | And (USPP, Not (ShiftLeft (1, Arg0)), USPP) |
| 567 | } |
| 568 | #endif |
| 569 | |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 570 | #include "ac.asl" |
| 571 | #include "battery.asl" |
Gwendal Grignou | 866cc3d | 2016-05-03 23:24:53 -0700 | [diff] [blame] | 572 | #include "cros_ec.asl" |
Duncan Laurie | 612163eb | 2014-06-13 10:35:22 -0700 | [diff] [blame] | 573 | |
| 574 | #ifdef EC_ENABLE_ALS_DEVICE |
| 575 | #include "als.asl" |
| 576 | #endif |
Shawn Nematbakhsh | 98cc94c | 2014-08-28 11:33:41 -0700 | [diff] [blame] | 577 | |
Duncan Laurie | ef549a0 | 2015-09-01 09:47:55 -0700 | [diff] [blame] | 578 | #ifdef EC_ENABLE_KEYBOARD_BACKLIGHT |
Elyes HAOUAS | b933109 | 2016-09-05 19:55:34 +0200 | [diff] [blame] | 579 | #include "keyboard_backlight.asl" |
Duncan Laurie | ef549a0 | 2015-09-01 09:47:55 -0700 | [diff] [blame] | 580 | #endif |
| 581 | |
Furquan Shaikh | c96ad86 | 2018-01-26 10:40:09 -0800 | [diff] [blame] | 582 | #ifdef EC_ENABLE_TBMC_DEVICE |
Gwendal Grignou | 87d5fb8 | 2017-01-19 18:30:21 -0800 | [diff] [blame] | 583 | #include "tbmc.asl" |
| 584 | #endif |
Stefan Reinauer | d6682e8 | 2013-02-21 15:39:35 -0800 | [diff] [blame] | 585 | } |