From 07fe6184bc1d834377a91bfbe7e796d8027f1f24 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Fri, 26 Jan 2018 14:37:16 +0800 Subject: chromeec: Add support for reading second battery info We share the same shared memory fields for both batteries. When the host wants to switch battery to read out, it will: - Set BTID (EC_ACPI_MEM_BATTERY_INDEX) to the required index - Wait for BITX (EC_MEMMAP_BATT_INDEX) to have the required value - Then fetch the data BRANCH=none BUG=b:65697620 TEST=Boot lux, both /sys/class/power_supply/BAT0 and BAT1 are present, data is valid. Change-Id: Ib06176e6ab4c45a899259f0917e6292121865ed6 Signed-off-by: Nicolas Boichat Reviewed-on: https://review.coreboot.org/23598 Reviewed-by: Furquan Shaikh Tested-by: build bot (Jenkins) Reviewed-by: Duncan Laurie --- src/ec/google/chromeec/acpi/ec.asl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/ec/google/chromeec/acpi/ec.asl') diff --git a/src/ec/google/chromeec/acpi/ec.asl b/src/ec/google/chromeec/acpi/ec.asl index 618b00a79e..62f9acda4c 100644 --- a/src/ec/google/chromeec/acpi/ec.asl +++ b/src/ec/google/chromeec/acpi/ec.asl @@ -90,7 +90,9 @@ Device (EC0) DEVE, 1, // EC supports device events // make sure we're within our space envelope Offset (0x0e), - } + Offset (0x12), + BTID, 8, // Battery index that host wants to read +} #if IS_ENABLED(CONFIG_EC_GOOGLE_CHROMEEC_ACPI_MEMMAP) OperationRegion (EMEM, EmbeddedControl, @@ -272,6 +274,11 @@ Device (EC0) { Store ("EC: BATTERY INFO", Debug) Notify (BAT0, 0x81) +#ifdef EC_ENABLE_SECOND_BATTERY_DEVICE + If (CondRefOf (BAT1)) { + Notify (BAT1, 0x81) + } +#endif } // Thermal Overload Event @@ -347,6 +354,11 @@ Device (EC0) { Store ("EC: BATTERY STATUS", Debug) Notify (BAT0, 0x80) +#ifdef EC_ENABLE_SECOND_BATTERY_DEVICE + If (CondRefOf (BAT1)) { + Notify (BAT1, 0x80) + } +#endif } // MKBP interrupt. -- cgit v1.2.3