diff options
author | Simon Glass <sjg@chromium.org> | 2012-07-05 19:25:48 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-07-05 22:56:39 -0700 |
commit | 9284cec2fcbd76175ac2337c1f897840cc706488 (patch) | |
tree | 058eaa43f44f0f98e15b3d3f354042cbf2056d40 /common | |
parent | 10058960d7843fe625c7b6653ccd03522e2d69c0 (diff) | |
download | chrome-ec-9284cec2fcbd76175ac2337c1f897840cc706488.tar.gz |
snow: Add pmu command to print out pmu registers
This command is primarily useful for testing, since it repeatedly
hammers the i2c bus.
Enable the command on snow for now.
BUG=chrome-os-partner:10888
TEST=manual:
run 'pmu 100' on snow and see that it displays the correct output.
Change-Id: I36c15af195d17f67dff4c05559d1756693a65c19
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26829
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/pmu_tps65090.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/common/pmu_tps65090.c b/common/pmu_tps65090.c index e674da9ff4..3198e1eae4 100644 --- a/common/pmu_tps65090.c +++ b/common/pmu_tps65090.c @@ -10,6 +10,7 @@ #include "common.h" #include "i2c.h" #include "pmu_tpschrome.h" +#include "timer.h" #include "util.h" #define CPUTS(outstr) cputs(CC_CHARGER, outstr) @@ -151,3 +152,54 @@ void pmu_init(void) pmu_write(IRQ2MASK, 0xff); } + +#ifdef CONFIG_CMD_PMU +static int print_pmu_info(void) +{ + int reg, ret; + int value; + + for (reg = 0; reg < 0xc; reg++) { + ret = pmu_read(reg, &value); + if (ret) + return ret; + if (!reg) + ccputs("PMU: "); + + ccprintf("%02x ", value); + } + ccputs("\n"); + + return 0; +} + +static int command_pmu(int argc, char **argv) +{ + int repeat = 1; + int rv = 0; + int loop; + char *e; + + if (argc > 1) { + repeat = strtoi(argv[1], &e, 0); + if (*e) { + ccputs("Invalid repeat count\n"); + return EC_ERROR_INVAL; + } + } + + for (loop = 0; loop < repeat; loop++) { + rv = print_pmu_info(); + usleep(1000); + } + + if (rv) + ccprintf("Failed - error %d\n", rv); + + return rv ? EC_ERROR_UNKNOWN : EC_SUCCESS; +} +DECLARE_CONSOLE_COMMAND(pmu, command_pmu, + "<repeat_count>", + "Print PMU info", + NULL); +#endif |