2 * keystone2: commands for clocks
4 * (C) Copyright 2012-2014
5 * Texas Instruments Incorporated, <www.ti.com>
7 * SPDX-License-Identifier: GPL-2.0+
12 #include <asm/arch/hardware.h>
13 #include <asm/arch/clock.h>
14 #include <asm/arch/psc_defs.h>
16 struct pll_init_data cmd_pll_data = {
23 int do_pll_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
28 if (strncmp(argv[1], "pa", 2) == 0)
29 cmd_pll_data.pll = PASS_PLL;
30 else if (strncmp(argv[1], "arm", 3) == 0)
31 cmd_pll_data.pll = TETRIS_PLL;
32 else if (strncmp(argv[1], "ddr3a", 5) == 0)
33 cmd_pll_data.pll = DDR3A_PLL;
34 else if (strncmp(argv[1], "ddr3b", 5) == 0)
35 cmd_pll_data.pll = DDR3B_PLL;
39 cmd_pll_data.pll_m = simple_strtoul(argv[2], NULL, 10);
40 cmd_pll_data.pll_d = simple_strtoul(argv[3], NULL, 10);
41 cmd_pll_data.pll_od = simple_strtoul(argv[4], NULL, 10);
43 printf("Trying to set pll %d; mult %d; div %d; OD %d\n",
44 cmd_pll_data.pll, cmd_pll_data.pll_m,
45 cmd_pll_data.pll_d, cmd_pll_data.pll_od);
46 init_pll(&cmd_pll_data);
51 return cmd_usage(cmdtp);
55 pllset, 5, 0, do_pll_cmd,
56 "set pll multiplier and pre divider",
57 "<pa|arm|ddr3a|ddr3b> <mult> <div> <OD>\n"
60 int do_getclk_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
66 goto getclk_cmd_usage;
68 clk = simple_strtoul(argv[1], NULL, 10);
70 freq = clk_get_rate(clk);
71 printf("clock index [%d] - frequency %u\n", clk, freq);
75 return cmd_usage(cmdtp);
79 getclk, 2, 0, do_getclk_cmd,
82 "See the 'enum clk_e' in the k2hk clock.h for clk indexes\n"
85 int do_psc_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
93 psc_module = simple_strtoul(argv[1], NULL, 10);
94 if (strcmp(argv[2], "en") == 0) {
95 res = psc_enable_module(psc_module);
96 printf("psc_enable_module(%d) - %s\n", psc_module,
97 (res) ? "ERROR" : "OK");
101 if (strcmp(argv[2], "di") == 0) {
102 res = psc_disable_module(psc_module);
103 printf("psc_disable_module(%d) - %s\n", psc_module,
104 (res) ? "ERROR" : "OK");
108 if (strcmp(argv[2], "domain") == 0) {
109 res = psc_disable_domain(psc_module);
110 printf("psc_disable_domain(%d) - %s\n", psc_module,
111 (res) ? "ERROR" : "OK");
116 return cmd_usage(cmdtp);
120 psc, 3, 0, do_psc_cmd,
121 "<enable/disable psc module os disable domain>",
122 "<mod/domain index> <en|di|domain>\n"
123 "See the hardware.h for Power and Sleep Controller (PSC) Domains\n"