From ac35e7a2052d39a927d739ca16f5a59f474e4534 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Mon, 23 May 2022 11:08:37 +0300 Subject: [PATCH] debugcc: add support for printing clocks from a single CC Add a way to print clocks related to a particular CC. Add -b option, which takes 'block' name: cam, disp, cpu, gpu, video. Pass "-b core" to limit debugcc to "core" (gcc) clocks. Signed-off-by: Dmitry Baryshkov --- debugcc.c | 39 ++++++++++++++++++++++++++++++--------- debugcc.h | 3 +++ 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/debugcc.c b/debugcc.c index 04e7956..07ca257 100644 --- a/debugcc.c +++ b/debugcc.c @@ -227,12 +227,26 @@ static const struct measure_clk *find_clock(const struct debugcc_platform *platf return NULL; } -static void list_clocks(const struct debugcc_platform *platform) +static bool clock_from_block(const struct measure_clk *clk, const char *block_name) +{ + return !block_name || + (!clk->leaf && !strcmp(block_name, CORE_CC_BLOCK)) || + (clk->leaf && clk->leaf->block_name && !strcmp(block_name, clk->leaf->block_name)); +} + +static void list_clocks_block(const struct debugcc_platform *platform, const char *block_name) { const struct measure_clk *clk; - for (clk = platform->clocks; clk->name; clk++) - printf("%s\n", clk->name); + for (clk = platform->clocks; clk->name; clk++) { + if (!clock_from_block(clk, block_name)) + continue; + + if (clk->leaf && clk->leaf->block_name) + printf("%-40s %s\n", clk->name, clk->leaf->block_name); + else + printf("%s\n", clk->name); + } } static int mmap_mux(int devmem, struct debug_mux *mux) @@ -279,8 +293,8 @@ static void usage(void) { const struct debugcc_platform **p; - fprintf(stderr, "debugcc <-p platform> <-a | -l | clk>\n"); - fprintf(stderr, "-debugcc <-a | -l | clk>\n"); + fprintf(stderr, "debugcc <-p platform> [-b blk] <-a | -l | clk>\n"); + fprintf(stderr, "-debugcc [-b blk] <-a | -l | clk>\n"); fprintf(stderr, "available platforms:"); for (p = platforms; *p; p++) @@ -296,15 +310,19 @@ int main(int argc, char **argv) const struct measure_clk *clk = NULL; bool do_list_clocks = false; bool all_clocks = false; + const char *block_name = NULL; int devmem; int opt; int ret; - while ((opt = getopt(argc, argv, "alp:")) != -1) { + while ((opt = getopt(argc, argv, "ab:lp:")) != -1) { switch (opt) { case 'a': all_clocks = true; break; + case 'b': + block_name = strdup(optarg); + break; case 'l': do_list_clocks = true; break; @@ -324,7 +342,7 @@ int main(int argc, char **argv) } if (do_list_clocks) { - list_clocks(platform); + list_clocks_block(platform, block_name); exit(0); } @@ -350,8 +368,11 @@ int main(int argc, char **argv) if (clk) { measure(clk); } else { - for (clk = platform->clocks; clk->name; clk++) - measure(clk); + for (clk = platform->clocks; clk->name; clk++) { + if (clock_from_block(clk, block_name)) { + measure(clk); + } + } } return 0; diff --git a/debugcc.h b/debugcc.h index 5a51efd..8f2ae4b 100644 --- a/debugcc.h +++ b/debugcc.h @@ -33,9 +33,12 @@ #define BIT(x) (1 << (x)) +#define CORE_CC_BLOCK "core" + struct debug_mux { unsigned long phys; void *base; + const char *block_name; size_t size; unsigned int enable_reg;