Debian Codegraph @

src/ec/google/wilco/acpi/dptf.asl

raw
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3 /*
4 * Dynamic Platform Thermal Framework support
5 */
6
7 /* Mutex for EC PAT interface */
8 Mutex (PATM, 0)
9
10 /* Read requested temperature sensor */
11 Method (TSRD, 1, Serialized)
12 {
13 If (Acquire (^PATM, 1000)) {
14 Return (0)
15 }
16
17 /* Set sensor ID */
18 W (DWTI, ToInteger (Arg0))
19
20 Local0 = R (DRTV)
21
22 Release (^PATM)
23 Return (\_SB.DPTF.CTOK (Local0))
24 }
25
26 /*
27 * Set Aux Trip Point 0
28 * Arg0 = Temp Sensor ID
29 * Arg1 = Value to set
30 */
31 Method (PAT0, 2, Serialized)
32 {
33 If (Acquire (^PATM, 1000)) {
34 Return (0)
35 }
36
37 /* Set sensor ID */
38 W (DWTI, ToInteger (Arg0))
39
40 /* Set LOW trip point for this sensor */
41 W (DWTL, \_SB.DPTF.KTOC (Arg1))
42
43 Release (^PATM)
44 Return (1)
45 }
46
47 /*
48 * Set Aux Trip Point 1
49 * Arg0 = Temp Sensor ID
50 * Arg1 = Value to set
51 */
52 Method (PAT1, 2, Serialized)
53 {
54 If (Acquire (^PATM, 1000)) {
55 Return (0)
56 }
57
58 /* Set sensor ID */
59 W (DWTI, ToInteger (Arg0))
60
61 /* Set HIGH trip point for this sensor */
62 W (DWTH, \_SB.DPTF.KTOC (Arg1))
63
64 Release (^PATM)
65 Return (1)
66 }
67
68 /*
69 * Disable Aux Trip Points
70 * Arg0 = Temp Sensor ID
71 */
72 Method (PATD, 1, Serialized)
73 {
74 If (Acquire (^PATM, 1000)) {
75 Return (0)
76 }
77
78 /* Set sensor ID */
79 W (DWTI, ToInteger (Arg0))
80
81 /* Disable LOW and HIGH trip points */
82 W (DWTL, 0xff)
83 W (DWTH, 0xff)
84
85 Release (^PATM)
86 Return (1)
87 }
88
89 /*
90 * Handle sensor trip events
91 */
92 Method (PATX, 0, Serialized)
93 {
94 Local0 = R (DRTQ)
95 Local1 = Local0
96
97 Printf ("Sensor trip mask: %o", Local0)
98
99 If (!Acquire (^PATM, 1000)) {
100
101 /* Handle bits that are set */
102 While (FindSetRightBit (Local1, Local2))
103 {
104 #ifdef HAVE_THERM_EVENT_HANDLER
105 /* DPTF will Notify sensor devices */
106 \_SB.DPTF.TEVT (Local2)
107 #endif
108
109 /* Clear current sensor number */
110 Local1 &= ~(1 << (Local2 - 1))
111 }
112
113 Release (^PATM)
114 }
115
116 /* Clear sensor events */
117 W (DWTQ, Local0)
118 }
119
120 #ifdef EC_ENABLE_MULTIPLE_DPTF_PROFILES
121 /*
122 * Read current Device DPTF Profile Number
123 */
124 Method (RCDP, 0, NotSerialized)
125 {
126 Local0 = R(DRTI)
127 If (Local0 == 0) {
128 Return (R(OTBL))
129 } else {
130 Return (Local0 - 1)
131 }
132 }
133 #endif