<p>Alexey Derlaft has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/23178">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">ec/lenovo/h8: Implement ACPI methods to set battery thresholds<br><br>There are two known (yet) different ways to<br>manage battery thresholds.<br>This patch implements them<br>and adds a way to enable them for<br>different mobos.<br><br>Change-Id: I2a90f9e9b32462b8a5e9bc8d3087ae0fea563ea5<br>Signed-off-by: Alexey Kharlamov <der@2-47.ru><br>---<br>M src/ec/lenovo/h8/Kconfig<br>M src/ec/lenovo/h8/acpi/ec.asl<br>A src/ec/lenovo/h8/acpi/tp_acpi_bat.asl<br>A src/ec/lenovo/h8/acpi/tp_acpi_bat_24.asl<br>A src/ec/lenovo/h8/acpi/tp_acpi_bat_b0.asl<br>M src/mainboard/lenovo/t400/Kconfig<br>M src/mainboard/lenovo/t420/Kconfig<br>M src/mainboard/lenovo/t420s/Kconfig<br>M src/mainboard/lenovo/t430/Kconfig<br>M src/mainboard/lenovo/t430s/Kconfig<br>10 files changed, 361 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/78/23178/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/ec/lenovo/h8/Kconfig b/src/ec/lenovo/h8/Kconfig</span><br><span>index 190f4a9..5360be8 100644</span><br><span>--- a/src/ec/lenovo/h8/Kconfig</span><br><span>+++ b/src/ec/lenovo/h8/Kconfig</span><br><span>@@ -21,6 +21,31 @@</span><br><span>   help</span><br><span>           Flash all LEDs when encountered a fatal error.</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+config IMPLEMENTS_ACPI_H8_BAT_TRESHOLDS</span><br><span style="color: hsl(120, 100%, 40%);">+ bool</span><br><span style="color: hsl(120, 100%, 40%);">+  help</span><br><span style="color: hsl(120, 100%, 40%);">+    Select this if you mainboard implements the GETT</span><br><span style="color: hsl(120, 100%, 40%);">+      and SETT to get and set battery starting and stopping</span><br><span style="color: hsl(120, 100%, 40%);">+         charging tresholds. This will then implement the</span><br><span style="color: hsl(120, 100%, 40%);">+      tpacpi-bat interface provides to include</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+config IMPLEMENTS_ACPI_H8_BAT_TRESHOLDS_24</span><br><span style="color: hsl(120, 100%, 40%);">+      bool</span><br><span style="color: hsl(120, 100%, 40%);">+  select IMPLEMENTS_ACPI_H8_BAT_TRESHOLDS</span><br><span style="color: hsl(120, 100%, 40%);">+       help</span><br><span style="color: hsl(120, 100%, 40%);">+          Select this to enable an implementation for setting</span><br><span style="color: hsl(120, 100%, 40%);">+           battery thresholds that is suitable for the older</span><br><span style="color: hsl(120, 100%, 40%);">+             Lenovo Thinkpad laptops: X200, T400, T500, and probably some others.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+config IMPLEMENTS_ACPI_H8_BAT_TRESHOLDS_B0</span><br><span style="color: hsl(120, 100%, 40%);">+    bool</span><br><span style="color: hsl(120, 100%, 40%);">+  select IMPLEMENTS_ACPI_H8_BAT_TRESHOLDS</span><br><span style="color: hsl(120, 100%, 40%);">+       help</span><br><span style="color: hsl(120, 100%, 40%);">+          Select this to enable an implementation for setting</span><br><span style="color: hsl(120, 100%, 40%);">+           battery thresholds that is suitable for the newer</span><br><span style="color: hsl(120, 100%, 40%);">+             Lenovo Thinkpad laptops: X220/230, T420/430,</span><br><span style="color: hsl(120, 100%, 40%);">+          and probably some others.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> endif</span><br><span> </span><br><span> config H8_DOCK_EARLY_INIT</span><br><span>diff --git a/src/ec/lenovo/h8/acpi/ec.asl b/src/ec/lenovo/h8/acpi/ec.asl</span><br><span>index 944858f..d133061 100644</span><br><span>--- a/src/ec/lenovo/h8/acpi/ec.asl</span><br><span>+++ b/src/ec/lenovo/h8/acpi/ec.asl</span><br><span>@@ -436,6 +436,10 @@</span><br><span>            {</span><br><span>                    Return (\_SB.PCI0.LPCB.EC.GSTS)</span><br><span>              }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+           #if IS_ENABLED(CONFIG_IMPLEMENTS_ACPI_H8_BAT_TRESHOLDS)</span><br><span style="color: hsl(120, 100%, 40%);">+               #include "tp_acpi_bat.asl"</span><br><span style="color: hsl(120, 100%, 40%);">+          #endif</span><br><span>       }</span><br><span> </span><br><span> #include "ac.asl"</span><br><span>diff --git a/src/ec/lenovo/h8/acpi/tp_acpi_bat.asl b/src/ec/lenovo/h8/acpi/tp_acpi_bat.asl</span><br><span>new file mode 100644</span><br><span>index 0000000..33858f3</span><br><span>--- /dev/null</span><br><span>+++ b/src/ec/lenovo/h8/acpi/tp_acpi_bat.asl</span><br><span>@@ -0,0 +1,158 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file is part of the coreboot project.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2017 Arthur Heymans <arthur@aheymans.xyz></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or</span><br><span style="color: hsl(120, 100%, 40%);">+ * modify it under the terms of the GNU General Public License as</span><br><span style="color: hsl(120, 100%, 40%);">+ * published by the Free Software Foundation; version 2 of</span><br><span style="color: hsl(120, 100%, 40%);">+ * the License.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This defines the methods tpacpi-bat can use. This implements what</span><br><span style="color: hsl(120, 100%, 40%);">+ * the vendor defines but is rather ugly...</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* SetBatteryCharge Start/Stop Capacity Threshold</span><br><span style="color: hsl(120, 100%, 40%);">+ * In Parameter:</span><br><span style="color: hsl(120, 100%, 40%);">+ * DWORD</span><br><span style="color: hsl(120, 100%, 40%);">+ * Bit 7-0: Charge stop capacity (Unit:%)</span><br><span style="color: hsl(120, 100%, 40%);">+ *     =0: Use battery default setting</span><br><span style="color: hsl(120, 100%, 40%);">+ *     =1-99: Threshold to stop charging battery (Relative capacity)</span><br><span style="color: hsl(120, 100%, 40%);">+ * Bit 9-8:BatteryID</span><br><span style="color: hsl(120, 100%, 40%);">+ *    = 0: Any battery</span><br><span style="color: hsl(120, 100%, 40%);">+ *    = 1: Primary battery</span><br><span style="color: hsl(120, 100%, 40%);">+ *    = 2: Secondary battery</span><br><span style="color: hsl(120, 100%, 40%);">+ *    = Others: Reserved (0)</span><br><span style="color: hsl(120, 100%, 40%);">+ * Bit 31-10: Reserved (0)</span><br><span style="color: hsl(120, 100%, 40%);">+ *     Must be Zero</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Out Parameter:</span><br><span style="color: hsl(120, 100%, 40%);">+ * DWORD</span><br><span style="color: hsl(120, 100%, 40%);">+ * Bit 30-0: Reserved (0)</span><br><span style="color: hsl(120, 100%, 40%);">+ * Bit 31:     Error status</span><br><span style="color: hsl(120, 100%, 40%);">+ *  0 ... Success</span><br><span style="color: hsl(120, 100%, 40%);">+ *  1 ... Fail</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define START_THRESH_ARG 0</span><br><span style="color: hsl(120, 100%, 40%);">+#define STOP_THRESH_ARG 1</span><br><span style="color: hsl(120, 100%, 40%);">+/* set stop threshold */</span><br><span style="color: hsl(120, 100%, 40%);">+Method (BCSS, 1, NotSerialized)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  Local0 = Arg0 & 0xff /* percentage */</span><br><span style="color: hsl(120, 100%, 40%);">+     Local1 = (Arg0 >> 8) & 0x3 /* BAT id */</span><br><span style="color: hsl(120, 100%, 40%);">+     If (Local1 == 0) /* default bat */</span><br><span style="color: hsl(120, 100%, 40%);">+    {</span><br><span style="color: hsl(120, 100%, 40%);">+             \_SB.PCI0.LPCB.EC.BAT0.SETT(STOP_THRESH_ARG, Arg0)</span><br><span style="color: hsl(120, 100%, 40%);">+            Return ((Local0 !=</span><br><span style="color: hsl(120, 100%, 40%);">+                    \_SB.PCI0.LPCB.EC.BAT0.GETT(STOP_THRESH_ARG)) << 31)</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+     If (Local1 == 1)</span><br><span style="color: hsl(120, 100%, 40%);">+      {</span><br><span style="color: hsl(120, 100%, 40%);">+             \_SB.PCI0.LPCB.EC.BAT0.SETT(STOP_THRESH_ARG, Arg0)</span><br><span style="color: hsl(120, 100%, 40%);">+            Return ((Local0 !=</span><br><span style="color: hsl(120, 100%, 40%);">+                    \_SB.PCI0.LPCB.EC.BAT0.GETT(STOP_THRESH_ARG)) << 31)</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+     If (Local1 == 2)</span><br><span style="color: hsl(120, 100%, 40%);">+      {</span><br><span style="color: hsl(120, 100%, 40%);">+             \_SB.PCI0.LPCB.EC.BAT1.SETT(STOP_THRESH_ARG, Arg0)</span><br><span style="color: hsl(120, 100%, 40%);">+            Return ((Local0 !=</span><br><span style="color: hsl(120, 100%, 40%);">+                    \_SB.PCI0.LPCB.EC.BAT1.GETT(STOP_THRESH_ARG)) << 31)</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+     Return (1 << 31) /* Should not be reached */</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Set start threshold */</span><br><span style="color: hsl(120, 100%, 40%);">+Method (BCCS, 1, NotSerialized)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        Local0 = Arg0 & 0xff /* percentage */</span><br><span style="color: hsl(120, 100%, 40%);">+     Local1 = (Arg0 >> 8) & 0x3 /* BAT id */</span><br><span style="color: hsl(120, 100%, 40%);">+     If (Local1 == 0) /* default bat */</span><br><span style="color: hsl(120, 100%, 40%);">+    {</span><br><span style="color: hsl(120, 100%, 40%);">+             \_SB.PCI0.LPCB.EC.BAT0.SETT(START_THRESH_ARG, Arg0)</span><br><span style="color: hsl(120, 100%, 40%);">+           Return ((Local0 !=</span><br><span style="color: hsl(120, 100%, 40%);">+                    \_SB.PCI0.LPCB.EC.BAT0.GETT(START_THRESH_ARG)) << 31)</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+     If (Local1 == 1)</span><br><span style="color: hsl(120, 100%, 40%);">+      {</span><br><span style="color: hsl(120, 100%, 40%);">+             \_SB.PCI0.LPCB.EC.BAT0.SETT(START_THRESH_ARG, Arg0)</span><br><span style="color: hsl(120, 100%, 40%);">+           Return ((Local0 !=</span><br><span style="color: hsl(120, 100%, 40%);">+                    \_SB.PCI0.LPCB.EC.BAT0.GETT(START_THRESH_ARG)) << 31)</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+     If (Local1 == 2)</span><br><span style="color: hsl(120, 100%, 40%);">+      {</span><br><span style="color: hsl(120, 100%, 40%);">+             \_SB.PCI0.LPCB.EC.BAT0.SETT(START_THRESH_ARG, Arg0)</span><br><span style="color: hsl(120, 100%, 40%);">+           Return ((Local0 !=</span><br><span style="color: hsl(120, 100%, 40%);">+                    \_SB.PCI0.LPCB.EC.BAT1.GETT(START_THRESH_ARG)) << 31)</span><br><span style="color: hsl(120, 100%, 40%);">+   }</span><br><span style="color: hsl(120, 100%, 40%);">+     Return (1 << 31) /* Should not be reached */</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * GetBatteryCharge Start/Stop Capacity Threshold</span><br><span style="color: hsl(120, 100%, 40%);">+ * In Parameter:</span><br><span style="color: hsl(120, 100%, 40%);">+ * DWORD</span><br><span style="color: hsl(120, 100%, 40%);">+ * Bit 7-0:BatteryID</span><br><span style="color: hsl(120, 100%, 40%);">+ * Bit 31-8: Reserved (0)</span><br><span style="color: hsl(120, 100%, 40%);">+ *     Must be Zero</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Out Parameter:</span><br><span style="color: hsl(120, 100%, 40%);">+ * DWORD</span><br><span style="color: hsl(120, 100%, 40%);">+ * Bit 7-0: Charge stop capacity (Unit:%)</span><br><span style="color: hsl(120, 100%, 40%);">+ *     =0: Use battery default setting</span><br><span style="color: hsl(120, 100%, 40%);">+ *     =1-99: Threshold to stop charging battery (Relative capacity)</span><br><span style="color: hsl(120, 100%, 40%);">+ *     =Others: Reserved (0)</span><br><span style="color: hsl(120, 100%, 40%);">+ * Bit 9-8: Capability of BatteryCharge Stop Capacity Threshold</span><br><span style="color: hsl(120, 100%, 40%);">+ * Bit 8:Batterycharge stop capacity threshold</span><br><span style="color: hsl(120, 100%, 40%);">+ *     (0:Not support   1:Support)</span><br><span style="color: hsl(120, 100%, 40%);">+ * Bit 9: Specify every battery parameter</span><br><span style="color: hsl(120, 100%, 40%);">+ *     (0:Not support(apply parameter for all battery)</span><br><span style="color: hsl(120, 100%, 40%);">+ *      1:Support(apply parameter for all battery))</span><br><span style="color: hsl(120, 100%, 40%);">+ * Bit 30-10: Reserved (0)</span><br><span style="color: hsl(120, 100%, 40%);">+ * Bit 31:     Error status</span><br><span style="color: hsl(120, 100%, 40%);">+ *     0 ... Success</span><br><span style="color: hsl(120, 100%, 40%);">+ *     1 ... Fail</span><br><span style="color: hsl(120, 100%, 40%);">+*/</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* get stop threshold */</span><br><span style="color: hsl(120, 100%, 40%);">+Method (BCSG, 1, NotSerialized)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   If (Arg0 == 0) /* Default battery */</span><br><span style="color: hsl(120, 100%, 40%);">+  {</span><br><span style="color: hsl(120, 100%, 40%);">+             Return (0x300 | \_SB.PCI0.LPCB.EC.BAT0.GETT(STOP_THRESH_ARG))</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+     If (Arg0 == 1) /* battery1 */</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+             Return (0x300 | \_SB.PCI0.LPCB.EC.BAT0.GETT(STOP_THRESH_ARG))</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+     If (Arg0 == 2) /* battery2 */</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+             Return (0x300 | \_SB.PCI0.LPCB.EC.BAT1.GETT(STOP_THRESH_ARG))</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+     Return (1 << 31)</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* get start threshold */</span><br><span style="color: hsl(120, 100%, 40%);">+Method (BCTG, 1, NotSerialized)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    If (Arg0 == 0) /* Default battery */</span><br><span style="color: hsl(120, 100%, 40%);">+  {</span><br><span style="color: hsl(120, 100%, 40%);">+             Return (0x300 | \_SB.PCI0.LPCB.EC.BAT0.GETT(START_THRESH_ARG))</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span style="color: hsl(120, 100%, 40%);">+     If (Arg0 == 1) /* battery1 */</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+             Return (0x300 | \_SB.PCI0.LPCB.EC.BAT0.GETT(START_THRESH_ARG))</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span style="color: hsl(120, 100%, 40%);">+     If (Arg0 == 2) /* battery2 */</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+             Return (0x300 | \_SB.PCI0.LPCB.EC.BAT1.GETT(START_THRESH_ARG))</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span style="color: hsl(120, 100%, 40%);">+     Return (1 << 31)</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/src/ec/lenovo/h8/acpi/tp_acpi_bat_24.asl b/src/ec/lenovo/h8/acpi/tp_acpi_bat_24.asl</span><br><span>new file mode 100644</span><br><span>index 0000000..40ddeaf</span><br><span>--- /dev/null</span><br><span>+++ b/src/ec/lenovo/h8/acpi/tp_acpi_bat_24.asl</span><br><span>@@ -0,0 +1,78 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file is part of the coreboot project.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2017 Arthur Heymans <arthur@aheymans.xyz></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or</span><br><span style="color: hsl(120, 100%, 40%);">+ * modify it under the terms of the GNU General Public License as</span><br><span style="color: hsl(120, 100%, 40%);">+ * published by the Free Software Foundation; version 2 of</span><br><span style="color: hsl(120, 100%, 40%);">+ * the License.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Scope(\_SB.PCI0.LPCB.EC)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   Field (ERAM, ByteAcc, NoLock, Preserve)</span><br><span style="color: hsl(120, 100%, 40%);">+       {</span><br><span style="color: hsl(120, 100%, 40%);">+             Offset (0x03),</span><br><span style="color: hsl(120, 100%, 40%);">+                                , 2,</span><br><span style="color: hsl(120, 100%, 40%);">+                          BSTP, 1, /* Battery start/stop threshold */</span><br><span style="color: hsl(120, 100%, 40%);">+           Offset (0x24),</span><br><span style="color: hsl(120, 100%, 40%);">+                                TSH0, 8, /* Battery0 threshold */</span><br><span style="color: hsl(120, 100%, 40%);">+             Offset (0x25),</span><br><span style="color: hsl(120, 100%, 40%);">+                                TSH1, 8 /* Battery1 threshold */</span><br><span style="color: hsl(120, 100%, 40%);">+      }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Scope(\_SB.PCI0.LPCB.EC.BAT0)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      /*</span><br><span style="color: hsl(120, 100%, 40%);">+     * Set threshold on battery0,</span><br><span style="color: hsl(120, 100%, 40%);">+  * Arg0: threshold (0 start, 1 stop) charging, Arg1: Threshold</span><br><span style="color: hsl(120, 100%, 40%);">+         */</span><br><span style="color: hsl(120, 100%, 40%);">+   Method (SETT, 2, NotSerialized)</span><br><span style="color: hsl(120, 100%, 40%);">+       {</span><br><span style="color: hsl(120, 100%, 40%);">+             if (Arg0 <= 1 && Arg1 <= 100) {</span><br><span style="color: hsl(120, 100%, 40%);">+                 BSTP = Arg0</span><br><span style="color: hsl(120, 100%, 40%);">+                   TSH0 = Arg1 | 0x80</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+     /* Get threshold on battery0, Arg0: (0 start, 1 stop) chargning */</span><br><span style="color: hsl(120, 100%, 40%);">+    Method (GETT, 1, NotSerialized)</span><br><span style="color: hsl(120, 100%, 40%);">+       {</span><br><span style="color: hsl(120, 100%, 40%);">+             if (Arg0 <= 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+                   BSTP = Arg0</span><br><span style="color: hsl(120, 100%, 40%);">+                   Return (TSH0)</span><br><span style="color: hsl(120, 100%, 40%);">+         }</span><br><span style="color: hsl(120, 100%, 40%);">+             Return (0)</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Scope(\_SB.PCI0.LPCB.EC.BAT1)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      /*</span><br><span style="color: hsl(120, 100%, 40%);">+     * Set threshold on battery1,</span><br><span style="color: hsl(120, 100%, 40%);">+  * Arg0: threshold (0 start, 1 stop) charging, Arg1: Threshold</span><br><span style="color: hsl(120, 100%, 40%);">+         */</span><br><span style="color: hsl(120, 100%, 40%);">+   Method (SETT, 2, NotSerialized)</span><br><span style="color: hsl(120, 100%, 40%);">+       {</span><br><span style="color: hsl(120, 100%, 40%);">+             if (Arg0 <= 1 && Arg1 <= 100) {</span><br><span style="color: hsl(120, 100%, 40%);">+                 BSTP = Arg0</span><br><span style="color: hsl(120, 100%, 40%);">+                   TSH1 = Arg1 | 0x80</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span style="color: hsl(120, 100%, 40%);">+     }</span><br><span style="color: hsl(120, 100%, 40%);">+     /* Get threshold on battery1, Arg0: (0 start, 1 stop) chargning */</span><br><span style="color: hsl(120, 100%, 40%);">+    Method (GETT, 1, NotSerialized)</span><br><span style="color: hsl(120, 100%, 40%);">+       {</span><br><span style="color: hsl(120, 100%, 40%);">+             if (Arg0 <= 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+                   BSTP = Arg0</span><br><span style="color: hsl(120, 100%, 40%);">+                   Return (TSH1)</span><br><span style="color: hsl(120, 100%, 40%);">+         }</span><br><span style="color: hsl(120, 100%, 40%);">+             Return (0)</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/src/ec/lenovo/h8/acpi/tp_acpi_bat_b0.asl b/src/ec/lenovo/h8/acpi/tp_acpi_bat_b0.asl</span><br><span>new file mode 100644</span><br><span>index 0000000..8040b17</span><br><span>--- /dev/null</span><br><span>+++ b/src/ec/lenovo/h8/acpi/tp_acpi_bat_b0.asl</span><br><span>@@ -0,0 +1,91 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file is part of the coreboot project.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (c) 2017 Arthur Heymans <arthur@aheymans.xyz></span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or</span><br><span style="color: hsl(120, 100%, 40%);">+ * modify it under the terms of the GNU General Public License as</span><br><span style="color: hsl(120, 100%, 40%);">+ * published by the Free Software Foundation; version 2 of</span><br><span style="color: hsl(120, 100%, 40%);">+ * the License.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Scope(\_SB.PCI0.LPCB.EC)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        Field (ERAM, ByteAcc, NoLock, Preserve)</span><br><span style="color: hsl(120, 100%, 40%);">+       {</span><br><span style="color: hsl(120, 100%, 40%);">+             Offset (0xb0),</span><br><span style="color: hsl(120, 100%, 40%);">+                                TSL0, 8, /* Battery0 start threshold */</span><br><span style="color: hsl(120, 100%, 40%);">+               Offset (0xb1),</span><br><span style="color: hsl(120, 100%, 40%);">+                                TSH0, 8, /* Battery0 stop threshold */</span><br><span style="color: hsl(120, 100%, 40%);">+                Offset (0xb2),</span><br><span style="color: hsl(120, 100%, 40%);">+                                TSL1, 8, /* Battery1 start threshold */</span><br><span style="color: hsl(120, 100%, 40%);">+               Offset (0xb3),</span><br><span style="color: hsl(120, 100%, 40%);">+                                TSH1, 8 /* Battery1 stop threshold */</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Scope(\_SB.PCI0.LPCB.EC.BAT0)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      /*</span><br><span style="color: hsl(120, 100%, 40%);">+     * Set threshold on battery0,</span><br><span style="color: hsl(120, 100%, 40%);">+  * Arg0: threshold (0 start, 1 stop) charging, Arg1: Threshold</span><br><span style="color: hsl(120, 100%, 40%);">+         */</span><br><span style="color: hsl(120, 100%, 40%);">+   Method (SETT, 2, NotSerialized)</span><br><span style="color: hsl(120, 100%, 40%);">+       {</span><br><span style="color: hsl(120, 100%, 40%);">+        if (Arg1 <= 100) {</span><br><span style="color: hsl(120, 100%, 40%);">+            if (Arg0 == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                TSL0 = Arg1</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span style="color: hsl(120, 100%, 40%);">+            if (Arg0 == 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+                TSH0 = Arg1</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+     /* Get threshold on battery0, Arg0: (0 start, 1 stop) chargning */</span><br><span style="color: hsl(120, 100%, 40%);">+    Method (GETT, 1, NotSerialized)</span><br><span style="color: hsl(120, 100%, 40%);">+       {</span><br><span style="color: hsl(120, 100%, 40%);">+             if (Arg0 == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      Return (TSL0)</span><br><span style="color: hsl(120, 100%, 40%);">+         }</span><br><span style="color: hsl(120, 100%, 40%);">+             if (Arg0 == 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      Return (TSH0)</span><br><span style="color: hsl(120, 100%, 40%);">+         }</span><br><span style="color: hsl(120, 100%, 40%);">+             Return (0)</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Scope(\_SB.PCI0.LPCB.EC.BAT1)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      /*</span><br><span style="color: hsl(120, 100%, 40%);">+     * Set threshold on battery1,</span><br><span style="color: hsl(120, 100%, 40%);">+  * Arg0: threshold (0 start, 1 stop) charging, Arg1: Threshold</span><br><span style="color: hsl(120, 100%, 40%);">+         */</span><br><span style="color: hsl(120, 100%, 40%);">+   Method (SETT, 2, NotSerialized)</span><br><span style="color: hsl(120, 100%, 40%);">+       {</span><br><span style="color: hsl(120, 100%, 40%);">+        if (Arg1 <= 100) {</span><br><span style="color: hsl(120, 100%, 40%);">+            if (Arg0 == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                TSL1 = Arg1</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span style="color: hsl(120, 100%, 40%);">+            if (Arg0 == 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+                TSH1 = Arg1</span><br><span style="color: hsl(120, 100%, 40%);">+            }</span><br><span style="color: hsl(120, 100%, 40%);">+        }</span><br><span style="color: hsl(120, 100%, 40%);">+       }</span><br><span style="color: hsl(120, 100%, 40%);">+     /* Get threshold on battery1, Arg0: (0 start, 1 stop) chargning */</span><br><span style="color: hsl(120, 100%, 40%);">+    Method (GETT, 1, NotSerialized)</span><br><span style="color: hsl(120, 100%, 40%);">+       {</span><br><span style="color: hsl(120, 100%, 40%);">+             if (Arg0 == 0) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      Return (TSL1)</span><br><span style="color: hsl(120, 100%, 40%);">+         }</span><br><span style="color: hsl(120, 100%, 40%);">+             if (Arg0 == 1) {</span><br><span style="color: hsl(120, 100%, 40%);">+                      Return (TSH1)</span><br><span style="color: hsl(120, 100%, 40%);">+         }</span><br><span style="color: hsl(120, 100%, 40%);">+             Return (0)</span><br><span style="color: hsl(120, 100%, 40%);">+    }</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/src/mainboard/lenovo/t400/Kconfig b/src/mainboard/lenovo/t400/Kconfig</span><br><span>index 8eb5fc5..6c9b1d3 100644</span><br><span>--- a/src/mainboard/lenovo/t400/Kconfig</span><br><span>+++ b/src/mainboard/lenovo/t400/Kconfig</span><br><span>@@ -8,6 +8,7 @@</span><br><span>      select SOUTHBRIDGE_INTEL_I82801IX</span><br><span>    select EC_LENOVO_PMH7</span><br><span>        select EC_LENOVO_H8</span><br><span style="color: hsl(120, 100%, 40%);">+   select IMPLEMENTS_ACPI_H8_BAT_TRESHOLDS_24</span><br><span>   select H8_DOCK_EARLY_INIT</span><br><span>    select BOARD_ROMSIZE_KB_8192</span><br><span>         select DRIVERS_GENERIC_IOAPIC</span><br><span>diff --git a/src/mainboard/lenovo/t420/Kconfig b/src/mainboard/lenovo/t420/Kconfig</span><br><span>index c0b4752..c2044e7 100644</span><br><span>--- a/src/mainboard/lenovo/t420/Kconfig</span><br><span>+++ b/src/mainboard/lenovo/t420/Kconfig</span><br><span>@@ -9,6 +9,7 @@</span><br><span>     select SOUTHBRIDGE_INTEL_BD82X6X</span><br><span>     select EC_LENOVO_PMH7</span><br><span>        select EC_LENOVO_H8</span><br><span style="color: hsl(120, 100%, 40%);">+   select IMPLEMENTS_ACPI_H8_BAT_TRESHOLDS_B0</span><br><span>   select NO_UART_ON_SUPERIO</span><br><span>    select BOARD_ROMSIZE_KB_8192</span><br><span>         select HAVE_ACPI_TABLES</span><br><span>diff --git a/src/mainboard/lenovo/t420s/Kconfig b/src/mainboard/lenovo/t420s/Kconfig</span><br><span>index 08052b1..ab579fb 100644</span><br><span>--- a/src/mainboard/lenovo/t420s/Kconfig</span><br><span>+++ b/src/mainboard/lenovo/t420s/Kconfig</span><br><span>@@ -9,6 +9,7 @@</span><br><span>       select SOUTHBRIDGE_INTEL_BD82X6X</span><br><span>     select EC_LENOVO_PMH7</span><br><span>        select EC_LENOVO_H8</span><br><span style="color: hsl(120, 100%, 40%);">+   select IMPLEMENTS_ACPI_H8_BAT_TRESHOLDS_B0</span><br><span>   select NO_UART_ON_SUPERIO</span><br><span>    select BOARD_ROMSIZE_KB_8192</span><br><span>         select HAVE_ACPI_TABLES</span><br><span>diff --git a/src/mainboard/lenovo/t430/Kconfig b/src/mainboard/lenovo/t430/Kconfig</span><br><span>index a621fdb..8d759c0 100644</span><br><span>--- a/src/mainboard/lenovo/t430/Kconfig</span><br><span>+++ b/src/mainboard/lenovo/t430/Kconfig</span><br><span>@@ -6,6 +6,7 @@</span><br><span>   select CPU_INTEL_SOCKET_RPGA989</span><br><span>      select DRIVERS_RICOH_RCE822</span><br><span>  select EC_LENOVO_H8</span><br><span style="color: hsl(120, 100%, 40%);">+   select IMPLEMENTS_ACPI_H8_BAT_TRESHOLDS_B0</span><br><span>   select EC_LENOVO_PMH7</span><br><span>        select NO_UART_ON_SUPERIO</span><br><span>    select HAVE_ACPI_RESUME</span><br><span>diff --git a/src/mainboard/lenovo/t430s/Kconfig b/src/mainboard/lenovo/t430s/Kconfig</span><br><span>index f45fb0d..5f68d90 100644</span><br><span>--- a/src/mainboard/lenovo/t430s/Kconfig</span><br><span>+++ b/src/mainboard/lenovo/t430s/Kconfig</span><br><span>@@ -9,6 +9,7 @@</span><br><span>       select SOUTHBRIDGE_INTEL_C216</span><br><span>        select EC_LENOVO_PMH7</span><br><span>        select EC_LENOVO_H8</span><br><span style="color: hsl(120, 100%, 40%);">+   select IMPLEMENTS_ACPI_H8_BAT_TRESHOLDS_B0</span><br><span>   select NO_UART_ON_SUPERIO</span><br><span>    select BOARD_ROMSIZE_KB_16384</span><br><span>        select HAVE_ACPI_TABLES</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/23178">change 23178</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/23178"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I2a90f9e9b32462b8a5e9bc8d3087ae0fea563ea5 </div>
<div style="display:none"> Gerrit-Change-Number: 23178 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Alexey Derlaft <derlafff@ya.ru> </div>