From: Marek Vasut Date: Wed, 8 Aug 2018 20:10:44 +0000 (+0200) Subject: cmd: clk: Add trivial implementation of clock dump for DM X-Git-Tag: v2018.11-rc1~2^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ff8eee0330a68ee3fbb3e15ed8e315043784869f;p=platform%2Fkernel%2Fu-boot.git cmd: clk: Add trivial implementation of clock dump for DM Add trivial implementation of the clk dump in case DM is enabled. This implementation just iterates over all the clock registered with the CLK uclass and prints their rate. Signed-off-by: Marek Vasut Cc: Chin Liang See Cc: Dinh Nguyen Cc: Ley Foon Tan Cc: Simon Glass Cc: Tom Rini Reviewed-by: Ley Foon Tan --- diff --git a/cmd/clk.c b/cmd/clk.c index 73fb250..fd42315 100644 --- a/cmd/clk.c +++ b/cmd/clk.c @@ -5,11 +5,48 @@ #include #include #include +#if defined(CONFIG_DM) && defined(CONFIG_CLK) +#include +#include +#endif int __weak soc_clk_dump(void) { +#if defined(CONFIG_DM) && defined(CONFIG_CLK) + struct udevice *dev; + struct uclass *uc; + struct clk clk; + int ret; + + /* Device addresses start at 1 */ + ret = uclass_get(UCLASS_CLK, &uc); + if (ret) + return ret; + + uclass_foreach_dev(dev, uc) { + memset(&clk, 0, sizeof(clk)); + ret = device_probe(dev); + if (ret) { + printf("%-30.30s : ? Hz\n", dev->name); + continue; + } + + ret = clk_request(dev, &clk); + if (ret) { + printf("%-30.30s : ? Hz\n", dev->name); + continue; + } + + printf("%-30.30s : %lu Hz\n", dev->name, clk_get_rate(&clk)); + + clk_free(&clk); + } + + return 0; +#else puts("Not implemented\n"); return 1; +#endif } static int do_clk_dump(cmd_tbl_t *cmdtp, int flag, int argc,