Merge "dev: gcdb: update innolux 720p panel header"
diff --git a/include/target.h b/include/target.h
index 3986a97..c7c05db 100644
--- a/include/target.h
+++ b/include/target.h
@@ -73,5 +73,5 @@
 target_usb_iface_t * target_usb30_init();
 bool target_is_cdp_qvga();
 uint32_t target_hw_interposer();
-
+uint32_t target_override_pll();
 #endif
diff --git a/platform/fsm9900/rules.mk b/platform/fsm9900/rules.mk
index 23b1040..c21e460 100644
--- a/platform/fsm9900/rules.mk
+++ b/platform/fsm9900/rules.mk
@@ -14,6 +14,10 @@
 
 INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared/include
 
+# Disabling stack-protection for lk
+# as it's not yet supported by bootloader's libc
+CFLAGS += -fno-stack-protector
+
 DEVS += fbcon
 MODULES += dev/fbcon
 
diff --git a/platform/msm_shared/board.c b/platform/msm_shared/board.c
index 48baa8f..1f5267b 100644
--- a/platform/msm_shared/board.c
+++ b/platform/msm_shared/board.c
@@ -50,78 +50,92 @@
 	unsigned ret = 0;
 	unsigned format = 0;
 	uint8_t i;
+	uint16_t format_major = 0;
+	uint16_t format_minor = 0;
 
 	ret = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION,
 						   &format, sizeof(format), 0);
 	if (ret)
 		return;
 
-	if (format == 6)
+	/* Extract the major & minor version info,
+	 * Upper two bytes: major info
+	 * Lower two byets: minor info
+	 */
+	format_major = (format & 0xffff0000) >> 16;
+	format_minor = format & 0x0000ffff;
+
+	if (format_major == 0x0)
 	{
+		if (format_minor == 6)
+		{
 			board_info_len = sizeof(board_info_v6);
 
-		ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
-				&board_info_v6,
-				board_info_len);
-		if (ret)
-			return;
+			ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
+					&board_info_v6,
+					board_info_len);
+			if (ret)
+				return;
 
-		board.platform = board_info_v6.board_info_v3.msm_id;
-		board.platform_version = board_info_v6.board_info_v3.msm_version;
-		board.platform_hw = board_info_v6.board_info_v3.hw_platform;
-		board.platform_subtype = board_info_v6.platform_subtype;
-	}
-	else if (format == 7)
-	{
-		board_info_len = sizeof(board_info_v7);
+			board.platform = board_info_v6.board_info_v3.msm_id;
+			board.platform_version = board_info_v6.board_info_v3.msm_version;
+			board.platform_hw = board_info_v6.board_info_v3.hw_platform;
+			board.platform_subtype = board_info_v6.platform_subtype;
+		}
+		else if (format_minor == 7)
+		{
+			board_info_len = sizeof(board_info_v7);
 
-		ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
-				&board_info_v7,
-				board_info_len);
-		if (ret)
-			return;
+			ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
+					&board_info_v7,
+					board_info_len);
+			if (ret)
+				return;
 
-		board.platform = board_info_v7.board_info_v3.msm_id;
-		board.platform_version = board_info_v7.board_info_v3.msm_version;
-		board.platform_hw = board_info_v7.board_info_v3.hw_platform;
-		board.platform_subtype = board_info_v7.platform_subtype;
-		board.pmic_info[0].pmic_type = board_info_v7.pmic_type;
-		board.pmic_info[0].pmic_version = board_info_v7.pmic_version;
-	}
-	else if (format == 8 || format == 9)
-	{
-		board_info_len = sizeof(board_info_v8);
+			board.platform = board_info_v7.board_info_v3.msm_id;
+			board.platform_version = board_info_v7.board_info_v3.msm_version;
+			board.platform_hw = board_info_v7.board_info_v3.hw_platform;
+			board.platform_subtype = board_info_v7.platform_subtype;
+			board.pmic_info[0].pmic_type = board_info_v7.pmic_type;
+			board.pmic_info[0].pmic_version = board_info_v7.pmic_version;
+		}
+		else if (format_minor >= 8)
+		{
+			dprintf(INFO, "Minor socinfo format detected: %u.%u\n", format_major, format_minor);
 
-		ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
-				&board_info_v8,
-				board_info_len);
-		if (ret)
-			return;
+			board_info_len = sizeof(board_info_v8);
 
-		board.platform = board_info_v8.board_info_v3.msm_id;
-		board.platform_version = board_info_v8.board_info_v3.msm_version;
-		board.platform_hw = board_info_v8.board_info_v3.hw_platform;
-		board.platform_subtype = board_info_v8.platform_subtype;
+			ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
+					&board_info_v8,
+					board_info_len);
+			if (ret)
+				return;
 
-		/*
-		 * fill in board.target with variant_id information
-		 * bit no         |31  24 | 23   16            | 15   8             |7         0|
-		 * board.target = |subtype| plat_hw_ver major  | plat_hw_ver minor  |hw_platform|
-		 *
-		 */
-		board.target = (((board_info_v8.platform_subtype & 0xff) << 24) |
-					   (((board_info_v8.platform_version >> 16) & 0xff) << 16) |
-					   ((board_info_v8.platform_version & 0xff) << 8) |
-					   (board_info_v8.board_info_v3.hw_platform & 0xff));
+			board.platform = board_info_v8.board_info_v3.msm_id;
+			board.platform_version = board_info_v8.board_info_v3.msm_version;
+			board.platform_hw = board_info_v8.board_info_v3.hw_platform;
+			board.platform_subtype = board_info_v8.platform_subtype;
 
