diff options
author | Furquan Shaikh <furquan@google.com> | 2019-04-15 13:17:32 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-05-09 16:05:37 -0700 |
commit | 28fc766751a6fd8919dc5b9a92e22c528790f282 (patch) | |
tree | 52091ef46629edda18db106a0537f18596e8ac21 /driver | |
parent | 71b346c3ef20fbb6b9ed7c84681a40876d0c7415 (diff) | |
download | chrome-ec-28fc766751a6fd8919dc5b9a92e22c528790f282.tar.gz |
bq25710: Add support for charger_dump command
This change adds a debug command to dump all readable charger
registers on bq25710.
BUG=None
BRANCH=None
TEST=Verified that charger_dump command works on EC console.
Change-Id: Ide4a39c6bb2a9410a3beb913aa6ebcb44919f844
Signed-off-by: Furquan Shaikh <furquan@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1566667
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/charger/bq25710.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/driver/charger/bq25710.c b/driver/charger/bq25710.c index 6ace672da3..1d89946401 100644 --- a/driver/charger/bq25710.c +++ b/driver/charger/bq25710.c @@ -443,3 +443,51 @@ error: return 0; } #endif /* CONFIG_CHARGE_RAMP_HW */ + +#ifdef CONFIG_CMD_CHARGER_DUMP +static int console_bq25710_dump_regs(int argc, char **argv) +{ + int i; + int val; + + /* Dump all readable registers on bq25710. */ + static const uint8_t regs[] = { + BQ25710_REG_CHARGE_OPTION_0, + BQ25710_REG_CHARGE_CURRENT, + BQ25710_REG_MAX_CHARGE_VOLTAGE, + BQ25710_REG_CHARGE_OPTION_1, + BQ25710_REG_CHARGE_OPTION_2, + BQ25710_REG_CHARGE_OPTION_3, + BQ25710_REG_PROCHOT_OPTION_0, + BQ25710_REG_PROCHOT_OPTION_1, + BQ25710_REG_ADC_OPTION, + BQ25710_REG_CHARGER_STATUS, + BQ25710_REG_PROCHOT_STATUS, + BQ25710_REG_IIN_DPM, + BQ25710_REG_ADC_VBUS_PSYS, + BQ25710_REG_ADC_IBAT, + BQ25710_REG_ADC_CMPIN_IIN, + BQ25710_REG_ADC_VSYS_VBAT, + BQ25710_REG_PROCHOT_OPTION_1, + BQ25710_REG_OTG_VOLTAGE, + BQ25710_REG_OTG_CURRENT, + BQ25710_REG_INPUT_VOLTAGE, + BQ25710_REG_MIN_SYSTEM_VOLTAGE, + BQ25710_REG_IIN_HOST, + BQ25710_REG_MANUFACTURER_ID, + BQ25710_REG_DEVICE_ADDRESS, + }; + + for (i = 0; i < ARRAY_SIZE(regs); ++i) { + if (raw_read16(regs[i], &val)) + continue; + ccprintf("BQ25710 REG 0x%02x: 0x%04x\n", regs[i], val); + } + + return 0; +} +DECLARE_CONSOLE_COMMAND(charger_dump, console_bq25710_dump_regs, + "", + "Dump all charger registers"); + +#endif /* CONFIG_CMD_CHARGER_DUMP */ |