blob: 2d44ae3c1b780106ca8869580e0ae315ac4fbb26 [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 }
131#endif
132
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
180 // Initialize LID switch state
Felix Singerff6b3af2022-12-12 04:54:46 +0100181 \LIDS = LIDS
Kevin Chiu83f0c692020-09-22 00:48:36 +0800182
Tim Van Patten2873fd22022-08-29 11:36:35 -0600183#if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
Kevin Chiu83f0c692020-09-22 00:48:36 +0800184 /*
185 * Per the device mode (clamshell or tablet) to initialize
186 * the thermal setting on OS startup.
187 */
188 If (CondRefOf (\_SB.DPTC)) {
189 \_SB.DPTC()
190 }
191#endif
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800192 }
193
Duncan Lauriead8d9132013-12-10 07:41:33 -0800194 /* Read requested temperature and check against EC error values */
195 Method (TSRD, 1, Serialized)
196 {
Felix Singerff6b3af2022-12-12 04:54:46 +0100197 Local0 = \_SB.PCI0.LPCB.EC0.TINS (Arg0)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800198
199 /* Check for sensor not calibrated */
Felix Singer3c799fa2022-01-02 00:55:18 +0100200 If (Local0 == \_SB.PCI0.LPCB.EC0.TNCA) {
Felix Singer42efd7f2022-12-26 09:38:45 +0100201 Return (0)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800202 }
203
204 /* Check for sensor not present */
Felix Singer3c799fa2022-01-02 00:55:18 +0100205 If (Local0 == \_SB.PCI0.LPCB.EC0.TNPR) {
Felix Singer42efd7f2022-12-26 09:38:45 +0100206 Return (0)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800207 }
208
209 /* Check for sensor not powered */
Felix Singer3c799fa2022-01-02 00:55:18 +0100210 If (Local0 == \_SB.PCI0.LPCB.EC0.TNOP) {
Felix Singer42efd7f2022-12-26 09:38:45 +0100211 Return (0)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800212 }
213
214 /* Check for sensor bad reading */
Felix Singer3c799fa2022-01-02 00:55:18 +0100215 If (Local0 == \_SB.PCI0.LPCB.EC0.TBAD) {
Felix Singer42efd7f2022-12-26 09:38:45 +0100216 Return (0)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800217 }
218
219 /* Adjust by offset to get Kelvin */
Felix Singer3a462062021-12-30 01:22:36 +0100220 Local0 += \_SB.PCI0.LPCB.EC0.TOFS
Duncan Lauriead8d9132013-12-10 07:41:33 -0800221
222 /* Convert to 1/10 Kelvin */
Felix Singer89818d12022-01-01 23:36:28 +0100223 Local0 *= 10
Duncan Lauriead8d9132013-12-10 07:41:33 -0800224
225 Return (Local0)
226 }
227
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800228 // Lid Closed Event
229 Method (_Q01, 0, NotSerialized)
230 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100231 Printf ("EC: LID CLOSE")
EricKY Cheng366b2052022-09-23 17:04:01 +0800232#if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
233 If (CondRefOf (\_SB.DPTC)) {
234 \_SB.DPTC()
235 }
236#endif
Felix Singerff6b3af2022-12-12 04:54:46 +0100237 \LIDS = LIDS
Aaron Durbin05201d72016-09-23 16:06:14 -0500238#ifdef EC_ENABLE_LID_SWITCH
239 Notify (LID0, 0x80)
Aaron Durbin05201d72016-09-23 16:06:14 -0500240#endif
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800241 }
242
243 // Lid Open Event
244 Method (_Q02, 0, NotSerialized)
245 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100246 Printf ("EC: LID OPEN")
EricKY Cheng366b2052022-09-23 17:04:01 +0800247#if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
248 If (CondRefOf (\_SB.DPTC)) {
249 \_SB.DPTC()
250 }
251#endif
Felix Singerff6b3af2022-12-12 04:54:46 +0100252 \LIDS = LIDS
Furquan Shaikha3a84562017-11-28 14:32:17 -0800253 Notify (CREC, 0x2)
Aaron Durbin05201d72016-09-23 16:06:14 -0500254#ifdef EC_ENABLE_LID_SWITCH
255 Notify (LID0, 0x80)
Aaron Durbin05201d72016-09-23 16:06:14 -0500256#endif
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800257 }
258
259 // Power Button
260 Method (_Q03, 0, NotSerialized)
261 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100262 Printf ("EC: POWER BUTTON")
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800263 }
264
265 // AC Connected
266 Method (_Q04, 0, NotSerialized)
267 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100268 Printf ("EC: AC CONNECTED")
Felix Singerff6b3af2022-12-12 04:54:46 +0100269 \PWRS = ACEX
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800270 Notify (AC, 0x80)
Freddy Paule8cc52f2015-10-02 19:06:57 -0700271#ifdef DPTF_ENABLE_CHARGER
Duncan Laurie3f1500f2014-03-06 08:37:49 -0800272 If (CondRefOf (\_SB.DPTF.TCHG)) {
273 Notify (\_SB.DPTF.TCHG, 0x80)
274 }
Freddy Paule8cc52f2015-10-02 19:06:57 -0700275#endif
Tim Van Patten14fa11f2022-08-22 14:06:11 -0600276 /*
277 * Call PNOT (Platform Notify) to inform platform code
278 * about the current battery state. This handles all cases,
279 * the battery transitioning into and out of having critically
280 * low charge.
281 */
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800282 \PNOT ()
283 }
284
285 // AC Disconnected
286 Method (_Q05, 0, NotSerialized)
287 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100288 Printf ("EC: AC DISCONNECTED")
Felix Singerff6b3af2022-12-12 04:54:46 +0100289 \PWRS = ACEX
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800290 Notify (AC, 0x80)
Freddy Paule8cc52f2015-10-02 19:06:57 -0700291#ifdef DPTF_ENABLE_CHARGER
Duncan Laurie3f1500f2014-03-06 08:37:49 -0800292 If (CondRefOf (\_SB.DPTF.TCHG)) {
293 Notify (\_SB.DPTF.TCHG, 0x80)
294 }
Freddy Paule8cc52f2015-10-02 19:06:57 -0700295#endif
Tim Van Patten14fa11f2022-08-22 14:06:11 -0600296 /*
297 * Call PNOT (Platform Notify) to inform platform code
298 * about the current battery state. This handles all cases,
299 * the battery transitioning into and out of having critically
300 * low charge.
301 */
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800302 \PNOT ()
303 }
304
305 // Battery Low Event
306 Method (_Q06, 0, NotSerialized)
307 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100308 Printf ("EC: BATTERY LOW")
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800309 Notify (BAT0, 0x80)
310 }
311
312 // Battery Critical Event
313 Method (_Q07, 0, NotSerialized)
314 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100315 Printf ("EC: BATTERY CRITICAL")
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800316 Notify (BAT0, 0x80)
317 }
318
319 // Battery Info Event
320 Method (_Q08, 0, NotSerialized)
321 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100322 Printf ("EC: BATTERY INFO")
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800323 Notify (BAT0, 0x81)
Nicolas Boichat07fe6182018-01-26 14:37:16 +0800324#ifdef EC_ENABLE_SECOND_BATTERY_DEVICE
325 If (CondRefOf (BAT1)) {
326 Notify (BAT1, 0x81)
327 }
328#endif
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800329 }
330
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800331 // Thermal Overload Event
332 Method (_Q0A, 0, NotSerialized)
333 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100334 Printf ("EC: THERMAL OVERLOAD")
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800335 Notify (\_TZ, 0x80)
336 }
337
338 // Thermal Event
339 Method (_Q0B, 0, NotSerialized)
340 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100341 Printf ("EC: THERMAL")
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800342 Notify (\_TZ, 0x80)
343 }
344
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800345 // Key Pressed
346 Method (_Q0D, 0, NotSerialized)
347 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100348 Printf ("EC: KEY PRESSED")
Furquan Shaikha3a84562017-11-28 14:32:17 -0800349 Notify (CREC, 0x2)
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800350 }
351
Duncan Laurie18d9899b2013-08-28 09:54:04 -0700352 // Thermal Shutdown Imminent
353 Method (_Q10, 0, NotSerialized)
354 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100355 Printf ("EC: THERMAL SHUTDOWN")
Duncan Laurie18d9899b2013-08-28 09:54:04 -0700356 Notify (\_TZ, 0x80)
357 }
358
359 // Battery Shutdown Imminent
360 Method (_Q11, 0, NotSerialized)
361 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100362 Printf ("EC: BATTERY SHUTDOWN")
Duncan Laurie18d9899b2013-08-28 09:54:04 -0700363 Notify (BAT0, 0x80)
364 }
365
Duncan Lauried338b462013-07-31 15:30:41 -0700366 // Throttle Start
367 Method (_Q12, 0, NotSerialized)
368 {
Martin Roth6b1ceac2018-05-06 17:58:36 -0500369#ifdef EC_ENABLE_THROTTLING_HANDLER
Felix Singer3462a1b2021-12-26 15:05:45 +0100370 Printf ("EC: THROTTLE START")
Martin Roth6b1ceac2018-05-06 17:58:36 -0500371 \_TZ.THRT (1)
372#endif
Tony Huanga434f612022-08-09 11:32:55 +0800373
374#ifdef DPTF_ENABLE_OEM_VARIABLES
375 Local0 = ToInteger(EOVD) & EC_OEM_VARIABLE_DATA_MASK
376 \_SB.DPTF.ODUP(0, Local0)
377 Local0 = \_SB.DPTF.ODGT(0)
378 \_SB.DPTF.ODVP()
379 Notify (\_SB.DPTF, INT3400_ODVP_CHANGED)
380#endif
Duncan Lauried338b462013-07-31 15:30:41 -0700381 }
382
383 // Throttle Stop
384 Method (_Q13, 0, NotSerialized)
385 {
Martin Roth6b1ceac2018-05-06 17:58:36 -0500386#ifdef EC_ENABLE_THROTTLING_HANDLER
Felix Singer3462a1b2021-12-26 15:05:45 +0100387 Printf ("EC: THROTTLE STOP")
Martin Roth6b1ceac2018-05-06 17:58:36 -0500388 \_TZ.THRT (0)
389#endif
Duncan Lauried338b462013-07-31 15:30:41 -0700390 }
391
Shawn Nematbakhsh98cc94c2014-08-28 11:33:41 -0700392#ifdef EC_ENABLE_PD_MCU_DEVICE
393 // PD event
394 Method (_Q16, 0, NotSerialized)
395 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100396 Printf ("EC: GOT PD EVENT")
Prashant Malanidabc0ad2020-03-10 15:42:54 -0700397 Notify (\_SB.PCI0.LPCB.EC0.CREC.ECPD, 0x80)
Varshit B Pandyaa872b9a2022-03-20 22:20:11 +0530398 If (CondRefOf (\_SB.DPTF.TPWR)) {
399 Notify (\_SB.DPTF.TPWR, POWER_STATE_CHANGE_NOTIFICATION)
400 }
Shawn Nematbakhsh98cc94c2014-08-28 11:33:41 -0700401 }
402#endif
403
Duncan Lauried8401182014-09-29 08:32:19 -0700404 // Battery Status
405 Method (_Q17, 0, NotSerialized)
406 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100407 Printf ("EC: BATTERY STATUS")
Duncan Lauried8401182014-09-29 08:32:19 -0700408 Notify (BAT0, 0x80)
Nicolas Boichat07fe6182018-01-26 14:37:16 +0800409#ifdef EC_ENABLE_SECOND_BATTERY_DEVICE
410 If (CondRefOf (BAT1)) {
411 Notify (BAT1, 0x80)
412 }
413#endif
Tim Van Patten14fa11f2022-08-22 14:06:11 -0600414
415 /*
416 * Call PNOT (Platform Notify) to inform platform code
417 * about the current battery state. This handles all cases,
418 * the battery transitioning into and out of having critically
419 * low charge.
420 */
421 \PNOT ()
Duncan Lauried8401182014-09-29 08:32:19 -0700422 }
423
Rob Barnesa3148ca2022-11-08 07:47:14 -0700424 // EC Panic
425 Method (_Q18, 0, NotSerialized)
426 {
427 Printf ("EC: PANIC")
428 Notify (CREC, ACPI_NOTIFY_CROS_EC_PANIC)
429 }
430
Gwendal Grignou95b7a6c2016-05-03 23:53:23 -0700431 // MKBP interrupt.
Gwendal Grignou880b4582016-06-20 08:49:25 -0700432 Method (_Q1B, 0, NotSerialized)
Gwendal Grignou95b7a6c2016-05-03 23:53:23 -0700433 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100434 Printf ("EC: MKBP")
Gwendal Grignou95b7a6c2016-05-03 23:53:23 -0700435 Notify (CREC, 0x80)
436 }
437
Brandon Breitensteinbc885c12020-04-01 13:30:37 -0700438#ifdef EC_ENABLE_PD_MCU_DEVICE
439 // USB MUX Interrupt
440 Method (_Q1C, 0, NotSerialized)
441 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100442 Printf ("EC: USB MUX")
Brandon Breitensteinbc885c12020-04-01 13:30:37 -0700443 Notify (\_SB.PCI0.LPCB.EC0.CREC.ECPD, 0x80)
444 }
445#endif
446
jiazi Yang51fc93f2016-07-28 05:15:01 -0400447 // TABLET mode switch Event
448 Method (_Q1D, 0, NotSerialized)
449 {
Felix Singer3462a1b2021-12-26 15:05:45 +0100450 Printf ("EC: TABLET mode switch Event")
Furquan Shaikha3a84562017-11-28 14:32:17 -0800451 Notify (CREC, 0x2)
Karthikeyan Ramasubramanian017b5c42018-11-14 08:53:01 -0700452#ifdef EC_ENABLE_MULTIPLE_DPTF_PROFILES
Martin Roth9c055982018-05-01 21:52:42 -0500453 \_SB.DPTF.TPET()
Furquan Shaikhc96ad862018-01-26 10:40:09 -0800454#endif
455#ifdef EC_ENABLE_TBMC_DEVICE
Gwendal Grignou87d5fb82017-01-19 18:30:21 -0800456 Notify (TBMC, 0x80)
Gwendal Grignou87d5fb82017-01-19 18:30:21 -0800457#endif
Tim Van Patten2873fd22022-08-29 11:36:35 -0600458#if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
Chris Wange019bd92020-08-06 16:38:04 +0800459 If (CondRefOf (\_SB.DPTC)) {
460 \_SB.DPTC()
461 }
462#endif
Furquan Shaikha3a84562017-11-28 14:32:17 -0800463 }
jiazi Yang51fc93f2016-07-28 05:15:01 -0400464
Duncan Lauriead8d9132013-12-10 07:41:33 -0800465 /*
466 * Dynamic Platform Thermal Framework support
467 */
468
Duncan Laurie93e24442014-01-06 12:30:52 -0800469 /* Mutex for EC PAT interface */
470 Mutex (PATM, 1)
471
Duncan Lauriead8d9132013-12-10 07:41:33 -0800472 /*
473 * Set Aux Trip Point 0
474 * Arg0 = Temp Sensor ID
475 * Arg1 = Value to set
476 */
477 Method (PAT0, 2, Serialized)
478 {
Duncan Laurie93e24442014-01-06 12:30:52 -0800479 If (Acquire (^PATM, 1000)) {
480 Return (0)
481 }
482
Duncan Laurie93e24442014-01-06 12:30:52 -0800483 /* Set sensor ID */
Felix Singerff6b3af2022-12-12 04:54:46 +0100484 ^PATI = ToInteger (Arg0)
Duncan Laurie93e24442014-01-06 12:30:52 -0800485
Duncan Laurie8be67592014-01-09 10:01:05 -0800486 /* Temperature is passed in 1/10 Kelvin */
Felix Singer81623fb2022-01-02 00:13:07 +0100487 Local1 = ToInteger (Arg1) / 10
Duncan Laurie8be67592014-01-09 10:01:05 -0800488
489 /* Adjust by EC temperature offset */
Felix Singer73078ed2021-12-29 23:39:59 +0100490 ^PATT = Local1 - ^TOFS
Duncan Laurie93e24442014-01-06 12:30:52 -0800491
492 /* Set commit value with SELECT=0 and ENABLE=1 */
Felix Singerff6b3af2022-12-12 04:54:46 +0100493 ^PATC = 0x02
Duncan Laurie93e24442014-01-06 12:30:52 -0800494
495 Release (^PATM)
496 Return (1)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800497 }
498
499 /*
500 * Set Aux Trip Point 1
501 * Arg0 = Temp Sensor ID
502 * Arg1 = Value to set
503 */
504 Method (PAT1, 2, Serialized)
505 {
Duncan Laurie93e24442014-01-06 12:30:52 -0800506 If (Acquire (^PATM, 1000)) {
507 Return (0)
508 }
509
Duncan Laurie93e24442014-01-06 12:30:52 -0800510 /* Set sensor ID */
Felix Singerff6b3af2022-12-12 04:54:46 +0100511 ^PATI = ToInteger (Arg0)
Duncan Laurie93e24442014-01-06 12:30:52 -0800512
Duncan Laurie8be67592014-01-09 10:01:05 -0800513 /* Temperature is passed in 1/10 Kelvin */
Felix Singer81623fb2022-01-02 00:13:07 +0100514 Local1 = ToInteger (Arg1) / 10
Duncan Laurie8be67592014-01-09 10:01:05 -0800515
516 /* Adjust by EC temperature offset */
Felix Singer73078ed2021-12-29 23:39:59 +0100517 ^PATT = Local1 - ^TOFS
Duncan Laurie93e24442014-01-06 12:30:52 -0800518
519 /* Set commit value with SELECT=1 and ENABLE=1 */
Felix Singerff6b3af2022-12-12 04:54:46 +0100520 ^PATC = 0x03
Duncan Laurie93e24442014-01-06 12:30:52 -0800521
522 Release (^PATM)
523 Return (1)
524 }
525
Duncan Laurie8be67592014-01-09 10:01:05 -0800526 /* Disable Aux Trip Points
527 * Arg0 = Temp Sensor ID
528 */
529 Method (PATD, 1, Serialized)
Duncan Laurie93e24442014-01-06 12:30:52 -0800530 {
531 If (Acquire (^PATM, 1000)) {
532 Return (0)
533 }
534
Felix Singerff6b3af2022-12-12 04:54:46 +0100535 ^PATI = ToInteger (Arg0)
536 ^PATT = 0x00
Duncan Laurie93e24442014-01-06 12:30:52 -0800537
538 /* Disable PAT0 */
Felix Singerff6b3af2022-12-12 04:54:46 +0100539 ^PATC = 0x00
Duncan Laurie93e24442014-01-06 12:30:52 -0800540
541 /* Disable PAT1 */
Felix Singerff6b3af2022-12-12 04:54:46 +0100542 ^PATC = 0x01
Duncan Laurie93e24442014-01-06 12:30:52 -0800543
544 Release (^PATM)
545 Return (1)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800546 }
547
548 /*
Duncan Laurie93e24442014-01-06 12:30:52 -0800549 * Thermal Threshold Event
Duncan Lauriee6b280e2014-02-10 16:21:05 -0800550 */
Duncan Laurie8be67592014-01-09 10:01:05 -0800551 Method (_Q09, 0, NotSerialized)
Duncan Lauriead8d9132013-12-10 07:41:33 -0800552 {
EricKY Cheng366b2052022-09-23 17:04:01 +0800553
554#if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
555 If (CondRefOf (\_SB.DPTC)) {
556 \_SB.DPTC()
557 }
558#endif
Felix Singer98be4d62021-12-31 14:32:03 +0100559 If (!Acquire (^PATM, 1000)) {
Marc Jonese17ec3e2018-08-15 22:53:34 -0600560 /* Read sensor ID for event */
Felix Singerff6b3af2022-12-12 04:54:46 +0100561 Local0 = ^PATI
Duncan Laurie93e24442014-01-06 12:30:52 -0800562
Marc Jonese17ec3e2018-08-15 22:53:34 -0600563 /* When sensor ID returns 0xFF then no more events */
Felix Singer8ab09752022-01-02 02:48:53 +0100564 While (Local0 != EC_TEMP_SENSOR_NOT_PRESENT)
Marc Jonese17ec3e2018-08-15 22:53:34 -0600565 {
Martin Roth15f232d2018-04-29 22:41:58 -0500566#ifdef HAVE_THERM_EVENT_HANDLER
Marc Jonese17ec3e2018-08-15 22:53:34 -0600567 \_SB.DPTF.TEVT (Local0)
Martin Roth15f232d2018-04-29 22:41:58 -0500568#endif
Aaron Durbinb3ce6582014-05-13 09:23:10 -0500569
Marc Jonese17ec3e2018-08-15 22:53:34 -0600570 /* Keep reaading sensor ID for event */
Felix Singerff6b3af2022-12-12 04:54:46 +0100571 Local0 = ^PATI
Marc Jonese17ec3e2018-08-15 22:53:34 -0600572 }
Duncan Laurie93e24442014-01-06 12:30:52 -0800573
Marc Jonese17ec3e2018-08-15 22:53:34 -0600574 Release (^PATM)
575 }
Duncan Lauriead8d9132013-12-10 07:41:33 -0800576 }
577
Duncan Lauriee6b280e2014-02-10 16:21:05 -0800578 /*
579 * Set Charger Current Limit
580 * Arg0 = Current Limit in 64mA steps
581 */
582 Method (CHGS, 1, Serialized)
583 {
Felix Singerff6b3af2022-12-12 04:54:46 +0100584 ^CHGL = ToInteger (Arg0)
Duncan Lauriee6b280e2014-02-10 16:21:05 -0800585 }
586
587 /*
588 * Disable Charger Current Limit
589 */
590 Method (CHGD, 0, Serialized)
591 {
Felix Singerff6b3af2022-12-12 04:54:46 +0100592 ^CHGL = 0xFF
Duncan Lauriee6b280e2014-02-10 16:21:05 -0800593 }
594
jiazi Yang51fc93f2016-07-28 05:15:01 -0400595 /* Read current Tablet mode */
596 Method (RCTM, 0, NotSerialized)
597 {
598 Return (^TBMD)
599 }
600
Wim Vervoorn8629b492020-01-15 09:16:46 +0100601#ifdef EC_ENABLE_MULTIPLE_DPTF_PROFILES
Karthikeyan Ramasubramanian036ccd72018-10-23 22:16:36 -0600602 /* Read current Device DPTF Profile Number */
603 Method (RCDP, 0, NotSerialized)
604 {
605 /*
606 * DDPN = 0 is reserved for backwards compatibility.
607 * If DDPN == 0 use TBMD to load appropriate DPTF table.
608 */
Felix Singer3c799fa2022-01-02 00:55:18 +0100609 If (^DDPN == 0) {
Karthikeyan Ramasubramanian036ccd72018-10-23 22:16:36 -0600610 Return (^TBMD)
611 } Else {
Felix Singer73078ed2021-12-29 23:39:59 +0100612 Local0 = ^DDPN - 1
Karthikeyan Ramasubramanian036ccd72018-10-23 22:16:36 -0600613 Return (Local0)
614 }
615 }
Wim Vervoorn8629b492020-01-15 09:16:46 +0100616#endif
Julius Wernercd49cce2019-03-05 16:53:33 -0800617#if CONFIG(EC_GOOGLE_CHROMEEC_ACPI_USB_PORT_POWER)
Emil Lundmark9d5f9f22018-05-22 19:31:37 +0200618 /*
619 * Enable USB Port Power
620 * Arg0 = USB port ID
621 */
622 Method (UPPS, 1, Serialized)
623 {
Felix Singer86bc2e72022-12-16 04:40:39 +0100624 USPP |= 1 << Arg0
Emil Lundmark9d5f9f22018-05-22 19:31:37 +0200625 }
626
627 /*
628 * Disable USB Port Power
629 * Arg0 = USB port ID
630 */
631 Method (UPPC, 1, Serialized)
632 {
Felix Singerc87c1ab2022-12-25 16:25:06 +0100633 USPP &= ~(1 << Arg0)
Emil Lundmark9d5f9f22018-05-22 19:31:37 +0200634 }
635#endif
636
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800637 #include "ac.asl"
638 #include "battery.asl"
Gwendal Grignou866cc3d2016-05-03 23:24:53 -0700639 #include "cros_ec.asl"
Duncan Laurie612163eb2014-06-13 10:35:22 -0700640
641#ifdef EC_ENABLE_ALS_DEVICE
642 #include "als.asl"
643#endif
Shawn Nematbakhsh98cc94c2014-08-28 11:33:41 -0700644
Duncan Laurieef549a02015-09-01 09:47:55 -0700645#ifdef EC_ENABLE_KEYBOARD_BACKLIGHT
Elyes HAOUASb9331092016-09-05 19:55:34 +0200646 #include "keyboard_backlight.asl"
Duncan Laurieef549a02015-09-01 09:47:55 -0700647#endif
648
Furquan Shaikhc96ad862018-01-26 10:40:09 -0800649#ifdef EC_ENABLE_TBMC_DEVICE
Gwendal Grignou87d5fb82017-01-19 18:30:21 -0800650 #include "tbmc.asl"
651#endif
Stefan Reinauerd6682e82013-02-21 15:39:35 -0800652}