From 287e8936613a7a83281ff692b20383dacf7fcaf6 Mon Sep 17 00:00:00 2001 From: Duncan Laurie Date: Mon, 10 Feb 2014 16:25:33 -0800 Subject: [PATCH] baytrail: DPTF: implement charger current limit Now that the EC supports limiting charger current we can fill out the placeholder charger participant. The charger performance states table is moved to the mainboard dptf configuration so it can be tuned for the actual charger/battery in a device. The method to retrieve the number of performance states is implemented based on whether or not the device is connected to AC power. There may need to be a hook that issues a Notify to DPTF to have it re-execute this method if the AC power state changes, but I have not found it yet. The method to set charger current is implemented to find the control value in the charger performance states table and pass that value to the embedded controller. An init function is defined which will disable the charger current limit. BUG=chrome-os-partner:17279 BRANCH=baytrail TEST=build and boot on rambi, start DPTF and heat up device to see the charger current limited as expected. Change-Id: I531fa5903b9ef11573c31e96b7ecfe0a8a4d3c23 Signed-off-by: Duncan Laurie Reviewed-on: https://chromium-review.googlesource.com/185759 Reviewed-by: Aaron Durbin --- src/soc/intel/baytrail/acpi/dptf/charger.asl | 43 +++++++++++++++----- src/soc/intel/baytrail/acpi/dptf/dptf.asl | 5 +++ 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/soc/intel/baytrail/acpi/dptf/charger.asl b/src/soc/intel/baytrail/acpi/dptf/charger.asl index 7560f139be..7c7f62fb57 100644 --- a/src/soc/intel/baytrail/acpi/dptf/charger.asl +++ b/src/soc/intel/baytrail/acpi/dptf/charger.asl @@ -14,23 +14,46 @@ Device (TCHG) } } - Name (PPSS, Package () + /* Return charger performance states defined by mainboard */ + Method (PPSS) { - Package () { 0, 0, 0, 0, 0, 0x880, "mA", 0 }, /* 2.1A */ - Package () { 0, 0, 0, 0, 1, 0x800, "mA", 0 }, /* 2.0A */ - Package () { 0, 0, 0, 0, 2, 0x600, "mA", 0 }, /* 1.5A */ - Package () { 0, 0, 0, 0, 3, 0x400, "mA", 0 }, /* 1.0A */ - Package () { 0, 0, 0, 0, 4, 0x200, "mA", 0 }, /* 0.5A */ - Package () { 0, 0, 0, 0, 5, 0x000, "mA", 0 }, /* 0.0A */ - }) + Return (\_SB.CHPS) + } + /* Return maximum charger current limit */ Method (PPPC) { + /* Convert size of PPSS table to index */ + Store (SizeOf (\_SB.CHPS), Local0) + Decrement (Local0) + + /* Check if charging is disabled (AC removed) */ + If (LEqual (\PWRS, Zero)) { + /* Return last power state */ + Return (Local0) + } Else { + /* Return highest power state */ + Return (0) + } + Return (0) } - Method (SPPC, 1, Serialized) + /* Set charger current limit */ + Method (SPPC, 1) { - /* TODO: Tell EC to limit battery charging */ + /* Retrieve Control (index 4) for specified PPSS level */ + Store (DeRefOf (Index (DeRefOf (Index + (\_SB.CHPS, ToInteger (Arg0))), 4)), Local0) + + /* Pass Control value to EC to limit charging */ + \_SB.PCI0.LPCB.EC0.CHGS (Local0) + } + + /* Initialize charger participant */ + Method (INIT) + { + /* Disable charge limit */ + \_SB.PCI0.LPCB.EC0.CHGD () } } diff --git a/src/soc/intel/baytrail/acpi/dptf/dptf.asl b/src/soc/intel/baytrail/acpi/dptf/dptf.asl index a54478cd05..9ebfb8c9ce 100644 --- a/src/soc/intel/baytrail/acpi/dptf/dptf.asl +++ b/src/soc/intel/baytrail/acpi/dptf/dptf.asl @@ -36,6 +36,11 @@ Device (DPTF) If (LEqual (DeRefOf (Index (IDSP, 0)), Arg0)) { /* Initialize Thermal Devices */ ^TINI () + +#ifdef DPTF_ENABLE_CHARGER + /* Initialize Charger Device */ + ^TCHG.INIT () +#endif } Return (Arg3)