From: Eric van Tassell <evt@evtM17x.(none)>
--- powerdebug.c | 53 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 8 deletions(-)
diff --git a/powerdebug.c b/powerdebug.c index 0f15b38..6fe4b19 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -28,6 +28,10 @@ #include "mainloop.h" #include "powerdebug.h" #include "utils.h" +#include "tree_mgr.h" + +struct tree_mgr *pwrdm; +struct tree_mgr *vdd;
void usage(void) { @@ -38,6 +42,8 @@ void usage(void) printf("powerdebug [ -r | -s | -c ]\n"); printf(" -r, --regulator Show regulator information\n"); printf(" -s, --sensor Show sensor information\n"); + printf(" -P, --pwrdm Show power domain information\n"); + printf(" -V, --vdd Show voltage domain information\n"); printf(" -c, --clock Show clock information\n"); printf(" -p, --findparents Show all parents for a particular" " clock\n"); @@ -45,7 +51,7 @@ void usage(void) printf(" -d, --dump Dump information once (no refresh)\n"); printf(" -v, --verbose Verbose mode (use with -r and/or" " -s)\n"); - printf(" -V, --version Show Version\n"); + printf(" -i, --version Show Version\n"); printf(" -h, --help Help\n"); }
@@ -58,13 +64,15 @@ void version() * Options: * -r, --regulator : regulators * -s, --sensor : sensors + * -P, --pwrdm : pwrdm + * -V, --vdd : vdd * -c, --clock : clocks * -g, --gpio : gpios * -p, --findparents : clockname whose parents have to be found * -t, --time : ticktime * -d, --dump : dump * -v, --verbose : verbose - * -V, --version : version + * -i, --version : version * -h, --help : help * no option / default : show usage! */ @@ -72,13 +80,15 @@ void version() static struct option long_options[] = { { "regulator", 0, 0, 'r' }, { "sensor", 0, 0, 's' }, + { "pwrdm", 0, 0, 'P' }, + { "vdd", 0, 0, 'V' }, { "clock", 0, 0, 'c' }, { "gpio", 0, 0, 'g' }, { "findparents", 1, 0, 'p' }, { "time", 1, 0, 't' }, { "dump", 0, 0, 'd' }, { "verbose", 0, 0, 'v' }, - { "version", 0, 0, 'V' }, + { "version", 0, 0, 'i' }, { "help", 0, 0, 'h' }, { 0, 0, 0, 0 } }; @@ -87,6 +97,8 @@ struct powerdebug_options { bool verbose; bool regulators; bool sensors; + bool pwrdms; + bool vdds; bool clocks; bool gpios; bool dump; @@ -106,7 +118,7 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) while (1) { int optindex = 0;
- c = getopt_long(argc, argv, "rscgp:t:dvVh", + c = getopt_long(argc, argv, "rsPcgp:t:dvVhi", long_options, &optindex); if (c == -1) break; @@ -120,6 +132,13 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) options->sensors = true; options->selectedwindow = SENSOR; break; + case 'P': + options->pwrdms = true; + options->selectedwindow = PWRDM; + case 'V': + options->vdds = true; + options->selectedwindow = VDD; + break; case 'c': options->clocks = true; options->selectedwindow = CLOCK; @@ -146,7 +165,7 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options) case 'v': options->verbose = true; break; - case 'V': + case 'i': version(); break; case '?': @@ -159,9 +178,11 @@ int getoptions(int argc, char *argv[], struct powerdebug_options *options)
/* No system specified to be dump, let's default to all */ if (!options->regulators && !options->clocks && + !options->pwrdms && !options->vdds && !options->sensors && !options->gpios) - options->regulators = options->clocks = - options->sensors = options->gpios = true; + options->regulators = options->clocks = options->sensors + = options->pwrdms = options->vdds = options->gpios + = true;
if (options->selectedwindow == -1) options->selectedwindow = CLOCK; @@ -180,6 +201,12 @@ static int powerdebug_dump(struct powerdebug_options *options) if (options->sensors) sensor_dump();
+ if (options->pwrdms) + tree_mgr_dump(pwrdm); + + if (options->vdds) + tree_mgr_dump(vdd); + if (options->gpios) gpio_dump();
@@ -247,12 +274,22 @@ int main(int argc, char **argv) printf("failed to initialize sensors\n"); options->sensors = false; } + pwrdm = tree_mgr_new(PWRDM, "\nPower Domain Information:\n*******\n\n"); + if (!pwrdm) { + printf("failed to initialize pwrdms\n"); + options->pwrdms = false; + } + + vdd = tree_mgr_new(VDD, "\nVoltage Domain Information:\n*********\n\n"); + if (!vdd) { + printf("failed to initialize vdds\n"); + options->vdds = false; + }
if (gpio_init()) { printf("failed to initialize gpios\n"); options->gpios = false; } - ret = options->dump ? powerdebug_dump(options) : powerdebug_display(options);