summaryrefslogtreecommitdiffstats
path: root/src/ec/google/wilco/acpi/dptf.asl
blob: 705988af24bfa53bdb6651f2e54dc39acd7a671b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/* SPDX-License-Identifier: GPL-2.0-only */

/*
 * Dynamic Platform Thermal Framework support
 */

/* Mutex for EC PAT interface */
Mutex (PATM, 1)

/* Read requested temperature sensor */
Method (TSRD, 1, Serialized)
{
	If (Acquire (^PATM, 1000)) {
		Return (0)
	}

	/* Set sensor ID */
	W (DWTI, ToInteger (Arg0))

	Local0 = R (DRTV)

	Release (^PATM)
	Return (\_SB.DPTF.CTOK (Local0))
}

/*
 * Set Aux Trip Point 0
 *   Arg0 = Temp Sensor ID
 *   Arg1 = Value to set
 */
Method (PAT0, 2, Serialized)
{
	If (Acquire (^PATM, 1000)) {
		Return (0)
	}

	/* Set sensor ID */
	W (DWTI, ToInteger (Arg0))

	/* Set LOW trip point for this sensor */
	W (DWTL, \_SB.DPTF.KTOC (Arg1))

	Release (^PATM)
	Return (1)
}

/*
 * Set Aux Trip Point 1
 *   Arg0 = Temp Sensor ID
 *   Arg1 = Value to set
 */
Method (PAT1, 2, Serialized)
{
	If (Acquire (^PATM, 1000)) {
		Return (0)
	}

	/* Set sensor ID */
	W (DWTI, ToInteger (Arg0))

	/* Set HIGH trip point for this sensor */
	W (DWTH, \_SB.DPTF.KTOC (Arg1))

	Release (^PATM)
	Return (1)
}

/*
 * Disable Aux Trip Points
 *   Arg0 = Temp Sensor ID
 */
Method (PATD, 1, Serialized)
{
	If (Acquire (^PATM, 1000)) {
		Return (0)
	}

	/* Set sensor ID */
	W (DWTI, ToInteger (Arg0))

	/* Disable LOW and HIGH trip points */
	W (DWTL, 0xff)
	W (DWTH, 0xff)

	Release (^PATM)
	Return (1)
}

/*
 * Handle sensor trip events
 */
Method (PATX, 0, Serialized)
{
	Local0 = R (DRTQ)
	Local1 = Local0

	Printf ("Sensor trip mask: %o", Local0)

	If (LNot (Acquire (^PATM, 1000))) {

		/* Handle bits that are set */
		While (FindSetRightBit (Local1, Local2))
		{
#ifdef HAVE_THERM_EVENT_HANDLER
			/* DPTF will Notify sensor devices */
			\_SB.DPTF.TEVT (Local2)
#endif

			/* Clear current sensor number */
			Local1 &= ~(1 << (Local2 - 1))
		}

		Release (^PATM)
	}

	/* Clear sensor events */
	W (DWTQ, Local0)
}