diff options
| author | Marek Vasut <[email protected]> | 2018-08-08 22:10:44 +0200 |
|---|---|---|
| committer | Simon Glass <[email protected]> | 2018-09-29 11:49:35 -0600 |
| commit | ff8eee0330a68ee3fbb3e15ed8e315043784869f (patch) | |
| tree | 35294432b19e1faad7148aa6d8c9276c79ba7fff /cmd | |
| parent | e6fd0181082a04e743a07ebd9f6fdd0e06dc1399 (diff) | |
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 <[email protected]>
Cc: Chin Liang See <[email protected]>
Cc: Dinh Nguyen <[email protected]>
Cc: Ley Foon Tan <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: Tom Rini <[email protected]>
Reviewed-by: Ley Foon Tan <[email protected]>
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/clk.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/cmd/clk.c b/cmd/clk.c index 73fb25092b3..fd4231589c5 100644 --- a/cmd/clk.c +++ b/cmd/clk.c @@ -5,11 +5,48 @@ #include <common.h> #include <command.h> #include <clk.h> +#if defined(CONFIG_DM) && defined(CONFIG_CLK) +#include <dm.h> +#include <dm/device-internal.h> +#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, |
