diff options
author | Amit Arora <amit.arora@linaro.org> | 2010-11-30 13:55:50 +0530 |
---|---|---|
committer | Amit Arora <amit.arora@linaro.org> | 2010-11-30 13:55:50 +0530 |
commit | f4fb810d919be557220c48b3dfa7a1f5a0e7a8b4 (patch) | |
tree | 76d65fc8d69ce394a599ec7968410c7100119953 /clocks.c | |
parent | 51d1b9c9b9988ef7101f542c3a16de4df546c028 (diff) | |
download | powerdebug-f4fb810d919be557220c48b3dfa7a1f5a0e7a8b4.tar.gz |
Show parents, when given a clock name in dump mode
Diffstat (limited to 'clocks.c')
-rw-r--r-- | clocks.c | 84 |
1 files changed, 84 insertions, 0 deletions
@@ -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) { |