ec/system76/ec: Add battery charging thresholds

System76 EC firmware supports setting charging thresholds for a single
battery.

Change-Id: I3d656291c096f320d469274677e9fe6c74819d25
Signed-off-by: Tim Crawford <tcrawford@system76.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/45532
Reviewed-by: Jeremy Soller <jeremy@system76.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Tim Crawford 2020-09-18 13:37:15 -06:00 committed by Patrick Georgi
parent f8051e7c8b
commit a4e75ab0cd
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

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