summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoy Cho <joy.cho@hardkernel.com>2020-03-25 05:08:47 +0300
committerGerrit Code Review <gerrit@almond.hardkernel.com>2020-03-25 05:08:47 +0300
commit67ef0dba8e28d6934f6f83dc58db8b50bb961ce3 (patch)
tree434e84f879d9d37868d14a70d1cca94cac35d291
parent494e6776629e386051677ed03f7929f1442cde87 (diff)
parent5b7de5fdab48ca8e2520c3d6519a805e6f18aaae (diff)
downloadu-boot-67ef0dba8e28d6934f6f83dc58db8b50bb961ce3.tar.xz
Merge "odroid-goA: Add hw revision detection" into odroidgo2-v2017.09
-rw-r--r--board/rockchip/odroidgo2/odroidgo2.c8
-rw-r--r--cmd/Kconfig6
-rw-r--r--cmd/Makefile1
-rw-r--r--cmd/hwrev.c47
-rw-r--r--configs/odroidgo2_defconfig1
-rw-r--r--include/configs/odroidgo2.h6
6 files changed, 68 insertions, 1 deletions
diff --git a/board/rockchip/odroidgo2/odroidgo2.c b/board/rockchip/odroidgo2/odroidgo2.c
index 86dcffdc12..102a08b238 100644
--- a/board/rockchip/odroidgo2/odroidgo2.c
+++ b/board/rockchip/odroidgo2/odroidgo2.c
@@ -135,11 +135,19 @@ err:
odroid_wait_pwrkey();
}
+void board_check_hwrev(void)
+{
+ run_command("hwrev", 0);
+}
+
int rk_board_late_init(void)
{
/* turn on blue led */
board_alive_led();
+ /* check hw revision */
+ board_check_hwrev();
+
/* set uart2-m1 port as a default debug console */
board_debug_uart2m1();
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 0e0ee4a451..2d20e07a8a 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -1688,6 +1688,12 @@ config CMD_ODROID_TEST
help
This enables hw test functions for ODROID GO-Advanced board.
+config CMD_ODROID_HWREV
+ bool "hwrev command - check hw revision for go advanced"
+ depends on TARGET_ODROIDGO2
+ help
+ This enables hw revision check function for ODROID GO-Advanced board.
+
endmenu
endmenu
diff --git a/cmd/Makefile b/cmd/Makefile
index 92c55012a2..103fe2923d 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -173,6 +173,7 @@ obj-$(CONFIG_CMD_ODROID_CFGLOAD) += cfgload.o
obj-$(CONFIG_CMD_ODROID_ADC) += adc.o
obj-$(CONFIG_CMD_ODROID_BATTERY) += battery.o
obj-$(CONFIG_CMD_ODROID_TEST) += odroidtest.o
+obj-$(CONFIG_CMD_ODROID_HWREV) += hwrev.o
endif # !CONFIG_SPL_BUILD
diff --git a/cmd/hwrev.c b/cmd/hwrev.c
new file mode 100644
index 0000000000..e58c591be6
--- /dev/null
+++ b/cmd/hwrev.c
@@ -0,0 +1,47 @@
+/*
+ * (C) Copyright 2020 Hardkernel Co., Ltd
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include <common.h>
+#include <command.h>
+#include <adc.h>
+
+#define check_range(min,max,val) (val > 0 && val > min && val < max ? 1 : 0)
+
+int do_hwrev(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ unsigned int hwrev_adc;
+
+ if (adc_channel_single_shot("saradc", 0, &hwrev_adc)) {
+ printf("board hw rev failed\n");
+ return CMD_RET_FAILURE;
+ }
+
+ /* rev 1.1 */
+ if (check_range(898, 978, hwrev_adc)) {
+ env_set("hwrev", "v11");
+ env_set("dtb_name", "rk3326-odroidgo2-linux-v11.dtb");
+ }
+ /* rev 1.0 */
+ else if (check_range(816, 896, hwrev_adc)) {
+ env_set("hwrev", "v10");
+ env_set("dtb_name", "rk3326-odroidgo2-linux.dtb");
+ }
+ /* engineer samples */
+ else {
+ env_set("hwrev", "v00");
+ env_set("dtb_name", "rk3326-odroidgo2-linux.dtb");
+ }
+
+ debug("adc0 (hw rev) %d\n", hwrev_adc);
+
+ return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(
+ hwrev, 1, 1, do_hwrev,
+ "check hw revision of OGA",
+ ""
+);
diff --git a/configs/odroidgo2_defconfig b/configs/odroidgo2_defconfig
index 23fe842219..707ac14260 100644
--- a/configs/odroidgo2_defconfig
+++ b/configs/odroidgo2_defconfig
@@ -641,6 +641,7 @@ CONFIG_CMD_ODROID_ADC=y
CONFIG_CMD_ODROID_CFGLOAD=y
CONFIG_CMD_ODROID_BATTERY=y
CONFIG_CMD_ODROID_TEST=y
+CONFIG_CMD_ODROID_HWREV=y
#
# Partition Types
diff --git a/include/configs/odroidgo2.h b/include/configs/odroidgo2.h
index e4bd8c3281..962d3c92f5 100644
--- a/include/configs/odroidgo2.h
+++ b/include/configs/odroidgo2.h
@@ -84,7 +84,11 @@
"net.iframes=0 fbcon=rotate:3\0" \
"bootcmd=mmc dev 1; cfgload; run setbootargs;" \
"load mmc 1:1 0x02000000 Image; " \
- "load mmc 1:1 0x01f00000 rk3326-odroidgo2-linux.dtb; " \
+ "if test ${hwrev} = 'v11'; then " \
+ "load mmc 1:1 0x01f00000 rk3326-odroidgo2-linux-v11.dtb; " \
+ "else " \
+ "load mmc 1:1 0x01f00000 rk3326-odroidgo2-linux.dtb; " \
+ "fi; "\
"booti 0x02000000 - 0x01f00000\0"
#undef CONFIG_BOOTDELAY