diff options
author | Amit Arora <amit.arora@linaro.org> | 2010-10-01 12:24:16 +0530 |
---|---|---|
committer | Amit Arora <amit.arora@linaro.org> | 2010-10-01 12:24:16 +0530 |
commit | 0e51272d811662f00dcc26cde17644b8c1196112 (patch) | |
tree | d7481720fc929438808af28288eafbd3afbd6169 | |
parent | 24ed7d119a6de5a915b50c78a9b1ff7f2f842b55 (diff) |
Add dump option support for displaying clock tree (from debugfs)
-rw-r--r-- | clocks.c | 104 | ||||
-rw-r--r-- | powerdebug.c | 22 | ||||
-rw-r--r-- | powerdebug.h | 2 |
3 files changed, 119 insertions, 9 deletions
@@ -171,3 +171,107 @@ int read_and_print_clock_one_level(int verbose, int hrow, int selected) hrow = -1; return hrow; } + +void dump_clock_info(int verbose) +{ + printf("Clock Tree :\n"); + printf("**********\n"); + printf("/\n"); + dump_clock_info_recur(verbose, clk_dir_path); +} + +void dump_clock_info_recur(int verbose, char *clkdirpath) +{ + int usecount = 0, flags = 0, rate = 0; + DIR *dir, *subdir; + char filename[PATH_MAX], devpath[PATH_MAX]; + struct dirent *item, *subitem; + char *clock, *clockp; + + sprintf(filename, "%s", clkdirpath); + + dir = opendir(filename); + if (!dir) + return; + + while ((item = readdir(dir))) { + int cnt = 0; + + /* skip hidden dirs except ".." */ + if (item->d_name[0] == '.' ) + continue; + + sprintf(devpath, "%s/%s", clkdirpath, item->d_name); + + subdir = opendir(devpath); + + if (!subdir) + continue; + + while ((subitem = readdir(subdir))) { + if (subitem->d_name[0] == '.') /* skip hidden +files */ + continue; + + sprintf(filename, "%s/%s", devpath, subitem->d_name); + + if (!strcmp(subitem->d_name, "flags")) + flags = get_int_from(filename); + + if (!strcmp(subitem->d_name, "rate")) + rate = get_int_from(filename); + + if (!strcmp(subitem->d_name, "usecount")) + usecount = get_int_from(filename); + } + + if (!usecount && !verbose) + continue; + + + clockp = strrchr(devpath, '/'); + if (clockp) + clockp++; + else + continue; + + clock = strchr(devpath, '/'); + if (clock) { + clock++; + clock = strchr(clock, '/'); + if (clock) + clock++; + } + + while (clock) { + clock = strchr(clock, '/'); + if (clock) + clock++; + else + break; + cnt ++; + } + + printf("|"); + if (cnt == 1) { + cnt --; + printf("-- "); + } else + printf(" "); + + + while (cnt) { + if (cnt == 2) + printf("|-"); + else if (cnt == 1) + printf("- "); + else + printf("| "); + cnt --; + } + + printf("%s <flags=0x%x:rate=%d:usecount=%d>\n", + clockp, flags, rate, usecount); + dump_clock_info_recur(verbose, devpath); + } +} diff --git a/powerdebug.c b/powerdebug.c index 043c0ce..87e60bc 100644 --- a/powerdebug.c +++ b/powerdebug.c @@ -347,17 +347,21 @@ int main(int argc, char **argv) print_regulator_info(verbose); } - if (clocks && !dump) { - int hrow; - + if (clocks) { if (firsttime) init_clock_details(); - row = create_clock_win(row, 100, &c_share);//giv big no.as of now - hrow = read_and_print_clock_info(verbose, - highlighted_row, - enter_hit); - highlighted_row = hrow; - enter_hit = 0; + if (!dump) { + int hrow; + + //giv big no. in second arg as of now + row = create_clock_win(row, 100, &c_share); + hrow = read_and_print_clock_info(verbose, + highlighted_row, + enter_hit); + highlighted_row = hrow; + enter_hit = 0; + } else + dump_clock_info(verbose); } if (sensors) { diff --git a/powerdebug.h b/powerdebug.h index 356308c..25c8787 100644 --- a/powerdebug.h +++ b/powerdebug.h @@ -56,6 +56,8 @@ extern int dump; extern void usage(char **argv); extern void version(void); extern void print_regulator_info(int verbose); +extern void dump_clock_info(int verbose); +extern void dump_clock_info_recur(int verbose, char *clkdirpath); extern int read_and_print_clock_info(int verbose, int hrow, int selected); extern int read_and_print_clock_one_level(int verbose, int hrow, int selected); extern void get_sensor_info(char *path, char *name, char *sensor, int verbose); |