X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cmd%2Fclk.c;h=74ad8685002461bb431c13dc32e41ef61c976b77;hb=a5e609b982a004e009e8ee0aa6066785db425ac2;hp=73fb25092b32fa8589e7daf319acf6bb9b691460;hpb=83d290c56fab2d38cd1ab4c4cc7099559c1d5046;p=oweals%2Fu-boot.git diff --git a/cmd/clk.c b/cmd/clk.c index 73fb25092b..74ad868500 100644 --- a/cmd/clk.c +++ b/cmd/clk.c @@ -5,12 +5,72 @@ #include #include #include +#if defined(CONFIG_DM) && defined(CONFIG_CLK) +#include +#include +#include +#include +#include +#endif + +#if defined(CONFIG_DM) && defined(CONFIG_CLK) +static void show_clks(struct udevice *dev, int depth, int last_flag) +{ + int i, is_last; + struct udevice *child; + struct clk *clkp; + u32 rate; + + clkp = dev_get_clk_ptr(dev); + if (device_get_uclass_id(dev) == UCLASS_CLK && clkp) { + rate = clk_get_rate(clkp); + + printf(" %-12u %8d ", rate, clkp->enable_count); + + for (i = depth; i >= 0; i--) { + is_last = (last_flag >> i) & 1; + if (i) { + if (is_last) + printf(" "); + else + printf("| "); + } else { + if (is_last) + printf("`-- "); + else + printf("|-- "); + } + } + + printf("%s\n", dev->name); + } + + list_for_each_entry(child, &dev->child_head, sibling_node) { + is_last = list_is_last(&child->sibling_node, &dev->child_head); + show_clks(child, depth + 1, (last_flag << 1) | is_last); + } +} +int __weak soc_clk_dump(void) +{ + struct udevice *root; + + root = dm_root(); + if (root) { + printf(" Rate Usecnt Name\n"); + printf("------------------------------------------\n"); + show_clks(root, -1, 0); + } + + return 0; +} +#else int __weak soc_clk_dump(void) { puts("Not implemented\n"); return 1; } +#endif static int do_clk_dump(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])