aboutsummaryrefslogtreecommitdiff
path: root/src/ec
diff options
context:
space:
mode:
authorTim Crawford <tcrawford@system76.com>2020-09-18 13:37:15 -0600
committerPatrick Georgi <pgeorgi@google.com>2020-11-02 06:23:36 +0000
commita4e75ab0cd7895d9b9b8d1219da75021ce2ebf36 (patch)
treefab0511d86dbe6e9119e9b2e2cc84b75c4e8c02a /src/ec
parentf8051e7c8b9ab986c2dd98f9836994caeb761c01 (diff)
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>
Diffstat (limited to 'src/ec')
-rw-r--r--src/ec/system76/ec/Kconfig5
-rw-r--r--src/ec/system76/ec/acpi/battery_thresholds.asl46
-rw-r--r--src/ec/system76/ec/acpi/ec.asl4
3 files changed, 55 insertions, 0 deletions
diff --git a/src/ec/system76/ec/Kconfig b/src/ec/system76/ec/Kconfig
index fea4743593..8c9030e599 100644
--- a/src/ec/system76/ec/Kconfig
+++ b/src/ec/system76/ec/Kconfig
@@ -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
diff --git a/src/ec/system76/ec/acpi/battery_thresholds.asl b/src/ec/system76/ec/acpi/battery_thresholds.asl
new file mode 100644
index 0000000000..3bb1330fbf
--- /dev/null
+++ b/src/ec/system76/ec/acpi/battery_thresholds.asl
@@ -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
+ }
+ }
+}
diff --git a/src/ec/system76/ec/acpi/ec.asl b/src/ec/system76/ec/acpi/ec.asl
index 98abc66e9e..128bd56304 100644
--- a/src/ec/system76/ec/acpi/ec.asl
+++ b/src/ec/system76/ec/acpi/ec.asl
@@ -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
}