summaryrefslogtreecommitdiff
path: root/src/ec/lenovo/h8/acpi/thinkpad.asl
blob: 73eee52deb6d8f1af59d64ce51b135bc1ca755e9 (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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
/* SPDX-License-Identifier: GPL-2.0-only */

Device (HKEY)
{
	/* Generated by ssdt.c */
	External (\HBDC, IntObj)
	External (\HWAN, IntObj)
	External (\HKBL, IntObj)
	External (\HUWB, IntObj)

	Name (_HID, EisaId (CONFIG_THINKPADEC_HKEY_EISAID))

	Name (BTN, 0)

	Name (BTAB, 0)

	/* MASK */
	Name (DHKN, 0x080C)

	/* Effective Mask */
	Name (EMSK, 0)

	/* Effective Mask for tablet */
	Name (ETAB, 0)

	/* Device enabled. */
	Name (EN, 0)

	Method (_STA, 0, NotSerialized)
	{
		Return (0x0F)
	}

	/* Retrieve event. */
	Method (MHKP, 0, NotSerialized)
	{
		Local0 = BTN
		If (Local0 != 0) {
			BTN = Zero
			Local0 += 0x1000
			Return (Local0)
		}
		Local0 = BTAB
		If (Local0 != 0) {
			BTAB = Zero
			Local0 += 0x5000
			Return (Local0)
		}
		Return (Zero)
	}

	/* Report event  */
	Method (RHK, 1, NotSerialized) {
		Local0 = 1 << (Arg0 - 1)
		If (EMSK & Local0) {
			BTN = Arg0
			Notify (HKEY, 0x80)
		}
	}

	/* Report tablet  */
	Method (RTAB, 1, NotSerialized) {
		Local0 = 1 << (Arg0 - 1)
		If (ETAB & Local0) {
			BTAB = Arg0
			Notify (HKEY, 0x80)
		}
	}

	/* Enable/disable all events.  */
	Method (MHKC, 1, NotSerialized) {
		If (Arg0) {
			EMSK = DHKN
			ETAB = Ones
		}
		Else
		{
			EMSK = Zero
			ETAB = Zero
		}
		EN = Arg0
	}

	/* Enable/disable event.  */
	Method (MHKM, 2, NotSerialized) {
		If (Arg0 <= 0x20) {
			Local0 = 1 << (Arg0 - 1)
			If (Arg1)
			{
				DHKN |= Local0
			}
			Else
			{
				DHKN = DHKN & ~Local0
			}
			If (EN)
			{
				EMSK = DHKN
			}
		}
	}

	/* Mask hotkey all. */
	Method (MHKA, 0, NotSerialized)
	{
		Return (0x07FFFFFF)
	}

	/* Report tablet mode switch state */
	Method (MHKG, 0, NotSerialized)
	{
		Return (TBSW << 3)
	}

	/* Mute audio */
	Method (SSMS, 1, NotSerialized)
	{
		ALMT = Arg0
	}

	/* Control mute microphone LED */
	Method (MMTS, 1, NotSerialized)
	{
		If (Arg0)
		{
			TLED(0x8E)
		}
		Else
		{
			TLED(0x0E)
		}
	}

	/* Version */
	Method (MHKV, 0, NotSerialized)
	{
		Return (0x0100)
	}

	/* Master wireless switch state */
	Method (WLSW, 0, NotSerialized)
	{
		Return (\_SB.PCI0.LPCB.EC.GSTS)
	}

	/* Set to one on first boot */
	Name (INIT, 0)

	/* Has thinkpad_acpi module loaded */
	Name (HAST, 0)

	/* State after sleep */
	Name (WBDC, 0)
	/*
	 * Returns the current state:
	 *  Bit 0: BT HW present
	 *  Bit 1: BT radio enabled
	 *  Bit 2: BT state at resume
	 */
	Method (GBDC, 0)
	{
		HAST = 1

		If (HBDC) {
			Local0 = 1
			If(\_SB.PCI0.LPCB.EC.BTEB)
			{
				Local0 |= 2
			}
			Local0 |= WBDC << 2
			Return (Local0)
		} Else {
			Return (0)
		}
	}

	/*
	 * Set the current state:
	 *  Bit 1: BT radio enabled
	 *  Bit 2: BT state at resume
	 */
	Method (SBDC, 1)
	{
		HAST = 1

		If (HBDC) {
			Local0 = (Arg0 & 2) >> 1
			\_SB.PCI0.LPCB.EC.BTEB = Local0
			Local0 = (Arg0 & 4) >> 2
			WBDC = Local0
		}
	}

	/* State after sleep */
	Name (WWAN, 0)
	/*
	 * Returns the current state:
	 *  Bit 0: WWAN HW present
	 *  Bit 1: WWAN radio enabled
	 *  Bit 2: WWAN state at resume
	 */
	Method (GWAN, 0)
	{
		HAST = 1

		If (HWAN) {
			Local0 = 1
			If(\_SB.PCI0.LPCB.EC.WWEB)
			{
				Local0 |= 2
			}
			Local0 |= WWAN << 2
			Return (Local0)
		} Else {
			Return (0)
		}
	}

	/*
	 * Set the current state:
	 *  Bit 1: WWAN radio enabled
	 *  Bit 2: WWAN state at resume
	 */
	Method (SWAN, 1)
	{
		HAST = 1

		If (HWAN) {
			Local0 = (Arg0 & 2) >> 1
			\_SB.PCI0.LPCB.EC.WWEB = Local0
			WWAN = (Arg0 & 4) >> 2
		}
	}

	/*
	 * Argument is unused.
	 * Returns the current state:
	 *  Bit 9: Backlight HW present
	 *  Bit 0-1: Brightness level
	 */
	Method (MLCG, 1)
	{
		If (HKBL) {
			Local0 = 0x200
			/* FIXME: Support 2bit brightness control */
			Local0 |= \_SB.PCI0.LPCB.EC.KBLT
			Return (Local0)
		} Else {
			Return (0)
		}
	}

	/*
	 * Set the current state:
	 * Bit 0-1: Brightness level
	 */
	Method (MLCS, 1)
	{
		If (HKBL) {
			/* FIXME: Support 2bit brightness control */
			\_SB.PCI0.LPCB.EC.WWEB = Arg0 & 1
		}
	}

	/*
	 * Returns the current state:
	 *  Bit 0: UWB HW present
	 *  Bit 1: UWB radio enabled
	 */
	Method (GUWB, 0)
	{
		If (HUWB) {
			Local0 = 1
			If(\_SB.PCI0.LPCB.EC.UWBE)
			{
				Local0 |= 2
			}
			Return (Local0)
		} Else {
			Return (0)
		}
	}

	/*
	 * Set the current state:
	 *  Bit 1: UWB radio enabled
	 */
	Method (SUWB, 1)
	{
		If (HUWB) {
			Local0 = (Arg0 & 2) >> 1
			\_SB.PCI0.LPCB.EC.UWBE = Local0
		}
	}

	/*
	 * Called from _WAK
	 */
	Method (WAKE, 1)
	{
		If (HAST) {
			\_SB.PCI0.LPCB.EC.BTEB = WBDC
			\_SB.PCI0.LPCB.EC.WWEB = WWAN
		}
	}

	#if CONFIG(H8_HAS_BAT_THRESHOLDS_IMPL)
	#include "thinkpad_bat_thresholds.asl"
	#endif
}