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 <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/185759
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Duncan Laurie 2014-02-10 16:25:33 -08:00 committed by chrome-internal-fetch
commit 287e893661
2 changed files with 38 additions and 10 deletions

View file

@ -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 ()
}
}

View file

@ -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)