aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clocks.c84
-rw-r--r--clocks.h2
-rw-r--r--output.c1
-rw-r--r--powerdebug.c27
-rw-r--r--powerdebug.h1
5 files changed, 110 insertions, 5 deletions
diff --git a/clocks.c b/clocks.c
index e20553e..5cdc8d5 100644
--- a/clocks.c
+++ b/clocks.c
@@ -232,6 +232,14 @@ void destroy_clocks_info_recur(struct clock_info *clock)
}
}
+void read_and_dump_clock_info_one(char *clk)
+{
+ printf("Clock Tree : (clock name = %s)\n", clk);
+ printf("**********\n");
+ read_clock_info(clk_dir_path);
+ dump_all_parents(clk);
+}
+
void read_and_dump_clock_info(int verbose)
{
(void)verbose;
@@ -357,6 +365,82 @@ void insert_children(struct clock_info **parent, struct clock_info *clk)
(*parent)->num_children++;
}
+void dump_parent(struct clock_info *clk)
+{
+ char *unit = "Hz";
+ double drate;
+ static char spaces[256];
+
+ if (clk && clk->parent)
+ dump_parent(clk->parent);
+
+ drate = (double)clk->rate;
+ if (drate > 1000 && drate < 1000000) {
+ unit = "KHz";
+ drate /= 1000;
+ }
+ if (drate > 1000000) {
+ unit = "MHz";
+ drate /= 1000000;
+ }
+ if (clk == clocks_info) {
+ strcpy(spaces, "");
+ printf("%s%s (flags:%d,usecount:%d,rate:%5.2f %s)\n", spaces,
+ clk->name, clk->flags, clk->usecount, drate, unit);
+ } else {
+ if (!(clk->parent == clocks_info))
+ strcat(spaces, " ");
+ printf("%s`- %s (flags:%d,usecount:%d,rate:%5.2f %s)\n", spaces,
+ clk->name, clk->flags, clk->usecount, drate, unit);
+ }
+}
+
+void dump_all_parents(char *clkarg)
+{
+ struct clock_info *clk;
+ char spaces[1024];
+
+ strcpy(spaces, "");
+
+ clk = find_clock(clocks_info, clkarg);
+
+ if (!clk)
+ printf("Clock NOT found!\n");
+ else {
+// while(clk && clk != clocks_info) {
+// printf("%s\n", clk->name);
+// strcat(spaces, " ");
+// clk = clk->parent;
+// printf("%s <-- ", spaces);
+// }
+// printf(" /\n");
+ dump_parent(clk);
+ }
+}
+
+struct clock_info *find_clock(struct clock_info *clk, char *clkarg)
+{
+ int i;
+ struct clock_info *ret = clk;
+
+ if (!strcmp(clk->name, clkarg))
+ return ret;
+
+ if (clk->children) {
+ for (i = 0; i < clk->num_children; i++) {
+ if (!strcmp(clk->children[i]->name, clkarg))
+ return clk->children[i];
+ }
+ for (i = 0; i < clk->num_children; i++) {
+ ret = find_clock(clk->children[i], clkarg);
+ if (ret)
+ return ret;
+ }
+ }
+
+ return NULL;
+}
+
void dump_clock_info(struct clock_info *clk, int level, int bmp)
{
diff --git a/clocks.h b/clocks.h
index f0bb7f9..b893efc 100644
--- a/clocks.h
+++ b/clocks.h
@@ -53,3 +53,5 @@ void add_clock_details_recur(struct clock_info *clk, int hrow, int selected);
void destroy_clocks_info(void);
void destroy_clocks_info_recur(struct clock_info *clock);
void collapse_all_subclocks(struct clock_info *clock);
+void dump_all_parents(char *clkarg);
+struct clock_info *find_clock(struct clock_info *clk, char *clkarg);
diff --git a/output.c b/output.c
index 419ae63..9d0d76c 100644
--- a/output.c
+++ b/output.c
@@ -22,6 +22,7 @@ void usage(char **argv)
printf(" -r, --regulator Show regulator information\n");
printf(" -s, --sensor Show sensor information\n");
printf(" -c, --clock Show clock information\n");
+ printf(" -p, --findparents Show all parents for a particular clock\n");
printf(" -t, --time Set ticktime in seconds (eg. 10.0)\n");
printf(" -d, --dump Dump information once (no refresh)\n");
printf(" -v, --verbose Verbose mode (use with -r and/or -s)\n");
diff --git a/powerdebug.c b/powerdebug.c
index 72faa02..439f8f2 100644
--- a/powerdebug.c
+++ b/powerdebug.c
@@ -216,8 +216,9 @@ int main(int argc, char **argv)
{
int c, i;
int firsttime[TOTAL_FEATURE_WINS];
- int enter_hit = 0;
- int regulators = 0, sensors = 0, clocks = 0, verbose = 0;
+ int enter_hit = 0, verbose = 0;
+ int regulators = 0, sensors = 0, clocks = 0, findparent = 0;
+ char clkarg[64];
for (i = 0; i < TOTAL_FEATURE_WINS; i++)
firsttime[i] = 1;
@@ -227,6 +228,7 @@ int main(int argc, char **argv)
* -r, --regulator : regulator
* -s, --sensor : sensors
* -c, --clock : clocks
+ * -p, --findparents : clockname whose parents have to be found
* -t, --time : ticktime
* -d, --dump : dump
* -v, --verbose : verbose
@@ -241,6 +243,7 @@ int main(int argc, char **argv)
{"regulator", 0, 0, 'r'},
{"sensor", 0, 0, 's'},
{"clock", 0, 0, 'c'},
+ {"findparents", 0, 0, 'p'},
{"time", 0, 0, 't'},
{"dump", 0, 0, 'd'},
{"verbose", 0, 0, 'v'},
@@ -249,7 +252,7 @@ int main(int argc, char **argv)
{0, 0, 0, 0}
};
- c = getopt_long(argc, argv, "rsct:dvVh", long_options, &optindex);
+ c = getopt_long(argc, argv, "rscp:t:dvVh", long_options, &optindex);
if (c == -1)
break;
@@ -266,6 +269,10 @@ int main(int argc, char **argv)
clocks = 1;
selectedwindow = CLOCK;
break;
+ case 'p':
+ findparent = 1;
+ strcpy(clkarg, optarg);
+ break;
case 't':
ticktime = strtod(optarg, NULL);
break;
@@ -296,6 +303,12 @@ int main(int argc, char **argv)
usage(argv);
}
+ if (findparent && (!clocks || !dump)) {
+ fprintf(stderr, "-p option passed without -c and -d."
+ " Exiting...\n");
+ usage(argv);
+ }
+
if (!dump)
selectedwindow = REGULATOR;
@@ -341,8 +354,12 @@ int main(int argc, char **argv)
highlighted_row = hrow;
enter_hit = 0;
}
- if (!ret && dump)
- read_and_dump_clock_info(verbose);
+ if (!ret && dump) {
+ if (findparent)
+ read_and_dump_clock_info_one(clkarg);
+ else
+ read_and_dump_clock_info(verbose);
+ }
}
if (selectedwindow == SENSOR) {
diff --git a/powerdebug.h b/powerdebug.h
index 75171b0..d07849d 100644
--- a/powerdebug.h
+++ b/powerdebug.h
@@ -56,6 +56,7 @@ extern void usage(char **argv);
extern void version(void);
extern void print_regulator_info(int verbose);
extern void read_and_dump_clock_info(int verbose);
+extern void read_and_dump_clock_info_one(char *clk);
extern void read_clock_info(char *clkpath);
extern struct clock_info *read_clock_info_recur(char *clkpath, int level,
struct clock_info *parent);