summaryrefslogtreecommitdiffstats
path: root/src/ec/lenovo/h8/acpi/thinkpad_bat_thresholds_24.asl
blob: f730765a76f519611645f087ab407ad02ddd184b (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
/* SPDX-License-Identifier: GPL-2.0-only */
/* This file is part of the coreboot project. */


Scope(\_SB.PCI0.LPCB.EC)
{
	Field (ERAM, ByteAcc, NoLock, Preserve)
	{
		Offset (0x03),
				, 2,
				BSTP, 1, /* Battery start/stop threshold */
		Offset (0x24),
				TSH0, 8, /* Battery0 threshold */
		Offset (0x25),
				TSH1, 8, /* Battery1 threshold */
	}
}

Scope(\_SB.PCI0.LPCB.EC.BAT0)
{
	/*
	 * Set threshold on battery0,
	 *
	 * Arg0: 0: Start threshold
	 *       1: Stop threshold
	 * Arg1: Percentage
	 */
	Method (SETT, 2, NotSerialized)
	{
		if (Arg0 <= 1 && Arg1 <= 100)
		{
			BSTP = Arg0
#if defined(H8_BAT_THRESHOLDS_BIT7)
			TSH0 = Arg1
#else
			TSH0 = Arg1 | 0x80
#endif
		}
	}

	/**
	 * Get threshold on battery0
	 *
	 * Arg0: 0: Start threshold
	 *       1: Stop threshold
	 */
	Method (GETT, 1, NotSerialized)
	{
		if (Arg0 <= 1)
		{
			BSTP = Arg0
#if defined(H8_BAT_THRESHOLDS_BIT7)
			Return (TSH0)
#else
			Return (TSH0 & ~0x80)
#endif
		}
		Return (0)
	}
}

Scope(\_SB.PCI0.LPCB.EC.BAT1)
{
	/*
	 * Set threshold on battery1
	 *
	 * Arg0: 0: Start threshold
	 *       1: Stop threshold
	 * Arg1: Percentage
	 */
	Method (SETT, 2, NotSerialized)
	{
		if (Arg0 <= 1 && Arg1 <= 100)
		{
			BSTP = Arg0
#if defined(H8_BAT_THRESHOLDS_BIT7)
			TSH1 = Arg1
#else
			TSH1 = Arg1 | 0x80
#endif
		}
	}

	/**
	 * Get threshold on battery1
	 *
	 * Arg0: 0: Start threshold
	 *       1: Stop threshold
	 */
	Method (GETT, 1, NotSerialized)
	{
		if (Arg0 <= 1)
		{
			BSTP = Arg0
#if defined(H8_BAT_THRESHOLDS_BIT7)
			Return (TSH1)
#else
			Return (TSH1 & ~0x80)
#endif
		}
		Return (0)
	}
}