1 // SPDX-License-Identifier: GPL-2.0+
3 * keystone2: commands for clocks
5 * (C) Copyright 2012-2014
6 * Texas Instruments Incorporated, <www.ti.com>
11 #include <asm/arch/hardware.h>
12 #include <asm/arch/clock.h>
13 #include <asm/arch/psc_defs.h>
15 struct pll_init_data cmd_pll_data = {
22 int do_pll_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
27 if (strncmp(argv[1], "pa", 2) == 0)
28 cmd_pll_data.pll = PASS_PLL;
29 #ifndef CONFIG_SOC_K2E
30 else if (strncmp(argv[1], "arm", 3) == 0)
31 cmd_pll_data.pll = TETRIS_PLL;
33 #ifdef CONFIG_SOC_K2HK
34 else if (strncmp(argv[1], "ddr3a", 5) == 0)
35 cmd_pll_data.pll = DDR3A_PLL;
36 else if (strncmp(argv[1], "ddr3b", 5) == 0)
37 cmd_pll_data.pll = DDR3B_PLL;
39 else if (strncmp(argv[1], "ddr3", 4) == 0)
40 cmd_pll_data.pll = DDR3_PLL;
45 cmd_pll_data.pll_m = dectoul(argv[2], NULL);
46 cmd_pll_data.pll_d = dectoul(argv[3], NULL);
47 cmd_pll_data.pll_od = dectoul(argv[4], NULL);
49 printf("Trying to set pll %d; mult %d; div %d; OD %d\n",
50 cmd_pll_data.pll, cmd_pll_data.pll_m,
51 cmd_pll_data.pll_d, cmd_pll_data.pll_od);
52 init_pll(&cmd_pll_data);
57 return cmd_usage(cmdtp);
61 pllset, 5, 0, do_pll_cmd,
62 "set pll multiplier and pre divider",
63 PLLSET_CMD_LIST " <mult> <div> <OD>\n"
66 int do_getclk_cmd(struct cmd_tbl *cmdtp, int flag, int argc,
73 goto getclk_cmd_usage;
75 clk = dectoul(argv[1], NULL);
77 freq = ks_clk_get_rate(clk);
79 printf("clock index [%d] - frequency %lu\n", clk, freq);
81 printf("clock index [%d] Not available\n", clk);
85 return cmd_usage(cmdtp);
89 getclk, 2, 0, do_getclk_cmd,
92 "The indexes for clocks:\n"
96 int do_psc_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
104 psc_module = dectoul(argv[1], NULL);
105 if (strcmp(argv[2], "en") == 0) {
106 res = psc_enable_module(psc_module);
107 printf("psc_enable_module(%d) - %s\n", psc_module,
108 (res) ? "ERROR" : "OK");
112 if (strcmp(argv[2], "di") == 0) {
113 res = psc_disable_module(psc_module);
114 printf("psc_disable_module(%d) - %s\n", psc_module,
115 (res) ? "ERROR" : "OK");
119 if (strcmp(argv[2], "domain") == 0) {
120 res = psc_disable_domain(psc_module);
121 printf("psc_disable_domain(%d) - %s\n", psc_module,
122 (res) ? "ERROR" : "OK");
127 return cmd_usage(cmdtp);
131 psc, 3, 0, do_psc_cmd,
132 "<enable/disable psc module os disable domain>",
133 "<mod/domain index> <en|di|domain>\n"
134 "Intended to control Power and Sleep Controller (PSC) domains and\n"
135 "modules. The module or domain index exectly corresponds to ones\n"
136 "listed in official TRM. For instance, to enable MSMC RAM clock\n"
137 "domain use command: psc 14 en.\n"