mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-09 17:11:42 +00:00
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>
This commit is contained in:
@@ -55,6 +55,8 @@
|
||||
#define I2C_PORT_SLAVE 1
|
||||
#define CONFIG_ARBITRATE_I2C I2C_PORT_HOST
|
||||
|
||||
#define CONFIG_CMD_PMU
|
||||
|
||||
/* GPIO signal list */
|
||||
enum gpio_signal {
|
||||
/* Inputs with interrupt handlers are first for efficiency */
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user