blob: afd30f3853428cf78268e6040d071855b8cd5581 [file] [log] [blame]
Vitaly Andrianov7bcf4d62014-04-04 13:16:53 -04001/*
2 * keystone2: commands for clocks
3 *
4 * (C) Copyright 2012-2014
5 * Texas Instruments Incorporated, <www.ti.com>
6 *
7 * SPDX-License-Identifier: GPL-2.0+
8 */
9
10#include <common.h>
11#include <command.h>
12#include <asm/arch/hardware.h>
13#include <asm/arch/clock.h>
14#include <asm/arch/psc_defs.h>
15
16struct pll_init_data cmd_pll_data = {
17 .pll = MAIN_PLL,
18 .pll_m = 16,
19 .pll_d = 1,
20 .pll_od = 2,
21};
22
23int do_pll_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
24{
25 if (argc != 5)
26 goto pll_cmd_usage;
27
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;
36 else
37 goto pll_cmd_usage;
38
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);
42
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);
47
48 return 0;
49
50pll_cmd_usage:
51 return cmd_usage(cmdtp);
52}
53
54U_BOOT_CMD(
55 pllset, 5, 0, do_pll_cmd,
56 "set pll multiplier and pre divider",
57 "<pa|arm|ddr3a|ddr3b> <mult> <div> <OD>\n"
58);
59
60int do_getclk_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
61{
62 unsigned int clk;
63 unsigned int freq;
64
65 if (argc != 2)
66 goto getclk_cmd_usage;
67
68 clk = simple_strtoul(argv[1], NULL, 10);
69
70 freq = clk_get_rate(clk);
71 printf("clock index [%d] - frequency %u\n", clk, freq);
72 return 0;
73
74getclk_cmd_usage:
75 return cmd_usage(cmdtp);
76}
77
78U_BOOT_CMD(
79 getclk, 2, 0, do_getclk_cmd,
80 "get clock rate",
81 "<clk index>\n"
82 "See the 'enum clk_e' in the k2hk clock.h for clk indexes\n"
83);
84
85int do_psc_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
86{
87 int psc_module;
88 int res;
89
90 if (argc != 3)
91 goto psc_cmd_usage;
92
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");
98 return 0;
99 }
100
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");
105 return 0;
106 }
107
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");
112 return 0;
113 }
114
115psc_cmd_usage:
116 return cmd_usage(cmdtp);
117}
118
119U_BOOT_CMD(
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"
124);