2008-03-14 12:03:43 +00:00
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <asm/arch/imx-regs.h>
|
2009-03-19 16:46:48 +00:00
|
|
|
#include <asm/arch/clock.h>
|
2008-03-14 12:03:43 +00:00
|
|
|
|
|
|
|
static int do_clko (cmd_tbl_t *cmdtp, int argc, char *argv[])
|
|
|
|
{
|
2009-03-19 16:46:48 +00:00
|
|
|
int opt, div = 0, src = -2, ret;
|
2008-03-14 12:03:43 +00:00
|
|
|
|
|
|
|
getopt_reset();
|
|
|
|
|
|
|
|
while((opt = getopt(argc, argv, "d:s:")) > 0) {
|
|
|
|
switch(opt) {
|
|
|
|
case 'd':
|
|
|
|
div = simple_strtoul(optarg, NULL, 0);
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
src = simple_strtoul(optarg, NULL, 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (div == 0 && src == -2) {
|
|
|
|
u_boot_cmd_usage(cmdtp);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (src == -1) {
|
2009-03-19 16:46:48 +00:00
|
|
|
imx_clko_set_src(-1);
|
2008-03-14 12:03:43 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-03-19 16:46:48 +00:00
|
|
|
if (src != -2)
|
|
|
|
imx_clko_set_src(src);
|
2008-03-14 12:03:43 +00:00
|
|
|
|
|
|
|
if (div != 0) {
|
2009-03-19 16:46:48 +00:00
|
|
|
ret = imx_clko_set_div(div);
|
|
|
|
if (ret != div)
|
|
|
|
printf("limited divider to %d\n", ret);
|
2008-03-14 12:03:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __maybe_unused char cmd_clko_help[] =
|
|
|
|
"Usage: clko [OPTION]...\n"
|
|
|
|
"Route different signals to the i.MX clko pin\n"
|
2009-03-19 16:46:48 +00:00
|
|
|
" -d <div> Divider\n"
|
2008-03-14 12:03:43 +00:00
|
|
|
" -s <source> Clock select. See Ref. Manual for valid sources. Use -1\n"
|
|
|
|
" for disabling clock output\n";
|
|
|
|
|
|
|
|
U_BOOT_CMD_START(clko)
|
|
|
|
.maxargs = CONFIG_MAXARGS,
|
|
|
|
.cmd = do_clko,
|
|
|
|
.usage = "Adjust CLKO setting",
|
|
|
|
U_BOOT_CMD_HELP(cmd_clko_help)
|
|
|
|
U_BOOT_CMD_END
|
|
|
|
|