ec/system76/ec: Add battery charging thresholds

Change-Id: I3d656291c096f320d469274677e9fe6c74819d25
Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
Tim Crawford
2020-09-18 13:04:19 -06:00
committed by Jeremy Soller
parent 2ee83f8df4
commit 1f24cd4271
3 changed files with 55 additions and 0 deletions

View File

@@ -3,6 +3,11 @@ config EC_SYSTEM76_EC
help
System76 EC
config EC_SYSTEM76_EC_BAT_THRESHOLDS
depends on EC_SYSTEM76_EC
bool
default n
config EC_SYSTEM76_EC_COLOR_KEYBOARD
depends on EC_SYSTEM76_EC
bool

View File

@@ -0,0 +1,46 @@
/* SPDX-License-Identifier: GPL-2.0-only */
Field (ERAM, ByteAcc, Lock, Preserve)
{
Offset (0xBC),
BTL0, 8, /* BAT0 charging start threshold */
BTH0, 8, /* BAT0 charging end threshold */
}
/*
* Get battery charging threshold
*
* Arg0: 0: Start threshold
* 1: Stop threshold
*/
Method (GBCT, 1, NotSerialized)
{
If (Arg0 == 0) {
Return (BTL0)
}
If (Arg0 == 1) {
Return (BTH0)
}
Return (0xFF)
}
/*
* Set battery charging threshold
*
* Arg0: 0: Start threshold
* 1: Stop threshold
* Arg1: Percentage
*/
Method (SBCT, 2, NotSerialized)
{
If (Arg1 <= 100) {
If (Arg0 == 0) {
BTL0 = Arg1
}
If (Arg0 == 1) {
BTH0 = Arg1
}
}
}

View File

@@ -230,4 +230,8 @@ Device (\_SB.PCI0.LPCB.EC0)
Debug = Concatenate("EC: Other: ", ToHexString(Local0))
}
}
#if CONFIG(EC_SYSTEM76_EC_BAT_THRESHOLDS)
#include "battery_thresholds.asl"
#endif
}