Merge "appsbl: qseecom_lk: Fix Double mutex acquire"
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 4911344..f21d9b4 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -92,6 +92,7 @@
 #include "secapp_loader.h"
 #include <menu_keys_detect.h>
 #include <display_menu.h>
+#include "fastboot_test.h"
 
 extern  bool target_use_signed_kernel(void);
 extern void platform_uninit(void);
@@ -192,6 +193,7 @@
 static char *target_boot_params = NULL;
 static bool boot_reason_alarm;
 static bool devinfo_present = true;
+bool boot_into_fastboot = false;
 
 /* Assuming unauthorized kernel image by default */
 static int auth_kernel_img = 0;
@@ -324,6 +326,11 @@
 
 #if VERIFIED_BOOT
 	cmdline_len += strlen(verified_state) + strlen(vbsn[boot_state].name);
+	if ((device.verity_mode != 0 ) && (device.verity_mode != 1))
+	{
+		dprintf(CRITICAL, "Devinfo paritition possibly corrupted!!!. Please erase devinfo partition to continue booting\n");
+		ASSERT(0);
+	}
 	cmdline_len += strlen(verity_mode) + strlen(vbvm[device.verity_mode].name);
 #endif
 
@@ -449,6 +456,11 @@
 		if(have_cmdline) --dst;
 		while ((*dst++ = *src++));
 
+		if ((device.verity_mode != 0 ) && (device.verity_mode != 1))
+		{
+			dprintf(CRITICAL, "Devinfo paritition possibly corrupted!!!. Please erase devinfo partition to continue booting\n");
+			ASSERT(0);
+		}
 		src = verity_mode;
 		if(have_cmdline) --dst;
 		while ((*dst++ = *src++));
@@ -1108,7 +1120,11 @@
 		device.is_unlocked,
 		device.is_tampered);
 
-	if(target_use_signed_kernel() && (!device.is_unlocked))
+	/* Change the condition a little bit to include the test framework support.
+	 * We would never reach this point if device is in fastboot mode, even if we did
+	 * that means we are in test mode, so execute kernel authentication part for the
+	 * tests */
+	if((target_use_signed_kernel() && (!device.is_unlocked)) || boot_into_fastboot)
 	{
 		offset = imagesize_actual;
 		if (check_aboot_addr_range_overlap((uint32_t)image_addr + offset, page_size))
@@ -1125,6 +1141,9 @@
 		}
 
 		verify_signed_bootimg((uint32_t)image_addr, imagesize_actual);
+		/* The purpose of our test is done here */
+		if (boot_into_fastboot && auth_kernel_img)
+			return 0;
 	} else {
 		second_actual  = ROUND_TO_PAGE(hdr->second_size,  page_mask);
 		#ifdef TZ_SAVE_KERNEL_HASH
@@ -3199,8 +3218,8 @@
 			return 0;
 		}
 
