summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
}