diff options
author | Aseda Aboagye <aaboagye@google.com> | 2018-04-17 15:55:21 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-04-18 02:08:11 -0700 |
commit | b107af470ec7d15d1931b943ef9fc902e57c27f9 (patch) | |
tree | 94dd8789ae978027e9a8e26f6b8fb5444b648fcb /driver | |
parent | 6f8c010eb587dd1f017ff369a6e645913205a3a7 (diff) | |
download | chrome-ec-b107af470ec7d15d1931b943ef9fc902e57c27f9.tar.gz |
isl923x: Add 'charger_dump' console command.
This commit adds an optional console command that will dump the contents
of the battery charger IC registers. Currently, the only chargers
supported are the BD9995x as well as the ISL923x.
BUG=None
BRANCH=None
TEST=Enable on meowth; Flash; Verify that the command works without any
issues.
Change-Id: I2221efe0ed6e0f6063c97547e0da2d775bf4da45
Signed-off-by: Aseda Aboagye <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1016004
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/charger/bd9995x.c | 7 | ||||
-rw-r--r-- | driver/charger/isl923x.c | 35 |
2 files changed, 39 insertions, 3 deletions
diff --git a/driver/charger/bd9995x.c b/driver/charger/bd9995x.c index 7cdbdc4893..4af7be9363 100644 --- a/driver/charger/bd9995x.c +++ b/driver/charger/bd9995x.c @@ -1284,8 +1284,7 @@ void usb_charger_task(void *u) /*** Console commands ***/ - -#ifdef CONFIG_CMD_CHARGER +#ifdef CONFIG_CMD_CHARGER_DUMP static int read_bat(uint8_t cmd) { int read = 0; @@ -1320,10 +1319,12 @@ static int console_bd9995x_dump_regs(int argc, char **argv) return 0; } -DECLARE_CONSOLE_COMMAND(bd9995x_dump, console_bd9995x_dump_regs, +DECLARE_CONSOLE_COMMAND(charger_dump, console_bd9995x_dump_regs, NULL, "Dump all charger registers"); +#endif /* CONFIG_CMD_CHARGER_DUMP */ +#ifdef CONFIG_CMD_CHARGER static int console_command_bd9995x(int argc, char **argv) { int rv, reg, data, val; diff --git a/driver/charger/isl923x.c b/driver/charger/isl923x.c index 97e540d62e..c52f4be6c7 100644 --- a/driver/charger/isl923x.c +++ b/driver/charger/isl923x.c @@ -662,3 +662,38 @@ DECLARE_CONSOLE_COMMAND(amonbmon, console_command_amon_bmon, #endif "Get charger AMON/BMON voltage diff, current"); #endif /* CONFIG_CMD_CHARGER_ADC_AMON_BMON */ + +#ifdef CONFIG_CMD_CHARGER_DUMP +static void dump_reg_range(int low, int high) +{ + int reg; + int regval; + int rv; + + for (reg = low; reg <= high; reg++) { + CPRINTF("[%Xh] = ", reg); + rv = i2c_read16(I2C_PORT_CHARGER, I2C_ADDR_CHARGER, reg, + ®val); + if (!rv) + CPRINTF("0x%04x\n", regval); + else + CPRINTF("ERR (%d)\n", rv); + cflush(); + } +} + +static int command_isl923x_dump(int argc, char **argv) +{ + dump_reg_range(0x14, 0x15); + dump_reg_range(0x38, 0x3F); + dump_reg_range(0x47, 0x4A); +#ifdef CONFIG_CHARGER_ISL9238 + dump_reg_range(0x4B, 0x4E); +#endif /* CONFIG_CHARGER_ISL9238 */ + dump_reg_range(0xFE, 0xFF); + + return EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(charger_dump, command_isl923x_dump, "", + "Dumps ISL923x registers"); +#endif /* CONFIG_CMD_CHARGER_DUMP */ |