-		for (i = 0; i < SMEM_V8_SMEM_MAX_PMIC_DEVICES; i++) {
-			board.pmic_info[i].pmic_type = board_info_v8.pmic_info[i].pmic_type;
-			board.pmic_info[i].pmic_version = board_info_v8.pmic_info[i].pmic_version;
+			/*
+			 * fill in board.target with variant_id information
+			 * bit no         |31  24 | 23   16            | 15   8             |7         0|
+			 * board.target = |subtype| plat_hw_ver major  | plat_hw_ver minor  |hw_platform|
+			 *
+			 */
+			board.target = (((board_info_v8.platform_subtype & 0xff) << 24) |
+						   (((board_info_v8.platform_version >> 16) & 0xff) << 16) |
+						   ((board_info_v8.platform_version & 0xff) << 8) |
+						   (board_info_v8.board_info_v3.hw_platform & 0xff));
+
+			for (i = 0; i < SMEM_V8_SMEM_MAX_PMIC_DEVICES; i++) {
+				board.pmic_info[i].pmic_type = board_info_v8.pmic_info[i].pmic_type;
+				board.pmic_info[i].pmic_version = board_info_v8.pmic_info[i].pmic_version;
+			}
 		}
 	}
 	else
 	{
-		dprintf(CRITICAL, "Unsupported board info format\n");
+		dprintf(CRITICAL, "Unsupported board info format %u.%u\n", format_major, format_minor);
 		ASSERT(0);
 	}
 }
diff --git a/platform/msm_shared/include/qmp_phy.h b/platform/msm_shared/include/qmp_phy.h
index 7731576..7d4400e 100644
--- a/platform/msm_shared/include/qmp_phy.h
+++ b/platform/msm_shared/include/qmp_phy.h
@@ -31,6 +31,7 @@
 #include <platform/iomap.h>
 
 /* QMP register offsets */
+#define QSERDES_COM_PLL_VCOTAIL_EN           (PLATFORM_QMP_OFFSET + 0x004)
 #define QSERDES_COM_SYSCLK_EN_SEL_TXBAND     (PLATFORM_QMP_OFFSET + 0x48)
 #define QSERDES_COM_DEC_START1               (PLATFORM_QMP_OFFSET + 0xA4)
 #define QSERDES_COM_DEC_START2               (PLATFORM_QMP_OFFSET + 0x104)
diff --git a/platform/msm_shared/qmp_usb30_phy.c b/platform/msm_shared/qmp_usb30_phy.c
index d9ff39e..7b1d2c3 100644
--- a/platform/msm_shared/qmp_usb30_phy.c
+++ b/platform/msm_shared/qmp_usb30_phy.c
@@ -44,6 +44,11 @@
 #define QMP_PHY_MAX_TIMEOUT            1000
 #define PHYSTATUS                      BIT(6)
 
+__WEAK uint32_t target_override_pll()
+{
+	return 0;
+}
+
 /* USB3.0 QMP phy reset */
 void usb30_qmp_phy_reset(void)
 {
@@ -144,6 +149,10 @@
 
 	writel(0x01, QMP_PHY_BASE + PCIE_USB3_PHY_POWER_DOWN_CONTROL);
 	writel(0x08, QMP_PHY_BASE + QSERDES_COM_SYSCLK_EN_SEL_TXBAND);
+
+	if (target_override_pll())
+		writel(0xE1, QMP_PHY_BASE + QSERDES_COM_PLL_VCOTAIL_EN);
+
 	writel(0x82, QMP_PHY_BASE + QSERDES_COM_DEC_START1);
 	writel(0x03, QMP_PHY_BASE + QSERDES_COM_DEC_START2);
 	writel(0xD5, QMP_PHY_BASE + QSERDES_COM_DIV_FRAC_START1);
@@ -167,7 +176,10 @@
 
 	/* Calibration Settings */
 	writel(0x90, QMP_PHY_BASE + QSERDES_COM_RESETSM_CNTRL);
-	writel(0x05, QMP_PHY_BASE + QSERDES_COM_RESETSM_CNTRL2);
+	if (target_override_pll())
+		writel(0x07, QMP_PHY_BASE + QSERDES_COM_RESETSM_CNTRL2);
+	else
+		writel(0x05, QMP_PHY_BASE + QSERDES_COM_RESETSM_CNTRL2);
 
 	writel(0x20, QMP_PHY_BASE + QSERDES_COM_RES_CODE_START_SEG1);
 	writel(0x77, QMP_PHY_BASE + QSERDES_COM_RES_CODE_CAL_CSR);
diff --git a/target/mdm9635/init.c b/target/mdm9635/init.c
index c42aa1b..8de21ed 100644
--- a/target/mdm9635/init.c
+++ b/target/mdm9635/init.c
@@ -301,3 +301,8 @@
         phy_mux_configure_with_tcsr();
     }
 }
+
+uint32_t target_override_pll()
+{
+	return board_soc_version() == BOARD_SOC_VERSION2 ? 1 : 0;
+}