Blob Blame History Raw
From 6f617cf4eeb14eceecfac499c723753ab1dded54 Mon Sep 17 00:00:00 2001
From: Peter Robinson <pbrobinson@gmail.com>
Date: Sun, 4 Mar 2018 13:27:10 +0000
Subject: [PATCH] mx6cuboxi: add support for detecting Revision 1.5 SoMs

Solid Run have a rev 1.5 SoM with different a different WiFi/BT module and some
other changes. Their downstream commit 99e18b7f14 adds support for detecting
this new SoM revision. This adds that support and sets up the new
device tree naming that landed in the linux 4.16 kernel.

Tested on a Hummingboard2 Gate.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
---
 board/solidrun/mx6cuboxi/mx6cuboxi.c | 30 +++++++++++++++++++++++++++---
 include/configs/mx6cuboxi.h          | 12 ++++++------
 2 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c
index ee9e4f7c01..bea6275b78 100644
--- a/board/solidrun/mx6cuboxi/mx6cuboxi.c
+++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c
@@ -79,9 +79,11 @@ static iomux_v3_cfg_t const usdhc2_pads[] = {
 };
 
 static iomux_v3_cfg_t const hb_cbi_sense[] = {
-	/* These pins are for sensing if it is a CuBox-i or a HummingBoard */
-	IOMUX_PADS(PAD_KEY_ROW1__GPIO4_IO09  | MUX_PAD_CTRL(UART_PAD_CTRL)),
-	IOMUX_PADS(PAD_EIM_DA4__GPIO3_IO04   | MUX_PAD_CTRL(UART_PAD_CTRL)),
+	/* These pins are for sensing if it is a CuBox-i, HummingBoard(2) and SoM rev */
+	IOMUX_PADS(PAD_KEY_ROW1__GPIO4_IO09   | MUX_PAD_CTRL(UART_PAD_CTRL)),
+	IOMUX_PADS(PAD_EIM_DA4__GPIO3_IO04    | MUX_PAD_CTRL(UART_PAD_CTRL)),
+	IOMUX_PADS(PAD_CSI0_DAT14__GPIO6_IO00 | MUX_PAD_CTRL(UART_PAD_CTRL)),
+	IOMUX_PADS(PAD_CSI0_DAT18__GPIO6_IO04 | MUX_PAD_CTRL(UART_PAD_CTRL)),
 };
 
 static iomux_v3_cfg_t const usb_pads[] = {
@@ -390,6 +392,25 @@ static bool is_hummingboard2(void)
 		return false;
 }
 
+static bool is_som_rev15(void)
+{
+	int val1;
+	int val2;
+
+	SETUP_IOMUX_PADS(hb_cbi_sense);
+
+	gpio_direction_input(IMX_GPIO_NR(6, 0));
+	gpio_direction_input(IMX_GPIO_NR(6, 4));
+
+	val1 = gpio_get_value(IMX_GPIO_NR(6, 0));
+	val2 = gpio_get_value(IMX_GPIO_NR(6, 4));
+
+	if (val1 == 1 && val2 == 0)
+		return true;
+	else
+		return false;
+}
+
 int checkboard(void)
 {
 	if (is_hummingboard2())
@@ -412,6 +433,9 @@ int board_late_init(void)
 	else
 		env_set("board_name", "CUBOXI");
 
+	if (is_som_rev15())
+		env_set("som_rev", "-som-v15");
+
 	if (is_mx6dq())
 		env_set("board_rev", "MX6Q");
 	else
diff --git a/include/configs/mx6cuboxi.h b/include/configs/mx6cuboxi.h
index 0e1d18cad8..076fd2c40e 100644
--- a/include/configs/mx6cuboxi.h
+++ b/include/configs/mx6cuboxi.h
@@ -104,17 +104,17 @@
 		"fi\0" \
 	"findfdt="\
 		"if test $board_name = HUMMINGBOARD2 && test $board_rev = MX6Q ; then " \
-			"setenv fdtfile imx6q-hummingboard2.dtb; fi; " \
+			"setenv fdtfile imx6q-hummingboard2${som_rev}.dtb; fi; " \
 		"if test $board_name = HUMMINGBOARD2 && test $board_rev = MX6DL ; then " \
-			"setenv fdtfile imx6dl-hummingboard2.dtb; fi; " \
+			"setenv fdtfile imx6dl-hummingboard2${som_rev}.dtb; fi; " \
 		"if test $board_name = HUMMINGBOARD && test $board_rev = MX6Q ; then " \
-			"setenv fdtfile imx6q-hummingboard.dtb; fi; " \
+			"setenv fdtfile imx6q-hummingboard${som_rev}.dtb; fi; " \
 		"if test $board_name = HUMMINGBOARD && test $board_rev = MX6DL ; then " \
-			"setenv fdtfile imx6dl-hummingboard.dtb; fi; " \
+			"setenv fdtfile imx6dl-hummingboard${som_rev}.dtb; fi; " \
 		"if test $board_name = CUBOXI && test $board_rev = MX6Q ; then " \
-			"setenv fdtfile imx6q-cubox-i.dtb; fi; " \
+			"setenv fdtfile imx6q-cubox-i${som_rev}.dtb; fi; " \
 		"if test $board_name = CUBOXI && test $board_rev = MX6DL ; then " \
-			"setenv fdtfile imx6dl-cubox-i.dtb; fi; " \
+			"setenv fdtfile imx6dl-cubox-i${som_rev}.dtb; fi; " \
 		"if test $fdtfile = undefined; then " \
 			"echo WARNING: Could not determine dtb to use; fi; \0" \
 	BOOTENV
-- 
2.14.3