summaryrefslogtreecommitdiff
path: root/src/ec
diff options
context:
space:
mode:
authorTobias Diedrich <ranma+openocd@tdiedrich.de>2017-02-12 13:16:18 +0100
committerMartin Roth <martinroth@google.com>2017-03-21 17:45:14 +0100
commit1583dbd7b70cce8a334563b4cf9d17f7a1979856 (patch)
treef521b6d13d19a90cceaad47ad02034be3932e43a /src/ec
parentb4d07578554926c36b6256eca974bc12d41dffb5 (diff)
ec/lenovo/h8: Support an optional battery page flip delay
The Lenovo H8 battery interface uses a paged EC memory area. Some Thinkpads (in particular the S230U) use a different EC controller (ENE KB9012) with mostly compatible firmware, which requires an explicit delay between writing the page register and reading the page data. Change-Id: Iaeb8c4829efa29139396b519de803f10dd93f03f Signed-off-by: Tobias Diedrich <ranma+coreboot@tdiedrich.de> Reviewed-on: https://review.coreboot.org/18348 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Nico Huber <nico.h@gmx.de>
Diffstat (limited to 'src/ec')
-rw-r--r--src/ec/lenovo/h8/acpi/battery.asl32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/ec/lenovo/h8/acpi/battery.asl b/src/ec/lenovo/h8/acpi/battery.asl
index fef994a1d6..080f247838 100644
--- a/src/ec/lenovo/h8/acpi/battery.asl
+++ b/src/ec/lenovo/h8/acpi/battery.asl
@@ -84,6 +84,22 @@ Field (ERAM, ByteAcc, NoLock, Preserve)
BANA, 128
}
+/*
+ * Switches the battery information page (16 bytes ERAM @0xa0) with an
+ * optional compile-time delay.
+ *
+ * Arg0:
+ * bit7-4: Battery number
+ * bit3-0: Information page number
+ */
+Method(BPAG, 1, NotSerialized)
+{
+ Store(Arg0, PAGE)
+#ifdef BATTERY_PAGE_DELAY_MS
+ Sleep(BATTERY_PAGE_DELAY_MS)
+#endif
+}
+
/* Arg0: Battery
* Arg1: Battery Status Package
* Arg2: charging
@@ -93,9 +109,9 @@ Method(BSTA, 4, NotSerialized)
{
Acquire(ECLK, 0xffff)
Store(0, Local0)
- Or(1, Arg0, PAGE)
+ ^BPAG(Or(1, Arg0))
Store(BAMA, Local1)
- Store(Arg0, PAGE) /* Battery dynamic information */
+ ^BPAG(Arg0) /* Battery dynamic information */
/*
* Present rate is a 16bit signed int, positive while charging
@@ -147,12 +163,12 @@ Method(BSTA, 4, NotSerialized)
Method(BINF, 2, NotSerialized)
{
Acquire(ECLK, 0xffff)
- Or(1, Arg1, PAGE) /* Battery 0 static information */
+ ^BPAG(Or(1, Arg1)) /* Battery 0 static information */
Xor(BAMA, 1, Index(Arg0, 0))
Store(BAMA, Local0)
- Store(Arg1, PAGE)
+ ^BPAG(Arg1)
Store(BAFC, Local2)
- Or(2, Arg1, PAGE)
+ ^BPAG(Or(2, Arg1))
Store(BADC, Local1)
if (Local0)
@@ -177,13 +193,13 @@ Method(BINF, 2, NotSerialized)
}
Store (SERN, Index (Arg0, 10)) // Serial Number
- Or(4, Arg1, PAGE)
+ ^BPAG(Or(4, Arg1))
Name (TYPE, Buffer() { 0, 0, 0, 0, 0 })
Store(BATY, TYPE)
Store(TYPE, Index (Arg0, 11)) // Battery type
- Or(5, Arg1, PAGE)
+ ^BPAG(Or(5, Arg1))
Store(BAOE, Index (Arg0, 12)) // OEM information
- Or(6, Arg1, PAGE)
+ ^BPAG(Or(6, Arg1))
Store(BANA, Index (Arg0, 9)) // Model number
Release(ECLK)
Return (Arg0)