summaryrefslogtreecommitdiff
path: root/src/ec/purism/librem-ec/acpi/battery_thresholds.asl
diff options
context:
space:
mode:
Diffstat (limited to 'src/ec/purism/librem-ec/acpi/battery_thresholds.asl')
-rw-r--r--src/ec/purism/librem-ec/acpi/battery_thresholds.asl46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/ec/purism/librem-ec/acpi/battery_thresholds.asl b/src/ec/purism/librem-ec/acpi/battery_thresholds.asl
new file mode 100644
index 0000000000..3bb1330fbf
--- /dev/null
+++ b/src/ec/purism/librem-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
+ }
+ }
+}