xref: /openbmc/u-boot/cmd/clk.c (revision af1b492d)
1 /*
2  * Copyright (C) 2013 Xilinx, Inc.
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 #include <common.h>
7 #include <command.h>
8 #include <clk.h>
9 
10 int __weak soc_clk_dump(void)
11 {
12 	puts("Not implemented\n");
13 	return 1;
14 }
15 
16 static int do_clk_dump(cmd_tbl_t *cmdtp, int flag, int argc,
17 		       char *const argv[])
18 {
19 	int ret;
20 
21 	ret = soc_clk_dump();
22 	if (ret < 0) {
23 		printf("Clock dump error %d\n", ret);
24 		ret = CMD_RET_FAILURE;
25 	}
26 
27 	return ret;
28 }
29 
30 static cmd_tbl_t cmd_clk_sub[] = {
31 	U_BOOT_CMD_MKENT(dump, 1, 1, do_clk_dump, "", ""),
32 };
33 
34 static int do_clk(cmd_tbl_t *cmdtp, int flag, int argc,
35 		  char *const argv[])
36 {
37 	cmd_tbl_t *c;
38 
39 	if (argc < 2)
40 		return CMD_RET_USAGE;
41 
42 	/* Strip off leading 'clk' command argument */
43 	argc--;
44 	argv++;
45 
46 	c = find_cmd_tbl(argv[0], &cmd_clk_sub[0], ARRAY_SIZE(cmd_clk_sub));
47 
48 	if (c)
49 		return c->cmd(cmdtp, flag, argc, argv);
50 	else
51 		return CMD_RET_USAGE;
52 }
53 
54 #ifdef CONFIG_SYS_LONGHELP
55 static char clk_help_text[] =
56 	"dump - Print clock frequencies";
57 #endif
58 
59 U_BOOT_CMD(clk, 2, 1, do_clk, "CLK sub-system", clk_help_text);
60