Debian Codegraph @

src/ec/lenovo/h8/acpi/thinkpad_bat_thresholds_24.asl

raw
1 /* SPDX-License-Identifier: GPL-2.0-only */
2
3
4 Scope(\_SB.PCI0.LPCB.EC)
5 {
6 Field (ERAM, ByteAcc, NoLock, Preserve)
7 {
8 Offset (0x03),
9 , 2,
10 BSTP, 1, /* Battery start/stop threshold */
11 Offset (0x24),
12 TSH0, 8, /* Battery0 threshold */
13 Offset (0x25),
14 TSH1, 8, /* Battery1 threshold */
15 }
16 }
17
18 Scope(\_SB.PCI0.LPCB.EC.BAT0)
19 {
20 /*
21 * Set threshold on battery0,
22 *
23 * Arg0: 0: Start threshold
24 * 1: Stop threshold
25 * Arg1: Percentage
26 */
27 Method (SETT, 2, NotSerialized)
28 {
29 if (Arg0 <= 1 && Arg1 <= 100)
30 {
31 BSTP = Arg0
32 #if defined(H8_BAT_THRESHOLDS_BIT7)
33 TSH0 = Arg1
34 #else
35 TSH0 = Arg1 | 0x80
36 #endif
37 }
38 }
39
40 /**
41 * Get threshold on battery0
42 *
43 * Arg0: 0: Start threshold
44 * 1: Stop threshold
45 */
46 Method (GETT, 1, NotSerialized)
47 {
48 if (Arg0 <= 1)
49 {
50 BSTP = Arg0
51 #if defined(H8_BAT_THRESHOLDS_BIT7)
52 Return (TSH0)
53 #else
54 Return (TSH0 & ~0x80)
55 #endif
56 }
57 Return (0)
58 }
59 }
60
61 Scope(\_SB.PCI0.LPCB.EC.BAT1)
62 {
63 /*
64 * Set threshold on battery1
65 *
66 * Arg0: 0: Start threshold
67 * 1: Stop threshold
68 * Arg1: Percentage
69 */
70 Method (SETT, 2, NotSerialized)
71 {
72 if (Arg0 <= 1 && Arg1 <= 100)
73 {
74 BSTP = Arg0
75 #if defined(H8_BAT_THRESHOLDS_BIT7)
76 TSH1 = Arg1
77 #else
78 TSH1 = Arg1 | 0x80
79 #endif
80 }
81 }
82
83 /**
84 * Get threshold on battery1
85 *
86 * Arg0: 0: Start threshold
87 * 1: Stop threshold
88 */
89 Method (GETT, 1, NotSerialized)
90 {
91 if (Arg0 <= 1)
92 {
93 BSTP = Arg0
94 #if defined(H8_BAT_THRESHOLDS_BIT7)
95 Return (TSH1)
96 #else
97 Return (TSH1 & ~0x80)
98 #endif
99 }
100 Return (0)
101 }
102 }