chrome ec: Add support for limiting charger current

Update the ec_commands header (direct from EC source) and
add support for the new charger current limit interface
which will be used by DPTF.

Change-Id: Ia9a2a84b612a2982dbe996f07a856be6cd53ebdb
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/185758
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
(cherry picked from commit 1fcca2d75856ecefd3aeb1c551182aa76d649466)
Signed-off-by: Isaac Christensen <isaac.christensen@se-eng.com>
Reviewed-on: http://review.coreboot.org/6925
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@google.com>
This commit is contained in:
Duncan Laurie 2014-02-10 16:21:05 -08:00 committed by Isaac Christensen
parent 0c0efa7e50
commit e6b280e24b
2 changed files with 86 additions and 1 deletions

View File

@ -52,6 +52,7 @@ Device (EC0)
PATI, 8, // Programmable Auxiliary Trip Sensor ID PATI, 8, // Programmable Auxiliary Trip Sensor ID
PATT, 8, // Programmable Auxiliary Trip Threshold PATT, 8, // Programmable Auxiliary Trip Threshold
PATC, 8, // Programmable Auxiliary Trip Commit PATC, 8, // Programmable Auxiliary Trip Commit
CHGL, 8, // Charger Current Limit
} }
OperationRegion (EMEM, SystemIO, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE) OperationRegion (EMEM, SystemIO, EC_LPC_ADDR_MEMMAP, EC_MEMMAP_SIZE)
@ -380,7 +381,7 @@ Device (EC0)
/* /*
* Thermal Threshold Event * Thermal Threshold Event
*/ */
Method (_Q09, 0, NotSerialized) Method (_Q09, 0, NotSerialized)
{ {
If (Acquire (^PATM, 1000)) { If (Acquire (^PATM, 1000)) {
@ -404,6 +405,23 @@ Device (EC0)
Release (^PATM) Release (^PATM)
} }
/*
* Set Charger Current Limit
* Arg0 = Current Limit in 64mA steps
*/
Method (CHGS, 1, Serialized)
{
Store (ToInteger (Arg0), ^CHGL)
}
/*
* Disable Charger Current Limit
*/
Method (CHGD, 0, Serialized)
{
Store (0xFF, ^CHGL)
}
#include "ac.asl" #include "ac.asl"
#include "battery.asl" #include "battery.asl"
} }

View File

@ -249,6 +249,11 @@ enum host_event_code {
/* Suggest that the AP resume normal speed */ /* Suggest that the AP resume normal speed */
EC_HOST_EVENT_THROTTLE_STOP = 19, EC_HOST_EVENT_THROTTLE_STOP = 19,
/* Hang detect logic detected a hang and host event timeout expired */
EC_HOST_EVENT_HANG_DETECT = 20,
/* Hang detect logic detected a hang and warm rebooted the AP */
EC_HOST_EVENT_HANG_REBOOT = 21,
/* /*
* The high bit of the event mask is not used as a host event code. If * The high bit of the event mask is not used as a host event code. If
* it reads back as set, then the entire event mask should be * it reads back as set, then the entire event mask should be
@ -1707,6 +1712,60 @@ struct ec_response_i2c_passthru {
uint8_t data[]; /* Data read by messages concatenated here */ uint8_t data[]; /* Data read by messages concatenated here */
} __packed; } __packed;
/*****************************************************************************/
/* Power button hang detect */
#define EC_CMD_HANG_DETECT 0x9f
/* Reasons to start hang detection timer */
/* Power button pressed */
#define EC_HANG_START_ON_POWER_PRESS (1 << 0)
/* Lid closed */
#define EC_HANG_START_ON_LID_CLOSE (1 << 1)
/* Lid opened */
#define EC_HANG_START_ON_LID_OPEN (1 << 2)
/* Start of AP S3->S0 transition (booting or resuming from suspend) */
#define EC_HANG_START_ON_RESUME (1 << 3)
/* Reasons to cancel hang detection */
/* Power button released */
#define EC_HANG_STOP_ON_POWER_RELEASE (1 << 8)
/* Any host command from AP received */
#define EC_HANG_STOP_ON_HOST_COMMAND (1 << 9)
/* Stop on end of AP S0->S3 transition (suspending or shutting down) */
#define EC_HANG_STOP_ON_SUSPEND (1 << 10)
/*
* If this flag is set, all the other fields are ignored, and the hang detect
* timer is started. This provides the AP a way to start the hang timer
* without reconfiguring any of the other hang detect settings. Note that
* you must previously have configured the timeouts.
*/
#define EC_HANG_START_NOW (1 << 30)
/*
* If this flag is set, all the other fields are ignored (including
* EC_HANG_START_NOW). This provides the AP a way to stop the hang timer
* without reconfiguring any of the other hang detect settings.
*/
#define EC_HANG_STOP_NOW (1 << 31)
struct ec_params_hang_detect {
/* Flags; see EC_HANG_* */
uint32_t flags;
/* Timeout in msec before generating host event, if enabled */
uint16_t host_event_timeout_msec;
/* Timeout in msec before generating warm reboot, if enabled */
uint16_t warm_reboot_timeout_msec;
} __packed;
/*****************************************************************************/ /*****************************************************************************/
/* Debug commands for battery charging */ /* Debug commands for battery charging */
@ -1912,6 +1971,14 @@ struct ec_params_reboot_ec {
* write 0x1 to [0x07] -- disable threshold 1 * write 0x1 to [0x07] -- disable threshold 1
*/ */
/* DPTF battery charging current limit */
#define EC_ACPI_MEM_CHARGING_LIMIT 0x08
/* Charging limit is specified in 64 mA steps */
#define EC_ACPI_MEM_CHARGING_LIMIT_STEP_MA 64
/* Value to disable DPTF battery charging limit */
#define EC_ACPI_MEM_CHARGING_LIMIT_DISABLED 0xff
/* Current version of ACPI memory address space */ /* Current version of ACPI memory address space */
#define EC_ACPI_MEM_VERSION_CURRENT 1 #define EC_ACPI_MEM_VERSION_CURRENT 1