1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2013 Xilinx, Inc.
8 #if defined(CONFIG_DM) && defined(CONFIG_CLK)
10 #include <dm/device-internal.h>
13 int __weak soc_clk_dump(void)
15 #if defined(CONFIG_DM) && defined(CONFIG_CLK)
22 /* Device addresses start at 1 */
23 ret = uclass_get(UCLASS_CLK, &uc);
27 uclass_foreach_dev(dev, uc) {
28 memset(&clk, 0, sizeof(clk));
29 ret = device_probe(dev);
33 ret = clk_request(dev, &clk);
37 rate = clk_get_rate(&clk);
43 printf("%-30.30s : %lu Hz\n", dev->name, rate);
46 printf("%-30.30s : ? Hz\n", dev->name);
51 puts("Not implemented\n");
56 static int do_clk_dump(cmd_tbl_t *cmdtp, int flag, int argc,
63 printf("Clock dump error %d\n", ret);
64 ret = CMD_RET_FAILURE;
70 static cmd_tbl_t cmd_clk_sub[] = {
71 U_BOOT_CMD_MKENT(dump, 1, 1, do_clk_dump, "", ""),
74 static int do_clk(cmd_tbl_t *cmdtp, int flag, int argc,
82 /* Strip off leading 'clk' command argument */
86 c = find_cmd_tbl(argv[0], &cmd_clk_sub[0], ARRAY_SIZE(cmd_clk_sub));
89 return c->cmd(cmdtp, flag, argc, argv);
94 #ifdef CONFIG_SYS_LONGHELP
95 static char clk_help_text[] =
96 "dump - Print clock frequencies";
99 U_BOOT_CMD(clk, 2, 1, do_clk, "CLK sub-system", clk_help_text);