mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-02 13:14:51 +00:00
Add host command to exit force idle charge state
Currently the only way to exit force idle state is to unplug AC power. Let's add a host command to do so. Signed-off-by: Vic Yang <victoryang@chromium.org> BUG=chrome-os-partner:9716 TEST=# ectool chargeforceidle 0 - Check nothing happened # ectool chargeforceidle 1 - Power LED blinking green. Check current = 0. # ectool chargeforceidle 0 - Power LED back to yellow. Check charging. Change-Id: Ia8f504b6cf9f42b7d57af3ce2d240f3b00a095f1 Reviewed-on: https://gerrit.chromium.org/gerrit/27768 Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Vic Yang <victoryang@chromium.org> Commit-Ready: Vic Yang <victoryang@chromium.org>
This commit is contained in:
@@ -519,6 +519,12 @@ static int enter_force_idle_mode(void)
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
static int exit_force_idle_mode(void)
|
||||
{
|
||||
state_machine_force_idle = 0;
|
||||
return EC_SUCCESS;
|
||||
}
|
||||
|
||||
/* Battery charging task */
|
||||
void charge_state_machine_task(void)
|
||||
{
|
||||
@@ -642,9 +648,19 @@ void charge_state_machine_task(void)
|
||||
|
||||
static int charge_command_force_idle(struct host_cmd_handler_args *args)
|
||||
{
|
||||
const struct ec_params_force_idle *p =
|
||||
(const struct ec_params_force_idle *)args->params;
|
||||
int rv;
|
||||
|
||||
if (system_is_locked())
|
||||
return EC_RES_ACCESS_DENIED;
|
||||
if (enter_force_idle_mode() != EC_SUCCESS)
|
||||
|
||||
if (p->enabled)
|
||||
rv = enter_force_idle_mode();
|
||||
else
|
||||
rv = exit_force_idle_mode();
|
||||
|
||||
if (rv != EC_SUCCESS)
|
||||
return EC_RES_ERROR;
|
||||
return EC_RES_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -863,6 +863,10 @@ struct ec_params_i2c_write {
|
||||
/* Force charge state machine to stop in idle mode */
|
||||
#define EC_CMD_CHARGE_FORCE_IDLE 0x96
|
||||
|
||||
struct ec_params_force_idle {
|
||||
uint8_t enabled;
|
||||
} __packed;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* System commands */
|
||||
|
||||
|
||||
@@ -1743,13 +1743,31 @@ int cmd_lcd_backlight(int argc, char *argv[])
|
||||
|
||||
int cmd_charge_force_idle(int argc, char *argv[])
|
||||
{
|
||||
int rv = ec_command(EC_CMD_CHARGE_FORCE_IDLE, 0, NULL, 0, NULL, 0);
|
||||
struct ec_params_force_idle p;
|
||||
int rv;
|
||||
char *e;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: %s <0|1>\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
p.enabled = strtol(argv[1], &e, 0);
|
||||
if (e && *e) {
|
||||
fprintf(stderr, "Bad value.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rv = ec_command(EC_CMD_CHARGE_FORCE_IDLE, 0, &p, sizeof(p), NULL, 0);
|
||||
if (rv < 0) {
|
||||
fprintf(stderr, "Is AC connected?\n");
|
||||
return rv;
|
||||
}
|
||||
|
||||
printf("Charge state machine force idle.\n");
|
||||
if (p.enabled)
|
||||
printf("Charge state machine force idle.\n");
|
||||
else
|
||||
printf("Charge state machine normal mode.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user