-		if ((header->width != fb_display->width) || (header->height != fb_display->height)) {
-			dprintf(CRITICAL, "Logo config doesn't match with fb config. Fall back default logo\n");
+		if ((header->width > fb_display->width) || (header->height > fb_display->height)) {
+			dprintf(CRITICAL, "Logo config greater than fb config. Fall back default logo\n");
 			return -1;
 		}
 
@@ -3286,8 +3305,8 @@
 			fbcon_extract_to_screen(header, (base + LOGO_IMG_HEADER_SIZE));
 		} else { /* 2 Raw BGR data */
 
-			if ((header->width != fb_display->width) || (header->height != fb_display->height)) {
-				dprintf(CRITICAL, "Logo config doesn't match with fb config. Fall back default logo\n");
+			if ((header->width > fb_display->width) || (header->height > fb_display->height)) {
+				dprintf(CRITICAL, "Logo config greater than fb config. Fall back default logo\n");
 				return -1;
 			}
 
@@ -3439,6 +3458,9 @@
 						{"oem disable-charger-screen", cmd_oem_disable_charger_screen},
 						{"oem off-mode-charge", cmd_oem_off_mode_charger},
 						{"oem select-display-panel", cmd_oem_select_display_panel},
+#if UNITTEST_FW_SUPPORT
+						{"oem run-tests", cmd_oem_runtests},
+#endif
 #endif
 						};
 
@@ -3492,7 +3514,6 @@
 void aboot_init(const struct app_descriptor *app)
 {
 	unsigned reboot_mode = 0;
-	bool boot_into_fastboot = false;
 
 	/* Setup page size information for nv storage */
 	if (target_is_emmc_boot())
diff --git a/app/aboot/fastboot_test.c b/app/aboot/fastboot_test.c
new file mode 100644
index 0000000..5cad0b5
--- /dev/null
+++ b/app/aboot/fastboot_test.c
@@ -0,0 +1,121 @@
+/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+#include <stdlib.h>
+#include <debug.h>
+#include "devinfo.h"
+#include "fastboot.h"
+#include "fastboot_test.h"
+#include <app/tests.h>
+#include <target.h>
+#include <boot_device.h>
+#if USE_RPMB_FOR_DEVINFO
+#include <rpmb.h>
+#endif
+/* main function that calls into the tests */
+
+extern void ramdump_table_map();
+extern void kauth_test();
+extern int ufs_get_boot_lun();
+extern int ufs_set_boot_lun(uint32_t bootlunid);
+extern int fastboot_init();
+
+void cmd_oem_runtests()
+{
+	dprintf(INFO, "Running LK tests ... \n");
+
+	// Test boot lun enable for UFS
+	if (!platform_boot_dev_isemmc())
+	{
+		int ret = 0;
+		uint32_t set_lun = 0x2, get_lun;
+		ret = ufs_set_boot_lun(set_lun);
+		if (ret == UFS_SUCCESS)
+		{
+			get_lun = ufs_get_boot_lun();
+			if (get_lun == set_lun)
+			{
+				dprintf(INFO, "UFS Boot LUN En TEST: [ PASS ]\n");
+				set_lun = 0x1; // default is 0x1 LUN A, revert back to 0x1
+				ret = ufs_set_boot_lun(set_lun);
+			}
+			else
+				dprintf(INFO, "UFS Boot LUN En TEST: [ FAIL ]\n");
+		}
+		else
+			dprintf(INFO, "UFS Boot LUN En TEST: [ FAIL ]\n");
+	}
+
+
+#if LPAE
+	ramdump_table_map();
+#endif
+
+#if USE_RPMB_FOR_DEVINFO
+	dprintf(INFO, "Running RPMB test case, please make sure RPMB key is provisioned ...\n");
+	struct device_info *write_info = memalign(PAGE_SIZE, 4096);
+	struct device_info *read_info = memalign(PAGE_SIZE, 4096);
+	if((read_device_info_rpmb((void*) read_info, PAGE_SIZE)) < 0)
+		dprintf(INFO, "RPMB READ TEST : [ FAIL ]\n");
+
+	write_info->is_unlocked = !read_info->is_unlocked;
+
+	if((write_device_info_rpmb((void*) write_info, PAGE_SIZE)) < 0)
+		dprintf(INFO, "RPMB WRITE TEST : [ FAIL ]\n");
+
+	if((read_device_info_rpmb((void*) read_info, PAGE_SIZE)) < 0)
+		dprintf(INFO, "RPMB READ TEST : [ FAIL ]\n");
+
+	if (read_info->is_unlocked == write_info->is_unlocked)
+		dprintf(INFO, "RPMB READ/WRITE TEST: [ PASS ]\n");
+	else
+		dprintf(INFO, "RPMB READ/WRITE TEST: [ FAIL ]\n");
+
+	free(read_info);
+	free(write_info);
+#endif
+
+#if VERIFIED_BOOT
+	if (!boot_linux_from_mmc())
+		dprintf(INFO, "Verifid Boot authentication test: [ PASS ]\n");
+	else
+		dprintf(INFO, "Verifid Boot authentication test: [ FAIL ]\n");
+
+	kauth_test();
+#endif
+
+	if (!thread_tests())
+		dprintf(INFO, "Thread Test: [ PASS ]\n");
+	else
+		dprintf(INFO, "Thread Test: [ FAIL ]\n");
+
+	printf_tests();
+
+	fastboot_okay("");
+}
diff --git a/app/aboot/fastboot_test.h b/app/aboot/fastboot_test.h
new file mode 100644
index 0000000..005bfa7
--- /dev/null
+++ b/app/aboot/fastboot_test.h
@@ -0,0 +1,36 @@
+/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of The Linux Foundation nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+#ifndef __FASTBOOT_TEST_H__
+#define __FASTBOOT_TEST_H__
+#include <sys/types.h>
+extern void ramdump_table_map();
+void cmd_oem_runtests();
+extern int boot_linux_from_mmc();
+#endif
diff --git a/app/aboot/rules.mk b/app/aboot/rules.mk
index 24bca43..09a5152 100644
--- a/app/aboot/rules.mk
+++ b/app/aboot/rules.mk
@@ -11,6 +11,11 @@
 	$(LOCAL_DIR)/fastboot.o \
 	$(LOCAL_DIR)/recovery.o
 
+ifeq ($(ENABLE_UNITTEST_FW), 1)
+OBJS += \
+	$(LOCAL_DIR)/fastboot_test.o
+endif
+
 ifeq ($(ENABLE_MDTP_SUPPORT),1)
 OBJS += \
 	$(LOCAL_DIR)/mdtp.o \
diff --git a/app/mmutest/mmu_test.c b/app/mmutest/mmu_test.c
index 849a9e6..27ed628 100644
--- a/app/mmutest/mmu_test.c
+++ b/app/mmutest/mmu_test.c
@@ -29,6 +29,7 @@
 #include <sys/types.h>
 #include <debug.h>
 #include <arch/arm/mmu.h>
+#include <arch/ops.h>
 #include <mmu.h>
 #include <string.h>
 #include <smem.h>
diff --git a/app/mmutest/rules.mk b/app/mmutest/rules.mk
index 78918a1..5094f65 100644
--- a/app/mmutest/rules.mk
+++ b/app/mmutest/rules.mk
@@ -1,6 +1,6 @@
 LOCAL_DIR := $(GET_LOCAL_DIR)
 
-INCLUDES += -I$(LK_TOP_DIR)/platform/msm_shared/include
+INCLUDES += -I$(LOCAL_DIR)/include  -I$(LK_TOP_DIR)/platform/msm_shared/include
 
 OBJS += \
 	$(LOCAL_DIR)/mmu_test.o
diff --git a/app/rules.mk b/app/rules.mk
index e564fe0..0c06ce6 100644
--- a/app/rules.mk
+++ b/app/rules.mk
@@ -3,6 +3,11 @@
 MODULES += \
 	lib/openssl
 
+ifeq ($(ENABLE_UNITTEST_FW), 1)
+MODULES += \
+	app/tests
+endif
+
 OBJS += \
 	$(LOCAL_DIR)/app.o
 
diff --git a/app/tests/adc_tests.c b/app/tests/adc_tests.c
deleted file mode 100644
index 5f2d511..0000000
--- a/app/tests/adc_tests.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation, Inc. nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <pm8x41_adc.h>
-#include <debug.h>
-
-void adc_test()
-{
-	uint32_t vadc_chan1;
-	uint32_t vadc_chan2;
-	uint16_t iusb = 3250000;
-	uint16_t ibat = 2500000;
-	uint16_t batt_id_chan = 49;
-	uint16_t vbat_sns_chan = 6;
-
-	/*
-	 * TEST: Read the voltage on batt_id & vbat_sns channels
-	 */
-	vadc_chan1 = pm8x41_adc_channel_read(batt_id_chan);
-	dprintf(INFO, "The channel [%ud] voltage is :%ud\n",batt_id_chan, vadc_chan1);
-
-	vadc_chan2 = pm8x41_adc_channel_read(vbat_sns_chan);
-	dprintf(INFO, "The channel [%ud] voltage is :%ud\n",vbat_sns_chan, vadc_chan2);
-
-	/*
-	 * TEST: Set the IUSB & IBAT max values
-	 */
-
-	if (!pm8x41_iusb_max_config(iusb))
-		dprintf(INFO, "Iusb max current is set\n");
-
-	if (!pm8x41_ibat_max_config(ibat))
-		dprintf(INFO, "Ibat max current is set\n");
-
-}
diff --git a/app/tests/led_tests.c b/app/tests/led_tests.c
deleted file mode 100644
index 11ef9f2..0000000
--- a/app/tests/led_tests.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2011, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *     * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include<dev/pm8921_leds.h>
-#include<dev/pm8921.h>
-
-void led_tests()
-{
-uint32_t duty_us, period_us;
-
-    /* 50% Duty cycle */
-    duty_us = 500000;
-    period_us = 1000000;
-
-    /* Configure PM8921_ID_LED_0 from PWM2*/
-    pm8921_config_led_current(PM8921_ID_LED_0, 2, PWM2, 1);
-
-    /* PWM2 for PM8921_ID_LED_0 is LPG 5
-     * Configure and enable lpg5
-     */
-    pm_set_pwm_config(5, duty_us, period_us, &pmic);
-    pm_pwm_channel_enable(5, &pmic);
-
-    /* Configure and enable lpg0 for  panel backlight*/
-    pm_set_pwm_config(0, duty_us, period_us, &pmic);
-    pm_pwm_channel_enable(0, &pmic);
-
-    mdelay(10000);
-
-    /* Configure PM8921_ID_LED_1 also from PWM2*/
-    pm8921_config_led_current(PM8921_ID_LED_1, 2, PWM2, 1);
-    mdelay(10000);
-
-    /* Disable PM8921_ID_LED_0 */
-    pm8921_config_led_current(PM8921_ID_LED_0, 2, 2, 0);
-
-    /* Turn on GPIO 24 through LPG 0
-     * Will be reconfigured during display_init
-     */
-    panel_backlight_on_pwm();
-
-    mdelay(10000);
-
-    /* Disable PM8921_ID_LED_1 */
-    pm8921_config_led_current(PM8921_ID_LED_1, 2, 2, 0);
-}
diff --git a/app/tests/rules.mk b/app/tests/rules.mk
index f8151ac..ec79a7f 100644
--- a/app/tests/rules.mk
+++ b/app/tests/rules.mk
@@ -5,7 +5,9 @@
 OBJS += \
 	$(LOCAL_DIR)/tests.o \
 	$(LOCAL_DIR)/thread_tests.o \
-	$(LOCAL_DIR)/printf_tests.o \
-	$(LOCAL_DIR)/i2c_tests.o \
-	$(LOCAL_DIR)/adc_tests.o \
+	$(LOCAL_DIR)/printf_tests.o
+
+ifeq ($(VERIFIED_BOOT),1)
+OBJS += \
 	$(LOCAL_DIR)/kauth_test.o
+endif
diff --git a/dev/gcdb/display/include/panel_r69006_1080p_cmd.h b/dev/gcdb/display/include/panel_r69006_1080p_cmd.h
new file mode 100755
index 0000000..ed96942
--- /dev/null
+++ b/dev/gcdb/display/include/panel_r69006_1080p_cmd.h
@@ -0,0 +1,317 @@
+/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *  * Neither the name of The Linux Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*---------------------------------------------------------------------------
+ * This file is autogenerated file using gcdb parser. Please do not edit it.
+ * Update input XML file to add a new entry or update variable in this file
+ * VERSION = "1.0"
+ *---------------------------------------------------------------------------*/
+
+#ifndef _PANEL_R69006_1080P_CMD_H_
+#define _PANEL_R69006_1080P_CMD_H_
+/*---------------------------------------------------------------------------*/
+/* HEADER files                                                              */
+/*---------------------------------------------------------------------------*/
+#include "panel.h"
+
+/*---------------------------------------------------------------------------*/
+/* Panel configuration                                                       */
+/*---------------------------------------------------------------------------*/
+static struct panel_config r69006_1080p_cmd_panel_data = {
+	"qcom,mdss_dsi_r69006_1080p_cmd", "dsi:0:", "qcom,mdss-dsi-panel",
+	10, 1, "DISPLAY_1", 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel resolution                                                          */
+/*---------------------------------------------------------------------------*/
+static struct panel_resolution r69006_1080p_cmd_panel_res = {
+	1080, 1920, 100, 82, 20, 0, 3, 9, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel color information                                                   */
+/*---------------------------------------------------------------------------*/
+static struct color_info r69006_1080p_cmd_color = {
+	24, 0, 0xff, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel on/off command information                                          */
+/*---------------------------------------------------------------------------*/
+static char r69006_1080p_cmd_on_cmd0[] = {
+	0XB0, 0x00, 0x23, 0x80
+};
+
+static char r69006_1080p_cmd_on_cmd1[] = {
+	0x06, 0x00, 0x29, 0xC0,
+	0XB3, 0x04, 0x10, 0x00,
+	0x00, 0x00, 0xFF, 0xFF,
+};
+
+static char r69006_1080p_cmd_on_cmd2[] = {
+	0x03, 0x00, 0x29, 0xC0,
+	0XB4, 0x0c, 0x00, 0xFF,
+};
+
+static char r69006_1080p_cmd_on_cmd3[] = {
+	0x04, 0x00, 0x29, 0xC0,
+	0XB6, 0x3b, 0xc3, 0x00,
+};
+
+static char r69006_1080p_cmd_on_cmd4[] = {
+	0XC0, 0x00, 0x23, 0x80
+};
+
+static char r69006_1080p_cmd_on_cmd5[] = {
+	0X36, 0x90, 0x15, 0x80
+};
+
+static char r69006_1080p_cmd_on_cmd6[] = {
+	0XCC, 0x04, 0x23, 0x80
+};
+
+static char r69006_1080p_cmd_on_cmd7[] = {
+	0x20, 0x00, 0x29, 0xC0,
+	0xC1, 0x84, 0x00, 0x10,
+	0xEF, 0x8B, 0xF1, 0xFF,
+	0xFF, 0xDF, 0x9C, 0xC5,
+	0x9A, 0x73, 0x8D, 0xAD,
+	0x63, 0xFE, 0xFF, 0xFF,
+	0xCB, 0xF8, 0x01, 0x00,
+	0xAA, 0x40, 0x00, 0xC2,
+	0x01, 0x08, 0x00, 0x01,
+};
+
+static char r69006_1080p_cmd_on_cmd8[] = {
+	0x0A, 0x00, 0x29, 0xC0,
+	0xCB, 0x0D, 0xFE, 0x1F,
+	0x2C, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0xFF, 0xFF,
+};
+
+static char r69006_1080p_cmd_on_cmd9[] = {
+	0x0B, 0x00, 0x29, 0xC0,
+	0xC2, 0x01, 0xF7, 0x80,
+	0x04, 0x63, 0x00, 0x60,
+	0x00, 0x01, 0x30, 0xFF,
+};
+
+static char r69006_1080p_cmd_on_cmd10[] = {
+	0x07, 0x00, 0x29, 0xC0,
+	0XC3, 0x55, 0x01, 0x00,
+	0x01, 0x00, 0x00, 0xFF,
+};
+
+static char r69006_1080p_cmd_on_cmd11[] = {
+	0x12, 0x00, 0x29, 0xC0,
+	0XC4, 0x70, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x02, 0x01,
+	0x00, 0x05, 0x01, 0x00,
+	0x00, 0x00, 0xFF, 0xFF,
+};
+
+static char r69006_1080p_cmd_on_cmd12[] = {
+	0x0F, 0x00, 0x29, 0xC0,
+	0xC6, 0x59, 0x07, 0x4a,
+	0x07, 0x4a, 0x01, 0x0E,
+	0x01, 0x02, 0x01, 0x02,
+	0x09, 0x15, 0x07, 0xFF,
+};
+
+static char r69006_1080p_cmd_on_cmd13[] = {
+	0x1F, 0x00, 0x29, 0xC0,
+	0XC7, 0x00, 0x30, 0x32,
+	0x34, 0x42, 0x4E, 0x56,
+	0x62, 0x44, 0x4A, 0x54,
+	0x62, 0x6B, 0x73, 0x7F,
+	0x08, 0x30, 0x32, 0x34,
+	0x42, 0x4E, 0x56, 0x62,
+	0x44, 0x4A, 0x54, 0x62,
+	0x6B, 0x73, 0x7F, 0xFF,
+};
+
+static char r69006_1080p_cmd_on_cmd14[] = {
+	0x14, 0x00, 0x29, 0xC0,
+	0xC8, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0xFC, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0xFC, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0xFC, 0x00,
+};
+
+static char r69006_1080p_cmd_on_cmd15[] = {
+	0x09, 0x00, 0x29, 0xC0,
+	0xC9, 0x1F, 0x68, 0x1F,
+	0x68, 0x4C, 0x4C, 0xC4,
+	0x11, 0xFF, 0xFF, 0xFF,
+};
+
+static char r69006_1080p_cmd_on_cmd16[] = {
+	0x11, 0x00, 0x29, 0xC0,
+	0xD0, 0x33, 0x01, 0x91,
+	0x0B, 0xD9, 0x19, 0x19,
+	0x00, 0x00, 0x00, 0x19,
+	0x99, 0x00, 0x00, 0x00,
+	0x00, 0xFF, 0xFF, 0xFF,
+};
+
+static char r69006_1080p_cmd_on_cmd17[] = {
+	0x1D, 0x00, 0x29, 0xC0,
+	0xD3, 0x1B, 0x3B, 0xBB,
+	0xAD, 0xA5, 0x33, 0x33,
+	0x33, 0x00, 0x80, 0xAD,
+	0xA8, 0x6f, 0x6f, 0x33,
+	0x33, 0x33, 0xF7, 0xF2,
+	0x1F, 0x7D, 0x7C, 0xFF,
+	0x0F, 0x99, 0x00, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF,
+};
+
+static char r69006_1080p_cmd_on_cmd18[] = {
+	0x04, 0x00, 0x29, 0xC0,
+	0xD4, 0x57, 0x33, 0x03,
+};
+
+static char r69006_1080p_cmd_on_cmd19[] = {
+	0x0C, 0x00, 0x29, 0xC0,
+	0XD5, 0x66, 0x00, 0x00,
+	0x01, 0x27, 0x01, 0x27,
+	0x00, 0x6D, 0x00, 0x6D,
+};
+
+static char r69006_1080p_cmd_on_cmd20[] = {
+	0xD6, 0x81, 0x23, 0x80
+};
+
+static char r69006_1080p_cmd_on_cmd21[] = {
+	0x29, 0x00, 0x05, 0x80
+};
+
+static char r69006_1080p_cmd_on_cmd22[] = {
+	0x11, 0x00, 0x05, 0x80
+};
+
+static struct mipi_dsi_cmd r69006_1080p_cmd_on_command[] = {
+	{0x4, r69006_1080p_cmd_on_cmd0, 0x00},
+	{0xc, r69006_1080p_cmd_on_cmd1, 0x00},
+	{0x8, r69006_1080p_cmd_on_cmd2, 0x00},
+	{0x8, r69006_1080p_cmd_on_cmd3, 0x00},
+	{0x4, r69006_1080p_cmd_on_cmd4, 0x00},
+	{0x4, r69006_1080p_cmd_on_cmd5, 0x00},
+	{0x4, r69006_1080p_cmd_on_cmd6, 0x00},
+	{0x24, r69006_1080p_cmd_on_cmd7, 0x00},
+	{0x10, r69006_1080p_cmd_on_cmd8, 0x00},
+	{0x10, r69006_1080p_cmd_on_cmd9, 0x00},
+	{0xc, r69006_1080p_cmd_on_cmd10, 0x00},
+	{0x18, r69006_1080p_cmd_on_cmd11, 0x00},
+	{0x14, r69006_1080p_cmd_on_cmd12, 0x00},
+	{0x24, r69006_1080p_cmd_on_cmd13, 0x00},
+	{0x18, r69006_1080p_cmd_on_cmd14, 0x00},
+	{0x10, r69006_1080p_cmd_on_cmd15, 0x00},
+	{0x18, r69006_1080p_cmd_on_cmd16, 0x00},
+	{0x24, r69006_1080p_cmd_on_cmd17, 0x00},
+	{0x8, r69006_1080p_cmd_on_cmd18, 0x00},
+	{0x10, r69006_1080p_cmd_on_cmd19, 0x00},
+	{0x4, r69006_1080p_cmd_on_cmd20, 0x00},
+	{0x4, r69006_1080p_cmd_on_cmd21, 0x78},
+	{0x4, r69006_1080p_cmd_on_cmd22, 0x78}
+};
+
+#define R69006_1080P_CMD_ON_COMMAND 23
+
+
+static char r69006_1080p_cmdoff_cmd0[] = {
+	0x28, 0x00, 0x05, 0x80
+};
+
+static char r69006_1080p_cmdoff_cmd1[] = {
+	0x10, 0x00, 0x05, 0x80
+};
+
+static struct mipi_dsi_cmd r69006_1080p_cmd_off_command[] = {
+	{0x4, r69006_1080p_cmdoff_cmd0, 0x78},
+	{0x4, r69006_1080p_cmdoff_cmd1, 0x96}
+};
+
+#define R69006_1080P_CMD_OFF_COMMAND 2
+
+
+static struct command_state r69006_1080p_cmd_state = {
+	0, 1
+};
+
+/*---------------------------------------------------------------------------*/
+/* Command mode panel information                                            */
+/*---------------------------------------------------------------------------*/
+static struct commandpanel_info r69006_1080p_cmd_command_panel = {
+	1, 1, 1, 0, 0, 0x2c, 0, 0, 0, 1, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Video mode panel information                                              */
+/*---------------------------------------------------------------------------*/
+static struct videopanel_info r69006_1080p_cmd_video_panel = {
+	1, 0, 0, 0, 1, 1, 2, 0, 0x9
+};
+
+/*---------------------------------------------------------------------------*/
+/* Lane configuration                                                        */
+/*---------------------------------------------------------------------------*/
+static struct lane_configuration r69006_1080p_cmd_lane_config = {
+	4, 0, 1, 1, 1, 1, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel timing                                                              */
+/*---------------------------------------------------------------------------*/
+static const uint32_t r69006_1080p_cmd_timings[] = {
+	0x7d, 0x25, 0x1d, 0x00, 0x37, 0x33, 0x22, 0x27, 0x1e, 0x03, 0x04, 0x00
+};
+
+static struct panel_timing r69006_1080p_cmd_timing_info = {
+	0, 4, 0x20, 0x2c
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel reset sequence                                                      */
+/*---------------------------------------------------------------------------*/
+static struct panel_reset_sequence r69006_1080p_cmd_reset_seq = {
+	{1, 0, 1, }, {20, 2, 20, }, 2
+};
+
+/*---------------------------------------------------------------------------*/
+/* Backlight setting                                                         */
+/*---------------------------------------------------------------------------*/
+static struct backlight r69006_1080p_cmd_backlight = {
+	1, 1, 4095, 100, 1, "PMIC_8941"
+};
+
+#endif /*_PANEL_R69006_1080P_CMD_H_*/
diff --git a/dev/gcdb/display/include/panel_r69006_1080p_video.h b/dev/gcdb/display/include/panel_r69006_1080p_video.h
new file mode 100755
index 0000000..205df55
--- /dev/null
+++ b/dev/gcdb/display/include/panel_r69006_1080p_video.h
@@ -0,0 +1,317 @@
+/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *  * Neither the name of The Linux Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*---------------------------------------------------------------------------
+ * This file is autogenerated file using gcdb parser. Please do not edit it.
+ * Update input XML file to add a new entry or update variable in this file
+ * VERSION = "1.0"
+ *---------------------------------------------------------------------------*/
+
+#ifndef _PANEL_R69006_1080P_VIDEO_H_
+#define _PANEL_R69006_1080P_VIDEO_H_
+/*---------------------------------------------------------------------------*/
+/* HEADER files                                                              */
+/*---------------------------------------------------------------------------*/
+#include "panel.h"
+
+/*---------------------------------------------------------------------------*/
+/* Panel configuration                                                       */
+/*---------------------------------------------------------------------------*/
+static struct panel_config r69006_1080p_video_panel_data = {
+	"qcom,mdss_dsi_r69006_1080p_video", "dsi:0:", "qcom,mdss-dsi-panel",
+	10, 0, "DISPLAY_1", 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel resolution                                                          */
+/*---------------------------------------------------------------------------*/
+static struct panel_resolution r69006_1080p_video_panel_res = {
+	1080, 1920, 100, 82, 20, 0, 3, 9, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel color information                                                   */
+/*---------------------------------------------------------------------------*/
+static struct color_info r69006_1080p_video_color = {
+	24, 0, 0xff, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel on/off command information                                          */
+/*---------------------------------------------------------------------------*/
+static char r69006_1080p_video_on_cmd0[] = {
+	0XB0, 0x00, 0x23, 0x80
+};
+
+static char r69006_1080p_video_on_cmd1[] = {
+	0x06, 0x00, 0x29, 0xC0,
+	0XB3, 0x05, 0x10, 0x00,
+	0x00, 0x00, 0xFF, 0xFF,
+};
+
+static char r69006_1080p_video_on_cmd2[] = {
+	0x03, 0x00, 0x29, 0xC0,
+	0XB4, 0x0c, 0x00, 0xFF,
+};
+
+static char r69006_1080p_video_on_cmd3[] = {
+	0x04, 0x00, 0x29, 0xC0,
+	0XB6, 0x3b, 0xc3, 0x00,
+};
+
+static char r69006_1080p_video_on_cmd4[] = {
+	0XC0, 0x00, 0x23, 0x80
+};
+
+static char r69006_1080p_video_on_cmd5[] = {
+	0X36, 0x90, 0x15, 0x80
+};
+
+static char r69006_1080p_video_on_cmd6[] = {
+	0XCC, 0x04, 0x23, 0x80
+};
+
+static char r69006_1080p_video_on_cmd7[] = {
+	0x20, 0x00, 0x29, 0xC0,
+	0xC1, 0x84, 0x00, 0x10,
+	0xEF, 0x8B, 0xF1, 0xFF,
+	0xFF, 0xDF, 0x9C, 0xC5,
+	0x9A, 0x73, 0x8D, 0xAD,
+	0x63, 0xFE, 0xFF, 0xFF,
+	0xCB, 0xF8, 0x01, 0x00,
+	0xAA, 0x40, 0x00, 0xC2,
+	0x01, 0x08, 0x00, 0x01,
+};
+
+static char r69006_1080p_video_on_cmd8[] = {
+	0x0A, 0x00, 0x29, 0xC0,
+	0xCB, 0x0D, 0xFE, 0x1F,
+	0x2C, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0xFF, 0xFF,
+};
+
+static char r69006_1080p_video_on_cmd9[] = {
+	0x0B, 0x00, 0x29, 0xC0,
+	0xC2, 0x01, 0xF7, 0x80,
+	0x04, 0x63, 0x00, 0x60,
+	0x00, 0x01, 0x30, 0xFF,
+};
+
+static char r69006_1080p_video_on_cmd10[] = {
+	0x07, 0x00, 0x29, 0xC0,
+	0XC3, 0x55, 0x01, 0x00,
+	0x01, 0x00, 0x00, 0xFF,
+};
+
+static char r69006_1080p_video_on_cmd11[] = {
+	0x12, 0x00, 0x29, 0xC0,
+	0XC4, 0x70, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x02, 0x01,
+	0x00, 0x05, 0x01, 0x00,
+	0x00, 0x00, 0xFF, 0xFF,
+};
+
+static char r69006_1080p_video_on_cmd12[] = {
+	0x0F, 0x00, 0x29, 0xC0,
+	0xC6, 0x59, 0x07, 0x4a,
+	0x07, 0x4a, 0x01, 0x0E,
+	0x01, 0x02, 0x01, 0x02,
+	0x09, 0x15, 0x07, 0xFF,
+};
+
+static char r69006_1080p_video_on_cmd13[] = {
+	0x1F, 0x00, 0x29, 0xC0,
+	0XC7, 0x00, 0x30, 0x32,
+	0x34, 0x42, 0x4E, 0x56,
+	0x62, 0x44, 0x4A, 0x54,
+	0x62, 0x6B, 0x73, 0x7F,
+	0x08, 0x30, 0x32, 0x34,
+	0x42, 0x4E, 0x56, 0x62,
+	0x44, 0x4A, 0x54, 0x62,
+	0x6B, 0x73, 0x7F, 0xFF,
+};
+
+static char r69006_1080p_video_on_cmd14[] = {
+	0x14, 0x00, 0x29, 0xC0,
+	0xC8, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0xFC, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0xFC, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0xFC, 0x00,
+};
+
+static char r69006_1080p_video_on_cmd15[] = {
+	0x09, 0x00, 0x29, 0xC0,
+	0xC9, 0x1F, 0x68, 0x1F,
+	0x68, 0x4C, 0x4C, 0xC4,
+	0x11, 0xFF, 0xFF, 0xFF,
+};
+
+static char r69006_1080p_video_on_cmd16[] = {
+	0x11, 0x00, 0x29, 0xC0,
+	0xD0, 0x33, 0x01, 0x91,
+	0x0B, 0xD9, 0x19, 0x19,
+	0x00, 0x00, 0x00, 0x19,
+	0x99, 0x00, 0x00, 0x00,
+	0x00, 0xFF, 0xFF, 0xFF,
+};
+
+static char r69006_1080p_video_on_cmd17[] = {
+	0x1D, 0x00, 0x29, 0xC0,
+	0xD3, 0x1B, 0x3B, 0xBB,
+	0xAD, 0xA5, 0x33, 0x33,
+	0x33, 0x00, 0x80, 0xAD,
+	0xA8, 0x6f, 0x6f, 0x33,
+	0x33, 0x33, 0xF7, 0xF2,
+	0x1F, 0x7D, 0x7C, 0xFF,
+	0x0F, 0x99, 0x00, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF,
+};
+
+static char r69006_1080p_video_on_cmd18[] = {
+	0x04, 0x00, 0x29, 0xC0,
+	0xD4, 0x57, 0x33, 0x03,
+};
+
+static char r69006_1080p_video_on_cmd19[] = {
+	0x0C, 0x00, 0x29, 0xC0,
+	0XD5, 0x66, 0x00, 0x00,
+	0x01, 0x27, 0x01, 0x27,
+	0x00, 0x6D, 0x00, 0x6D,
+};
+
+static char r69006_1080p_video_on_cmd20[] = {
+	0xD6, 0x81, 0x23, 0x80
+};
+
+static char r69006_1080p_video_on_cmd21[] = {
+	0x29, 0x00, 0x05, 0x80
+};
+
+static char r69006_1080p_video_on_cmd22[] = {
+	0x11, 0x00, 0x05, 0x80
+};
+
+static struct mipi_dsi_cmd r69006_1080p_video_on_command[] = {
+	{0x4, r69006_1080p_video_on_cmd0, 0x00},
+	{0xc, r69006_1080p_video_on_cmd1, 0x00},
+	{0x8, r69006_1080p_video_on_cmd2, 0x00},
+	{0x8, r69006_1080p_video_on_cmd3, 0x00},
+	{0x4, r69006_1080p_video_on_cmd4, 0x00},
+	{0x4, r69006_1080p_video_on_cmd5, 0x00},
+	{0x4, r69006_1080p_video_on_cmd6, 0x00},
+	{0x24, r69006_1080p_video_on_cmd7, 0x00},
+	{0x10, r69006_1080p_video_on_cmd8, 0x00},
+	{0x10, r69006_1080p_video_on_cmd9, 0x00},
+	{0xc, r69006_1080p_video_on_cmd10, 0x00},
+	{0x18, r69006_1080p_video_on_cmd11, 0x00},
+	{0x14, r69006_1080p_video_on_cmd12, 0x00},
+	{0x24, r69006_1080p_video_on_cmd13, 0x00},
+	{0x18, r69006_1080p_video_on_cmd14, 0x00},
+	{0x10, r69006_1080p_video_on_cmd15, 0x00},
+	{0x18, r69006_1080p_video_on_cmd16, 0x00},
+	{0x24, r69006_1080p_video_on_cmd17, 0x00},
+	{0x8, r69006_1080p_video_on_cmd18, 0x00},
+	{0x10, r69006_1080p_video_on_cmd19, 0x00},
+	{0x4, r69006_1080p_video_on_cmd20, 0x00},
+	{0x4, r69006_1080p_video_on_cmd21, 0x78},
+	{0x4, r69006_1080p_video_on_cmd22, 0x78}
+};
+
+#define R69006_1080P_VIDEO_ON_COMMAND 23
+
+
+static char r69006_1080p_videooff_cmd0[] = {
+	0x28, 0x00, 0x05, 0x80
+};
+
+static char r69006_1080p_videooff_cmd1[] = {
+	0x10, 0x00, 0x05, 0x80
+};
+
+static struct mipi_dsi_cmd r69006_1080p_video_off_command[] = {
+	{0x4, r69006_1080p_videooff_cmd0, 0x78},
+	{0x4, r69006_1080p_videooff_cmd1, 0x96}
+};
+
+#define R69006_1080P_VIDEO_OFF_COMMAND 2
+
+
+static struct command_state r69006_1080p_video_state = {
+	0, 1
+};
+
+/*---------------------------------------------------------------------------*/
+/* Command mode panel information                                            */
+/*---------------------------------------------------------------------------*/
+static struct commandpanel_info r69006_1080p_video_command_panel = {
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Video mode panel information                                              */
+/*---------------------------------------------------------------------------*/
+static struct videopanel_info r69006_1080p_video_video_panel = {
+	1, 0, 0, 0, 1, 1, 2, 0, 0x9
+};
+
+/*---------------------------------------------------------------------------*/
+/* Lane configuration                                                        */
+/*---------------------------------------------------------------------------*/
+static struct lane_configuration r69006_1080p_video_lane_config = {
+	4, 0, 1, 1, 1, 1, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel timing                                                              */
+/*---------------------------------------------------------------------------*/
+static const uint32_t r69006_1080p_video_timings[] = {
+	0x7d, 0x25, 0x1d, 0x00, 0x37, 0x33, 0x22, 0x27, 0x1e, 0x03, 0x04, 0x00
+};
+
+static struct panel_timing r69006_1080p_video_timing_info = {
+	0, 4, 0x20, 0x2c
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel reset sequence                                                      */
+/*---------------------------------------------------------------------------*/
+static struct panel_reset_sequence r69006_1080p_video_reset_seq = {
+	{1, 0, 1, }, {20, 2, 20, }, 2
+};
+
+/*---------------------------------------------------------------------------*/
+/* Backlight setting                                                         */
+/*---------------------------------------------------------------------------*/
+static struct backlight r69006_1080p_video_backlight = {
+	1, 1, 4095, 100, 1, "PMIC_8941"
+};
+
+#endif /*_PANEL_R69006_1080P_VIDEO_H_*/
diff --git a/dev/pmic/pmi8994/pm_app_smbchg.c b/dev/pmic/pmi8994/pm_app_smbchg.c
index 4b9693b..c3a03be 100644
--- a/dev/pmic/pmi8994/pm_app_smbchg.c
+++ b/dev/pmic/pmi8994/pm_app_smbchg.c
@@ -46,6 +46,9 @@
 #include <sys/types.h>
 #include <target.h>
 #include <pm8x41.h>
+#include <bits.h>
+#include <board.h>
+#include <smem.h>
 
 /*===========================================================================
 
@@ -80,13 +83,15 @@
 static bool display_initialized;
 static bool charge_in_progress;
 static bool display_shutdown_in_prgs;
+static bool pm_app_read_from_sram;
 
 char panel_name[256];
 
 pm_err_flag_type pm_smbchg_get_charger_path(uint32 device_index, pm_smbchg_usb_chgpth_pwr_pth_type* charger_path);
 pm_err_flag_type pm_appsbl_chg_config_vbat_low_threshold(uint32 device_index, pm_smbchg_specific_data_type *chg_param_ptr);
 static void display_thread_initialize();
-
+static void pm_app_ima_read_voltage(uint32_t *);
+static void pm_app_pmi8994_read_voltage(uint32_t *voltage);
 /*===========================================================================
 
                      FUNCTION IMPLEMENTATION
@@ -179,6 +184,20 @@
          err_flag |= pm_fg_adc_usr_get_calibrated_vbat(device_index, &vbat_adc); //Read calibrated vbatt ADC
          if ( err_flag != PM_ERR_FLAG__SUCCESS )  { break;}
 
+		/* FG_ADC hardware reports values that are off by ~120 to 200 mV, this results in boot up failures
+		 * on devices that boot up with battery close to threshold value. If the FG_ADC voltage is less than
+		 * threshold then read the voltage from a more accurate source FG SRAM to ascertain the voltage is indeed low.
+		 */
+		if (!pm_app_read_from_sram && (vbat_adc <= bootup_threshold))
+		{
+			if (board_pmic_type(PMIC_IS_PMI8996))
+				pm_app_ima_read_voltage(&vbat_adc);
+			else
+				pm_app_pmi8994_read_voltage(&vbat_adc);
+
+			pm_app_read_from_sram = true;
+		}
+
          //Check if ADC reading is within limit
          if ( vbat_adc >=  bootup_threshold)  //Compaire it with SW bootup threshold
          {
@@ -674,3 +693,160 @@
 		is_thread_start = true;
 	}
 }
+
+static void pm_app_wait_for_iacs_ready(uint32_t sid)
+{
+	uint8_t iacs;
+	int max_retry = 100;
+
+	udelay(50);
+	pm_comm_read_byte(sid, 0x4454, &iacs, 0);
+	while ((iacs & 0x02) == 0)
+	{
+		max_retry--;
+		pm_comm_read_byte(2, 0x4454, &iacs, 0);
+		mdelay(5);
+		if (!max_retry)
+		{
+			dprintf(CRITICAL, "Error: IACS not ready, shutting down\n");
+			shutdown_device();
+		}
+	}
+}
+
+static int pm_app_check_for_ima_exception(uint32_t sid)
+{
+	uint8_t ima_err_sts;
+	uint8_t ima_exception_sts;
+
+	pm_comm_read_byte(sid, 0x445f, &ima_err_sts, 0);
+	pm_comm_read_byte(sid, 0x4455, &ima_exception_sts, 0);
+
+	if (ima_err_sts != 0 || (ima_exception_sts & 0x1) == 1)
+	{
+		uint8_t ima_hw_sts;
+		pm_comm_read_byte(sid, 0x4456, &ima_hw_sts, 0);
+		dprintf(CRITICAL, "ima_err_sts: %x\tima_exception_sts:%x\tima_hw_sts:%x\n", ima_err_sts, ima_exception_sts, ima_hw_sts);
+		return 1;
+	}
+
+	return 0;
+}
+
+static void pm_app_ima_read_voltage(uint32_t *voltage)
+{
+	uint8_t start_beat_count;
+	uint8_t end_beat_count;
+	uint8_t vbat;
+	uint64_t vbat_adc = 0;
+	uint32_t sid = 2; //sid for pmi8996
+	int max_retry = 5;
+
+retry:
+	//Request IMA access
+	pm_comm_write_byte(sid, 0x4450, 0xA0, 0);
+	// Single read configure
+	pm_comm_write_byte(sid, 0x4451, 0x00, 0);
+
+	pm_app_wait_for_iacs_ready(sid);
+
+	//configure SRAM access
+	pm_comm_write_byte(sid, 0x4461, 0xCC, 0);
+	pm_comm_write_byte(sid, 0x4462, 0x05, 0);
+
+	pm_app_wait_for_iacs_ready(sid);
+
+	pm_comm_read_byte(sid, 0x4457, &start_beat_count, 0);
+
+	//Read the voltage
+	pm_comm_read_byte(sid, 0x4467, &vbat, 0);
+	vbat_adc = vbat;
+	pm_comm_read_byte(sid, 0x4468, &vbat, 0);
+	vbat_adc |= (vbat << 8);
+	pm_comm_read_byte(sid, 0x4469, &vbat, 0);
+	vbat_adc |= (vbat << 16);
+	pm_comm_read_byte(sid, 0x446A, &vbat, 0);
+	vbat_adc |= (vbat << 24);
+
+	pm_app_wait_for_iacs_ready(sid);
+
+	//Look for any errors
+	if(pm_app_check_for_ima_exception(sid))
+		goto err;
+
+	pm_comm_read_byte(sid, 0x4457, &end_beat_count, 0);
+
+	if (start_beat_count != end_beat_count)
+	{
+		max_retry--;
+		if (!max_retry)
+			goto err;
+		goto retry;
+	}
+
+	//Release the ima access
+	pm_comm_write_byte(2, 0x4450, 0x00, 0);
+
+	//extract the byte1 & byte2 and convert to mv
+	vbat_adc = ((vbat_adc & 0x00ffff00) >> 8) * 152587;
+	*voltage = vbat_adc / 1000000;
+	return;
+
+err:
+	dprintf(CRITICAL, "Failed to Read the Voltage from IMA, shutting down\n");
+	shutdown_device();
+}
+
+static void pm_app_pmi8994_read_voltage(uint32_t *voltage)
+{
+	uint8_t val = 0;
+	uint8_t vbat;
+	uint64_t vbat_adc = 0;
+	uint32_t sid = 2; //sid for pmi8994
+	int max_retry = 100;
+
+	pm_comm_read_byte(sid, 0x4440, &val, 0);
+
+	//Request for FG access
+	if ((val & BIT(7)) != 1)
+		pm_comm_write_byte(sid, 0x4440, 0x80, 0);
+
+	pm_comm_read_byte(sid, 0x4410, &val, 0);
+	while((val & 0x1) == 0)
+	{
+		//sleep and retry again, this takes up to 1.5 seconds
+		max_retry--;
+		mdelay(100);
+		pm_comm_read_byte(sid, 0x4410, &val, 0);
+		if (!max_retry)
+		{
+		  dprintf(CRITICAL, "Error: Failed to read from Fuel Guage, Shutting down\n");
+		  shutdown_device();
+		}
+	}
+
+	//configure single read access
+	pm_comm_write_byte(sid, 0x4441, 0x00, 0);
+	//configure SRAM for voltage shadow
+	pm_comm_write_byte(sid, 0x4442, 0xCC, 0);
+	pm_comm_write_byte(sid, 0x4443, 0x05, 0);
+
+	//Read voltage from SRAM
+	pm_comm_read_byte(sid, 0x444c, &vbat, 0);
+	vbat_adc = vbat;
+	pm_comm_read_byte(sid, 0x444d, &vbat, 0);
+	vbat_adc |= (vbat << 8);
+	pm_comm_read_byte(sid, 0x444e, &vbat, 0);
+	vbat_adc |= (vbat << 16);
+	pm_comm_read_byte(sid, 0x444f, &vbat, 0);
+	vbat_adc |= (vbat << 24);
+
+	//clean up to relase sram access
+	pm_comm_write_byte(sid, 0x4440, 0x00, 0);
+	//extract byte 1 & byte 2
+	vbat_adc = ((vbat_adc & 0x00ffff00) >> 8) * 152587;
+
+	//convert the voltage to mv
+	*voltage = vbat_adc / 1000000;
+}
+
diff --git a/include/km_main.h b/include/km_main.h
index 42920d1..fa606ad 100644
--- a/include/km_main.h
+++ b/include/km_main.h
@@ -67,6 +67,7 @@
     KEYMASTER_READ_LK_DEVICE_STATE			= (KEYMASTER_UTILS_CMD_ID + 2UL),
     KEYMASTER_WRITE_LK_DEVICE_STATE			= (KEYMASTER_UTILS_CMD_ID + 3UL),
     KEYMASTER_MILESTONE_CALL				= (KEYMASTER_UTILS_CMD_ID + 4UL),
+    KEYMASTER_SECURE_WRITE_PROTECT			= (KEYMASTER_UTILS_CMD_ID + 6UL),
 
     KEYMASTER_LAST_CMD_ENTRY				= (int)0xFFFFFFFFULL
 } keymaster_cmd_t;
@@ -163,4 +164,45 @@
 	int status;
 }__attribute__ ((packed)) key_op_delete_all_rsp_t;
 
+typedef enum _secure_write_prot_op_t
+{
+	SWP_READ_CONFIG,
+	SWP_WRITE_CONFIG,
+	SWP_LAST_CMD_ENTRY                    = (int)0xFFFFFFFFULL
+} secure_write_prot_op_t;
+
+/*
+	@brief
+	Data structure
+
+	@param[in]   cmd_id                   Command ID of the request
+	@param[in]   op                       Secure write protect operation (enum from secure_write_prot_op_t)
+	@param[in]   swp_write_data_offset    Offset of data for SWP operation
+	@param[in]   swp_write_data_len       Length of data for SWP operation
+*/
+
+typedef struct _secure_write_prot_req_t
+{
+	uint32 cmd_id;
+	uint32 op;
+	uint32 swp_write_data_offset;
+	uint32 swp_write_data_len;
+}__attribute__((packed)) secure_write_prot_req_t;
+
+/*
+	@brief
+	Data structure
+
+	@param[out]   status                  Status of the request
+	@param[out]   swp_read_data_offset    Offset of data for SWP operation
+	@param[out]   swp_read_data_len       Length of data for SWP operation
+*/
+
+typedef struct _secure_write_prot_rsp_t
+{
+	int status;
+	uint32 swp_read_data_offset;
+	uint32 swp_read_data_len;
+}__attribute__((packed)) secure_write_prot_rsp_t;
+
 #endif /* KM_MAIN_H */
diff --git a/platform/msm8996/include/platform/iomap.h b/platform/msm8996/include/platform/iomap.h
index 8aa0fab..2a31c8f 100644
--- a/platform/msm8996/include/platform/iomap.h
+++ b/platform/msm8996/include/platform/iomap.h
@@ -80,6 +80,7 @@
 
 #define AHB2_PHY_BASE               0x7416000
 #define PERIPH_SS_AHB2PHY_TOP_CFG   (AHB2_PHY_BASE + 0x10)
+#define GCC_RX2_USB2_CLKREF_EN      0x00388014
 
 /* Clocks */
 #define CLK_CTL_BASE                0x300000
diff --git a/platform/msm_shared/board.c b/platform/msm_shared/board.c
index 1265f29..8839a8a 100644
--- a/platform/msm_shared/board.c
+++ b/platform/msm_shared/board.c
@@ -400,6 +400,21 @@
 	return 0;
 }
 
+bool board_pmic_type(uint32_t type)
+{
+	uint8_t i;
+	if (format_major == 0x0 && format_minor >= 0x0B)
+	{
+		for (i = 0; i < SMEM_MAX_PMIC_DEVICES; i++)
+		{
+			if (type == (board.pmic_info_array[i].pmic_type & 0x0000ffff))
+				return true;
+		}
+	}
+
+	return false;
+}
+
 uint32_t board_pmic_target(uint8_t num_ent)
 {
 	if (format_major == 0x0 && num_ent < SMEM_MAX_PMIC_DEVICES)
diff --git a/platform/msm_shared/dme.c b/platform/msm_shared/dme.c
index f83ee93..c6d651d 100644
--- a/platform/msm_shared/dme.c
+++ b/platform/msm_shared/dme.c
@@ -96,7 +96,7 @@
 	}
 	if (resp_upiu->basic_hdr.response != UPIU_QUERY_RESP_SUCCESS)
 	{
-		dprintf(CRITICAL, "%s:%d UPIU Response is not SUCCESS\n", __func__, __LINE__);
+		dprintf(CRITICAL, "%s:%d UPIU Response is not SUCCESS, response code: 0x%x\n", __func__, __LINE__, resp_upiu->basic_hdr.response);
 		return -UFS_FAILURE;
 	}
 
@@ -111,8 +111,9 @@
 										return -UFS_FAILURE;
 									  }
 
-									  *((uint32_t *) buffer) = resp_upiu->flag_value;
+									  *((uint32_t *) buffer) = resp_upiu->resv_1[3]; //resv_1[3] contains the data for flag
 									  break;
+		case UPIU_QUERY_OP_WRITE_ATTRIBUTE:
 		case UPIU_QUERY_OP_TOGGLE_FLAG:
 		case UPIU_QUERY_OP_CLEAR_FLAG:
 		case UPIU_QUERY_OP_READ_DESCRIPTOR:
@@ -149,6 +150,9 @@
 		req_upiu.resp_data_len = query->buf_len;
 	}
 
+	if (query->opcode == UPIU_QUERY_OP_WRITE_ATTRIBUTE)
+		req_upiu.data_buffer_addr = query->buf; // attribute is 4 byte value
+
 	ret = utp_enqueue_upiu(dev, &req_upiu);
 	if (ret)
 		goto utp_send_query_upiu_err;
@@ -161,6 +165,47 @@
 	return ret;
 }
 
+int dme_set_bbootlunen(struct ufs_dev *dev, uint32_t val)
+{
+	int ret = 0;
+	STACKBUF_DMA_ALIGN(value, sizeof(uint32_t));
+	memset((void *)value, 0, sizeof(uint32_t));
+	*value = val;
+	struct utp_query_req_upiu_type set_query = {UPIU_QUERY_OP_WRITE_ATTRIBUTE,
+												 UFS_IDX_bBootLunEn,
+												 0,
+												 0,
+												 (addr_t)value,
+												 sizeof(uint32_t)};
+	if ((ret = dme_send_query_upiu(dev, &set_query)))
+	{
+		arch_invalidate_cache_range((addr_t) value, sizeof(uint32_t));
+		dprintf(CRITICAL, "%s:%d DME Set Boot Lun Query failed. Value 0x%x\n", __func__, __LINE__, *value);
+		return -UFS_FAILURE;
+	}
+	return UFS_SUCCESS;
+}
+
+int dme_get_bbootlunen(struct ufs_dev *dev)
+{
+	STACKBUF_DMA_ALIGN(value, sizeof(uint32_t));
+	memset((void *)value, 0, sizeof(uint32_t));
+	int ret = 0;
+	struct utp_query_req_upiu_type set_query = {UPIU_QUERY_OP_READ_ATTRIBUTE,
+												 UFS_IDX_bBootLunEn,
+												 0,
+												 0,
+												 (addr_t)value,
+												 sizeof(uint32_t)};
+	if ((ret = dme_send_query_upiu(dev, &set_query)))
+	{
+		dprintf(CRITICAL, "%s:%d DME Set Boot Lun Query failed\n", __func__, __LINE__);
+		return -UFS_FAILURE;
+	}
+	arch_invalidate_cache_range((addr_t) value, sizeof(uint32_t));
+	return *value;
+}
+
 int dme_set_fpurgeenable(struct ufs_dev *dev)
 {
 	STACKBUF_DMA_ALIGN(result, sizeof(uint32_t));
@@ -551,6 +596,7 @@
 											req_upiu->basic_hdr.query_task_mgmt_func = UPIU_QUERY_FUNC_STD_READ_REQ;
 											break;
 		case UPIU_QUERY_OP_TOGGLE_FLAG:
+		case UPIU_QUERY_OP_WRITE_ATTRIBUTE:
 		case UPIU_QUERY_OP_CLEAR_FLAG:
 		case UPIU_QUERY_OP_SET_FLAG:
 									 req_upiu->basic_hdr.query_task_mgmt_func = UPIU_QUERY_FUNC_STD_WRITE_REQ;
@@ -559,6 +605,13 @@
 				dprintf(CRITICAL, "%s:%d UPIU query opcode not supported.\n", __func__, __LINE__);
 				return -UFS_FAILURE;
 	}
+	if (upiu_data->opcode == UPIU_QUERY_OP_WRITE_ATTRIBUTE)
+	{
+		req_upiu->resv_1[0] = (*(uint32_t *)(upiu_data->data_buffer_addr) >> 24);
+		req_upiu->resv_1[1] = (*(uint32_t *)(upiu_data->data_buffer_addr) >> 16);
+		req_upiu->resv_1[2] = (*(uint32_t *)(upiu_data->data_buffer_addr) >> 8);
+		req_upiu->resv_1[3] = (*(uint32_t *)(upiu_data->data_buffer_addr) & 0xFF);
+	}
 
 	return UFS_SUCCESS;
 }
diff --git a/platform/msm_shared/include/board.h b/platform/msm_shared/include/board.h
index 4d4c7a9..9a5db02 100644
--- a/platform/msm_shared/include/board.h
+++ b/platform/msm_shared/include/board.h
@@ -90,5 +90,5 @@
 
 uint32_t board_foundry_id(void);
 void board_update_boot_dev(uint32_t);
-
+bool board_pmic_type(uint32_t type);
 #endif
diff --git a/platform/msm_shared/include/dme.h b/platform/msm_shared/include/dme.h
index aa11c54..4930024 100644
--- a/platform/msm_shared/include/dme.h
+++ b/platform/msm_shared/include/dme.h
@@ -73,6 +73,7 @@
 #define UFS_IDX_bBootLunEn          0x00
 #define UFS_IDX_bCurrentPowerMode   0x01
 #define UFS_IDX_bActiveICCLevel     0x03
+#define UFS_IDX_bBootLunID          0x04
 #define UFS_IDX_bPurgeStatus        0x06
 #define UFS_IDX_bRefClkFreq         0x0a
 #define UFS_IDX_bConfigDescrLock    0x0b
@@ -268,4 +269,9 @@
 */
 int dme_read_geo_desc(struct ufs_dev *dev);
 
+/* function to return the boot lun currently booting from */
+int dme_get_bbootlunen(struct ufs_dev *dev);
+
+/* function to set the boot lun to either 0, 1 or 2 */
+int dme_set_bbootlunen(struct ufs_dev *dev, uint32_t val);
 #endif
diff --git a/platform/msm_shared/include/mmc_wrapper.h b/platform/msm_shared/include/mmc_wrapper.h
index f52a117..fbae494 100644
--- a/platform/msm_shared/include/mmc_wrapper.h
+++ b/platform/msm_shared/include/mmc_wrapper.h
@@ -49,4 +49,6 @@
 uint8_t mmc_get_lun(void);
 void  mmc_read_partition_table(uint8_t arg);
 uint32_t mmc_write_protect(const char *name, int set_clr);
+int ufs_set_boot_lun(uint32_t boot_lun_id);
+int ufs_get_boot_lun();
 #endif
diff --git a/platform/msm_shared/include/qusb2_phy.h b/platform/msm_shared/include/qusb2_phy.h
index 1d5199a..fc971c8 100644
--- a/platform/msm_shared/include/qusb2_phy.h
+++ b/platform/msm_shared/include/qusb2_phy.h
@@ -34,6 +34,7 @@
 
 #define QUSB2PHY_PORT_POWERDOWN     (QUSB2_PHY_BASE + 0x000000B4)
 #define QUSB2PHY_PORT_UTMI_CTRL2    (QUSB2_PHY_BASE + 0x000000C4)
+#define QUSB2PHY_PLL_TEST           (QUSB2_PHY_BASE + 0x00000004)
 #define QUSB2PHY_PLL_TUNE           (QUSB2_PHY_BASE + 0x00000008)
 #define QUSB2PHY_PLL_USER_CTL1      (QUSB2_PHY_BASE + 0x0000000C)
 #define QUSB2PHY_PLL_USER_CTL2      (QUSB2_PHY_BASE + 0x00000010)
@@ -42,6 +43,8 @@
 #define QUSB2PHY_PORT_TUNE3         (QUSB2_PHY_BASE + 0x00000088)
 #define QUSB2PHY_PORT_TUNE4         (QUSB2_PHY_BASE + 0x0000008C)
 #define QUSB2PHY_PORT_TEST2         (QUSB2_PHY_BASE + 0x0000009C)
+#define QUSB2PHY_PLL_PWR_CTL        (QUSB2_PHY_BASE + 0x00000018)
+#define QUSB2PHY_PLL_AUTOPGM_CTL1   (QUSB2_PHY_BASE + 0x0000001C)
 
 
 #endif
diff --git a/platform/msm_shared/include/rpmb.h b/platform/msm_shared/include/rpmb.h
index 58f40a6..265a0d6 100644
--- a/platform/msm_shared/include/rpmb.h
+++ b/platform/msm_shared/include/rpmb.h
@@ -97,6 +97,23 @@
 	uint32_t dev_type;
 };
 
+/* Secure Write Protect Info Entry structure */
+typedef struct
+{
+	uint8_t  wp_enable;    /* UFS: WPF (Write Protect Flag), eMMC: SECURE_WP_MODE_ENABLE */
+	uint8_t  wp_type_mask; /* UFS: WPT (Write Protect Type), eMMC: SECURE_WP_MODE_CONFIG */
+	uint64_t addr;         /* UFS: LBA, eMMC: 0x1/0x2 (address of the device config register) */
+	uint32_t num_blocks;   /* UFS: Num LBA, eMMC: Set to 0 */
+} __attribute__ ((packed)) qsee_stor_secure_wp_info_entry_t;
+
+/* Secure Write Protect Info structure */
+typedef struct
+{
+	uint8_t                          lun_number;    /* UFS: LUN #, eMMC: Set to 0 */
+	uint8_t                          num_entries;   /* Number of Secure wp entries */
+	qsee_stor_secure_wp_info_entry_t wp_entries[4]; /* Max 4 entries total */
+} __attribute__ ((packed)) qsee_stor_secure_wp_info_t;
+
 /* dump a given RPMB frame */
 static inline void dump_rpmb_frame(uint8_t *frame, const char *frame_type)
 {
@@ -136,5 +153,6 @@
 int rpmb_write(uint32_t *req_buf, uint32_t blk_cnt, uint32_t rel_wr_count, uint32_t *resp_buf, uint32_t *resp_len);
 int rpmb_read(uint32_t *req_buf, uint32_t blk_cnt, uint32_t *resp_buf, uint32_t *resp_len);
 struct rpmb_init_info *rpmb_get_init_info();
-int rpmb_get_app_handle();
+/* RPMB API to set secure write protect configuration block */
+int swp_write(qsee_stor_secure_wp_info_t swp_cb);
 #endif
diff --git a/platform/msm_shared/include/upiu.h b/platform/msm_shared/include/upiu.h
index e081909..2c8fee5 100644
--- a/platform/msm_shared/include/upiu.h
+++ b/platform/msm_shared/include/upiu.h
@@ -74,8 +74,8 @@
 	uint8_t                   selector;

 	uint8_t                   resv_0[2];

 	uint16_t                  resp_len;

-	uint8_t                   resv_1[3];

-	uint8_t                   flag_value;

+	// this structure is used for several queries. resv_1 field is reserved for some and used for others

+	uint8_t                   resv_1[4];

 	uint8_t                   resv_2[4];

 }__PACKED;

 

diff --git a/platform/msm_shared/mmc_wrapper.c b/platform/msm_shared/mmc_wrapper.c
index 10e9955..495767a 100755
--- a/platform/msm_shared/mmc_wrapper.c
+++ b/platform/msm_shared/mmc_wrapper.c
@@ -534,6 +534,41 @@
 }
 
 /*
+ * Function    : ufs_get_boot_lun
+ * Arg         : none
+ * Return type : current boot lun
+ */
+
+int ufs_get_boot_lun()
+{
+	int ret = 0;
+	void *dev;
+	dev = target_mmc_device();
+
+	if (!(platform_boot_dev_isemmc()))
+		ret = dme_get_bbootlunen((struct ufs_dev *)dev);
+	return ret;
+}
+
+
+/*
+ * Function    : ufs_set_boot_lun
+ * Arg         : boot lun id
+ * Return type : status
+ */
+
+int ufs_set_boot_lun(uint32_t boot_lun_id)
+{
+	int ret = 0;
+	void *dev;
+	dev = target_mmc_device();
+
+	if (!(platform_boot_dev_isemmc()))
+		ret = dme_set_bbootlunen((struct ufs_dev *)dev, boot_lun_id);
+	return ret;
+}
+
+/*
  * Function     : mmc set LUN for ufs
  * Arg          : LUN number
  * Return type  : void
diff --git a/platform/msm_shared/qmp_usb30_phy.c b/platform/msm_shared/qmp_usb30_phy.c
index 91aed89..56b009a 100644
--- a/platform/msm_shared/qmp_usb30_phy.c
+++ b/platform/msm_shared/qmp_usb30_phy.c
@@ -107,7 +107,7 @@
 	{0x508, 0x77}, /* QSERDES_RX_RX_EQ_OFFSET_ADAPTOR_CNTRL1 */
 	{0x50c, 0x80}, /* QSERDES_RX_RX_OFFSET_ADAPTOR_CNTRL2 */
 	{0x514, 0x03}, /* QSERDES_RX_SIGDET_CNTRL */
-	{0x518, 0x1b}, /* QSERDES_RX_SIGDET_LVL */
+	{0x518, 0x18}, /* QSERDES_RX_SIGDET_LVL */
 	{0x51c, 0x16}, /* QSERDES_RX_SIGDET_DEGLITCH_CNTRL */
 
 	/* Tx settings */
@@ -135,6 +135,7 @@
 struct qmp_reg qmp_misc_settings_rev2[] =
 {
 	{0x178, 0x01}, /* QSERDES_COM_HSCLK_SEL */
+	{0x518, 0x1B}, /* QSERDES_RX_SIGDET_LVL */
 	{0xC4, 0x15}, /* USB3PHY_QSERDES_COM_RESCODE_DIV_NUM */
 	{0x1B8, 0x1F}, /* QSERDES_COM_CMN_MISC2 */
 };
diff --git a/platform/msm_shared/qusb2_phy.c b/platform/msm_shared/qusb2_phy.c
index 871bbcc..8981df7 100644
--- a/platform/msm_shared/qusb2_phy.c
+++ b/platform/msm_shared/qusb2_phy.c
@@ -77,12 +77,15 @@
 			tune2 = (tune2 & 0x0f) | (fuse_val << 4);
 #endif
 		writel(tune2, QUSB2PHY_PORT_TUNE2);
-		writel(0x93, QUSB2PHY_PORT_TUNE3);
+		writel(0x83, QUSB2PHY_PORT_TUNE3);
 		writel(0xC0, QUSB2PHY_PORT_TUNE4);
 		writel(0x30, QUSB2PHY_PLL_TUNE);
 		writel(0x79, QUSB2PHY_PLL_USER_CTL1);
 		writel(0x21, QUSB2PHY_PLL_USER_CTL2);
 		writel(0x14, QUSB2PHY_PORT_TEST2);
+		writel(0x80, QUSB2PHY_PLL_TEST);
+		writel(0x9F, QUSB2PHY_PLL_AUTOPGM_CTL1);
+		writel(0x00, QUSB2PHY_PLL_PWR_CTL);
 	}
 	else
 	{
diff --git a/platform/msm_shared/rpmb/rpmb.c b/platform/msm_shared/rpmb/rpmb.c
index 8ddfbd3..3c85b8d 100644
--- a/platform/msm_shared/rpmb/rpmb.c
+++ b/platform/msm_shared/rpmb/rpmb.c
@@ -25,8 +25,11 @@
  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+#include <stdlib.h>
+#include <string.h>
 #include <platform.h>
 #include <rpmb.h>
+#include <km_main.h>
 #include <rpmb_listener.h>
 #include <mmc_sdhci.h>
 #include <boot_device.h>
@@ -36,7 +39,6 @@
 
 
 static void *dev;
-static int app_handle;
 struct rpmb_init_info info;
 
 int rpmb_init()
@@ -94,7 +96,6 @@
 		dprintf(CRITICAL, "Error registering the handler\n");
 		goto err;
 	}
-	rpmb_get_app_handle();
 
 err:
 	return ret;
@@ -142,7 +143,7 @@
 
 	/* Read the device info */
 	arch_clean_invalidate_cache_range((addr_t) info, sz);
-	ret = qseecom_send_command(app_handle, (void*) &read_req, sizeof(read_req), (void*) &read_rsp, sizeof(read_rsp));
+	ret = qseecom_send_command(get_secapp_handle(), (void*) &read_req, sizeof(read_req), (void*) &read_rsp, sizeof(read_rsp));
 	arch_invalidate_cache_range((addr_t) info, sz);
 
 	if (ret < 0 || read_rsp.status < 0)
@@ -167,7 +168,7 @@
 
 	/* Write the device info */
 	arch_clean_invalidate_cache_range((addr_t) info, sz);
-	ret = qseecom_send_command(app_handle, (void *)&write_req, sizeof(write_req), (void *)&write_rsp, sizeof(write_rsp));
+	ret = qseecom_send_command(get_secapp_handle(), (void *)&write_req, sizeof(write_req), (void *)&write_rsp, sizeof(write_rsp));
 	arch_invalidate_cache_range((addr_t) info, sz);
 
 	if (ret < 0 || write_rsp.status < 0)
@@ -179,10 +180,33 @@
 	return 0;
 }
 
-int rpmb_get_app_handle()
+/*
+ * SWP Write function is used to send a configuration block to rpmb
+ * for enabling a secure write protect based on LBAs. This function
+ * should is enabled by the keymaster secure app and this function
+ * can only be called before we send the milestone call to keymaster.
+ */
+int swp_write(qsee_stor_secure_wp_info_t swp_cb)
 {
-	app_handle = get_secapp_handle();
-	return app_handle;
+	secure_write_prot_req_t *req;
+	secure_write_prot_rsp_t rsp;
+	int ret = 0;
+	uint32_t tlen = sizeof(secure_write_prot_req_t) + sizeof(swp_cb);
+	if(!(req = (secure_write_prot_req_t *) malloc(tlen)))
+		ASSERT(0);
+	void *cpy_ptr = (uint8_t *) req + sizeof(secure_write_prot_req_t);
+	req->cmd_id = KEYMASTER_SECURE_WRITE_PROTECT;
+	req->op = SWP_WRITE_CONFIG;
+	req->swp_write_data_offset = sizeof(secure_write_prot_req_t);
+	req->swp_write_data_len = sizeof(swp_cb);
+	memcpy(cpy_ptr, (void *)&swp_cb, sizeof(swp_cb));
+	ret = qseecom_send_command(get_secapp_handle(), (void *)req, tlen, (void *)&rsp, sizeof(rsp));
+	if(ret < 0 || rsp.status < 0)
+	{
+		dprintf(CRITICAL, "Setting secure write protect configuration failed\n");
+		return -1;
+	}
+	return 0;
 }
 
 int rpmb_uninit()
diff --git a/platform/msm_shared/smem.h b/platform/msm_shared/smem.h
index 5e3ae4b..278a0eb 100644
--- a/platform/msm_shared/smem.h
+++ b/platform/msm_shared/smem.h
@@ -141,7 +141,6 @@
 	PMIC_IS_PMI8950   = 17,
 	PMIC_IS_PMI8994   = 10,
 	PMIC_IS_PMI8996   = 19,
-
 } pm_model_type_bfly;
 
 struct smem_board_info_v3 {
diff --git a/project/msm8952.mk b/project/msm8952.mk
index f6d69b4..e808597 100644
--- a/project/msm8952.mk
+++ b/project/msm8952.mk
@@ -74,8 +74,6 @@
 
 ifeq ($(ENABLE_MDTP_SUPPORT),1)
 DEFINES += MDTP_SUPPORT=1
-DEFINES += MDTP_EFUSE_ADDRESS=0x0005C250 # QFPROM_CORR_QC_SPARE_REG_LSB_ADDR
-DEFINES += MDTP_EFUSE_START=0
 endif
 
 ENABLE_WDOG_SUPPORT := 0
diff --git a/project/msm8996.mk b/project/msm8996.mk
index 6a3973f..4c5d6a1 100644
--- a/project/msm8996.mk
+++ b/project/msm8996.mk
@@ -103,3 +103,8 @@
 
 #enable battery voltage check
 DEFINES += CHECK_BAT_VOLTAGE=1
+# Enable unit test FW
+ENABLE_UNITTEST_FW=1
+ifeq ($(ENABLE_UNITTEST_FW),1)
+DEFINES += UNITTEST_FW_SUPPORT=1
+endif
diff --git a/target/msm8952/mdtp_ui_defs.c b/target/msm8952/mdtp_defs.c
similarity index 77%
rename from target/msm8952/mdtp_ui_defs.c
rename to target/msm8952/mdtp_defs.c
index 668feb2..ebcdafb 100644
--- a/target/msm8952/mdtp_ui_defs.c
+++ b/target/msm8952/mdtp_defs.c
@@ -27,8 +27,15 @@
  *
  */
 
+#include "platform.h"
 #include "mdtp_defs.h"
 
+#define MDTP_EFUSE_ADDRESS_MSM8952  0x0005C250  // QFPROM_CORR_QC_SPARE_REG_LSB_ADDR
+#define MDTP_EFUSE_START_MSM8952    0
+
+#define MDTP_EFUSE_ADDRESS_MSM8956  0x000A4408  // QFPROM_CORR_SPARE_REG18_LSB_ADDR
+#define MDTP_EFUSE_START_MSM8956    0
+
 struct mdtp_ui_defs mdtp_ui_defs_msm8952 = {
         // Image dimensions
         952,      // error_msg_width;
@@ -65,3 +72,25 @@
 {
     return mdtp_ui_defs_msm8952;
 }
+
+int mdtp_get_target_efuse(struct mdtp_target_efuse* target_efuse)
+{
+    if (target_efuse == NULL)
+    {
+        dprintf(CRITICAL, "mdtp: mdtp_get_target_efuse: ERROR, target_efuse is NULL\n");
+        return -1;
+    }
+
+    if (platform_is_msm8956())
+    {
+        target_efuse->address = MDTP_EFUSE_ADDRESS_MSM8956;
+        target_efuse->start = MDTP_EFUSE_START_MSM8956;
+    }
+    else
+    {
+        target_efuse->address = MDTP_EFUSE_ADDRESS_MSM8952;
+        target_efuse->start = MDTP_EFUSE_START_MSM8952;
+    }
+
+    return 0;
+}
diff --git a/target/msm8952/rules.mk b/target/msm8952/rules.mk
index 1c404d7..cedc119 100644
--- a/target/msm8952/rules.mk
+++ b/target/msm8952/rules.mk
@@ -49,5 +49,5 @@
 endif
 ifeq ($(ENABLE_MDTP_SUPPORT),1)
 OBJS += \
-	$(LOCAL_DIR)/mdtp_ui_defs.o
+	$(LOCAL_DIR)/mdtp_defs.o
 endif