summaryrefslogtreecommitdiff
path: root/src/ec/purism/librem/acpi/ec.asl
blob: 668b7d11bf5e1c4d6ab67daaa449691a729ca9f5 (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/* SPDX-License-Identifier: GPL-2.0-only */

Device (TPSD)
{
	/*
	 * TPSACPI01 is not a valid _HID but it is what the linux topstar
	 * laptop driver expects, use this indirection to let it compile.
	 */
	Name (BHID, "TPSACPI01")
	Method (_HID)
	{
		Return (BHID)
	}
	Name (_UID, 0)

	Method (FNCX, 1, NotSerialized)
	{
		If (LEqual (Arg0, 0x86)) {
			/* Enable topstar-laptop kernel driver handling */
			Store (One, ^^EC.TPSE)
		} ElseIf (LEqual (Arg0, 0x87)) {
			/* Disable topstar-laptop kernel driver handling */
			Store (Zero, ^^EC.TPSE)
		}
	}
}

Device (EC)
{
	Name (_HID, EisaId ("PNP0C09"))
	Name (_UID, 0)
	Name (_GPE, EC_SCI_GPI)

	Name (_CRS, ResourceTemplate () {
		IO (Decode16, 0x62, 0x62, 0, 1)
		IO (Decode16, 0x66, 0x66, 0, 1)
	})

	OperationRegion (ERAM, EmbeddedControl, Zero, 0xFF)
	Field (ERAM, ByteAcc, Lock, Preserve)
	{
		Offset (0x13),
		RTMP, 8,
		, 8,
		BSTS, 2,	/* Battery Status */
		, 3,
		BTEX, 1,	/* Battery Present */
		Offset (0x1D),
		TPAD, 1,	/* Touchpad Enable/Disable */
		WIFI, 1,	/* WiFi Enable/Disable */
		, 3,
		BTLE, 1,	/* Bluetooth Enable/Disable */
		Offset (0x25),
		, 5,
		FANM, 2,
		TPSE, 1,	/* topstar-laptop driver enable/disable */
		Offset (0x31),
		, 6,
		LIDS, 1,	/* LID Switch */
		ACEX, 1,	/* AC present */
		Offset (0x8E),
		BTDA, 16,	/* Battery Design Capacity */
		Offset (0x92),
		BTVO, 16,	/* Battery Present Voltage */
		Offset (0x98),
		BTRA, 16,	/* Battery Remaining Capacity */
		BTDF, 16,	/* Battery Last Full Charge Capacity */
		Offset (0x9E),
		, 4,
		BFCR, 1,	/* Battery Level Critical */
		Offset (0xA0),
		BTDV, 16,	/* Battery Design Voltage */
		Offset (0xA4),
		BTPR, 16,	/* Battery Present Rate */
		Offset (0xE6),
		TURB, 1,	/* EC Requested Turbo Enable/Disable */
		EDTB, 1,	/* Confirm Turbo Enable/Disable */
	}

	Method (_REG, 2, NotSerialized)
	{
		/* Initialize AC power state */
		Store (ACEX, \PWRS)

		/* Initialize LID switch state */
		Store (LIDS, \LIDS)
	}

	/* Notify topstar-laptop kernel driver */
	Method (TPSN, 1)
	{
		If (TPSE) {
			Notify (^^TPSD, Arg0)
		}
	}

	/* KEY_WWW */
	Method (_Q10)
	{
		TPSN (0x8A)
	}

	/* KEY_MAIL */
	Method (_Q11)
	{
		TPSN (0x8B)
	}

	/* KEY_MEDIA */
	Method (_Q12)
	{
		TPSN (0x8C)
	}

	/* AC Status Changed */
	Method (_Q20)
	{
		Store (ACEX, \PWRS)
		Notify (AC, 0x80)
		Notify (BAT, 0x80)
		PNOT ()
	}

	/* Lid Event */
	Method (_Q21)
	{
		Store (LIDS, \LIDS)
		Notify (LID0, 0x80)
	}

	/* Battery Event */
	Method (_Q22)
	{
		Notify (BAT, 0x80)
	}

	/* KEY_SWITCHVIDEOMODE */
	Method (_Q25)
	{
		TPSN (0x86)
	}

	/* KEY_BRIGHTNESSUP */
	Method (_Q28)
	{
		TPSN (0x80)
	}

	/* KEY_BRIGHTNESSDOWN */
	Method (_Q29)
	{
		TPSN (0x81)
	}

	/* KEY_MUTE */
	Method (_Q2A)
	{
		TPSN (0x85)
	}

	/* KEY_VOLUMEUP */
	Method (_Q2B)
	{
		TPSN (0x83)
	}

	/* KEY_VOLUMEDOWN */
	Method (_Q2C)
	{
		TPSN (0x84)
	}

	/* KEY_SLEEP */
	Method (_Q2F)
	{
		Notify (\_SB.SLPB, 0x80)
	}

	/* KEY_F13 (Touchpad Enable/Disable)
	Method (_Q34)
	{
		TPSN (0x87)
		XOr (^TPAD, One, ^TPAD)
	}

	/* KEY_WLAN */
	Method (_Q35)
	{
		TPSN (0x88)
		XOr (^WIFI, One, ^WIFI)
	}

	/* KEY_BLUETOOTH */
	Method (_Q37)
	{
		XOr (^BTLE, One, ^BTLE)
	}

	/* Turbo Enable/Disable */
	Method (_Q50)
	{
		/*
		 * Limiting frequency via PPC doesn't do anything if the
		 * kernel is using intel_pstate instead of ACPI _PPC.
		 *
		 * If the state is not updated in EDTB the EC will
		 * repeatedly send this event several times a second
		 * when the system is charging.
		 */
		If (TURB) {
			Store (PPCM_TURBO, PPCM)
			PPCN ()
			Store (One, EDTB)
		} Else {
			Store (PPCM_NOTURBO, PPCM)
			PPCN ()
			Store (Zero, EDTB)
		}
	}

	#include "ac.asl"
	#include "battery.asl"
}

Scope (\_TZ)
{
	ThermalZone (TZ0)
	{
		/* _TMP: Temperature */
		Method (_TMP, 0, Serialized)
		{
			Local0 = (0x0AAC + (\_SB.PCI0.LPCB.EC.RTMP * 0x0A))
			Return (Local0)
		}

		/* _CRT: Critical Temperature */
		Method (_CRT, 0, Serialized)
		{
			/* defined in board ec.asl */
			Return (CRIT_TEMP)
		}
	}
}