blob: d6d33b2a08b7fdbcdf555e76b4d09ae76c501c63 [file] [log] [blame]
Angel Pons210a0082020-04-02 23:48:24 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Stefan Reinauerd6682e82013-02-21 15:39:35 -08002
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
Varshit B Pandyaa872b9a2022-03-20 22:20:11 +05309// DTT Power Participant Device Notification
10#define POWER_STATE_CHANGE_NOTIFICATION 0x81
Tony Huanga434f612022-08-09 11:32:55 +080011// DTT OEM variables change notification
12#define EC_OEM_VARIABLE_DATA_MASK 0x7
13#define INT3400_ODVP_CHANGED 0x88
Varshit B Pandyaa872b9a2022-03-20 22:20:11 +053014
Rob Barnesa3148ca2022-11-08 07:47:14 -070015#define ACPI_NOTIFY_CROS_EC_PANIC 0xB0
16
Duncan Lauried338b462013-07-31 15:30:41 -070017// Mainboard specific throttle handler
Freddy Paule8cc52f2015-10-02 19:06:57 -070018#ifdef DPTF_ENABLE_CHARGER
Duncan Laurie3f1500f2014-03-06 08:37:49 -080019External (\_SB.DPTF.TCHG, DeviceObj)
Freddy Paule8cc52f2015-10-02 19:06:57 -070020#endif
Chris Wange019bd92020-08-06 16:38:04 +080021/* Enable DPTC interface with AMD ALIB */
Tim Van Patten2873fd22022-08-29 11:36:35 -060022#if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
Chris Wange019bd92020-08-06 16:38:04 +080023External(\_SB.DPTC, MethodObj)
24#endif
Duncan Lauried338b462013-07-31 15:30:41 -070025
Varshit B Pandyaa872b9a2022-03-20 22:20:11 +053026External (\_SB.DPTF.TPWR, DeviceObj)
27
Tony Huanga434f612022-08-09 11:32:55 +080028#ifdef DPTF_ENABLE_OEM_VARIABLES
29External (\_SB.DPTF.ODVP, MethodObj)
30External (\_SB.DPTF.ODGT, MethodObj)
31External (\_SB.DPTF.ODUP, MethodObj)
32#endif
33
Stefan Reinauerd6682e82013-02-21 15:39:35 -080034Device (EC0)
35{
36 Name (_HID, EISAID ("PNP0C09"))
37 Name (_UID, 1)
Duncan Laurie045222f2013-05-21 07:49:11 -070038 Name (_GPE, EC_SCI_GPI)
Stefan Reinauerd6682e82013-02-21 15:39:35 -080039 Name (TOFS, EC_TEMP_SENSOR_OFFSET)
Duncan Laurie433432b2013-06-03 10:38:22 -070040 Name (TNCA, EC_TEMP_SENSOR_NOT_CALIBRATED)
41 Name (TNOP, EC_TEMP_SENSOR_NOT_POWERED)
42 Name (TBAD, EC_TEMP_SENSOR_ERROR)
43 Name (TNPR, EC_TEMP_SENSOR_NOT_PRESENT)
Stefan Reinauerd6682e82013-02-21 15:39:35 -080044 Name (DWRN, 15) // Battery capacity warning at 15%
45 Name (DLOW, 10) // Battery capacity low at 10%
46
Shawn Nematbakhsh37b7a662015-03-24 11:07:51 -070047 OperationRegion (ERAM, EmbeddedControl, 0x00, EC_ACPI_MEM_MAPPED_BEGIN)
Stefan Reinauerd6682e82013-02-21 15:39:35 -080048 Field (ERAM, ByteAcc, Lock, Preserve)
49 {
Stefan Reinauerd6682e82013-02-21 15:39:35 -080050 RAMV, 8, // EC RAM Version
51 TSTB, 8, // Test Byte
52 TSTC, 8, // Complement of Test Byte
Patrick Georgif9267f92017-08-24 23:12:55 +020053 KBLV, 8, // Keyboard Backlight value
Duncan Lauriead8d9132013-12-10 07:41:33 -080054 FAND, 8, // Set Fan Duty Cycle
Duncan Laurie93e24442014-01-06 12:30:52 -080055 PATI, 8, // Programmable Auxiliary Trip Sensor ID
56 PATT, 8, // Programmable Auxiliary Trip Threshold
57 PATC, 8, // Programmable Auxiliary Trip Commit
Duncan Lauriee6b280e2014-02-10 16:21:05 -080058 CHGL, 8, // Charger Current Limit
jiazi Yang51fc93f2016-07-28 05:15:01 -040059 TBMD, 1, // Tablet mode
Karthikeyan Ramasubramanian036ccd72018-10-23 22:16:36 -060060 DDPN, 3, // Device DPTF Profile Number
EricKY Cheng065c5872022-10-03 16:24:04 +080061 STTB, 1, // Switch thermal table by body detection status
Patrick Georgif9267f92017-08-24 23:12:55 +020062 // DFUD must be 0 for the other 31 values to be valid
Patrick Georgi4bd68b82017-08-18 21:06:24 +020063 Offset (0x0a),
Patrick Georgif9267f92017-08-24 23:12:55 +020064 DFUD, 1, // Device Features Undefined
65 FLSH, 1, // Flash commands present
66 PFAN, 1, // PWM Fan control present
67 KBLE, 1, // Keyboard Backlight present
68 LTBR, 1, // Lightbar present
69 LEDC, 1, // LED control
70 MTNS, 1, // Motion sensors present
71 KEYB, 1, // EC is keyboard controller
72 PSTR, 1, // Persistent storage
73 P80P, 1, // EC serves I/O Port 80h
74 THRM, 1, // EC supports thermal management
75 SBKL, 1, // Screen backlight switch present
76 WIFI, 1, // WIFI switch present
77 HOST, 1, // EC monitors host events (eg SCI, SMI)
78 GPIO, 1, // EC provides GPIO commands
79 I2CB, 1, // EC provides I2C controller access
80 CHRG, 1, // EC provides commands for charger control
81 BATT, 1, // Simply Battery support
82 SBAT, 1, // Smart Battery support
83 HANG, 1, // EC can detect host hang
84 PMUI, 1, // Power Information
85 DSEC, 1, // another EC exists downstream
86 UPDC, 1, // supports USB Power Delivery
87 UMUX, 1, // supports USB Mux
88 MSFF, 1, // Motion Sense has FIFO
89 TVST, 1, // supports temporary secure vstore
90 TCMV, 1, // USB Type C Muxing is virtual (host assisted)
91 RTCD, 1, // EC provides an RTC device
92 FPRD, 1, // EC provides a fingerprint reader device
93 TPAD, 1, // EC provides a touchpad device
94 RWSG, 1, // EC has RWSIG task enabled
95 DEVE, 1, // EC supports device events
96 // make sure we're within our space envelope
97 Offset (0x0e),
Nicolas Boichat07fe6182018-01-26 14:37:16 +080098 Offset (0x12),
99 BTID, 8, // Battery index that host wants to read
Emil Lundmark9d5f9f22018-05-22 19:31:37 +0200100 USPP, 8, // USB Port Power
John Zhao408e5ab2021-01-01 12:25:56 -0800101 RFWU, 8, // Retimer Firmware Update
Varshit B Pandyaa872b9a2022-03-20 22:20:11 +0530102 PBOK, 8, // Power source change count from dptf
Subrata Banikf5c3e292020-11-30 16:10:34 +0530103 }
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800104
Julius Wernercd49cce2019-03-05 16:53:33 -0800105#if CONFIG(EC_GOOGLE_CHROMEEC_ACPI_MEMMAP)
Shawn Nematbakhsh37b7a662015-03-24 11:07:51 -0700106 OperationRegion (EMEM, EmbeddedControl,
107 EC_ACPI_MEM_MAPPED_BEGIN, EC_ACPI_MEM_MAPPED_SIZE)
108 Field (EMEM, ByteAcc, Lock, Preserve)
109#else
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800110 OperationRegion (EMEM, SystemIO, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE)
111 Field (EMEM, ByteAcc, NoLock, Preserve)
Shawn Nematbakhsh37b7a662015-03-24 11:07:51 -0700112#endif
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800113 {
Shawn Nematbakhsh37b7a662015-03-24 11:07:51 -0700114 #include "emem.asl"
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800115 }
116
Aaron Durbin05201d72016-09-23 16:06:14 -0500117#ifdef EC_ENABLE_LID_SWITCH
118 /* LID Switch */
119 Device (LID0)
120 {
121 Name (_HID, EisaId ("PNP0C0D"))
122 Method (_LID, 0)
123 {
124 Return (^^LIDS)
125 }
126
127#ifdef EC_ENABLE_WAKE_PIN
128 Name (_PRW, Package () { EC_ENABLE_WAKE_PIN, 0x5 })
129#endif
130 }
Felix Held831d6862023-01-20 19:37:26 +0100131#endif /* EC_ENABLE_LID_SWITCH */
Aaron Durbin05201d72016-09-23 16:06:14 -0500132
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800133 Method (TINS, 1, Serialized)
134 {
135 Switch (ToInteger (Arg0))
136 {
137 Case (0) { Return (TIN0) }
138 Case (1) { Return (TIN1) }
139 Case (2) { Return (TIN2) }
140 Case (3) { Return (TIN3) }
141 Case (4) { Return (TIN4) }
142 Case (5) { Return (TIN5) }
143 Case (6) { Return (TIN6) }
144 Case (7) { Return (TIN7) }
145 Case (8) { Return (TIN8) }
146 Case (9) { Return (TIN9) }
147 Default { Return (TIN0) }
148 }
149 }
150
Duncan Laurie20373c02015-09-22 09:40:37 -0700151 Method (_CRS, 0, Serialized)
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800152 {
153 Name (ECMD, ResourceTemplate()
154 {
155 IO (Decode16,
156 EC_LPC_ADDR_ACPI_DATA,
157 EC_LPC_ADDR_ACPI_DATA,
158 0, 1)
159 IO (Decode16,
160 EC_LPC_ADDR_ACPI_CMD,
161 EC_LPC_ADDR_ACPI_CMD,
162 0, 1)
163 })
164 Return (ECMD)
165 }
166
167 Method (_REG, 2, NotSerialized)
168 {
169 // Initialize AC power state
Felix Singerff6b3af2022-12-12 04:54:46 +0100170 \PWRS = ACEX
Furquan Shaikh80c555d2020-06-12 10:01:20 -0700171 /*
Tim Van Patten14fa11f2022-08-22 14:06:11 -0600172 * Call PNOT (Platform Notify) to inform platform code
173 * about the current AC/battery state. This handles all cases,
174 * the battery transitioning into and out of having critically
175 * low charge.
Furquan Shaikh80c555d2020-06-12 10:01:20 -0700176 * PWRS isn't valid before this point.
177 */
178 \PNOT ()
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800179
Karthikeyan Ramasubramanian8fc20c42023-04-10 14:10:37 -0600180#ifndef EC_ENABLE_LID_SWITCH
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800181 // Initialize LID switch state
Felix Singerff6b3af2022-12-12 04:54:46 +0100182 \LIDS = LIDS
Karthikeyan Ramasubramanian8fc20c42023-04-10 14:10:37 -0600183#endif
Kevin Chiu83f0c692020-09-22 00:48:36 +0800184
Tim Van Patten2873fd22022-08-29 11:36:35 -0600185#if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
Kevin Chiu83f0c692020-09-22 00:48:36 +0800186 /*
187 * Per the device mode (clamshell or tablet) to initialize
188 * the thermal setting on OS startup.
189 */
190 If (CondRefOf (\_SB.DPTC)) {
191 \_SB.DPTC()
192 }
193#endif
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800194 }
195
Duncan Lauriead8d9132013-12-10 07:41:33 -0800196 /* Read requested temperature and check against EC error values */
197 Method (TSRD, 1, Serialized)
198 {
Felix Singerff6b3af2022-12-12 04:54:46 +0100199 Local0 = \_SB.PCI0.LPCB.EC0.TINS (Arg0)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800200
201 /* Check for sensor not calibrated */
Felix Singer3c799fa2022-01-02 00:55:18 +0100202 If (Local0 == \_SB.PCI0.LPCB.EC0.TNCA) {
Felix Singer42efd7f2022-12-26 09:38:45 +0100203 Return (0)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800204 }
205
206 /* Check for sensor not present */
Felix Singer3c799fa2022-01-02 00:55:18 +0100207 If (Local0 == \_SB.PCI0.LPCB.EC0.TNPR) {
Felix Singer42efd7f2022-12-26 09:38:45 +0100208 Return (0)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800209 }
210
211 /* Check for sensor not powered */
Felix Singer3c799fa2022-01-02 00:55:18 +0100212 If (Local0 == \_SB.PCI0.LPCB.EC0.TNOP) {
Felix Singer42efd7f2022-12-26 09:38:45 +0100213 Return (0)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800214 }
215
216 /* Check for sensor bad reading */
Felix Singer3c799fa2022-01-02 00:55:18 +0100217 If (Local0 == \_SB.PCI0.LPCB.EC0.TBAD) {
Felix Singer42efd7f2022-12-26 09:38:45 +0100218 Return (0)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800219 }
220
221 /* Adjust by offset to get Kelvin */
Felix Singer3a462062021-12-30 01:22:36 +0100222 Local0 += \_SB.PCI0.LPCB.EC0.TOFS
Duncan Lauriead8d9132013-12-10 07:41:33 -0800223
224 /* Convert to 1/10 Kelvin */
Felix Singer89818d12022-01-01 23:36:28 +0100225 Local0 *= 10
Duncan Lauriead8d9132013-12-10 07:41:33 -0800226
227 Return (Local0)
228 }
229
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800230 // Lid Closed Event
231 Method (_Q01, 0, NotSerialized)
232 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100233 Printf ("EC: LID CLOSE")
EricKY Cheng366b2052022-09-23 17:04:01 +0800234#if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
235 If (CondRefOf (\_SB.DPTC)) {
236 \_SB.DPTC()
237 }
238#endif
Aaron Durbin05201d72016-09-23 16:06:14 -0500239#ifdef EC_ENABLE_LID_SWITCH
240 Notify (LID0, 0x80)
Karthikeyan Ramasubramanian8fc20c42023-04-10 14:10:37 -0600241#else
242 \LIDS = LIDS
Aaron Durbin05201d72016-09-23 16:06:14 -0500243#endif
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800244 }
245
246 // Lid Open Event
247 Method (_Q02, 0, NotSerialized)
248 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100249 Printf ("EC: LID OPEN")
EricKY Cheng366b2052022-09-23 17:04:01 +0800250#if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
251 If (CondRefOf (\_SB.DPTC)) {
252 \_SB.DPTC()
253 }
254#endif
Furquan Shaikha3a84562017-11-28 14:32:17 -0800255 Notify (CREC, 0x2)
Aaron Durbin05201d72016-09-23 16:06:14 -0500256#ifdef EC_ENABLE_LID_SWITCH
257 Notify (LID0, 0x80)
Karthikeyan Ramasubramanian8fc20c42023-04-10 14:10:37 -0600258#else
259 \LIDS = LIDS
Aaron Durbin05201d72016-09-23 16:06:14 -0500260#endif
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800261 }
262
263 // Power Button
264 Method (_Q03, 0, NotSerialized)
265 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100266 Printf ("EC: POWER BUTTON")
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800267 }
268
269 // AC Connected
270 Method (_Q04, 0, NotSerialized)
271 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100272 Printf ("EC: AC CONNECTED")
Felix Singerff6b3af2022-12-12 04:54:46 +0100273 \PWRS = ACEX
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800274 Notify (AC, 0x80)
Freddy Paule8cc52f2015-10-02 19:06:57 -0700275#ifdef DPTF_ENABLE_CHARGER
Duncan Laurie3f1500f2014-03-06 08:37:49 -0800276 If (CondRefOf (\_SB.DPTF.TCHG)) {
277 Notify (\_SB.DPTF.TCHG, 0x80)
278 }
Freddy Paule8cc52f2015-10-02 19:06:57 -0700279#endif
Tim Van Patten14fa11f2022-08-22 14:06:11 -0600280 /*
281 * Call PNOT (Platform Notify) to inform platform code
282 * about the current battery state. This handles all cases,
283 * the battery transitioning into and out of having critically
284 * low charge.
285 */
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800286 \PNOT ()
287 }
288
289 // AC Disconnected
290 Method (_Q05, 0, NotSerialized)
291 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100292 Printf ("EC: AC DISCONNECTED")
Felix Singerff6b3af2022-12-12 04:54:46 +0100293 \PWRS = ACEX
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800294 Notify (AC, 0x80)
Freddy Paule8cc52f2015-10-02 19:06:57 -0700295#ifdef DPTF_ENABLE_CHARGER
Duncan Laurie3f1500f2014-03-06 08:37:49 -0800296 If (CondRefOf (\_SB.DPTF.TCHG)) {
297 Notify (\_SB.DPTF.TCHG, 0x80)
298 }
Freddy Paule8cc52f2015-10-02 19:06:57 -0700299#endif
Tim Van Patten14fa11f2022-08-22 14:06:11 -0600300 /*
301 * Call PNOT (Platform Notify) to inform platform code
302 * about the current battery state. This handles all cases,
303 * the battery transitioning into and out of having critically
304 * low charge.
305 */
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800306 \PNOT ()
307 }
308
309 // Battery Low Event
310 Method (_Q06, 0, NotSerialized)
311 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100312 Printf ("EC: BATTERY LOW")
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800313 Notify (BAT0, 0x80)
314 }
315
316 // Battery Critical Event
317 Method (_Q07, 0, NotSerialized)
318 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100319 Printf ("EC: BATTERY CRITICAL")
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800320 Notify (BAT0, 0x80)
321 }
322
323 // Battery Info Event
324 Method (_Q08, 0, NotSerialized)
325 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100326 Printf ("EC: BATTERY INFO")
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800327 Notify (BAT0, 0x81)
Nicolas Boichat07fe6182018-01-26 14:37:16 +0800328#ifdef EC_ENABLE_SECOND_BATTERY_DEVICE
329 If (CondRefOf (BAT1)) {
330 Notify (BAT1, 0x81)
331 }
332#endif
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800333 }
334
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800335 // Thermal Overload Event
336 Method (_Q0A, 0, NotSerialized)
337 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100338 Printf ("EC: THERMAL OVERLOAD")
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800339 Notify (\_TZ, 0x80)
340 }
341
342 // Thermal Event
343 Method (_Q0B, 0, NotSerialized)
344 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100345 Printf ("EC: THERMAL")
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800346 Notify (\_TZ, 0x80)
347 }
348
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800349 // Key Pressed
350 Method (_Q0D, 0, NotSerialized)
351 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100352 Printf ("EC: KEY PRESSED")
Furquan Shaikha3a84562017-11-28 14:32:17 -0800353 Notify (CREC, 0x2)
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800354 }
355
Duncan Laurie18d9899b2013-08-28 09:54:04 -0700356 // Thermal Shutdown Imminent
357 Method (_Q10, 0, NotSerialized)
358 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100359 Printf ("EC: THERMAL SHUTDOWN")
Duncan Laurie18d9899b2013-08-28 09:54:04 -0700360 Notify (\_TZ, 0x80)
361 }
362
363 // Battery Shutdown Imminent
364 Method (_Q11, 0, NotSerialized)
365 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100366 Printf ("EC: BATTERY SHUTDOWN")
Duncan Laurie18d9899b2013-08-28 09:54:04 -0700367 Notify (BAT0, 0x80)
368 }
369
Duncan Lauried338b462013-07-31 15:30:41 -0700370 // Throttle Start
371 Method (_Q12, 0, NotSerialized)
372 {
Martin Roth6b1ceac2018-05-06 17:58:36 -0500373#ifdef EC_ENABLE_THROTTLING_HANDLER
Felix Singer3462a1b2021-12-26 15:05:45 +0100374 Printf ("EC: THROTTLE START")
Martin Roth6b1ceac2018-05-06 17:58:36 -0500375 \_TZ.THRT (1)
376#endif
Tony Huanga434f612022-08-09 11:32:55 +0800377
378#ifdef DPTF_ENABLE_OEM_VARIABLES
379 Local0 = ToInteger(EOVD) & EC_OEM_VARIABLE_DATA_MASK
380 \_SB.DPTF.ODUP(0, Local0)
381 Local0 = \_SB.DPTF.ODGT(0)
382 \_SB.DPTF.ODVP()
383 Notify (\_SB.DPTF, INT3400_ODVP_CHANGED)
384#endif
Duncan Lauried338b462013-07-31 15:30:41 -0700385 }
386
387 // Throttle Stop
388 Method (_Q13, 0, NotSerialized)
389 {
Martin Roth6b1ceac2018-05-06 17:58:36 -0500390#ifdef EC_ENABLE_THROTTLING_HANDLER
Felix Singer3462a1b2021-12-26 15:05:45 +0100391 Printf ("EC: THROTTLE STOP")
Martin Roth6b1ceac2018-05-06 17:58:36 -0500392 \_TZ.THRT (0)
393#endif
Duncan Lauried338b462013-07-31 15:30:41 -0700394 }
395
Shawn Nematbakhsh98cc94c2014-08-28 11:33:41 -0700396#ifdef EC_ENABLE_PD_MCU_DEVICE
397 // PD event
398 Method (_Q16, 0, NotSerialized)
399 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100400 Printf ("EC: GOT PD EVENT")
Prashant Malanidabc0ad2020-03-10 15:42:54 -0700401 Notify (\_SB.PCI0.LPCB.EC0.CREC.ECPD, 0x80)
Varshit B Pandyaa872b9a2022-03-20 22:20:11 +0530402 If (CondRefOf (\_SB.DPTF.TPWR)) {
403 Notify (\_SB.DPTF.TPWR, POWER_STATE_CHANGE_NOTIFICATION)
404 }
Shawn Nematbakhsh98cc94c2014-08-28 11:33:41 -0700405 }
406#endif
407
Duncan Lauried8401182014-09-29 08:32:19 -0700408 // Battery Status
409 Method (_Q17, 0, NotSerialized)
410 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100411 Printf ("EC: BATTERY STATUS")
Duncan Lauried8401182014-09-29 08:32:19 -0700412 Notify (BAT0, 0x80)
Nicolas Boichat07fe6182018-01-26 14:37:16 +0800413#ifdef EC_ENABLE_SECOND_BATTERY_DEVICE
414 If (CondRefOf (BAT1)) {
415 Notify (BAT1, 0x80)
416 }
417#endif
Tim Van Patten14fa11f2022-08-22 14:06:11 -0600418
419 /*
420 * Call PNOT (Platform Notify) to inform platform code
421 * about the current battery state. This handles all cases,
422 * the battery transitioning into and out of having critically
423 * low charge.
424 */
425 \PNOT ()
Duncan Lauried8401182014-09-29 08:32:19 -0700426 }
427
Rob Barnesa3148ca2022-11-08 07:47:14 -0700428 // EC Panic
429 Method (_Q18, 0, NotSerialized)
430 {
431 Printf ("EC: PANIC")
432 Notify (CREC, ACPI_NOTIFY_CROS_EC_PANIC)
433 }
434
Gwendal Grignou95b7a6c2016-05-03 23:53:23 -0700435 // MKBP interrupt.
Gwendal Grignou880b4582016-06-20 08:49:25 -0700436 Method (_Q1B, 0, NotSerialized)
Gwendal Grignou95b7a6c2016-05-03 23:53:23 -0700437 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100438 Printf ("EC: MKBP")
Gwendal Grignou95b7a6c2016-05-03 23:53:23 -0700439 Notify (CREC, 0x80)
440 }
441
Brandon Breitensteinbc885c12020-04-01 13:30:37 -0700442#ifdef EC_ENABLE_PD_MCU_DEVICE
443 // USB MUX Interrupt
444 Method (_Q1C, 0, NotSerialized)
445 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100446 Printf ("EC: USB MUX")
Brandon Breitensteinbc885c12020-04-01 13:30:37 -0700447 Notify (\_SB.PCI0.LPCB.EC0.CREC.ECPD, 0x80)
448 }
449#endif
450
jiazi Yang51fc93f2016-07-28 05:15:01 -0400451 // TABLET mode switch Event
452 Method (_Q1D, 0, NotSerialized)
453 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100454 Printf ("EC: TABLET mode switch Event")
Furquan Shaikha3a84562017-11-28 14:32:17 -0800455 Notify (CREC, 0x2)
Karthikeyan Ramasubramanian017b5c42018-11-14 08:53:01 -0700456#ifdef EC_ENABLE_MULTIPLE_DPTF_PROFILES
Martin Roth9c055982018-05-01 21:52:42 -0500457 \_SB.DPTF.TPET()
Furquan Shaikhc96ad862018-01-26 10:40:09 -0800458#endif
459#ifdef EC_ENABLE_TBMC_DEVICE
Matt DeVillier3f0de3d2022-10-18 17:53:08 -0500460 Notify (^CREC.TBMC, 0x80)
Gwendal Grignou87d5fb82017-01-19 18:30:21 -0800461#endif
Tim Van Patten2873fd22022-08-29 11:36:35 -0600462#if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
Chris Wange019bd92020-08-06 16:38:04 +0800463 If (CondRefOf (\_SB.DPTC)) {
464 \_SB.DPTC()
465 }
466#endif
Furquan Shaikha3a84562017-11-28 14:32:17 -0800467 }
jiazi Yang51fc93f2016-07-28 05:15:01 -0400468
Tim Van Patten64871ad2023-02-10 14:03:30 -0700469 // Body Detect Change Event
470 Method (_Q21, 0, NotSerialized)
471 {
472 Printf ("EC: Body Detect Change Event")
473#if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
474 If (CondRefOf (\_SB.DPTC)) {
475 \_SB.DPTC()
476 }
477#endif
478 }
479
Duncan Lauriead8d9132013-12-10 07:41:33 -0800480 /*
481 * Dynamic Platform Thermal Framework support
482 */
483
Duncan Laurie93e24442014-01-06 12:30:52 -0800484 /* Mutex for EC PAT interface */
485 Mutex (PATM, 1)
486
Duncan Lauriead8d9132013-12-10 07:41:33 -0800487 /*
488 * Set Aux Trip Point 0
489 * Arg0 = Temp Sensor ID
490 * Arg1 = Value to set
491 */
492 Method (PAT0, 2, Serialized)
493 {
Duncan Laurie93e24442014-01-06 12:30:52 -0800494 If (Acquire (^PATM, 1000)) {
495 Return (0)
496 }
497
Duncan Laurie93e24442014-01-06 12:30:52 -0800498 /* Set sensor ID */
Felix Singerff6b3af2022-12-12 04:54:46 +0100499 ^PATI = ToInteger (Arg0)
Duncan Laurie93e24442014-01-06 12:30:52 -0800500
Duncan Laurie8be67592014-01-09 10:01:05 -0800501 /* Temperature is passed in 1/10 Kelvin */
Felix Singer81623fb2022-01-02 00:13:07 +0100502 Local1 = ToInteger (Arg1) / 10
Duncan Laurie8be67592014-01-09 10:01:05 -0800503
504 /* Adjust by EC temperature offset */
Felix Singer73078ed2021-12-29 23:39:59 +0100505 ^PATT = Local1 - ^TOFS
Duncan Laurie93e24442014-01-06 12:30:52 -0800506
507 /* Set commit value with SELECT=0 and ENABLE=1 */
Felix Singerff6b3af2022-12-12 04:54:46 +0100508 ^PATC = 0x02
Duncan Laurie93e24442014-01-06 12:30:52 -0800509
510 Release (^PATM)
511 Return (1)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800512 }
513
514 /*
515 * Set Aux Trip Point 1
516 * Arg0 = Temp Sensor ID
517 * Arg1 = Value to set
518 */
519 Method (PAT1, 2, Serialized)
520 {
Duncan Laurie93e24442014-01-06 12:30:52 -0800521 If (Acquire (^PATM, 1000)) {
522 Return (0)
523 }
524
Duncan Laurie93e24442014-01-06 12:30:52 -0800525 /* Set sensor ID */
Felix Singerff6b3af2022-12-12 04:54:46 +0100526 ^PATI = ToInteger (Arg0)
Duncan Laurie93e24442014-01-06 12:30:52 -0800527
Duncan Laurie8be67592014-01-09 10:01:05 -0800528 /* Temperature is passed in 1/10 Kelvin */
Felix Singer81623fb2022-01-02 00:13:07 +0100529 Local1 = ToInteger (Arg1) / 10
Duncan Laurie8be67592014-01-09 10:01:05 -0800530
531 /* Adjust by EC temperature offset */
Felix Singer73078ed2021-12-29 23:39:59 +0100532 ^PATT = Local1 - ^TOFS
Duncan Laurie93e24442014-01-06 12:30:52 -0800533
534 /* Set commit value with SELECT=1 and ENABLE=1 */
Felix Singerff6b3af2022-12-12 04:54:46 +0100535 ^PATC = 0x03
Duncan Laurie93e24442014-01-06 12:30:52 -0800536
537 Release (^PATM)
538 Return (1)
539 }
540
Duncan Laurie8be67592014-01-09 10:01:05 -0800541 /* Disable Aux Trip Points
542 * Arg0 = Temp Sensor ID
543 */
544 Method (PATD, 1, Serialized)
Duncan Laurie93e24442014-01-06 12:30:52 -0800545 {
546 If (Acquire (^PATM, 1000)) {
547 Return (0)
548 }
549
Felix Singerff6b3af2022-12-12 04:54:46 +0100550 ^PATI = ToInteger (Arg0)
551 ^PATT = 0x00
Duncan Laurie93e24442014-01-06 12:30:52 -0800552
553 /* Disable PAT0 */
Felix Singerff6b3af2022-12-12 04:54:46 +0100554 ^PATC = 0x00
Duncan Laurie93e24442014-01-06 12:30:52 -0800555
556 /* Disable PAT1 */
Felix Singerff6b3af2022-12-12 04:54:46 +0100557 ^PATC = 0x01
Duncan Laurie93e24442014-01-06 12:30:52 -0800558
559 Release (^PATM)
560 Return (1)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800561 }
562
563 /*
Duncan Laurie93e24442014-01-06 12:30:52 -0800564 * Thermal Threshold Event
Duncan Lauriee6b280e2014-02-10 16:21:05 -0800565 */
Duncan Laurie8be67592014-01-09 10:01:05 -0800566 Method (_Q09, 0, NotSerialized)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800567 {
EricKY Cheng366b2052022-09-23 17:04:01 +0800568
569#if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
570 If (CondRefOf (\_SB.DPTC)) {
571 \_SB.DPTC()
572 }
573#endif
Felix Singer98be4d62021-12-31 14:32:03 +0100574 If (!Acquire (^PATM, 1000)) {
Marc Jonese17ec3e2018-08-15 22:53:34 -0600575 /* Read sensor ID for event */
Felix Singerff6b3af2022-12-12 04:54:46 +0100576 Local0 = ^PATI
Duncan Laurie93e24442014-01-06 12:30:52 -0800577
Marc Jonese17ec3e2018-08-15 22:53:34 -0600578 /* When sensor ID returns 0xFF then no more events */
Felix Singer8ab09752022-01-02 02:48:53 +0100579 While (Local0 != EC_TEMP_SENSOR_NOT_PRESENT)
Marc Jonese17ec3e2018-08-15 22:53:34 -0600580 {
Martin Roth15f232d2018-04-29 22:41:58 -0500581#ifdef HAVE_THERM_EVENT_HANDLER
Marc Jonese17ec3e2018-08-15 22:53:34 -0600582 \_SB.DPTF.TEVT (Local0)
Martin Roth15f232d2018-04-29 22:41:58 -0500583#endif
Aaron Durbinb3ce6582014-05-13 09:23:10 -0500584
Marc Jonese17ec3e2018-08-15 22:53:34 -0600585 /* Keep reaading sensor ID for event */
Felix Singerff6b3af2022-12-12 04:54:46 +0100586 Local0 = ^PATI
Marc Jonese17ec3e2018-08-15 22:53:34 -0600587 }
Duncan Laurie93e24442014-01-06 12:30:52 -0800588
Marc Jonese17ec3e2018-08-15 22:53:34 -0600589 Release (^PATM)
590 }
Duncan Lauriead8d9132013-12-10 07:41:33 -0800591 }
592
Duncan Lauriee6b280e2014-02-10 16:21:05 -0800593 /*
594 * Set Charger Current Limit
595 * Arg0 = Current Limit in 64mA steps
596 */
597 Method (CHGS, 1, Serialized)
598 {
Felix Singerff6b3af2022-12-12 04:54:46 +0100599 ^CHGL = ToInteger (Arg0)
Duncan Lauriee6b280e2014-02-10 16:21:05 -0800600 }
601
602 /*
603 * Disable Charger Current Limit
604 */
605 Method (CHGD, 0, Serialized)
606 {
Felix Singerff6b3af2022-12-12 04:54:46 +0100607 ^CHGL = 0xFF
Duncan Lauriee6b280e2014-02-10 16:21:05 -0800608 }
609
jiazi Yang51fc93f2016-07-28 05:15:01 -0400610 /* Read current Tablet mode */
611 Method (RCTM, 0, NotSerialized)
612 {
613 Return (^TBMD)
614 }
615
Wim Vervoorn8629b492020-01-15 09:16:46 +0100616#ifdef EC_ENABLE_MULTIPLE_DPTF_PROFILES
Karthikeyan Ramasubramanian036ccd72018-10-23 22:16:36 -0600617 /* Read current Device DPTF Profile Number */
618 Method (RCDP, 0, NotSerialized)
619 {
620 /*
621 * DDPN = 0 is reserved for backwards compatibility.
622 * If DDPN == 0 use TBMD to load appropriate DPTF table.
623 */
Felix Singer3c799fa2022-01-02 00:55:18 +0100624 If (^DDPN == 0) {
Karthikeyan Ramasubramanian036ccd72018-10-23 22:16:36 -0600625 Return (^TBMD)
626 } Else {
Felix Singer73078ed2021-12-29 23:39:59 +0100627 Local0 = ^DDPN - 1
Karthikeyan Ramasubramanian036ccd72018-10-23 22:16:36 -0600628 Return (Local0)
629 }
630 }
Wim Vervoorn8629b492020-01-15 09:16:46 +0100631#endif
Julius Wernercd49cce2019-03-05 16:53:33 -0800632#if CONFIG(EC_GOOGLE_CHROMEEC_ACPI_USB_PORT_POWER)
Emil Lundmark9d5f9f22018-05-22 19:31:37 +0200633 /*
634 * Enable USB Port Power
635 * Arg0 = USB port ID
636 */
637 Method (UPPS, 1, Serialized)
638 {
Felix Singer86bc2e72022-12-16 04:40:39 +0100639 USPP |= 1 << Arg0
Emil Lundmark9d5f9f22018-05-22 19:31:37 +0200640 }
641
642 /*
643 * Disable USB Port Power
644 * Arg0 = USB port ID
645 */
646 Method (UPPC, 1, Serialized)
647 {
Felix Singerc87c1ab2022-12-25 16:25:06 +0100648 USPP &= ~(1 << Arg0)
Emil Lundmark9d5f9f22018-05-22 19:31:37 +0200649 }
650#endif
651
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800652 #include "ac.asl"
653 #include "battery.asl"
Gwendal Grignou866cc3d2016-05-03 23:24:53 -0700654 #include "cros_ec.asl"
Duncan Laurie612163eb2014-06-13 10:35:22 -0700655
656#ifdef EC_ENABLE_ALS_DEVICE
657 #include "als.asl"
658#endif
Shawn Nematbakhsh98cc94c2014-08-28 11:33:41 -0700659
Duncan Laurieef549a02015-09-01 09:47:55 -0700660#ifdef EC_ENABLE_KEYBOARD_BACKLIGHT
Elyes HAOUASb9331092016-09-05 19:55:34 +0200661 #include "keyboard_backlight.asl"
Duncan Laurieef549a02015-09-01 09:47:55 -0700662#endif
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800663}