1 /* SPDX-License-Identifier: GPL-2.0-only */
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.
9 // DTT Power Participant Device Notification
10 #define POWER_STATE_CHANGE_NOTIFICATION 0x81
11 // DTT OEM variables change notification
12 #define EC_OEM_VARIABLE_DATA_MASK 0x7
13 #define INT3400_ODVP_CHANGED 0x88
15 #define ACPI_NOTIFY_CROS_EC_MKBP 0x80
16 #define ACPI_NOTIFY_CROS_EC_PANIC 0xB0
18 // Mainboard specific throttle handler
19 #ifdef DPTF_ENABLE_CHARGER
20 External (\_SB.DPTF.TCHG, DeviceObj)
22 /* Enable DPTC interface with AMD ALIB */
23 #if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
24 External(\_SB.DPTC, MethodObj)
27 External (\_SB.DPTF.TPWR, DeviceObj)
29 #ifdef DPTF_ENABLE_OEM_VARIABLES
30 External (\_SB.DPTF.ODVP, MethodObj)
31 External (\_SB.DPTF.ODGT, MethodObj)
32 External (\_SB.DPTF.ODUP, MethodObj)
37 Name (_HID, EISAID ("PNP0C09"))
39 Name (_GPE, EC_SCI_GPI)
40 Name (TOFS, EC_TEMP_SENSOR_OFFSET)
41 Name (TNCA, EC_TEMP_SENSOR_NOT_CALIBRATED)
42 Name (TNOP, EC_TEMP_SENSOR_NOT_POWERED)
43 Name (TBAD, EC_TEMP_SENSOR_ERROR)
44 Name (TNPR, EC_TEMP_SENSOR_NOT_PRESENT)
45 Name (DWRN, 15) // Battery capacity warning at 15%
46 Name (DLOW, 10) // Battery capacity low at 10%
48 OperationRegion (ERAM, EmbeddedControl, 0x00, EC_ACPI_MEM_MAPPED_BEGIN)
49 Field (ERAM, ByteAcc, Lock, Preserve)
51 RAMV, 8, // EC RAM Version
53 TSTC, 8, // Complement of Test Byte
54 KBLV, 8, // Keyboard Backlight value
55 FAND, 8, // Set Fan Duty Cycle
56 PATI, 8, // Programmable Auxiliary Trip Sensor ID
57 PATT, 8, // Programmable Auxiliary Trip Threshold
58 PATC, 8, // Programmable Auxiliary Trip Commit
59 CHGL, 8, // Charger Current Limit
60 TBMD, 1, // Tablet mode
61 DDPN, 3, // Device DPTF Profile Number
62 STTB, 1, // Switch thermal table by body detection status
63 // DFUD must be 0 for the other 31 values to be valid
65 DFUD, 1, // Device Features Undefined
66 FLSH, 1, // Flash commands present
67 PFAN, 1, // PWM Fan control present
68 KBLE, 1, // Keyboard Backlight present
69 LTBR, 1, // Lightbar present
70 LEDC, 1, // LED control
71 MTNS, 1, // Motion sensors present
72 KEYB, 1, // EC is keyboard controller
73 PSTR, 1, // Persistent storage
74 P80P, 1, // EC serves I/O Port 80h
75 THRM, 1, // EC supports thermal management
76 SBKL, 1, // Screen backlight switch present
77 WIFI, 1, // WIFI switch present
78 HOST, 1, // EC monitors host events (eg SCI, SMI)
79 GPIO, 1, // EC provides GPIO commands
80 I2CB, 1, // EC provides I2C controller access
81 CHRG, 1, // EC provides commands for charger control
82 BATT, 1, // Simply Battery support
83 SBAT, 1, // Smart Battery support
84 HANG, 1, // EC can detect host hang
85 PMUI, 1, // Power Information
86 DSEC, 1, // another EC exists downstream
87 UPDC, 1, // supports USB Power Delivery
88 UMUX, 1, // supports USB Mux
89 MSFF, 1, // Motion Sense has FIFO
90 TVST, 1, // supports temporary secure vstore
91 TCMV, 1, // USB Type C Muxing is virtual (host assisted)
92 RTCD, 1, // EC provides an RTC device
93 FPRD, 1, // EC provides a fingerprint reader device
94 TPAD, 1, // EC provides a touchpad device
95 RWSG, 1, // EC has RWSIG task enabled
96 DEVE, 1, // EC supports device events
97 // make sure we're within our space envelope
100 BTID, 8, // Battery index that host wants to read
101 USPP, 8, // USB Port Power
102 RFWU, 8, // Retimer Firmware Update
103 PBOK, 8, // Power source change count from dptf
104 BSRF, 8, // Battery string readout FIFO
107 #if CONFIG(EC_GOOGLE_CHROMEEC_ACPI_MEMMAP)
108 OperationRegion (EMEM, EmbeddedControl,
109 EC_ACPI_MEM_MAPPED_BEGIN, EC_ACPI_MEM_MAPPED_SIZE)
110 Field (EMEM, ByteAcc, Lock, Preserve)
111 #elif CONFIG(EC_GOOGLE_CHROMEEC_LPC_GENERIC_MEMORY_RANGE)
112 OperationRegion (EMEM, SystemMemory, \_SB.PCI0.LPCB.GLGM() + 0x100, EC_MEMMAP_SIZE)
113 Field (EMEM, ByteAcc, NoLock, Preserve)
115 OperationRegion (EMEM, SystemIO, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE)
116 Field (EMEM, ByteAcc, NoLock, Preserve)
122 #ifdef EC_ENABLE_LID_SWITCH
126 Name (_HID, EisaId ("PNP0C0D"))
132 #ifdef EC_ENABLE_WAKE_PIN
133 Name (_PRW, Package () { EC_ENABLE_WAKE_PIN, 0x5 })
136 #endif /* EC_ENABLE_LID_SWITCH */
138 Method (TINS, 1, Serialized)
140 Switch (ToInteger (Arg0))
142 Case (0) { Return (TIN0) }
143 Case (1) { Return (TIN1) }
144 Case (2) { Return (TIN2) }
145 Case (3) { Return (TIN3) }
146 Case (4) { Return (TIN4) }
147 Case (5) { Return (TIN5) }
148 Case (6) { Return (TIN6) }
149 Case (7) { Return (TIN7) }
150 Case (8) { Return (TIN8) }
151 Case (9) { Return (TIN9) }
152 Default { Return (TIN0) }
156 Method (_CRS, 0, Serialized)
158 Name (ECMD, ResourceTemplate()
161 EC_LPC_ADDR_ACPI_DATA,
162 EC_LPC_ADDR_ACPI_DATA,
165 EC_LPC_ADDR_ACPI_CMD,
166 EC_LPC_ADDR_ACPI_CMD,
172 Method (_REG, 2, NotSerialized)
174 // Initialize AC power state
177 * Call PNOT (Platform Notify) to inform platform code
178 * about the current AC/battery state. This handles all cases,
179 * the battery transitioning into and out of having critically
181 * PWRS isn't valid before this point.
185 #ifndef EC_ENABLE_LID_SWITCH
186 // Initialize LID switch state
190 #if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
192 * Per the device mode (clamshell or tablet) to initialize
193 * the thermal setting on OS startup.
195 If (CondRefOf (\_SB.DPTC)) {
201 /* Read requested temperature and check against EC error values */
202 Method (TSRD, 1, Serialized)
204 Local0 = \_SB.PCI0.LPCB.EC0.TINS (Arg0)
206 /* Check for sensor not calibrated */
207 If (Local0 == \_SB.PCI0.LPCB.EC0.TNCA) {
211 /* Check for sensor not present */
212 If (Local0 == \_SB.PCI0.LPCB.EC0.TNPR) {
216 /* Check for sensor not powered */
217 If (Local0 == \_SB.PCI0.LPCB.EC0.TNOP) {
221 /* Check for sensor bad reading */
222 If (Local0 == \_SB.PCI0.LPCB.EC0.TBAD) {
226 /* Adjust by offset to get Kelvin */
227 Local0 += \_SB.PCI0.LPCB.EC0.TOFS
229 /* Convert to 1/10 Kelvin */
236 Method (_Q01, 0, NotSerialized)
238 Printf ("EC: LID CLOSE")
239 #if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
240 If (CondRefOf (\_SB.DPTC)) {
244 #ifdef EC_ENABLE_LID_SWITCH
252 Method (_Q02, 0, NotSerialized)
254 Printf ("EC: LID OPEN")
255 #if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
256 If (CondRefOf (\_SB.DPTC)) {
261 #ifdef EC_ENABLE_LID_SWITCH
269 Method (_Q03, 0, NotSerialized)
271 Printf ("EC: POWER BUTTON")
275 Method (_Q04, 0, NotSerialized)
277 Printf ("EC: AC CONNECTED")
280 #ifdef DPTF_ENABLE_CHARGER
281 If (CondRefOf (\_SB.DPTF.TCHG)) {
282 Notify (\_SB.DPTF.TCHG, 0x80)
286 * Call PNOT (Platform Notify) to inform platform code
287 * about the current battery state. This handles all cases,
288 * the battery transitioning into and out of having critically
295 Method (_Q05, 0, NotSerialized)
297 Printf ("EC: AC DISCONNECTED")
300 #ifdef DPTF_ENABLE_CHARGER
301 If (CondRefOf (\_SB.DPTF.TCHG)) {
302 Notify (\_SB.DPTF.TCHG, 0x80)
306 * Call PNOT (Platform Notify) to inform platform code
307 * about the current battery state. This handles all cases,
308 * the battery transitioning into and out of having critically
315 Method (_Q06, 0, NotSerialized)
317 Printf ("EC: BATTERY LOW")
321 // Battery Critical Event
322 Method (_Q07, 0, NotSerialized)
324 Printf ("EC: BATTERY CRITICAL")
328 // Battery Info Event
329 Method (_Q08, 0, NotSerialized)
331 Printf ("EC: BATTERY INFO")
333 #ifdef EC_ENABLE_SECOND_BATTERY_DEVICE
334 If (CondRefOf (BAT1)) {
340 // Thermal Overload Event
341 Method (_Q0A, 0, NotSerialized)
343 Printf ("EC: THERMAL OVERLOAD")
348 Method (_Q0B, 0, NotSerialized)
350 Printf ("EC: THERMAL")
355 Method (_Q0D, 0, NotSerialized)
357 Printf ("EC: KEY PRESSED")
361 // Thermal Shutdown Imminent
362 Method (_Q10, 0, NotSerialized)
364 Printf ("EC: THERMAL SHUTDOWN")
368 // Battery Shutdown Imminent
369 Method (_Q11, 0, NotSerialized)
371 Printf ("EC: BATTERY SHUTDOWN")
376 Method (_Q12, 0, NotSerialized)
378 #ifdef EC_ENABLE_THROTTLING_HANDLER
379 Printf ("EC: THROTTLE START")
383 #ifdef DPTF_ENABLE_OEM_VARIABLES
384 Local0 = ToInteger(EOVD) & EC_OEM_VARIABLE_DATA_MASK
385 \_SB.DPTF.ODUP(0, Local0)
386 Local0 = \_SB.DPTF.ODGT(0)
388 Notify (\_SB.DPTF, INT3400_ODVP_CHANGED)
393 Method (_Q13, 0, NotSerialized)
395 #ifdef EC_ENABLE_THROTTLING_HANDLER
396 Printf ("EC: THROTTLE STOP")
401 #ifdef EC_ENABLE_PD_MCU_DEVICE
403 Method (_Q16, 0, NotSerialized)
405 Printf ("EC: GOT PD EVENT")
406 Notify (\_SB.PCI0.LPCB.EC0.CREC.ECPD, 0x80)
407 If (CondRefOf (\_SB.DPTF.TPWR)) {
408 Notify (\_SB.DPTF.TPWR, POWER_STATE_CHANGE_NOTIFICATION)
414 Method (_Q17, 0, NotSerialized)
416 Printf ("EC: BATTERY STATUS")
418 #ifdef EC_ENABLE_SECOND_BATTERY_DEVICE
419 If (CondRefOf (BAT1)) {
425 * Call PNOT (Platform Notify) to inform platform code
426 * about the current battery state. This handles all cases,
427 * the battery transitioning into and out of having critically
434 Method (_Q18, 0, NotSerialized)
437 Notify (CREC, ACPI_NOTIFY_CROS_EC_PANIC)
441 Method (_Q1B, 0, NotSerialized)
444 Notify (CREC, ACPI_NOTIFY_CROS_EC_MKBP)
447 #ifdef EC_ENABLE_PD_MCU_DEVICE
449 Method (_Q1C, 0, NotSerialized)
451 Printf ("EC: USB MUX")
452 Notify (\_SB.PCI0.LPCB.EC0.CREC.ECPD, 0x80)
456 // TABLET mode switch Event
457 Method (_Q1D, 0, NotSerialized)
459 Printf ("EC: TABLET mode switch Event")
461 #ifdef EC_ENABLE_MULTIPLE_DPTF_PROFILES
464 #ifdef EC_ENABLE_TBMC_DEVICE
465 Notify (^CREC.TBMC, 0x80)
467 #if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
468 If (CondRefOf (\_SB.DPTC)) {
474 // Body Detect Change Event
475 Method (_Q21, 0, NotSerialized)
477 Printf ("EC: Body Detect Change Event")
478 #if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
479 If (CondRefOf (\_SB.DPTC)) {
486 * Dynamic Platform Thermal Framework support
489 /* Mutex for EC PAT interface */
493 * Set Aux Trip Point 0
494 * Arg0 = Temp Sensor ID
495 * Arg1 = Value to set
497 Method (PAT0, 2, Serialized)
499 If (Acquire (^PATM, 1000)) {
504 ^PATI = ToInteger (Arg0)
506 /* Temperature is passed in 1/10 Kelvin */
507 Local1 = ToInteger (Arg1) / 10
509 /* Adjust by EC temperature offset */
510 ^PATT = Local1 - ^TOFS
512 /* Set commit value with SELECT=0 and ENABLE=1 */
520 * Set Aux Trip Point 1
521 * Arg0 = Temp Sensor ID
522 * Arg1 = Value to set
524 Method (PAT1, 2, Serialized)
526 If (Acquire (^PATM, 1000)) {
531 ^PATI = ToInteger (Arg0)
533 /* Temperature is passed in 1/10 Kelvin */
534 Local1 = ToInteger (Arg1) / 10
536 /* Adjust by EC temperature offset */
537 ^PATT = Local1 - ^TOFS
539 /* Set commit value with SELECT=1 and ENABLE=1 */
546 /* Disable Aux Trip Points
547 * Arg0 = Temp Sensor ID
549 Method (PATD, 1, Serialized)
551 If (Acquire (^PATM, 1000)) {
555 ^PATI = ToInteger (Arg0)
569 * Thermal Threshold Event
571 Method (_Q09, 0, NotSerialized)
574 #if CONFIG(SOC_AMD_COMMON_BLOCK_ACPI_DPTC)
575 If (CondRefOf (\_SB.DPTC)) {
579 If (!Acquire (^PATM, 1000)) {
580 /* Read sensor ID for event */
583 /* When sensor ID returns 0xFF then no more events */
584 While (Local0 != EC_TEMP_SENSOR_NOT_PRESENT)
586 #ifdef HAVE_THERM_EVENT_HANDLER
587 \_SB.DPTF.TEVT (Local0)
590 /* Keep reaading sensor ID for event */
599 * Set Charger Current Limit
600 * Arg0 = Current Limit in 64mA steps
602 Method (CHGS, 1, Serialized)
604 ^CHGL = ToInteger (Arg0)
608 * Disable Charger Current Limit
610 Method (CHGD, 0, Serialized)
615 /* Read current Tablet mode */
616 Method (RCTM, 0, NotSerialized)
621 #ifdef EC_ENABLE_MULTIPLE_DPTF_PROFILES
622 /* Read current Device DPTF Profile Number */
623 Method (RCDP, 0, NotSerialized)
626 * DDPN = 0 is reserved for backwards compatibility.
627 * If DDPN == 0 use TBMD to load appropriate DPTF table.
637 #if CONFIG(EC_GOOGLE_CHROMEEC_ACPI_USB_PORT_POWER)
639 * Enable USB Port Power
642 Method (UPPS, 1, Serialized)
648 * Disable USB Port Power
651 Method (UPPC, 1, Serialized)
658 #include "battery.asl"
659 #include "cros_ec.asl"
661 #ifdef EC_ENABLE_ALS_DEVICE
665 #ifdef EC_ENABLE_KEYBOARD_BACKLIGHT
666 #include "keyboard_backlight.asl"