Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@xxxxxxxxxxxx> --- commands/Kconfig | 7 +++++++ drivers/clk/clkdev.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 0 deletions(-) diff --git a/commands/Kconfig b/commands/Kconfig index 57c9b75..fe13f90 100644 --- a/commands/Kconfig +++ b/commands/Kconfig @@ -338,4 +338,11 @@ config CMD_I2C include i2c_probe, i2c_read and i2c_write commands to communicate on i2c bus. +config CMD_CLOCK_INFO + bool + depends on CLKDEV_LOOKUP + prompt "clock info command" + help + show list of registered clock + endmenu diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 717fea5..49d98df 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c @@ -11,6 +11,7 @@ */ #include <common.h> +#include <command.h> #include <linux/list.h> #include <errno.h> #include <linux/err.h> @@ -166,3 +167,35 @@ void clkdev_drop(struct clk_lookup *cl) kfree(cl); } EXPORT_SYMBOL(clkdev_drop); + +#ifdef CONFIG_CMD_CLOCK_INFO +static int do_clock_info(struct command *cmdtp, int argc, char *argv[]) +{ + struct clk_lookup *p; + + puts("Global clocks:\n"); + + list_for_each_entry(p, &clocks, node) + if (!p->dev_id) + printf("%s: %#wHz\n", p->con_id, clk_get_rate(p->clk)); + + puts("Device specific clocks:\n"); + + list_for_each_entry(p, &clocks, node) + if (p->dev_id) + printf("%s[%s]: %#wHz\n", p->con_id, p->dev_id, + clk_get_rate(p->clk)); + + return 0; +} + +static const __maybe_unused char cmd_clock_info_help[] = +"Print clocks info\n" +; + +BAREBOX_CMD_START(clock_info) + .cmd = do_clock_info, + .usage = "Clocks Info", + BAREBOX_CMD_HELP(cmd_clock_info_help) +BAREBOX_CMD_END +#endif -- 1.7.1 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox