summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoy Cho <joy.cho@hardkernel.com>2017-07-04 06:19:49 +0300
committerJoy Cho <joy.cho@hardkernel.com>2017-07-04 10:40:29 +0300
commitc8a96831514d383b6d51efcd4aa0398a33f63273 (patch)
tree2194717f2eee99f1b840ae84e184ae900dd408f1
parentf9a34305b098cf3e78d2e53f467668ba51881e91 (diff)
downloadu-boot-s905_6.0.1_v3.2.tar.xz
ODROID-C2: Add a command, 'showddrclk's905_6.0.1_v3.3s905_6.0.1_v3.2
This command parses the acs structure that contains the current DDR clock value and saves it in the env parameter, 'ddrclk'. Change-Id: I1739ed0c17d76fc0408d6c8eb4bbbafeed425867
-rw-r--r--common/Makefile1
-rw-r--r--common/cmd_ddrclk.c40
-rwxr-xr-xinclude/configs/odroidc2.h1
3 files changed, 42 insertions, 0 deletions
diff --git a/common/Makefile b/common/Makefile
index dd3cbcd2b0..54d14b2cb6 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -80,6 +80,7 @@ obj-$(CONFIG_CMD_BOOTSTAGE) += cmd_bootstage.o
obj-$(CONFIG_CMD_CACHE) += cmd_cache.o
obj-$(CONFIG_CMD_CBFS) += cmd_cbfs.o
obj-$(CONFIG_CMD_CLK) += cmd_clk.o
+obj-$(CONFIG_CMD_DDRCLK) += cmd_ddrclk.o
obj-$(CONFIG_CMD_CONSOLE) += cmd_console.o
obj-$(CONFIG_CMD_SARADC) += cmd_saradc.o
obj-$(CONFIG_CMD_CPLBINFO) += cmd_cplbinfo.o
diff --git a/common/cmd_ddrclk.c b/common/cmd_ddrclk.c
new file mode 100644
index 0000000000..e486249bd2
--- /dev/null
+++ b/common/cmd_ddrclk.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2017 Hardkernel Co,. Ltd
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <command.h>
+
+#define LOAD_ADDR 0x21000000
+#define ACS_OFFSET 0x55
+#define ACS_DDR_OFFSET 0xA
+
+static int do_ddrclk(cmd_tbl_t *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ int ddrclk = 0;
+ char str[128];
+
+ /* dump acs structure in BL area */
+ sprintf(str, "mmc read 0x%x 0x%x 0x1",
+ (unsigned int)LOAD_ADDR, (unsigned int)ACS_OFFSET);
+ run_command(str, 0);
+
+ /* get ddr frequency value of acs structure */
+ ddrclk = *(u16 *) (LOAD_ADDR + ACS_DDR_OFFSET);
+
+ /* set env ddrclk */
+ sprintf(str, "%d", ddrclk);
+ setenv("ddrclk", str);
+
+ return CMD_RET_SUCCESS;
+}
+
+#ifdef CONFIG_SYS_LONGHELP
+static char ddrclk_help_text[] =
+ "show current ddr clock";
+#endif
+
+U_BOOT_CMD(showddrclk, 1, 1, do_ddrclk, "show current ddr clock", ddrclk_help_text);
diff --git a/include/configs/odroidc2.h b/include/configs/odroidc2.h
index 887c58f78b..d4accd0dde 100755
--- a/include/configs/odroidc2.h
+++ b/include/configs/odroidc2.h
@@ -117,6 +117,7 @@
#define CONFIG_CMD_USB_MASS_STORAGE 1
#define CONFIG_CMD_FASTBOOT 1
#define CONFIG_CMD_INI 1
+#define CONFIG_CMD_DDRCLK 1
#if defined(CONFIG_CMD_USB_MASS_STORAGE)
#define CONFIG_USB_GADGET 1