Merge "target: mdmfermium: fix for device serial number"
diff --git a/dev/gcdb/display/include/panel_hx8399a_1080p_video.h b/dev/gcdb/display/include/panel_hx8399a_1080p_video.h
index f2d828e..a7c4df0 100644
--- a/dev/gcdb/display/include/panel_hx8399a_1080p_video.h
+++ b/dev/gcdb/display/include/panel_hx8399a_1080p_video.h
@@ -66,6 +66,11 @@
 };
 
 static char hx8399a_1080p_video_on_cmd1[] = {
+	0x03, 0x00, 0x29, 0xC0,
+	0xBA, 0x63, 0x82, 0xFF,
+};
+
+static char hx8399a_1080p_video_on_cmd2[] = {
 	0x0D, 0x00, 0x29, 0xC0,
 	0xB1, 0x00, 0x74, 0x31,
 	0x31, 0x44, 0x09, 0x22,
@@ -73,14 +78,14 @@
 	0x6D, 0xFF, 0xFF, 0xFF,
 };
 
-static char hx8399a_1080p_video_on_cmd2[] = {
+static char hx8399a_1080p_video_on_cmd3[] = {
 	0x0B, 0x00, 0x29, 0xC0,
 	0xB2, 0x00, 0x80, 0x00,
 	0x7F, 0x05, 0x07, 0x23,
 	0x4D, 0x02, 0x02, 0xFF,
 };
 
-static char hx8399a_1080p_video_on_cmd3[] = {
+static char hx8399a_1080p_video_on_cmd4[] = {
 	0x29, 0x00, 0x29, 0xC0,
 	0xB4, 0x00, 0xFF, 0x00,
 	0x40, 0x00, 0x3E, 0x00,
@@ -95,12 +100,12 @@
 	0x44, 0xFF, 0xFF, 0xFF,
 };
 
-static char hx8399a_1080p_video_on_cmd4[] = {
+static char hx8399a_1080p_video_on_cmd5[] = {
 	0x02, 0x00, 0x29, 0xC0,
 	0xD2, 0x00, 0xFF, 0xFF,
 };
 
-static char hx8399a_1080p_video_on_cmd5[] = {
+static char hx8399a_1080p_video_on_cmd6[] = {
 	0x20, 0x00, 0x29, 0xC0,
 	0xD3, 0x00, 0x01, 0x00,
 	0x00, 0x00, 0x30, 0x00,
@@ -112,7 +117,7 @@
 	0x00, 0x00, 0x05, 0x08,
 };
 
-static char hx8399a_1080p_video_on_cmd6[] = {
+static char hx8399a_1080p_video_on_cmd7[] = {
 	0x21, 0x00, 0x29, 0xC0,
 	0xD5, 0x18, 0x18, 0x00,
 	0x00, 0x00, 0x00, 0x00,
@@ -125,7 +130,7 @@
 	0x32, 0xFF, 0xFF, 0xFF,
 };
 
-static char hx8399a_1080p_video_on_cmd7[] = {
+static char hx8399a_1080p_video_on_cmd8[] = {
 	0x21, 0x00, 0x29, 0xC0,
 	0xD6, 0x18, 0x18, 0x40,
 	0x40, 0x40, 0x40, 0x40,
@@ -138,7 +143,7 @@
 	0x32, 0xFF, 0xFF, 0xFF,
 };
 
-static char hx8399a_1080p_video_on_cmd8[] = {
+static char hx8399a_1080p_video_on_cmd9[] = {
 	0x31, 0x00, 0x29, 0xC0,
 	0xD8, 0x00, 0x00, 0x00,
 	0x00, 0x00, 0x00, 0x00,
@@ -155,17 +160,17 @@
 	0xBF, 0xFF, 0xFF, 0xFF,
 };
 
-static char hx8399a_1080p_video_on_cmd9[] = {
+static char hx8399a_1080p_video_on_cmd10[] = {
 	0x03, 0x00, 0x29, 0xC0,
 	0xB6, 0x34, 0x34, 0xFF,
 };
 
-static char hx8399a_1080p_video_on_cmd10[] = {
+static char hx8399a_1080p_video_on_cmd11[] = {
 	0x02, 0x00, 0x29, 0xC0,
 	0xCC, 0x08, 0xFF, 0xFF,
 };
 
-static char hx8399a_1080p_video_on_cmd11[] = {
+static char hx8399a_1080p_video_on_cmd12[] = {
 	0x2B, 0x00, 0x29, 0xC0,
 	0xE0, 0x01, 0x10, 0x15,
 	0x2B, 0x32, 0x3E, 0x22,
@@ -180,46 +185,47 @@
 	0x17, 0x06, 0x12, 0xFF,
 };
 
-static char hx8399a_1080p_video_on_cmd12[] = {
+static char hx8399a_1080p_video_on_cmd13[] = {
 	0x04, 0x00, 0x29, 0xC0,
 	0xBF, 0xCF, 0x00, 0x46,
 };
 
-static char hx8399a_1080p_video_on_cmd13[] = {
+static char hx8399a_1080p_video_on_cmd14[] = {
 	0x02, 0x00, 0x29, 0xC0,
 	0x36, 0xc0, 0xFF, 0xFF,
 };
 
-static char hx8399a_1080p_video_on_cmd14[] = {
+static char hx8399a_1080p_video_on_cmd15[] = {
 	0x02, 0x00, 0x29, 0xC0,
 	0x11, 0x00, 0xFF, 0xFF,
 };
 
-static char hx8399a_1080p_video_on_cmd15[] = {
+static char hx8399a_1080p_video_on_cmd16[] = {
 	0x02, 0x00, 0x29, 0xC0,
 	0x29, 0x00, 0xFF, 0xFF,
 };
 
 static struct mipi_dsi_cmd hx8399a_1080p_video_on_command[] = {
 	{0x8, hx8399a_1080p_video_on_cmd0, 0x00},
-	{0x14, hx8399a_1080p_video_on_cmd1, 0x00},
-	{0x10, hx8399a_1080p_video_on_cmd2, 0x00},
-	{0x30, hx8399a_1080p_video_on_cmd3, 0x00},
-	{0x8, hx8399a_1080p_video_on_cmd4, 0x00},
-	{0x24, hx8399a_1080p_video_on_cmd5, 0x00},
-	{0x28, hx8399a_1080p_video_on_cmd6, 0x00},
+	{0x8, hx8399a_1080p_video_on_cmd1, 0x00},
+	{0x14, hx8399a_1080p_video_on_cmd2, 0x00},
+	{0x10, hx8399a_1080p_video_on_cmd3, 0x00},
+	{0x30, hx8399a_1080p_video_on_cmd4, 0x00},
+	{0x8, hx8399a_1080p_video_on_cmd5, 0x00},
+	{0x24, hx8399a_1080p_video_on_cmd6, 0x00},
 	{0x28, hx8399a_1080p_video_on_cmd7, 0x00},
-	{0x38, hx8399a_1080p_video_on_cmd8, 0x00},
-	{0x8, hx8399a_1080p_video_on_cmd9, 0x00},
+	{0x28, hx8399a_1080p_video_on_cmd8, 0x00},
+	{0x38, hx8399a_1080p_video_on_cmd9, 0x00},
 	{0x8, hx8399a_1080p_video_on_cmd10, 0x00},
-	{0x30, hx8399a_1080p_video_on_cmd11, 0x00},
-	{0x8, hx8399a_1080p_video_on_cmd12, 0x00},
+	{0x8, hx8399a_1080p_video_on_cmd11, 0x00},
+	{0x30, hx8399a_1080p_video_on_cmd12, 0x00},
 	{0x8, hx8399a_1080p_video_on_cmd13, 0x00},
-	{0x8, hx8399a_1080p_video_on_cmd14, 0x78},
-	{0x8, hx8399a_1080p_video_on_cmd15, 0x0A}
+	{0x8, hx8399a_1080p_video_on_cmd14, 0x00},
+	{0x8, hx8399a_1080p_video_on_cmd15, 0x78},
+	{0x8, hx8399a_1080p_video_on_cmd16, 0x0A}
 };
 
-#define HX8399A_1080P_VIDEO_ON_COMMAND 16
+#define HX8399A_1080P_VIDEO_ON_COMMAND 17
 
 
 static char hx8399a_1080p_videooff_cmd0[] = {
diff --git a/dev/gcdb/display/include/panel_r69007_wqxga_cmd.h b/dev/gcdb/display/include/panel_r69007_wqxga_cmd.h
index ab68848..70a5225 100644
--- a/dev/gcdb/display/include/panel_r69007_wqxga_cmd.h
+++ b/dev/gcdb/display/include/panel_r69007_wqxga_cmd.h
@@ -378,4 +378,6 @@
 	1, 1, 4095, 100, 1, "PMIC_8941"
 };
 
+#define R69007_WQXGA_CMD_PANEL_ON_DELAY 60
+
 #endif /*_PANEL_R69007_WQXGA_CMD_H_*/
diff --git a/dev/pmic/pmi8994/pm_fg_adc_usr.c b/dev/pmic/pmi8994/pm_fg_adc_usr.c
index e7e01fc..e80faa0 100644
--- a/dev/pmic/pmi8994/pm_fg_adc_usr.c
+++ b/dev/pmic/pmi8994/pm_fg_adc_usr.c
@@ -1261,7 +1261,7 @@
 
   /* Applying gain calibration to the raw value*/
   // Twos_complement(VBAT_registerval) *39 * (1+ Twos_Complement(V_GAIN_registerval) * (.32/128))
-  *calibrated_vbat = (uint32)(((raw_vbat * (GAIN_LSB_DENOM + gain)))/GAIN_LSB_DENOM);
+  *calibrated_vbat = (uint32)((((raw_vbat + 2) * (GAIN_LSB_DENOM + gain)))/GAIN_LSB_DENOM);
 
   return errFlag;
 }
diff --git a/dev/qpnp_haptic/qpnp_haptic.c b/dev/qpnp_haptic/qpnp_haptic.c
index e1200a1..e472dff 100644
--- a/dev/qpnp_haptic/qpnp_haptic.c
+++ b/dev/qpnp_haptic/qpnp_haptic.c
@@ -32,7 +32,7 @@
 #include <target.h>
 #include <vibrator.h>
 
-#define HAPTIC_BASE (PMI_ADDR_BASE+ 0xC000)
+#define HAPTIC_BASE (PMI_SECOND_SLAVE_ADDR_BASE+ 0xC000)
 #define QPNP_HAP_EN_CTL_REG (HAPTIC_BASE + 0x46)
 #define QPNP_HAP_EN_CTL2_REG (HAPTIC_BASE + 0x48)
 #define QPNP_HAP_ACT_TYPE_REG (HAPTIC_BASE + 0x4C)
diff --git a/include/stdlib.h b/include/stdlib.h
index 4db77fa..22dcf4c 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2008 Travis Geiselbrecht
  *
- * Copyright (c) 2013, 2014 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013, 2014-2015 The Linux Foundation. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files
@@ -51,7 +51,7 @@
 
 /* allocate a buffer on the stack aligned and padded to the cpu's cache line size */
 #define STACKBUF_DMA_ALIGN(var, size) \
-	uint8_t __##var[(size) + CACHE_LINE]; uint8_t *var = (uint8_t *)(ROUNDUP((addr_t)__##var, CACHE_LINE))
+	uint8_t __##var[(size) + CACHE_LINE] __attribute__((aligned(CACHE_LINE))); uint8_t *var = (uint8_t *)(ROUNDUP((addr_t)__##var, CACHE_LINE))
 
 /* Macro to allocate buffer in both local & global space, the STACKBUF_DMA_ALIGN cannot
  * be used for global space.
diff --git a/platform/msm8952/include/platform/iomap.h b/platform/msm8952/include/platform/iomap.h
index 2bf5d7e..c135f3f 100644
--- a/platform/msm8952/include/platform/iomap.h
+++ b/platform/msm8952/include/platform/iomap.h
@@ -70,8 +70,12 @@
 
 #define CLK_CTL_BASE                       0x1800000
 
-#define PMI_SLAVE_ID 3
-#define PMI_ADDR_BASE (PMI_SLAVE_ID << 16)
+#define PMI_SLAVE_BASE           2
+#define PMI_FIRST_SLAVE_OFFSET   0
+#define PMI_SECOND_SLAVE_OFFSET  1
+
+#define PMI_FIRST_SLAVE_ADDR_BASE   (( PMI_SLAVE_BASE + PMI_FIRST_SLAVE_OFFSET ) << 16)
+#define PMI_SECOND_SLAVE_ADDR_BASE  (( PMI_SLAVE_BASE + PMI_SECOND_SLAVE_OFFSET) << 16)
 
 #define SPMI_BASE                          0x02000000
 #define SPMI_GENI_BASE                     (SPMI_BASE + 0xA000)
diff --git a/platform/msm8996/include/platform/iomap.h b/platform/msm8996/include/platform/iomap.h
index de4616b..265d7c7 100644
--- a/platform/msm8996/include/platform/iomap.h
+++ b/platform/msm8996/include/platform/iomap.h
@@ -85,6 +85,13 @@
 /* Clocks */
 #define CLK_CTL_BASE                0x300000
 
+#define PMI_SLAVE_BASE           2
+#define PMI_FIRST_SLAVE_OFFSET   0
+#define PMI_SECOND_SLAVE_OFFSET  1
+
+#define PMI_FIRST_SLAVE_ADDR_BASE   (( PMI_SLAVE_BASE + PMI_FIRST_SLAVE_OFFSET ) << 16)
+#define PMI_SECOND_SLAVE_ADDR_BASE  (( PMI_SLAVE_BASE + PMI_SECOND_SLAVE_OFFSET) << 16)
+
 /* GPLL */
 #define GPLL0_MODE                  (CLK_CTL_BASE + 0x0000)
 #define GPLL4_MODE                  (CLK_CTL_BASE + 0x77000)
diff --git a/platform/msm_shared/qusb2_phy.c b/platform/msm_shared/qusb2_phy.c
index ced1fea..c682727 100644
--- a/platform/msm_shared/qusb2_phy.c
+++ b/platform/msm_shared/qusb2_phy.c
@@ -96,19 +96,6 @@
 		writel(0x79, QUSB2PHY_PLL_USER_CTL1);
 		writel(0x21, QUSB2PHY_PLL_USER_CTL2);
 		writel(0x14, QUSB2PHY_PORT_TEST2);
-		/* TCSR register bit 0 indicates whether single ended clock
-		 * or differential clock configuration is enabled. Based on the
-		 * configuration set the PLL_TEST register.
-		 */
-#if TCSR_PHY_CLK_SCHEME_SEL
-		se_clock = readl(TCSR_PHY_CLK_SCHEME_SEL) & 0x1;
-#endif
-		/* By default consider differential clock configuration and if TCSR
-		 * register bit 0 is not set then use single ended setting
-		 */
-		if (se_clock)
-			writel(0x80, QUSB2PHY_PLL_TEST);
-
 		writel(0x9F, QUSB2PHY_PLL_AUTOPGM_CTL1);
 		writel(0x00, QUSB2PHY_PLL_PWR_CTL);
 	}
@@ -127,31 +114,47 @@
 		writel(0x85, QUSB2PHY_PORT_TUNE4);
 	}
 
-	/* Wait for tuning params to take effect right before re-enabling power*/
-	udelay(10);
-
 	/* Enable ULPI mode */
 	if (platform_is_msm8994())
 		writel(0x0,  QUSB2PHY_PORT_UTMI_CTRL2);
-	/* Enable PHY */
 	/* set CLAMP_N_EN and USB PHY is enabled*/
 	writel(0x22, QUSB2PHY_PORT_POWERDOWN);
-	mdelay(10);
+	udelay(150);
 
-#if GCC_RX2_USB2_CLKREF_EN
-	writel((readl(GCC_RX2_USB2_CLKREF_EN) | 0x1), GCC_RX2_USB2_CLKREF_EN);
-	dmb();
+	/* TCSR register bit 0 indicates whether single ended clock
+	 * or differential clock configuration is enabled. Based on the
+	 * configuration set the PLL_TEST register.
+	 */
+#if TCSR_PHY_CLK_SCHEME_SEL
+	se_clock = readl(TCSR_PHY_CLK_SCHEME_SEL) & 0x1;
 #endif
+	/* By default consider differential clock configuration and if TCSR
+	 * register bit 0 is not set then use single ended setting
+	 */
+	if (se_clock)
+	{
+		writel(0x80, QUSB2PHY_PLL_TEST);
+	}
+	else
+	{
+	/* turn the ref clock on for differential clocks */
+#if GCC_RX2_USB2_CLKREF_EN
+		writel((readl(GCC_RX2_USB2_CLKREF_EN) | 0x1), GCC_RX2_USB2_CLKREF_EN);
+		dmb();
+#endif
+	}
+	udelay(100);
 
 	/* Check PLL status */
 	while (!(readl(QUSB2PHY_PLL_STATUS) & QUSB2PHY_PLL_LOCK))
 	{
 		retry--;
-		udelay(100);
 		if (!retry)
 		{
 			dprintf(CRITICAL, "QUSB2PHY failed to lock: %d", readl(QUSB2PHY_PLL_STATUS));
 			break;
 		}
+		/* As per recommendation form hw team wait for 5 us before reading the status */
+		udelay(5);
 	}
 }
diff --git a/platform/msm_shared/rules.mk b/platform/msm_shared/rules.mk
index bffa003..b6647d8 100644
--- a/platform/msm_shared/rules.mk
+++ b/platform/msm_shared/rules.mk
@@ -558,7 +558,8 @@
 			$(LOCAL_DIR)/mipi_dsi.o \
 			$(LOCAL_DIR)/mipi_dsc.o \
 			$(LOCAL_DIR)/mipi_dsi_phy.o \
-			$(LOCAL_DIR)/mipi_dsi_autopll_thulium.o
+			$(LOCAL_DIR)/mipi_dsi_autopll_thulium.o \
+			$(LOCAL_DIR)/shutdown_detect.o
 endif
 
 ifeq ($(ENABLE_UFS_SUPPORT), 1)
diff --git a/platform/msm_shared/scm.c b/platform/msm_shared/scm.c
index ae381bc..055030b 100644
--- a/platform/msm_shared/scm.c
+++ b/platform/msm_shared/scm.c
@@ -56,9 +56,18 @@
 
 /* SCM interface as per ARM spec present? */
 bool scm_arm_support;
+static bool scm_initialized;
 
 bool is_scm_armv8_support()
 {
+#if !NO_SCM_V8_SUPPORT
+	if (!scm_initialized)
+	{
+		scm_init();
+		scm_initialized = true;
+	}
+#endif
+
 	return scm_arm_support;
 }
 
@@ -96,6 +105,9 @@
 {
 	int ret;
 
+	if (scm_initialized)
+		return;
+
 	ret = scm_arm_support_available(SCM_SVC_INFO, IS_CALL_AVAIL_CMD);
 
 	if (ret < 0)
@@ -308,7 +320,7 @@
 	secure_cfg.spare = 0;
 	scmcall_arg scm_arg = {0};
 
-	if(!scm_arm_support)
+	if(!is_scm_armv8_support())
 	{
 		ret = scm_call(SVC_MEMORY_PROTECTION, IOMMU_SECURE_CFG, &secure_cfg, sizeof(secure_cfg),
 					   NULL, 0);
@@ -348,7 +360,7 @@
 	 */
 	arch_clean_invalidate_cache_range((addr_t) *img_ptr, *img_len_ptr);
 
-	if (!scm_arm_support)
+	if (!is_scm_armv8_support())
 	{
 		ret = scm_call(SCM_SVC_SSD, SSD_ENCRYPT_ID, &cmd, sizeof(cmd), NULL, 0);
 	}
@@ -380,7 +392,7 @@
 	int ret;
 	img_req cmd;
 
-	if (scm_arm_support)
+	if (is_scm_armv8_support())
 	{
 		dprintf(INFO, "%s:SCM call is not supported\n",__func__);
 		return -1;
@@ -431,7 +443,7 @@
 
 	do
 	{
-		if (!scm_arm_support)
+		if (!is_scm_armv8_support())
 		{
 			ret = scm_call(SCM_SVC_SSD,
 					SSD_PARSE_MD_ID,
@@ -515,7 +527,7 @@
 			decrypt_req.frag_len  = *img_len_ptr;
 			decrypt_req.frag      = *img_ptr;
 
-			if (!scm_arm_support)
+			if (!is_scm_armv8_support())
 			{
 				ret = scm_call(SCM_SVC_SSD,
 						SSD_DECRYPT_IMG_FRAG_ID,
@@ -581,7 +593,7 @@
 
 	feature_req.feature_id = TZBSP_FVER_SSD;
 
-	if (!scm_arm_support)
+	if (!is_scm_armv8_support())
 	{
 		ret = scm_call(TZBSP_SVC_INFO,
 					   TZ_INFO_GET_FEATURE_ID,
@@ -616,7 +628,7 @@
 	scmcall_arg scm_arg = {0};
 	scmcall_ret scm_ret = {0};
 
-	if (!scm_arm_support)
+	if (!is_scm_armv8_support())
 	{
 		req.status_ptr = (uint32_t*)&rsp;
 		req.status_len = sizeof(rsp);
@@ -661,7 +673,7 @@
 
 	arch_clean_invalidate_cache_range((addr_t) img_ptr, img_len);
 
-	if (!scm_arm_support)
+	if (!is_scm_armv8_support())
 	{
 		ret = scm_call(SCM_SVC_SSD,
 				SSD_PROTECT_KEYSTORE_ID,
@@ -710,7 +722,7 @@
 	cmd_buf = (void *)&fuse_id;
 	cmd_len = sizeof(fuse_id);
 
-	if (!scm_arm_support)
+	if (!is_scm_armv8_support())
 	{
 		/*no response */
 		resp_buf = NULL;
@@ -750,7 +762,7 @@
 	cmd_buf = (void *)&fuse_id;
 	cmd_len = sizeof(fuse_id);
 
-	if (!scm_arm_support)
+	if (!is_scm_armv8_support())
 	{
 		/*response */
 		resp_len = sizeof(resp_buf);
@@ -802,7 +814,7 @@
 	req.partition_id = 0; /* kernel */
 	memcpy(req.digest, digest, sizeof(req.digest));
 
-	if (!scm_arm_support)
+	if (!is_scm_armv8_support())
 	{
 		svc_id = SCM_SVC_ES;
 		cmd_id = SCM_SAVE_PARTITION_HASH_ID;
@@ -846,7 +858,7 @@
 	req.out_buf_size = out_buf_size;
 	req.direction = direction;
 
-	if (!scm_arm_support)
+	if (!is_scm_armv8_support())
 	{
 		svc_id = SCM_SVC_MDTP;
 		cmd_id = SCM_MDTP_CIPHER_DIP;
@@ -902,7 +914,7 @@
 	req.row_data = row_data;
 	req.qfprom_api_status = qfprom_api_status;
 
-	if (!scm_arm_support)
+	if (!is_scm_armv8_support())
 	{
 		svc_id = SCM_SVC_FUSE;
 		cmd_id = SCM_QFPROM_READ_ROW_ID;
@@ -956,7 +968,7 @@
 		uint32_t chn_id;
 		}__PACKED switch_ce_chn_buf;
 
-	if (scm_arm_support)
+	if (is_scm_armv8_support())
 	{
 		dprintf(INFO, "%s:SCM call is not supported\n",__func__);
 		return 0;
@@ -982,7 +994,7 @@
 	int ret = 0;
 	scmcall_arg scm_arg = {0};
 
-	if (scm_arm_support) {
+	if (is_scm_armv8_support()) {
 		scm_arg.x0 = MAKE_SIP_SCM_CMD(SCM_SVC_PWR, SCM_IO_DISABLE_PMIC_ARBITER);
 		scm_arg.x1 = MAKE_SCM_ARGS(0x1);
 		scm_arg.x2 = 0;
@@ -994,7 +1006,7 @@
 
 	/* Retry with the SCM_IO_DISABLE_PMIC_ARBITER1 func ID if the above Func ID fails*/
 	if(ret) {
-		if (scm_arm_support) {
+		if (is_scm_armv8_support()) {
 			scm_arg.x0 = MAKE_SIP_SCM_CMD(SCM_SVC_PWR, SCM_IO_DISABLE_PMIC_ARBITER1);
 			scm_arg.x1 = MAKE_SCM_ARGS(0x1);
 			scm_arg.x2 = 0;
@@ -1035,7 +1047,7 @@
 	/* Response Buffer = Null as no response expected */
 	dprintf(INFO, "Jumping to kernel via monitor\n");
 
-	if (!scm_arm_support)
+	if (!is_scm_armv8_support())
 	{
 		/* Command Buffer */
 		cmd_buf = (void *)&param;
@@ -1067,7 +1079,7 @@
 	// Memory passed to TZ should be algined to cache line
 	BUF_DMA_ALIGN(rand_buf, uint32_t);
 
-	if (!scm_arm_support)
+	if (!is_scm_armv8_support())
 	{
 		data.out_buf     = (uint8_t*) rand_buf;
 		data.out_buf_size = r_len;
@@ -1123,7 +1135,7 @@
 	scmcall_arg scm_arg = {0};
 	scmcall_ret scm_ret = {0};
 
-	if (!scm_arm_support)
+	if (!is_scm_armv8_support())
 	{
 		cmd.config = ERR_FATAL_ENABLE;
 		cmd.spare = 0;
@@ -1234,7 +1246,7 @@
 	scmcall_arg scm_arg = {0};
 	scmcall_ret scm_ret = {0};
 
-	if (!scm_arm_support) {
+	if (!is_scm_armv8_support()) {
 		ret = scm_call(TZBSP_SVC_INFO, IS_SECURE_BOOT_ENABLED, NULL, 0, &resp, sizeof(resp));
 	} else {
 		scm_arg.x0 = MAKE_SIP_SCM_CMD(TZBSP_SVC_INFO, IS_SECURE_BOOT_ENABLED);
@@ -1266,7 +1278,7 @@
 	scmcall_arg scm_arg = {0};
 	scmcall_ret scm_ret = {0};
 
-	if (!scm_arm_support) {
+	if (!is_scm_armv8_support()) {
 		ret = scm_call_atomic(SCM_SVC_IO, SCM_IO_READ, address);
 	} else {
 		scm_arg.x0 = MAKE_SIP_SCM_CMD(SCM_SVC_IO, SCM_IO_READ);
@@ -1274,6 +1286,9 @@
 		scm_arg.x2 = address;
 		scm_arg.atomic = true;
 		ret = scm_call2(&scm_arg, &scm_ret);
+		/* Return the value read if the call is successful */
+		if (!ret)
+			ret = scm_ret.x1;
 	}
 	return ret;
 }
@@ -1284,7 +1299,7 @@
 	scmcall_arg scm_arg = {0};
 	scmcall_ret scm_ret = {0};
 
-	if (!scm_arm_support) {
+	if (!is_scm_armv8_support()) {
 		ret = scm_call_atomic2(SCM_SVC_IO, SCM_IO_WRITE, address, val);
 	} else {
 		scm_arg.x0 = MAKE_SIP_SCM_CMD(SCM_SVC_IO, SCM_IO_WRITE);
@@ -1303,7 +1318,7 @@
 	scmcall_arg scm_arg = {0};
 	scmcall_ret scm_ret = {0};
 
-	if (!scm_arm_support)
+	if (!is_scm_armv8_support())
 	{
 		ret = scm_call_atomic2(svc, cmd, arg1, arg2);
 	} else {
diff --git a/project/fsm9010.mk b/project/fsm9010.mk
index 7759f73..d3d0262 100644
--- a/project/fsm9010.mk
+++ b/project/fsm9010.mk
@@ -23,6 +23,7 @@
 #DEFINES += MMC_BOOT_BAM=1
 DEFINES += CRYPTO_BAM=1
 DEFINES += CRYPTO_REG_ACCESS=1
+DEFINES += NO_SCM_V8_SUPPORT=1
 
 #Disable thumb mode
 ENABLE_THUMB := false
diff --git a/project/msm8996.mk b/project/msm8996.mk
index 586922a..368dc99 100644
--- a/project/msm8996.mk
+++ b/project/msm8996.mk
@@ -48,9 +48,18 @@
 #Enable below flag to compile cmnlib64
 #DEFINES += ENABLE_CMNLIB64_LOADING=1
 
+ENABLE_HAP_VIB_SUPPORT := true
+
+#Enable the feature of long press power on
+DEFINES += LONG_PRESS_POWER_ON=1
+
 #Disable thumb mode
 ENABLE_THUMB := false
 
+ifeq ($(ENABLE_HAP_VIB_SUPPORT),true)
+DEFINES += PON_VIB_SUPPORT=1
+endif
+
 ifeq ($(ENABLE_GLINK_SUPPORT),1)
 DEFINES += GLINK_SUPPORT=1
 endif
diff --git a/target/mdm9640/init.c b/target/mdm9640/init.c
index 62d48ab..0b8cb1e 100644
--- a/target/mdm9640/init.c
+++ b/target/mdm9640/init.c
@@ -279,7 +279,7 @@
 			ret = 0;
 		}
 		else {
-			buflen = strlen("EXT4_CMDLINE") + sizeof(int) +1;
+			buflen = strlen(EXT4_CMDLINE) + sizeof(int) +1;
 			*buf = (char *)malloc(buflen);
 			if(!(*buf)) {
 				dprintf(CRITICAL,"Unable to allocate memory for boot params\n");
diff --git a/target/msm8952/init.c b/target/msm8952/init.c
index 41ff356..bc6f813 100644
--- a/target/msm8952/init.c
+++ b/target/msm8952/init.c
@@ -384,7 +384,7 @@
 	else
 		reset_type = PON_PSHOLD_HARD_RESET;
 
-	pm8x41_reset_configure(reset_type);
+	pm8994_reset_configure(reset_type);
 
 	ret = scm_halt_pmic_arbiter();
 	if (ret)
diff --git a/target/msm8952/oem_panel.c b/target/msm8952/oem_panel.c
index 30a56e9..5b2d59d 100644
--- a/target/msm8952/oem_panel.c
+++ b/target/msm8952/oem_panel.c
@@ -54,6 +54,7 @@
 #include "include/panel_nt35597_wqxga_dsc_video.h"
 #include "include/panel_nt35597_wqxga_dsc_cmd.h"
 #include "include/panel_hx8394d_720p_video.h"
+#include "include/panel_byd_1200p_video.h"
 
 /*---------------------------------------------------------------------------*/
 /* static panel selection variable                                           */
@@ -69,6 +70,7 @@
 	NT35597_WQXGA_DSC_VIDEO_PANEL,
 	NT35597_WQXGA_DSC_CMD_PANEL,
 	HX8394D_720P_VIDEO_PANEL,
+	BYD_1200P_VIDEO_PANEL,
 	UNKNOWN_PANEL
 };
 
@@ -91,6 +93,7 @@
 	{"nt35597_wqxga_dsc_video", NT35597_WQXGA_DSC_VIDEO_PANEL},
 	{"nt35597_wqxga_dsc_cmd", NT35597_WQXGA_DSC_CMD_PANEL},
 	{"hx8394d_720p_video", HX8394D_720P_VIDEO_PANEL},
+	{"byd_1200p_video", BYD_1200P_VIDEO_PANEL},
 };
 
 static uint32_t panel_id;
@@ -431,6 +434,33 @@
 				hx8394d_720p_video_timings, TIMING_SIZE);
 		pinfo->mipi.signature = HX8394D_720P_VIDEO_SIGNATURE;
 		break;
+	case BYD_1200P_VIDEO_PANEL:
+		panelstruct->paneldata    = &byd_1200p_video_panel_data;
+		panelstruct->paneldata->panel_with_enable_gpio = 1;
+		panelstruct->panelres     = &byd_1200p_video_panel_res;
+		panelstruct->color        = &byd_1200p_video_color;
+		panelstruct->videopanel   = &byd_1200p_video_video_panel;
+		panelstruct->commandpanel = &byd_1200p_video_command_panel;
+		panelstruct->state        = &byd_1200p_video_state;
+		panelstruct->laneconfig   = &byd_1200p_video_lane_config;
+		panelstruct->paneltiminginfo
+			= &byd_1200p_video_timing_info;
+		panelstruct->panelresetseq
+					 = &byd_1200p_video_panel_reset_seq;
+		panelstruct->backlightinfo = &byd_1200p_video_backlight;
+		pinfo->mipi.panel_on_cmds
+			= byd_1200p_video_on_command;
+		pinfo->mipi.num_of_panel_on_cmds
+			= BYD_1200P_VIDEO_ON_COMMAND;
+		pinfo->mipi.panel_off_cmds
+			= byd_1200p_video_off_command;
+		pinfo->mipi.num_of_panel_off_cmds
+			= BYD_1200P_VIDEO_OFF_COMMAND;
+		memcpy(phy_db->timing,
+			byd_1200p_video_timings, TIMING_SIZE);
+		pinfo->mipi.signature 	= BYD_1200P_VIDEO_SIGNATURE;
+		phy_db->regulator_mode = DSI_PHY_REGULATOR_LDO_MODE;
+		break;
 	case UNKNOWN_PANEL:
 	default:
 		memset(panelstruct, 0, sizeof(struct panel_struct));
@@ -461,6 +491,7 @@
 			struct mdss_dsi_phy_ctrl *phy_db)
 {
 	uint32_t hw_id = board_hardware_id();
+	uint32_t hw_subtype = board_hardware_subtype();
 	int32_t panel_override_id;
 	uint32_t target_id, plat_hw_ver_major;
 
@@ -496,6 +527,11 @@
 			panel_id = TRULY_1080P_VIDEO_PANEL;
 		break;
 	case HW_PLATFORM_QRD:
+		if (hw_subtype == HW_PLATFORM_SUBTYPE_POLARIS) {
+			panel_id = BYD_1200P_VIDEO_PANEL;
+			break;
+		}
+
 		target_id = board_target_id();
 		plat_hw_ver_major = ((target_id >> 16) & 0xFF);
 
diff --git a/target/msm8952/target_display.c b/target/msm8952/target_display.c
index 0598833..f3c3c32 100644
--- a/target/msm8952/target_display.c
+++ b/target/msm8952/target_display.c
@@ -354,10 +354,15 @@
 						struct msm_panel_info *pinfo)
 {
 	int ret = NO_ERROR;
+	uint32_t hw_id = board_hardware_id();
+	uint32_t hw_subtype = board_hardware_subtype();
 
 	if (platform_is_msm8956()) {
 		reset_gpio.pin_id = 25;
 		bkl_gpio.pin_id = 66;
+	} else if ((hw_id == HW_PLATFORM_QRD) &&
+		   (hw_subtype == HW_PLATFORM_SUBTYPE_POLARIS)) {
+		enable_gpio.pin_id = 19;
 	}
 
 	if (enable) {
diff --git a/target/msm8996/init.c b/target/msm8996/init.c
index a60a4dd..07295f1 100644
--- a/target/msm8996/init.c
+++ b/target/msm8996/init.c
@@ -66,6 +66,10 @@
 #include <shutdown_detect.h>
 #endif
 
+#if PON_VIB_SUPPORT
+#include <vibrator.h>
+#define VIBRATE_TIME 250
+#endif
 
 #define CE_INSTANCE             1
 #define CE_EE                   0
@@ -271,6 +275,7 @@
 	rpm_glink_init();
 
 	target_keystatus();
+
 #if defined(LONG_PRESS_POWER_ON) || defined(PON_VIB_SUPPORT)
 	switch(board_hardware_id())
 	{
@@ -278,6 +283,9 @@
 #if LONG_PRESS_POWER_ON
 			shutdown_detect();
 #endif
+#if PON_VIB_SUPPORT
+			vib_timed_turn_on(VIBRATE_TIME);
+#endif
 			break;
 	}
 #endif
diff --git a/target/msm8996/oem_panel.c b/target/msm8996/oem_panel.c
index 25ef683..b2896cd 100644
--- a/target/msm8996/oem_panel.c
+++ b/target/msm8996/oem_panel.c
@@ -97,8 +97,11 @@
 	if (panel_id == JDI_QHD_DUALDSI_CMD_PANEL) {
 		/* needs extra delay to avoid unexpected artifacts */
 		mdelay(JDI_QHD_DUALDSI_CMD_PANEL_ON_DELAY);
-
+	} else if (panel_id == R69007_WQXGA_CMD_PANEL) {
+		/* needs extra delay to avoid unexpected artifacts */
+		mdelay(R69007_WQXGA_CMD_PANEL_ON_DELAY);
 	}
+
 	return NO_ERROR;
 }
 
diff --git a/target/msm8996/rules.mk b/target/msm8996/rules.mk
index 6f06109..e59bfc2 100644
--- a/target/msm8996/rules.mk
+++ b/target/msm8996/rules.mk
@@ -31,6 +31,8 @@
 MODULES += \
 	dev/keys \
 	dev/pmic/pm8x41 \
+	dev/qpnp_haptic \
+	dev/vib \
 	dev/qpnp_wled \
 	dev/qpnp_led \
 	dev/gcdb/display \