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