charger: isl9237: Disable learn mode unless explicitly enabled.

In some rare instances the learn bit gets inadvertently set in the
charger which disables charging.  Disable it in charger_set_mode unless
its been set intentionally.

Signed-off-by: Todd Broch <tbroch@chromium.org>

BRANCH=none
BUG=chrome-os-partner:51196
BUG=chrome-os-partner:54484
TEST=manual,
on Chell w/ charger attached and charging
- force learn on manually, see charging stop
i2cxfer w16 4 0x12 0x3c 0x1000
- wait a second, see charging restored

- check learn has been disabled
i2cxfer r16 4 0x12 0x3
0x0000

- set learn on explicitly
ectool chargecontrol off
- see charging remain disabled

- check learn has been enabled
i2cxfer r16 4 0x12 0x3
0x1000

ectool chargecontrol normal

Change-Id: I26f1e855dcad1aa41530d06555a9be7956fdf435
Reviewed-on: https://chromium-review.googlesource.com/353530
Commit-Ready: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
Todd Broch
2016-04-05 16:42:23 -07:00
committed by chrome-bot
parent 7b98fdc0b8
commit afaf93e3c7

View File

@@ -29,6 +29,8 @@
/* Console output macros */
#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args)
static int learn_mode;
/* Charger parameters */
static const struct charger_info isl9237_charger_info = {
.name = CHARGER_NAME,
@@ -172,8 +174,17 @@ int charger_get_status(int *status)
int charger_set_mode(int mode)
{
int rv = EC_SUCCESS;
/*
* See crosbug.com/p/51196. Always disable learn mode unless it was set
* explicitly.
*/
if (!learn_mode)
rv = charger_discharge_on_ac(0);
/* ISL9237 does not support inhibit mode setting. */
return EC_SUCCESS;
return rv;
}
int charger_get_current(int *current)
@@ -272,7 +283,10 @@ int charger_discharge_on_ac(int enable)
else
control1 &= ~ISL9237_C1_LEARN_MODE_ENABLE;
return raw_write16(ISL9237_REG_CONTROL1, control1);
rv = raw_write16(ISL9237_REG_CONTROL1, control1);
learn_mode = !rv && enable;
return rv;
}
/*****************************************************************************/