Merge "lib: libc: Add support for secure memcpy"
diff --git a/AndroidBoot.mk b/AndroidBoot.mk
index b27a1a0..06647a9 100644
--- a/AndroidBoot.mk
+++ b/AndroidBoot.mk
@@ -25,6 +25,7 @@
 
 ifneq ($(TARGET_BUILD_VARIANT),user)
   DEVICE_STATUS := DEFAULT_UNLOCK=true
+  USER_BUILD_VARIANT=true
 endif
 
 ifeq ($(TARGET_BOARD_PLATFORM),msm8660)
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index f3b63b7..0d3cd76 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -40,6 +40,7 @@
 #include <arch/ops.h>
 
 #include <dev/flash.h>
+#include <dev/flash-ubi.h>
 #include <lib/ptable.h>
 #include <dev/keys.h>
 #include <dev/fbcon.h>
@@ -118,9 +119,7 @@
 #define DEFAULT_ERASE_SIZE  4096
 #define MAX_PANEL_BUF_SIZE 128
 
-#define UBI_MAGIC      "UBI#"
 #define DISPLAY_DEFAULT_PREFIX "mdss_mdp"
-#define UBI_MAGIC_SIZE 0x04
 #define BOOT_DEV_MAX_LEN  64
 
 #define IS_ARM64(ptr) (ptr->magic_64 == KERNEL64_HDR_MAGIC) ? true : false
@@ -626,7 +625,7 @@
 
 #if VERIFIED_BOOT
 	/* Write protect the device info */
-	if (mmc_write_protect("devinfo", 1))
+	if (target_build_variant_user() && mmc_write_protect("devinfo", 1))
 	{
 		dprintf(INFO, "Failed to write protect dev info\n");
 		ASSERT(0);
@@ -2316,19 +2315,21 @@
 		|| !strcmp(ptn->name, "persist")
 		|| !strcmp(ptn->name, "recoveryfs")
 		|| !strcmp(ptn->name, "modem"))
-	{
-		if (memcmp((void *)data, UBI_MAGIC, UBI_MAGIC_SIZE))
-			extra = 1;
-		else
-			extra = 0;
-	}
+		extra = 1;
 	else
 		sz = ROUND_TO_PAGE(sz, page_mask);
 
 	dprintf(INFO, "writing %d bytes to '%s'\n", sz, ptn->name);
-	if (flash_write(ptn, extra, data, sz)) {
-		fastboot_fail("flash write failure");
-		return;
+	if (!memcmp((void *)data, UBI_MAGIC, UBI_MAGIC_SIZE)) {
+		if (flash_ubi_img(ptn, data, sz)) {
+			fastboot_fail("flash write failure");
+			return;
+		}
+	} else {
+		if (flash_write(ptn, extra, data, sz)) {
+			fastboot_fail("flash write failure");
+			return;
+		}
 	}
 	dprintf(INFO, "partition '%s' updated\n", ptn->name);
 	fastboot_okay("");
diff --git a/arch/arm/cache-ops.S b/arch/arm/cache-ops.S
index 22d9a2b..cfcbaa4 100644
--- a/arch/arm/cache-ops.S
+++ b/arch/arm/cache-ops.S
@@ -328,6 +328,7 @@
 
 	/* void arch_flush_invalidate_cache_range(addr_t start, size_t len); */
 FUNCTION(arch_clean_invalidate_cache_range)
+	dsb
 	add 	r2, r0, r1					// Calculate the end address
 	bic 	r0,#(CACHE_LINE-1)			// Align start with cache line
 0:
diff --git a/dev/fbcon/fbcon.c b/dev/fbcon/fbcon.c
index e95036e..ce79a3e 100644
--- a/dev/fbcon/fbcon.c
+++ b/dev/fbcon/fbcon.c
@@ -2,7 +2,7 @@
  * Copyright (c) 2008, Google Inc.
  * All rights reserved.
  *
- * Copyright (c) 2009-2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2009-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
@@ -35,6 +35,7 @@
 #include <splash.h>
 #include <platform.h>
 #include <string.h>
+#include <arch/ops.h>
 
 #include "font5x12.h"
 
@@ -300,6 +301,8 @@
 			memcpy (config->base + ((image_base + (i * (config->width))) * bytes_per_bpp),
 				logo_base + (i * pitch * bytes_per_bpp), width * bytes_per_bpp);
 		}
+		/* Flush the contents to memory before giving the data to dma */
+		arch_clean_invalidate_cache_range((addr_t) config->base, (total_x * total_y * bytes_per_bpp));
 	}
 
 	fbcon_flush();
@@ -323,6 +326,8 @@
 				(header->height * bytes_per_bpp));
 		}
 	}
+	/* Flush the contents to memory before giving the data to dma */
+	arch_clean_invalidate_cache_range((addr_t) config->base, (total_x * total_y * bytes_per_bpp));
 	fbcon_flush();
 #endif
 }
diff --git a/dev/gcdb/display/include/panel.h b/dev/gcdb/display/include/panel.h
index f015aae..913bafb 100755
--- a/dev/gcdb/display/include/panel.h
+++ b/dev/gcdb/display/include/panel.h
@@ -149,6 +149,7 @@
 	uint8_t lane1_state;
 	uint8_t lane2_state;
 	uint8_t lane3_state;
+	uint8_t force_clk_lane_hs;
 };
 
 struct panel_timing {
diff --git a/dev/gcdb/display/include/panel_generic_720p_cmd.h b/dev/gcdb/display/include/panel_generic_720p_cmd.h
index 8320407..8e9ccd4 100644
--- a/dev/gcdb/display/include/panel_generic_720p_cmd.h
+++ b/dev/gcdb/display/include/panel_generic_720p_cmd.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -151,7 +151,7 @@
 /*---------------------------------------------------------------------------*/
 
 static struct lane_configuration generic_720p_cmd_lane_config = {
-  4, 0, 1, 1, 1, 1
+  4, 0, 1, 1, 1, 1, 0
 };
 
 
diff --git a/dev/gcdb/display/include/panel_hx8279a_wsvga_video.h b/dev/gcdb/display/include/panel_hx8279a_wsvga_video.h
index 7db42fd..b465b78 100644
--- a/dev/gcdb/display/include/panel_hx8279a_wsvga_video.h
+++ b/dev/gcdb/display/include/panel_hx8279a_wsvga_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -1115,7 +1115,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration hx8279a_wsvga_video_lane_config = {
-	4, 0, 1, 1, 1, 1
+	4, 0, 1, 1, 1, 1, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_hx8379a_fwvga_skua_video.h b/dev/gcdb/display/include/panel_hx8379a_fwvga_skua_video.h
index f4b5ff5..160a2a2 100644
--- a/dev/gcdb/display/include/panel_hx8379a_fwvga_skua_video.h
+++ b/dev/gcdb/display/include/panel_hx8379a_fwvga_skua_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -208,7 +208,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration hx8379a_fwvga_skua_video_lane_config = {
-	2, 0, 1, 1, 0, 0
+	2, 0, 1, 1, 0, 0, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_hx8379a_fwvga_video.h b/dev/gcdb/display/include/panel_hx8379a_fwvga_video.h
index b11b9b4..7b43162 100755
--- a/dev/gcdb/display/include/panel_hx8379a_fwvga_video.h
+++ b/dev/gcdb/display/include/panel_hx8379a_fwvga_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -206,7 +206,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration hx8379a_fwvga_video_lane_config = {
-	2, 1, 1, 1, 0, 0
+	2, 1, 1, 1, 0, 0, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_hx8379a_truly_fwvga_video.h b/dev/gcdb/display/include/panel_hx8379a_truly_fwvga_video.h
index 528cb26..e96f540 100755
--- a/dev/gcdb/display/include/panel_hx8379a_truly_fwvga_video.h
+++ b/dev/gcdb/display/include/panel_hx8379a_truly_fwvga_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -117,7 +117,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration hx8379a_truly_fwvga_video_lane_config = {
-	2, 0, 1, 1, 0, 0 /* 4, 0, 1, 1, 1, 1 */
+	2, 0, 1, 1, 0, 0, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_hx8379a_wvga_video.h b/dev/gcdb/display/include/panel_hx8379a_wvga_video.h
index ff6133d..12db690 100644
--- a/dev/gcdb/display/include/panel_hx8379a_wvga_video.h
+++ b/dev/gcdb/display/include/panel_hx8379a_wvga_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -243,7 +243,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration hx8379a_wvga_video_lane_config = {
-	2, 1, 1, 1, 0, 0
+	2, 1, 1, 1, 0, 0, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_hx8379c_fwvga_video.h b/dev/gcdb/display/include/panel_hx8379c_fwvga_video.h
index 8fe36af..d261148 100644
--- a/dev/gcdb/display/include/panel_hx8379c_fwvga_video.h
+++ b/dev/gcdb/display/include/panel_hx8379c_fwvga_video.h
@@ -226,7 +226,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration hx8379c_fwvga_video_lane_config = {
-	2, 0, 1, 1, 0, 0
+	2, 0, 1, 1, 0, 0, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_hx8389b_qhd_video.h b/dev/gcdb/display/include/panel_hx8389b_qhd_video.h
index 577918d..db6bfa0 100755
--- a/dev/gcdb/display/include/panel_hx8389b_qhd_video.h
+++ b/dev/gcdb/display/include/panel_hx8389b_qhd_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -255,7 +255,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration hx8389b_qhd_video_lane_config = {
-	2, 1, 1, 1, 0, 0
+	2, 1, 1, 1, 0, 0, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_hx8394a_720p_video.h b/dev/gcdb/display/include/panel_hx8394a_720p_video.h
index 2bf8c69..32bb066 100644
--- a/dev/gcdb/display/include/panel_hx8394a_720p_video.h
+++ b/dev/gcdb/display/include/panel_hx8394a_720p_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -242,7 +242,7 @@
 /*---------------------------------------------------------------------------*/
 
 static struct lane_configuration hx8394a_720p_video_lane_config = {
-  4, 0, 1, 1, 1, 1
+  4, 0, 1, 1, 1, 1, 0
 };
 
 
diff --git a/dev/gcdb/display/include/panel_hx8394d_720p_video.h b/dev/gcdb/display/include/panel_hx8394d_720p_video.h
index 3db296d..3ab32f8 100644
--- a/dev/gcdb/display/include/panel_hx8394d_720p_video.h
+++ b/dev/gcdb/display/include/panel_hx8394d_720p_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -248,7 +248,7 @@
 /*---------------------------------------------------------------------------*/
 
 static struct lane_configuration hx8394d_720p_video_lane_config = {
-  4, 0, 1, 1, 1, 1
+  4, 0, 1, 1, 1, 1, 0
 };
 
 
diff --git a/dev/gcdb/display/include/panel_ili9806e_fwvga_video.h b/dev/gcdb/display/include/panel_ili9806e_fwvga_video.h
index 0d70b2e..c4941c5 100644
--- a/dev/gcdb/display/include/panel_ili9806e_fwvga_video.h
+++ b/dev/gcdb/display/include/panel_ili9806e_fwvga_video.h
@@ -782,7 +782,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration ili9806e_fwvga_video_lane_config = {
-	2, 0, 1, 1, 0, 0
+	2, 0, 1, 1, 0, 0, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_innolux_720p_video.h b/dev/gcdb/display/include/panel_innolux_720p_video.h
index 8bd4680..ca50810 100644
--- a/dev/gcdb/display/include/panel_innolux_720p_video.h
+++ b/dev/gcdb/display/include/panel_innolux_720p_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -948,7 +948,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration innolux_720p_video_lane_config = {
-	4, 0, 1, 1, 1, 1
+	4, 0, 1, 1, 1, 1, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_jdi_1080p_video.h b/dev/gcdb/display/include/panel_jdi_1080p_video.h
index 2dbc2ba..add8e55 100755
--- a/dev/gcdb/display/include/panel_jdi_1080p_video.h
+++ b/dev/gcdb/display/include/panel_jdi_1080p_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -141,7 +141,7 @@
 /*---------------------------------------------------------------------------*/
 
 static struct lane_configuration jdi_1080p_video_lane_config = {
-  4, 0, 1, 1, 1, 1
+  4, 0, 1, 1, 1, 1, 0
 };
 
 
diff --git a/dev/gcdb/display/include/panel_jdi_4k_dualdsi_video.h b/dev/gcdb/display/include/panel_jdi_4k_dualdsi_video.h
index 8194916..8cfee8e 100644
--- a/dev/gcdb/display/include/panel_jdi_4k_dualdsi_video.h
+++ b/dev/gcdb/display/include/panel_jdi_4k_dualdsi_video.h
@@ -147,7 +147,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration jdi_4k_dualdsi_video_lane_config = {
-	4, 0, 1, 1, 1, 1
+	4, 0, 1, 1, 1, 1, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_jdi_fhd_video.h b/dev/gcdb/display/include/panel_jdi_fhd_video.h
index a301056..9405223 100644
--- a/dev/gcdb/display/include/panel_jdi_fhd_video.h
+++ b/dev/gcdb/display/include/panel_jdi_fhd_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -184,7 +184,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration jdi_fhd_video_lane_config = {
-	4, 0, 1, 1, 1, 1
+	4, 0, 1, 1, 1, 1, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_jdi_qhd_dualdsi_cmd.h b/dev/gcdb/display/include/panel_jdi_qhd_dualdsi_cmd.h
index 31b18f5..a0686d3 100644
--- a/dev/gcdb/display/include/panel_jdi_qhd_dualdsi_cmd.h
+++ b/dev/gcdb/display/include/panel_jdi_qhd_dualdsi_cmd.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -185,7 +185,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration jdi_qhd_dualdsi_cmd_lane_config = {
-	4, 0, 1, 1, 1, 1
+	4, 0, 1, 1, 1, 1, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_jdi_qhd_dualdsi_video.h b/dev/gcdb/display/include/panel_jdi_qhd_dualdsi_video.h
index bd5ae6d..79acd3f 100644
--- a/dev/gcdb/display/include/panel_jdi_qhd_dualdsi_video.h
+++ b/dev/gcdb/display/include/panel_jdi_qhd_dualdsi_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -196,7 +196,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration jdi_qhd_dualdsi_video_lane_config = {
-	4, 0, 1, 1, 1, 1
+	4, 0, 1, 1, 1, 1, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_nt35521_720p_video.h b/dev/gcdb/display/include/panel_nt35521_720p_video.h
index c5f9069..810fb6a 100644
--- a/dev/gcdb/display/include/panel_nt35521_720p_video.h
+++ b/dev/gcdb/display/include/panel_nt35521_720p_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -1443,7 +1443,7 @@
 /*---------------------------------------------------------------------------*/
 
 static struct lane_configuration nt35521_720p_video_lane_config = {
-  4, 0, 1, 1, 1, 1
+  4, 0, 1, 1, 1, 1, 0
 };
 
 
diff --git a/dev/gcdb/display/include/panel_nt35521_wxga_video.h b/dev/gcdb/display/include/panel_nt35521_wxga_video.h
index bdac711..2195176 100644
--- a/dev/gcdb/display/include/panel_nt35521_wxga_video.h
+++ b/dev/gcdb/display/include/panel_nt35521_wxga_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -1002,7 +1002,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration nt35521_wxga_video_lane_config = {
-	4, 0, 1, 1, 1, 1
+	4, 0, 1, 1, 1, 1, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_nt35590_720p_cmd.h b/dev/gcdb/display/include/panel_nt35590_720p_cmd.h
index 72f5a18..6894e96 100755
--- a/dev/gcdb/display/include/panel_nt35590_720p_cmd.h
+++ b/dev/gcdb/display/include/panel_nt35590_720p_cmd.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -2900,7 +2900,7 @@
 /*---------------------------------------------------------------------------*/
 
 static struct lane_configuration nt35590_720p_cmd_lane_config = {
-  4, 0, 1, 1, 1, 1
+  4, 0, 1, 1, 1, 1, 0
 };
 
 
diff --git a/dev/gcdb/display/include/panel_nt35590_720p_video.h b/dev/gcdb/display/include/panel_nt35590_720p_video.h
index b935482..b812ef0 100755
--- a/dev/gcdb/display/include/panel_nt35590_720p_video.h
+++ b/dev/gcdb/display/include/panel_nt35590_720p_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -2913,7 +2913,7 @@
 /*---------------------------------------------------------------------------*/
 
 static struct lane_configuration nt35590_720p_video_lane_config = {
-  4, 0, 1, 1, 1, 1
+  4, 0, 1, 1, 1, 1, 0
 };
 
 
diff --git a/dev/gcdb/display/include/panel_nt35590_qvga_cmd.h b/dev/gcdb/display/include/panel_nt35590_qvga_cmd.h
index 2a8b91f..a6854f8 100644
--- a/dev/gcdb/display/include/panel_nt35590_qvga_cmd.h
+++ b/dev/gcdb/display/include/panel_nt35590_qvga_cmd.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -2907,7 +2907,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration nt35590_qvga_cmd_lane_config = {
-	1, 0, 1, 0, 0, 0
+	1, 0, 1, 0, 0, 0, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_nt35596_1080p_skuk_video.h b/dev/gcdb/display/include/panel_nt35596_1080p_skuk_video.h
index 2cd3d07..b514c96 100644
--- a/dev/gcdb/display/include/panel_nt35596_1080p_skuk_video.h
+++ b/dev/gcdb/display/include/panel_nt35596_1080p_skuk_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -2988,7 +2988,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration nt35596_1080p_skuk_video_lane_config = {
-	4, 0, 1, 1, 1, 1
+	4, 0, 1, 1, 1, 1, 1
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_nt35596_1080p_video.h b/dev/gcdb/display/include/panel_nt35596_1080p_video.h
index 0c32667..57f6b4c 100644
--- a/dev/gcdb/display/include/panel_nt35596_1080p_video.h
+++ b/dev/gcdb/display/include/panel_nt35596_1080p_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -3236,7 +3236,7 @@
 /*---------------------------------------------------------------------------*/
 
 static struct lane_configuration nt35596_1080p_video_lane_config = {
-  4, 0, 1, 1, 1, 1
+  4, 0, 1, 1, 1, 1, 0
 };
 
 
diff --git a/dev/gcdb/display/include/panel_nt35597_wqxga_cmd.h b/dev/gcdb/display/include/panel_nt35597_wqxga_cmd.h
index e6fac4a..6e957be 100644
--- a/dev/gcdb/display/include/panel_nt35597_wqxga_cmd.h
+++ b/dev/gcdb/display/include/panel_nt35597_wqxga_cmd.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -206,7 +206,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration nt35597_wqxga_cmd_lane_config = {
-	4, 0, 1, 1, 1, 1
+	4, 0, 1, 1, 1, 1, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_nt35597_wqxga_video.h b/dev/gcdb/display/include/panel_nt35597_wqxga_video.h
index 7912ba8..d2f34d8 100644
--- a/dev/gcdb/display/include/panel_nt35597_wqxga_video.h
+++ b/dev/gcdb/display/include/panel_nt35597_wqxga_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -194,7 +194,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration nt35597_wqxga_video_lane_config = {
-	4, 0, 1, 1, 1, 1
+	4, 0, 1, 1, 1, 1, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_otm1283a_720p_video.h b/dev/gcdb/display/include/panel_otm1283a_720p_video.h
index ec44928..a7b6c96 100755
--- a/dev/gcdb/display/include/panel_otm1283a_720p_video.h
+++ b/dev/gcdb/display/include/panel_otm1283a_720p_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -930,7 +930,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration otm1283a_720p_video_lane_config = {
-	4, 0, 1, 1, 1, 1
+	4, 0, 1, 1, 1, 1, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_otm8018b_fwvga_video.h b/dev/gcdb/display/include/panel_otm8018b_fwvga_video.h
index 7fa9098..caaf38a 100755
--- a/dev/gcdb/display/include/panel_otm8018b_fwvga_video.h
+++ b/dev/gcdb/display/include/panel_otm8018b_fwvga_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -652,7 +652,7 @@
 /*---------------------------------------------------------------------------*/
 
 static struct lane_configuration otm8018b_fwvga_video_lane_config = {
-  2, 1, 1, 1, 0, 0
+  2, 1, 1, 1, 0, 0, 0
 };
 
 
diff --git a/dev/gcdb/display/include/panel_otm8019a_fwvga_video.h b/dev/gcdb/display/include/panel_otm8019a_fwvga_video.h
index 235057e..c88fbc3 100755
--- a/dev/gcdb/display/include/panel_otm8019a_fwvga_video.h
+++ b/dev/gcdb/display/include/panel_otm8019a_fwvga_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -786,7 +786,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration otm8019a_fwvga_video_lane_config = {
-	2, 1, 1, 1, 0, 0
+	2, 1, 1, 1, 0, 0, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_r61318_hd_video.h b/dev/gcdb/display/include/panel_r61318_hd_video.h
index b1dc22c..72c27c2 100644
--- a/dev/gcdb/display/include/panel_r61318_hd_video.h
+++ b/dev/gcdb/display/include/panel_r61318_hd_video.h
@@ -265,7 +265,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration r61318_hd_video_lane_config = {
-	4, 0, 1, 1, 1, 1
+	4, 0, 1, 1, 1, 1, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_samsung_wxga_video.h b/dev/gcdb/display/include/panel_samsung_wxga_video.h
index 20f2714..e01b562 100644
--- a/dev/gcdb/display/include/panel_samsung_wxga_video.h
+++ b/dev/gcdb/display/include/panel_samsung_wxga_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -196,7 +196,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration samsung_wxga_video_lane_config = {
-	4, 0, 1, 1, 1, 1
+	4, 0, 1, 1, 1, 1, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_sharp_qhd_video.h b/dev/gcdb/display/include/panel_sharp_qhd_video.h
index 6bd23ce..00f0147 100755
--- a/dev/gcdb/display/include/panel_sharp_qhd_video.h
+++ b/dev/gcdb/display/include/panel_sharp_qhd_video.h
@@ -144,7 +144,7 @@
 /*---------------------------------------------------------------------------*/
 
 static struct lane_configuration sharp_qhd_video_lane_config = {
-  2, 0, 1, 1, 0, 0
+  2, 0, 1, 1, 0, 0, 0
 };
 
 
diff --git a/dev/gcdb/display/include/panel_sharp_wqxga_dualdsi_video.h b/dev/gcdb/display/include/panel_sharp_wqxga_dualdsi_video.h
index 312b939..a1b57d3 100644
--- a/dev/gcdb/display/include/panel_sharp_wqxga_dualdsi_video.h
+++ b/dev/gcdb/display/include/panel_sharp_wqxga_dualdsi_video.h
@@ -119,7 +119,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration sharp_wqxga_dualdsi_video_lane_config = {
-	4, 0, 1, 1, 1, 1
+	4, 0, 1, 1, 1, 1, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_ssd2080m_720p_video.h b/dev/gcdb/display/include/panel_ssd2080m_720p_video.h
index 7a1c8e5..74bfd7b 100755
--- a/dev/gcdb/display/include/panel_ssd2080m_720p_video.h
+++ b/dev/gcdb/display/include/panel_ssd2080m_720p_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -457,7 +457,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration ssd2080m_720p_video_lane_config = {
-	4, 0, 1, 1, 1, 1
+	4, 0, 1, 1, 1, 1, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_toshiba_720p_video.h b/dev/gcdb/display/include/panel_toshiba_720p_video.h
index 7b16246..12c6326 100755
--- a/dev/gcdb/display/include/panel_toshiba_720p_video.h
+++ b/dev/gcdb/display/include/panel_toshiba_720p_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -309,7 +309,7 @@
 /*---------------------------------------------------------------------------*/
 
 static struct lane_configuration toshiba_720p_video_lane_config = {
-  4, 0, 1, 1, 1, 1
+  4, 0, 1, 1, 1, 1, 0
 };
 
 
diff --git a/dev/gcdb/display/include/panel_truly_wvga_cmd.h b/dev/gcdb/display/include/panel_truly_wvga_cmd.h
index 1addcce..89a9994 100644
--- a/dev/gcdb/display/include/panel_truly_wvga_cmd.h
+++ b/dev/gcdb/display/include/panel_truly_wvga_cmd.h
@@ -413,7 +413,7 @@
 /* Lane configuration                                                        */
 /*---------------------------------------------------------------------------*/
 static struct lane_configuration truly_wvga_cmd_lane_config = {
-	2, 0, 1, 1, 0, 0
+	2, 0, 1, 1, 0, 0, 0
 };
 
 /*---------------------------------------------------------------------------*/
diff --git a/dev/gcdb/display/include/panel_truly_wvga_video.h b/dev/gcdb/display/include/panel_truly_wvga_video.h
index ee1ab28..18ee099 100644
--- a/dev/gcdb/display/include/panel_truly_wvga_video.h
+++ b/dev/gcdb/display/include/panel_truly_wvga_video.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -291,7 +291,7 @@
 /*---------------------------------------------------------------------------*/
 
 static struct lane_configuration truly_wvga_video_lane_config = {
-  2, 0, 1, 1, 0, 0
+  2, 0, 1, 1, 0, 0, 0
 };
 
 
diff --git a/dev/gcdb/display/panel_display.c b/dev/gcdb/display/panel_display.c
index 24e1837..d2675dc 100755
--- a/dev/gcdb/display/panel_display.c
+++ b/dev/gcdb/display/panel_display.c
@@ -217,6 +217,7 @@
 	pinfo->mipi.data_lane2 = pstruct->laneconfig->lane2_state;
 	pinfo->mipi.data_lane3 = pstruct->laneconfig->lane3_state;
 	pinfo->mipi.lane_swap = pstruct->laneconfig->dsi_lanemap;
+	pinfo->mipi.force_clk_lane_hs = pstruct->laneconfig->force_clk_lane_hs;
 
 	pinfo->mipi.t_clk_post = pstruct->paneltiminginfo->tclk_post;
 	pinfo->mipi.t_clk_pre = pstruct->paneltiminginfo->tclk_pre;
diff --git a/include/dev/flash-ubi.h b/include/dev/flash-ubi.h
new file mode 100644
index 0000000..50577cc
--- /dev/null
+++ b/include/dev/flash-ubi.h
@@ -0,0 +1,158 @@
+/* Copyright (c) 2014-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 _FLASH_UBI_H_
+#define _FLASH_UBI_H_
+
+#include <sys/types.h>
+#include <lib/ptable.h>
+#include <stdint.h>
+
+struct __attribute__ ((packed)) ubifs_ch {
+	uint32_t magic;
+	uint32_t crc;
+	uint64_t sqnum;
+	uint32_t len;
+#define UBIFS_SB_NODE	6
+	uint8_t node_type;
+	uint8_t group_type;
+	uint8_t padding[2];
+};
+
+/* UBIFS superblock node */
+struct __attribute__ ((packed)) ubifs_sb_node {
+	struct ubifs_ch ch;
+	uint8_t padding[2];
+	uint8_t key_hash;
+	uint8_t key_fmt;
+#define UBIFS_FLG_SPACE_FIXUP  0x04
+	uint32_t flags;
+	uint32_t min_io_size;
+	uint32_t leb_size;
+	uint32_t leb_cnt;
+	uint32_t max_leb_cnt;
+	uint64_t max_bud_bytes;
+	uint32_t log_lebs;
+	uint32_t lpt_lebs;
+	uint32_t orph_lebs;
+	uint32_t jhead_cnt;
+	uint32_t fanout;
+	uint32_t lsave_cnt;
+	uint32_t fmt_version;
+	uint16_t default_compr;
+	uint8_t padding1[2];
+	uint32_t rp_uid;
+	uint32_t rp_gid;
+	uint64_t rp_size;
+	uint32_t time_gran;
+	uint8_t uuid[16];
+	uint32_t ro_compat_version;
+	uint8_t padding2[3968];
+};
+
+/* Erase counter header magic number (ASCII "UBI#") */
+#define UBI_EC_HDR_MAGIC  0x55424923
+
+#define UBI_MAGIC      "UBI#"
+#define UBI_MAGIC_SIZE 0x04
+
+#define UBI_VERSION 1
+#define UBI_MAX_ERASECOUNTER 0x7FFFFFFF
+#define UBI_IMAGE_SEQ_BASE 0x12345678
+#define UBI_DEF_ERACE_COUNTER 0
+#define UBI_CRC32_INIT 0xFFFFFFFFU
+#define UBIFS_CRC32_INIT 0xFFFFFFFFU
+
+/* Erase counter header fields */
+struct __attribute__ ((packed)) ubi_ec_hdr {
+	uint32_t  magic;
+	uint8_t   version;
+	uint8_t   padding1[3];
+	uint64_t  ec; /* Warning: the current limit is 31-bit anyway! */
+	uint32_t  vid_hdr_offset;
+	uint32_t  data_offset;
+	uint32_t  image_seq;
+	uint8_t   padding2[32];
+	uint32_t  hdr_crc;
+};
+
+/* Volume identifier header fields */
+struct __attribute__ ((packed)) ubi_vid_hdr {
+	uint32_t  magic;
+	uint8_t    version;
+	uint8_t    vol_type;
+	uint8_t    copy_flag;
+	uint8_t    compat;
+	uint32_t  vol_id;
+	uint32_t  lnum;
+	uint8_t    padding1[4];
+	uint32_t  data_size;
+	uint32_t  used_ebs;
+	uint32_t  data_pad;
+	uint32_t  data_crc;
+	uint8_t    padding2[4];
+	uint64_t  sqnum;
+	uint8_t    padding3[12];
+	uint32_t  hdr_crc;
+};
+
+#define UBI_EC_HDR_SIZE  sizeof(struct ubi_ec_hdr)
+#define UBI_VID_HDR_SIZE  sizeof(struct ubi_vid_hdr)
+#define UBI_EC_HDR_SIZE_CRC  (UBI_EC_HDR_SIZE  - sizeof(uint32_t))
+#define UBI_VID_HDR_SIZE_CRC (UBI_VID_HDR_SIZE - sizeof(uint32_t))
+
+#define UBI_MAX_VOLUMES 128
+#define UBI_INTERNAL_VOL_START (0x7FFFFFFF - 4096)
+#define UBI_LAYOUT_VOLUME_ID     UBI_INTERNAL_VOL_START
+#define UBI_FM_SB_VOLUME_ID	(UBI_INTERNAL_VOL_START + 1)
+
+/**
+ * struct ubi_scan_info - UBI scanning information.
+ * @ec: erase counters or eraseblock status for all eraseblocks
+ * @mean_ec: mean erase counter
+ * @bad_cnt: count of bad eraseblocks
+ * @good_cnt: count of non-bad eraseblocks
+ * @empty_cnt: count of empty eraseblocks
+ * @vid_hdr_offs: volume ID header offset from the found EC headers (%-1 means
+ *                undefined)
+ * @data_offs: data offset from the found EC headers (%-1 means undefined)
+ * @image_seq: image sequence
+ */
+struct ubi_scan_info {
+	uint64_t *ec;
+	uint64_t mean_ec;
+	int bad_cnt;
+	int good_cnt;
+	int empty_cnt;
+	unsigned vid_hdr_offs;
+	unsigned data_offs;
+	uint32_t  image_seq;
+};
+
+int flash_ubi_img(struct ptentry *ptn, void *data, unsigned size);
+#endif
diff --git a/include/target.h b/include/target.h
index 4a2891c..772afdf 100644
--- a/include/target.h
+++ b/include/target.h
@@ -85,4 +85,5 @@
 void ulpi_write(unsigned val, unsigned reg);
 void target_crypto_init_params(void);
 int target_cont_splash_screen(void);
+bool target_build_variant_user();
 #endif
diff --git a/platform/apq8084/include/platform/iomap.h b/platform/apq8084/include/platform/iomap.h
index d5201bd..fe66038 100644
--- a/platform/apq8084/include/platform/iomap.h
+++ b/platform/apq8084/include/platform/iomap.h
@@ -228,6 +228,7 @@
 #define COMMAND_MODE_MDP_STREAM1_TOTAL  0x064
 #define ERR_INT_MASK0               0x10C
 
+#define LANE_CTL                    0x0AC
 #define LANE_SWAP_CTL               0x0B0
 #define TIMING_CTL                  0x0C4
 
diff --git a/platform/fsm9010/include/platform/iomap.h b/platform/fsm9010/include/platform/iomap.h
index bfd31df..68ebd32 100644
--- a/platform/fsm9010/include/platform/iomap.h
+++ b/platform/fsm9010/include/platform/iomap.h
@@ -230,4 +230,7 @@
 #define CM_DWC_USB3_CM_DWC_USB3_BASE 0xFCA10000
 #define AHB2PHY_AHB2PHY_BASE         0xFCA06000
 
+#define QMP_PHY_BASE                 0xF9B38000
+#define PLATFORM_QMP_OFFSET          0x8
+
 #endif
diff --git a/platform/init.c b/platform/init.c
index aeb4f20..34c5726 100644
--- a/platform/init.c
+++ b/platform/init.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2008 Travis Geiselbrecht
  *
- * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 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
@@ -140,3 +140,8 @@
 {
 	return 0;
 }
+
+__WEAK uint32_t use_hsonly_mode()
+{
+	return 0;
+}
diff --git a/platform/msm8226/include/platform/iomap.h b/platform/msm8226/include/platform/iomap.h
index 8d728ca..4efca64 100644
--- a/platform/msm8226/include/platform/iomap.h
+++ b/platform/msm8226/include/platform/iomap.h
@@ -202,6 +202,7 @@
 #define COMMAND_MODE_MDP_STREAM1_TOTAL  0x064
 #define ERR_INT_MASK0               0x10C
 
+#define LANE_CTL                    0x0AC
 #define LANE_SWAP_CTL               0x0B0
 #define TIMING_CTL                  0x0C4
 
diff --git a/platform/msm8610/include/platform/iomap.h b/platform/msm8610/include/platform/iomap.h
index 65f5dc6..4605314 100644
--- a/platform/msm8610/include/platform/iomap.h
+++ b/platform/msm8610/include/platform/iomap.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
  *
  * Copyright (c) 2008, Google Inc.
  * All rights reserved.
@@ -183,6 +183,7 @@
 #define ERR_INT_MASK0               0x108
 #define RDBK_DATA0                  0x068
 
+#define LANE_CTL                    0x0A8
 #define LANE_SWAP_CTL               0x0AC
 #define TIMING_CTL                  0x0C0
 
diff --git a/platform/msm8909/include/platform/iomap.h b/platform/msm8909/include/platform/iomap.h
index 6411e3a..e2a66fe 100644
--- a/platform/msm8909/include/platform/iomap.h
+++ b/platform/msm8909/include/platform/iomap.h
@@ -247,6 +247,7 @@
 #define COMMAND_MODE_MDP_STREAM1_TOTAL  0x064
 #define ERR_INT_MASK0               0x10C
 
+#define LANE_CTL                    0x0AC
 #define LANE_SWAP_CTL               0x0B0
 #define TIMING_CTL                  0x0C4
 
diff --git a/platform/msm8909/platform.c b/platform/msm8909/platform.c
index 83f9060..97c6838 100644
--- a/platform/msm8909/platform.c
+++ b/platform/msm8909/platform.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-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
@@ -195,6 +195,7 @@
 		case MSM8209:
 		case MSM8208:
 		case APQ8009:
+		case MSM8609:
 			ret = 1;
 			break;
 		default:
diff --git a/platform/msm8916/include/platform/iomap.h b/platform/msm8916/include/platform/iomap.h
index c6780dd..fd56c0e 100644
--- a/platform/msm8916/include/platform/iomap.h
+++ b/platform/msm8916/include/platform/iomap.h
@@ -241,6 +241,7 @@
 #define COMMAND_MODE_MDP_STREAM1_TOTAL  0x064
 #define ERR_INT_MASK0               0x10C
 
+#define LANE_CTL                    0x0AC
 #define LANE_SWAP_CTL               0x0B0
 #define TIMING_CTL                  0x0C4
 
diff --git a/platform/msm8974/include/platform/iomap.h b/platform/msm8974/include/platform/iomap.h
index 1d2ad92..ccb086f 100644
--- a/platform/msm8974/include/platform/iomap.h
+++ b/platform/msm8974/include/platform/iomap.h
@@ -251,6 +251,7 @@
 #define COMMAND_MODE_MDP_STREAM1_TOTAL  0x064
 #define ERR_INT_MASK0               0x10C
 
+#define LANE_CTL                    0x0AC
 #define LANE_SWAP_CTL               0x0B0
 #define TIMING_CTL                  0x0C4
 
diff --git a/platform/msm8994/include/platform/iomap.h b/platform/msm8994/include/platform/iomap.h
index 28ae75a..bb9709f 100644
--- a/platform/msm8994/include/platform/iomap.h
+++ b/platform/msm8994/include/platform/iomap.h
@@ -545,6 +545,7 @@
 #define COMMAND_MODE_MDP_STREAM1_TOTAL  0x064
 #define ERR_INT_MASK0               0x10C
 
+#define LANE_CTL                    0x0AC
 #define LANE_SWAP_CTL               0x0B0
 #define TIMING_CTL                  0x0C4
 
diff --git a/platform/msm_shared/crypto5_eng.c b/platform/msm_shared/crypto5_eng.c
index 0f592f9..8caad79 100644
--- a/platform/msm_shared/crypto5_eng.c
+++ b/platform/msm_shared/crypto5_eng.c
@@ -139,6 +139,8 @@
 #else
 	ret = (uint32_t)bam_add_cmd_element(&cmd_list_ptr, reg_addr, val, CE_WRITE_TYPE);
 
+	arch_clean_invalidate_cache_range((addr_t)&cmd_list_ptr, sizeof(struct cmd_element));
+
 	/* Enqueue the desc for the above command */
 	ret = bam_add_one_desc(bam_core,
 						   CRYPTO_WRITE_PIPE_INDEX,
diff --git a/platform/msm_shared/dme.c b/platform/msm_shared/dme.c
index bac0cdb..e128453 100644
--- a/platform/msm_shared/dme.c
+++ b/platform/msm_shared/dme.c
@@ -138,7 +138,7 @@
 	req_upiu.idn           = query->idn;
 	req_upiu.trans_type    = UPIU_TYPE_QUERY_REQ;
 	req_upiu.dd            = UTRD_NO_DATA_TRANSFER;
-	req_upiu.resp_ptr      = (struct upiu_basic_hdr *) &resp_upiu;
+	req_upiu.resp_ptr      = (struct upiu_basic_resp_hdr *) &resp_upiu;
 	req_upiu.resp_len      = sizeof(resp_upiu);
 	req_upiu.resp_data_ptr = query->buf;
 	req_upiu.timeout_msecs = UTP_GENERIC_CMD_TIMEOUT;
@@ -504,7 +504,7 @@
 int dme_send_nop_query(struct ufs_dev *dev)
 {
 	struct upiu_req_build_type     req_upiu;
-	struct upiu_basic_hdr          resp_upiu;
+	struct upiu_basic_resp_hdr     resp_upiu;
 	int                            ret;
 	unsigned                       try_again;
 
diff --git a/platform/msm_shared/flash-ubi.c b/platform/msm_shared/flash-ubi.c
new file mode 100644
index 0000000..0051a3a
--- /dev/null
+++ b/platform/msm_shared/flash-ubi.c
@@ -0,0 +1,615 @@
+/* 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 <string.h>
+#include <dev/flash-ubi.h>
+#include <dev/flash.h>
+#include <qpic_nand.h>
+#include <rand.h>
+
+static
+const uint32_t crc32_table[256] = {
+	0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
+	0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
+	0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
+	0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
+	0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
+	0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
+	0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
+	0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
+	0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
+	0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
+	0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
+	0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
+	0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
+	0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
+	0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
+	0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
+	0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
+	0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
+	0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
+	0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
+	0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
+	0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
+	0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
+	0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
+	0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
+	0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
+	0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
+	0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
+	0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
+	0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
+	0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
+	0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
+	0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
+	0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
+	0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
+	0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
+	0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
+	0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
+	0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
+	0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
+	0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
+	0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
+	0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
+	0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
+	0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
+	0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
+	0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
+	0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
+	0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
+	0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
+	0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
+	0x2d02ef8dL
+};
+
+static uint32_t mtd_crc32(uint32_t crc, const void *buf, size_t size)
+{
+	const uint8_t *p = buf;
+
+	while (size--)
+		crc = crc32_table[(crc ^ *p++) & 0xff] ^ (crc >> 8);
+	return crc;
+}
+
+/**
+ * check_pattern - check if buffer contains only a certain byte pattern.
+ * @buf: buffer to check
+ * @patt: the pattern to check
+ * @size: buffer size in bytes
+ *
+ * This function returns %1 if there are only @patt bytes in @buf, and %0 if
+ * something else was also found.
+ */
+int check_pattern(const void *buf, uint8_t patt, int size)
+{
+	int i;
+
+	for (i = 0; i < size; i++)
+		if (((const uint8_t *)buf)[i] != patt)
+			return 0;
+	return 1;
+}
+
+/**
+ * read_ec_hdr - read and check an erase counter header.
+ * @peb: number of the physical erase block to read the header for
+ * @ec_hdr: a &struct ubi_ec_hdr object where to store the read erase counter
+ * 			header
+ *
+ * This function reads erase counter header from physical eraseblock @peb and
+ * stores it in @ec_hdr. This function also checks the validity of the read
+ * header.
+ *
+ * Return codes:
+ * -1 - in case of error
+ *  0 - if PEB was found valid
+ *  1 - if PEB is empty
+ */
+static int read_ec_hdr(uint32_t peb, struct ubi_ec_hdr *ec_hdr)
+{
+	unsigned char *spare, *tmp_buf;
+	int ret = -1;
+	uint32_t crc;
+	int page_size = flash_page_size();
+	int num_pages_per_blk = flash_block_size()/page_size;
+
+	spare = (unsigned char *)malloc(flash_spare_size());
+	if (!spare)
+	{
+		dprintf(CRITICAL, "read_ec_hdr: Mem allocation failed\n");
+		return ret;
+	}
+
+	tmp_buf = (unsigned char *)malloc(page_size);
+	if (!tmp_buf)
+	{
+		dprintf(CRITICAL, "read_ec_hdr: Mem allocation failed\n");
+		goto out_tmp_buf;
+	}
+
+	if (qpic_nand_block_isbad(peb * num_pages_per_blk)) {
+		dprintf(CRITICAL, "read_ec_hdr: Bad block @ %d\n", peb);
+		goto out;
+	}
+
+	if (qpic_nand_read(peb * num_pages_per_blk, 1, tmp_buf, spare)) {
+		dprintf(CRITICAL, "read_ec_hdr: Read %d failed \n", peb);
+		goto out;
+	}
+	memcpy(ec_hdr, tmp_buf, UBI_EC_HDR_SIZE);
+
+	if (check_pattern((void *)ec_hdr, 0xFF, UBI_EC_HDR_SIZE)) {
+		ret = 1;
+		goto out;
+	}
+
+	/* Make sure we read a valid UBI EC_HEADER */
+	if (BE32(ec_hdr->magic) != (uint32_t)UBI_EC_HDR_MAGIC) {
+		dprintf(CRITICAL,
+			"read_ec_hdr: Wrong magic at peb-%d Expected: %d, received %d\n",
+			peb, UBI_EC_HDR_MAGIC, BE32(ec_hdr->magic));
+		goto out;
+	}
+
+	if (ec_hdr->version != UBI_VERSION) {
+		dprintf(CRITICAL,
+			"read_ec_hdr: Wrong version at peb-%d Expected: %d, received %d\n",
+			peb, UBI_VERSION, ec_hdr->version);
+		goto out;
+	}
+
+	if (BE64(ec_hdr->ec) > UBI_MAX_ERASECOUNTER) {
+		dprintf(CRITICAL,
+			"read_ec_hdr: Wrong ec at peb-%d: %lld \n",
+			peb, BE64(ec_hdr->ec));
+		goto out;
+	}
+
+	crc = mtd_crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC);
+	if (BE32(ec_hdr->hdr_crc) != crc) {
+		dprintf(CRITICAL,
+			"read_ec_hdr: Wrong crc at peb-%d: calculated %d, recived %d\n",
+			peb,crc,  BE32(ec_hdr->hdr_crc));
+		goto out;
+	}
+
+	ret = 0;
+out:
+	free(tmp_buf);
+out_tmp_buf:
+	free(spare);
+	return ret;
+}
+
+/**
+ * write_ec_header() - Write provided ec_header for given PEB
+ * @peb: number of the physical erase block to write the header to
+ * @new_ech: the ec_header to write
+ *
+ * Return codes:
+ * -1 - in case of error
+ *  0 - on success
+ */
+static int write_ec_header(uint32_t peb, struct ubi_ec_hdr *new_ech)
+{
+	unsigned page_size = flash_page_size();
+	int num_pages_per_blk = flash_block_size()/page_size;
+	unsigned char *buf;
+	int ret = 0;
+
+	buf = malloc(sizeof(uint8_t) * page_size);
+	if (!buf) {
+		dprintf(CRITICAL, "write_ec_header: Mem allocation failed\n");
+		return -1;
+	}
+
+	memset(buf, 0, page_size);
+	ASSERT(page_size > sizeof(*new_ech));
+	memcpy(buf, new_ech, UBI_EC_HDR_SIZE);
+	ret = qpic_nand_write(peb * num_pages_per_blk, 1, buf, 0);
+	if (ret) {
+		dprintf(CRITICAL,
+			"write_ec_header: qpic_nand_write failed with %d\n", ret);
+		ret = -1;
+		goto out;
+	}
+
+out:
+	free(buf);
+	return ret;
+}
+
+/**
+ * scan_partition() - Collect the ec_headers info of a given partition
+ * @ptn: partition to read the headers of
+ *
+ * Returns allocated and filled struct ubi_scan_info (si).
+ * Note: si should be released by caller.
+ */
+static struct ubi_scan_info *scan_partition(struct ptentry *ptn)
+{
+	struct ubi_scan_info *si;
+	struct ubi_ec_hdr *ec_hdr;
+	unsigned i, curr_peb;
+	unsigned long long sum = 0;
+	int page_size = flash_page_size();
+	int ret;
+
+	si = malloc(sizeof(*si));
+	if (!si) {
+		dprintf(CRITICAL,"scan_partition: (%s) Memory allocation failed\n",
+				ptn->name);
+		return NULL;
+	}
+
+	memset((void *)si, 0, sizeof(*si));
+	si->ec = malloc(ptn->length * sizeof(uint64_t));
+	if (!si->ec) {
+		dprintf(CRITICAL,"scan_partition: (%s) Memory allocation failed\n",
+				ptn->name);
+		goto out_failed_ec;
+	}
+	memset((void *)si->ec, 0, ptn->length * sizeof(uint64_t));
+
+	ec_hdr = malloc(UBI_EC_HDR_SIZE);
+	if (!ec_hdr) {
+		dprintf(CRITICAL,"scan_partition: (%s) Memory allocation failed\n",
+				ptn->name);
+		goto out_failed;
+	}
+
+	curr_peb = ptn->start;
+	si->vid_hdr_offs = 0;
+	si->image_seq = rand() & UBI_IMAGE_SEQ_BASE;
+
+	for (i = 0; i < ptn->length; i++){
+		ret = read_ec_hdr(curr_peb + i, ec_hdr);
+		switch (ret) {
+		case 1:
+			si->empty_cnt++;
+			si->ec[i] = UBI_MAX_ERASECOUNTER;
+			break;
+		case 0:
+			if (!si->vid_hdr_offs) {
+				si->vid_hdr_offs = BE32(ec_hdr->vid_hdr_offset);
+				si->data_offs = BE32(ec_hdr->data_offset);
+				if (!si->vid_hdr_offs || !si->data_offs ||
+					si->vid_hdr_offs % page_size ||
+					si->data_offs % page_size) {
+					si->bad_cnt++;
+					si->ec[i] = UBI_MAX_ERASECOUNTER;
+					si->vid_hdr_offs = 0;
+					continue;
+				}
+				if (BE32(ec_hdr->vid_hdr_offset) != si->vid_hdr_offs) {
+					si->bad_cnt++;
+					si->ec[i] = UBI_MAX_ERASECOUNTER;
+					continue;
+				}
+				if (BE32(ec_hdr->data_offset) != si->data_offs) {
+					si->bad_cnt++;
+					si->ec[i] = UBI_MAX_ERASECOUNTER;
+					continue;
+				}
+			}
+			si->good_cnt++;
+			si->ec[i] = BE64(ec_hdr->ec);
+			break;
+		case -1:
+		default:
+			si->bad_cnt++;
+			si->ec[i] = UBI_MAX_ERASECOUNTER;
+			break;
+		}
+	}
+
+	/*
+	 * If less then 95% of the PEBs were "bad" (didn't have valid
+	 * ec header), then set mean_ec = UBI_DEF_ERACE_COUNTER.
+	 */
+	sum = 0;
+	if (si->good_cnt && (double)(si->good_cnt / ptn->length) * 100 > 95) {
+		for (i = 0; i < ptn->length; i++) {
+			if (si->ec[i] == UBI_MAX_ERASECOUNTER)
+				continue;
+			sum += si->ec[i];
+		}
+		si->mean_ec = sum / si->good_cnt;
+	} else {
+		si->mean_ec = UBI_DEF_ERACE_COUNTER;
+	}
+	free(ec_hdr);
+	return si;
+
+out_failed:
+	free(si->ec);
+out_failed_ec:
+	free(si);
+	return NULL;
+}
+
+/**
+ * update_ec_header() - Update provided ec_header
+ * @si: pointer to struct ubi_scan_info, holding the collected
+ * 		ec_headers information of the partition
+ * @index: index in si->ec[] of this peb. Relative to ptn->start
+ * @new_header: False if this is an update of an existing header.
+ * 		True if new header needs to be filled in
+ */
+static void update_ec_header(struct ubi_ec_hdr *old_ech,
+		const struct ubi_scan_info *si,
+		int index, bool new_header)
+{
+	uint32_t crc;
+
+	if (si->ec[index] < UBI_MAX_ERASECOUNTER)
+		old_ech->ec = BE64(si->ec[index] + 1);
+	else
+		old_ech->ec = BE64(si->mean_ec);
+
+	if (new_header) {
+		old_ech->vid_hdr_offset = BE32(si->vid_hdr_offs);
+		old_ech->data_offset = BE32(si->data_offs);
+		old_ech->magic = BE32(UBI_EC_HDR_MAGIC);
+		old_ech->version = UBI_VERSION;
+	}
+	old_ech->image_seq = BE32(si->image_seq);
+	crc = mtd_crc32(UBI_CRC32_INIT,
+			(const void *)old_ech, UBI_EC_HDR_SIZE_CRC);
+	old_ech->hdr_crc = BE32(crc);
+}
+
+/**
+ * calc_data_len - calculate how much real data is stored in the buffer
+ * @page_size: min I/O of the device
+ * @buf: a buffer with the contents of the physical eraseblock
+ * @len: the buffer length
+ *
+ * This function calculates how much "real data" is stored in @buf and
+ * returns the length (in number of pages). Continuous 0xFF bytes at the end
+ * of the buffer are not considered as "real data".
+ */
+static int calc_data_len(int page_size, const void *buf, int len)
+{
+	int i;
+
+	for (i = len - 1; i >= 0; i--)
+		if (((const uint8_t *)buf)[i] != 0xFF)
+			break;
+
+	/* The resulting length must be aligned to the minimum flash I/O size */
+	len = i + 1;
+	len = (len + page_size - 1) / page_size;
+	return len;
+}
+
+/**
+ * fastmap_present - returns true if Fastmap superblock is found
+ * @data: raw data to test
+ *
+ * This function returns 1 if the provided PEB data contains
+ * Fastmap superblock, 0 otherwise
+ */
+static int fastmap_present(const void *data){
+	struct ubi_ec_hdr *ec_hdr = (struct ubi_ec_hdr *)(data);
+	struct ubi_vid_hdr *vid_hdr;
+
+	vid_hdr = (struct ubi_vid_hdr *)(data + BE32(ec_hdr->vid_hdr_offset));
+	if (BE32(vid_hdr->vol_id) == UBI_FM_SB_VOLUME_ID)
+		return 1;
+	else
+		return 0;
+}
+
+/**
+ * ubi_erase_peb - Erase PEB and update EC header
+ * @peb_num: number of the PEB to erase
+ * @need_erase: if true PEB will be erased
+ * @si: UBI scan information
+ * @ptn_start: first PEB of the flashed partition
+ *
+ * This function erases the given PEB (if required) and writes a new EC
+ * header for it.
+ *
+ * Returns: -1 on error
+ *           0 on success
+ */
+static int ubi_erase_peb(int peb_num, int need_erase,
+		struct ubi_scan_info *si, int ptn_start)
+{
+	struct ubi_ec_hdr new_ech;
+	int page_size = flash_page_size();
+	int num_pages_per_blk = flash_block_size() / page_size;
+	int ret;
+
+	if (need_erase && qpic_nand_blk_erase(peb_num * num_pages_per_blk)) {
+		dprintf(INFO, "flash_ubi_img: erase of %d failed\n", peb_num);
+		return -1;
+	}
+	memset(&new_ech, 0xff, sizeof(new_ech));
+	update_ec_header(&new_ech, si, peb_num - ptn_start, true);
+
+	/* Write new ec_header */
+	ret = write_ec_header(peb_num, &new_ech);
+	if (ret) {
+		dprintf(CRITICAL, "flash_ubi_img: write ec_header to %d failed\n",
+				peb_num);
+		return -1;
+	}
+	return 0;
+}
+
+/**
+ * remove_F_flag() - Turn off space-fixup flag in the ubifs superblock
+ * @data: pointer to the peb to check in the flashed image
+ *
+ * The UBIFS Superblock will be located at LEB 0 of the image. LEB 0 will be
+ * mapped as follows:
+ * If the image contains Fastmap superblock:
+ * - LEB 0 will be at PEB3
+ * else:
+ * - LEB 0 will be at PEB2
+ */
+static void remove_F_flag(const void *leb_data)
+{
+	struct ubifs_ch *ch;
+	struct ubifs_sb_node *ubifs_sb;
+	struct ubi_ec_hdr *ech;
+	struct ubi_vid_hdr *vidh;
+	int vol_id;
+
+	ech = (struct ubi_ec_hdr *)leb_data;
+	vidh = (struct ubi_vid_hdr *)(leb_data + BE32(ech->vid_hdr_offset));
+	vol_id = BE32(vidh->vol_id);
+
+	if (vol_id > UBI_MAX_VOLUMES &&
+			vol_id != UBI_LAYOUT_VOLUME_ID &&
+			vol_id != UBI_FM_SB_VOLUME_ID)
+		return;
+
+	ubifs_sb = (struct ubifs_sb_node *)(leb_data + BE32(ech->data_offset));
+	ch = (struct ubifs_ch *)ubifs_sb;
+	if (ch->node_type != UBIFS_SB_NODE)
+		return;
+	if (ubifs_sb->flags & UBIFS_FLG_SPACE_FIXUP) {
+		ubifs_sb->flags &= (~UBIFS_FLG_SPACE_FIXUP);
+		ch->crc = mtd_crc32(UBIFS_CRC32_INIT, (void *)ubifs_sb + 8,
+				sizeof(struct ubifs_sb_node) - 8);
+	}
+}
+
+/**
+ * flash_ubi_img() - Write the provided (UBI) image to given partition
+ * @ptn: partition to write the image to
+ * @data: the image to write
+ * @size: size of the image to write
+ *
+ *  Return codes:
+ * -1 - in case of error
+ *  0 - on success
+ */
+int flash_ubi_img(struct ptentry *ptn, void *data, unsigned size)
+{
+	struct ubi_scan_info *si;
+	struct ubi_ec_hdr *old_ech;
+	uint32_t curr_peb = ptn->start;
+	void *img_peb;
+	unsigned page_size = flash_page_size();
+	unsigned block_size = flash_block_size();
+	int num_pages_per_blk = block_size / page_size;
+	int num_pages;
+	int ret, need_erase;
+	int bad_blocks_cnt = 0;
+	int fmsb_peb = 0;
+
+	si = scan_partition(ptn);
+	if (!si) {
+		dprintf(CRITICAL, "flash_ubi_img: scan_partition failed\n");
+		return -1;
+	}
+
+	/*
+	 * In case si->vid_hdr_offs is still -1 (non UBI image was
+	 * flashed on device, get the value from the image to flush
+	 */
+	if (!si->vid_hdr_offs){
+		struct ubi_ec_hdr *echd = (struct ubi_ec_hdr *)data;
+		si->vid_hdr_offs = BE32(echd->vid_hdr_offset);
+		si->data_offs = BE32(echd->data_offset);
+	}
+
+	need_erase = (si->empty_cnt == (int)ptn->length ? 0 : 1);
+	/* Update the "to be" flashed image and flash it */
+	img_peb = data;
+	while (size && curr_peb < ptn->start + ptn->length) {
+		if (need_erase && qpic_nand_blk_erase(curr_peb * num_pages_per_blk)) {
+			dprintf(CRITICAL, "flash_ubi_img: erase of %d failed\n",
+				curr_peb);
+			bad_blocks_cnt++;
+			curr_peb++;
+			continue;
+		}
+		remove_F_flag(img_peb);
+		/* Update the ec_header in the image */
+		old_ech = (struct ubi_ec_hdr *)img_peb;
+		update_ec_header(old_ech, si, curr_peb - ptn->start, false);
+		if (size < block_size)
+			num_pages = size / page_size;
+		else
+			num_pages = calc_data_len(page_size, img_peb, block_size);
+		/* Write one block from image */
+		ret = qpic_nand_write(curr_peb * num_pages_per_blk,
+				num_pages, img_peb, 0);
+		if (ret) {
+			dprintf(CRITICAL, "flash_ubi_img: writing to peb-%d failed\n",
+					curr_peb);
+			bad_blocks_cnt++;
+			curr_peb++;
+			continue;
+		}
+		if (size < block_size)
+			size = 0;
+		else
+			size -= block_size;
+
+		if (fastmap_present(img_peb))
+			fmsb_peb = curr_peb;
+		img_peb += flash_block_size();
+		curr_peb++;
+	}
+
+	if (size) {
+		dprintf(CRITICAL,
+				"flash_ubi_img: Not enough good blocks to flash image!");
+		ret = -1;
+		goto out;
+	}
+
+	/* Erase and write ec_header for the rest of the blocks */
+	for (; curr_peb < ptn->start + ptn->length; curr_peb++)
+		if (ubi_erase_peb(curr_peb, need_erase, si, ptn->start))
+			bad_blocks_cnt++;
+
+	ret = 0;
+	/*
+	 * If flashed image contains fastmap data and bad blocks were found
+	 * we need to invalidate the flashed fastmap since it isn't accurate
+	 * anymore.
+	 */
+	if (bad_blocks_cnt && fmsb_peb) {
+		dprintf(CRITICAL, "flash_ubi_img: invalidate fmsb\n");
+		ret = ubi_erase_peb(ptn->start + 2, 1, si, ptn->start);
+	}
+
+out:
+	free(si->ec);
+	free(si);
+	return ret;
+}
diff --git a/platform/msm_shared/hsusb.c b/platform/msm_shared/hsusb.c
index 839f301..0967cd1 100644
--- a/platform/msm_shared/hsusb.c
+++ b/platform/msm_shared/hsusb.c
@@ -2,7 +2,7 @@
  * Copyright (c) 2008, Google Inc.
  * All rights reserved.
  *
- * Copyright (c) 2009-2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2009-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
@@ -183,6 +183,11 @@
 	ept->next = ept_list;
 	ept_list = ept;
 
+	arch_clean_invalidate_cache_range((addr_t) ept,
+					  sizeof(struct udc_endpoint));
+	arch_clean_invalidate_cache_range((addr_t) ept->head,
+					  sizeof(struct ept_queue_head));
+
 	DBG("ept%d %s @%p/%p max=%d bit=%x\n",
 	    num, in ? "in" : "out", ept, ept->head, max_pkt, ept->bit);
 
@@ -525,6 +530,7 @@
 	DBG("setup_tx %p %d\n", buf, len);
 	memcpy(ep0req->buf, buf, len);
 	ep0req->buf = (void *)PA((addr_t)ep0req->buf);
+	arch_clean_invalidate_cache_range((addr_t)ep0req->buf, len);
 	ep0req->complete = ep0in_complete;
 	ep0req->length = len;
 	udc_request_queue(ep0in, ep0req);
@@ -541,6 +547,7 @@
 	arch_clean_invalidate_cache_range((addr_t) ept->head->setup_data,
 					  sizeof(struct ept_queue_head));
 	memcpy(&s, ept->head->setup_data, sizeof(s));
+	arch_clean_invalidate_cache_range((addr_t)&s, sizeof(s));
 	writel(ept->bit, USB_ENDPTSETUPSTAT);
 
 	DBG("handle_setup type=0x%02x req=0x%02x val=%d idx=%d len=%d (%s)\n",
diff --git a/platform/msm_shared/include/ucs.h b/platform/msm_shared/include/ucs.h
index 094946e..48c50db 100644
--- a/platform/msm_shared/include/ucs.h
+++ b/platform/msm_shared/include/ucs.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-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
@@ -175,4 +175,6 @@
 int ucs_do_scsi_rpmb_read(struct ufs_dev *dev, uint32_t *req_buf, uint32_t blk_cnt,
                                  uint32_t *resp_buffer, uint32_t *response_length);
 
+/* This function parses the first byte of the sense data and returns the sense key */
+int parse_sense_key(uint32_t sense_data);
 #endif
diff --git a/platform/msm_shared/include/upiu.h b/platform/msm_shared/include/upiu.h
index 1c9968d..e081909 100644
--- a/platform/msm_shared/include/upiu.h
+++ b/platform/msm_shared/include/upiu.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Linux Foundation. All rights reserved.

+/* Copyright (c) 2013-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

@@ -44,6 +44,27 @@
 	uint16_t data_seg_len;

 } __PACKED;

 

+

+struct upiu_basic_resp_hdr

+{

+	uint8_t  trans_type;

+	uint8_t  flags;

+	uint8_t  lun;

+	uint8_t  task_tag;

+	uint8_t  cmd_set_type;

+	uint8_t  query_task_mgmt_func;

+	uint8_t  response;

+	uint8_t  status;

+	uint8_t  total_ehs_len;

+	uint8_t  device_info;

+	uint16_t data_seg_len;

+	uint32_t residual_transfer_count;

+	uint32_t reserved[4];

+	uint16_t sense_length;

+	uint16_t sense_response_code;

+	uint32_t sense_data[4];

+} __PACKED;

+

 struct upiu_trans_mgmt_query_hdr

 {

 	struct upiu_basic_hdr basic_hdr;

@@ -149,7 +170,7 @@
 	uint8_t                         idn;

 	uint8_t                         index;

 	uint8_t                         selector;

-	struct upiu_basic_hdr       *resp_ptr;

+	struct upiu_basic_resp_hdr       *resp_ptr;

 	uint64_t                        resp_len;

 	uint16_t                        resp_data_len;

 	addr_t                        resp_data_ptr;

diff --git a/platform/msm_shared/mipi_dsi.c b/platform/msm_shared/mipi_dsi.c
index 4814894..b18a508 100644
--- a/platform/msm_shared/mipi_dsi.c
+++ b/platform/msm_shared/mipi_dsi.c
@@ -380,6 +380,14 @@
 			lane_swap_dsi1 = lane_swap;
 		writel(lane_swap_dsi1, mipi->sctl_base + LANE_SWAP_CTL);
 		writel(timing_ctl, mipi->sctl_base + TIMING_CTL);
+
+		if (mipi->force_clk_lane_hs) {
+			uint32_t tmp;
+
+			tmp = readl(mipi->sctl_base + LANE_CTL);
+			tmp |= BIT(28);
+			writel(tmp, mipi->sctl_base + LANE_CTL);
+		}
 	}
 
 	writel(0x0001, mipi->ctl_base + SOFT_RESET);
@@ -396,6 +404,14 @@
 
 	writel(lane_swap, mipi->ctl_base + LANE_SWAP_CTL);
 	writel(timing_ctl, mipi->ctl_base + TIMING_CTL);
+
+	if (mipi->force_clk_lane_hs) {
+		uint32_t tmp;
+
+		tmp = readl(mipi->ctl_base + LANE_CTL);
+		tmp |= BIT(28);
+		writel(tmp, mipi->ctl_base + LANE_CTL);
+	}
 #endif
 
 	return 0;
@@ -499,6 +515,12 @@
 	int status = 0;
 
 #if (DISPLAY_TYPE_MDSS == 1)
+	int last_line_interleave_en = 0;
+
+	/*Check if EOF_BLLP_PWR_MODE bit is set*/
+	if(eof_bllp_pwr & 0x8)
+		last_line_interleave_en = 1;
+
 	/* disable mdp first */
 	mdp_disable();
 
@@ -558,9 +580,10 @@
 	writel(0x00000100, ctl_base + MISR_VIDEO_CTRL);
 
 	if (mdp_get_revision() >= MDP_REV_41 || mdp_get_revision() == MDP_REV_305) {
-		writel(pulse_mode_hsa_he << 28 | low_pwr_stop_mode << 16 |
-				eof_bllp_pwr << 12 | traffic_mode << 8
-				| dst_format << 4 | 0x0, ctl_base + VIDEO_MODE_CTRL);
+		writel(last_line_interleave_en << 31 | pulse_mode_hsa_he << 28 |
+				low_pwr_stop_mode << 16 | eof_bllp_pwr << 12 |
+				traffic_mode << 8 | dst_format << 4 | 0x0,
+				ctl_base + VIDEO_MODE_CTRL);
 	} else {
 		writel(1 << 28 | 1 << 24 | 1 << 20 | low_pwr_stop_mode << 16 |
 				eof_bllp_pwr << 12 | traffic_mode << 8
diff --git a/platform/msm_shared/rules.mk b/platform/msm_shared/rules.mk
index 2040e16..793b88c 100755
--- a/platform/msm_shared/rules.mk
+++ b/platform/msm_shared/rules.mk
@@ -330,6 +330,7 @@
 			$(LOCAL_DIR)/board.o \
 			$(LOCAL_DIR)/spmi.o \
 			$(LOCAL_DIR)/qpic_nand.o \
+			$(LOCAL_DIR)/flash-ubi.o \
 			$(LOCAL_DIR)/bam.o \
 			$(LOCAL_DIR)/scm.o \
 			$(LOCAL_DIR)/dev_tree.o \
@@ -352,6 +353,7 @@
 			$(LOCAL_DIR)/board.o \
 			$(LOCAL_DIR)/spmi.o \
 			$(LOCAL_DIR)/qpic_nand.o \
+			$(LOCAL_DIR)/flash-ubi.o \
 			$(LOCAL_DIR)/bam.o \
 			$(LOCAL_DIR)/dev_tree.o \
 			$(LOCAL_DIR)/clock.o \
@@ -413,6 +415,7 @@
 			$(LOCAL_DIR)/crypto5_wrapper.o \
 			$(LOCAL_DIR)/i2c_qup.o \
 			$(LOCAL_DIR)/gpio.o \
+			$(LOCAL_DIR)/qmp_usb30_phy.o \
 			$(LOCAL_DIR)/dload_util.o
 endif
 
diff --git a/platform/msm_shared/smem.h b/platform/msm_shared/smem.h
index ab7de2b..db186d4 100644
--- a/platform/msm_shared/smem.h
+++ b/platform/msm_shared/smem.h
@@ -406,6 +406,7 @@
 	MSM8629  = 269,
 	MSM8229  = 270,
 	APQ8029  = 271,
+	MSM8609  = 275,
 	FSM9916  = 276,
 };
 
diff --git a/platform/msm_shared/ucs.c b/platform/msm_shared/ucs.c
index e77f2d1..3e7563a 100644
--- a/platform/msm_shared/ucs.c
+++ b/platform/msm_shared/ucs.c
@@ -37,8 +37,7 @@
 int ucs_do_scsi_cmd(struct ufs_dev *dev, struct scsi_req_build_type *req)
 {
 	struct upiu_req_build_type req_upiu;
-	struct upiu_basic_hdr      resp_upiu;
-	int                        ret;
+	struct upiu_basic_resp_hdr      resp_upiu;
 
 	memset(&req_upiu, 0 , sizeof(struct upiu_req_build_type));
 
@@ -68,9 +67,14 @@
 	{
 		if (resp_upiu.status == SCSI_STATUS_CHK_COND && (*((uint8_t *)(req->cdb)) != SCSI_CMD_SENSE_REQ))
 		{
-			ret = ucs_do_request_sense(dev);
-			if (ret)
-				dprintf(CRITICAL, "SCSI request sense failed.\n");
+			dprintf(CRITICAL, "Data segment length: %x\n", BE16(resp_upiu.data_seg_len));
+			if (BE16(resp_upiu.data_seg_len))
+			{
+				dprintf(CRITICAL, "SCSI Request failed and we have sense data\n");
+				dprintf(CRITICAL, "Sense Data Length/Response Code: 0x%x/0x%x\n", BE16(resp_upiu.sense_length), BE16(resp_upiu.sense_response_code));
+				parse_sense_key(resp_upiu.sense_data[0]);
+				dprintf(CRITICAL, "Sense Buffer (HEX): 0x%x 0x%x 0x%x 0x%x\n", BE32(resp_upiu.sense_data[0]), BE32(resp_upiu.sense_data[1]), BE32(resp_upiu.sense_data[2]), BE32(resp_upiu.sense_data[3]));
+			}
 		}
 
 		dprintf(CRITICAL, "ucs_do_scsi_cmd failed status = %x\n", resp_upiu.status);
@@ -80,6 +84,57 @@
 	return UFS_SUCCESS;
 }
 
+int parse_sense_key(uint32_t sense_data)
+{
+	uint32_t key = BE32(sense_data) >> 24;
+	dprintf(CRITICAL, "Sense Key: 0x%x\n", key);
+	switch(key)
+	{
+		case 0x0:
+			dprintf(INFO, "NO SENSE: No information available to be reported\n");
+			break;
+		case 0x1:
+			dprintf(INFO, "RECOVERED ERROR: Additional sense buffer bytes indicate further details\n");
+			break;
+		case 0x2:
+			dprintf(INFO, "NOT READY: Logical Unit Not Ready and cannot be accessed at this time\n");
+			break;
+		case 0x3:
+			dprintf(INFO, "MEDIUM ERROR: Last command unsuccessful due to non-recoverable error condition\n");
+			break;
+		case 0x4:
+			dprintf(INFO, "HARDWARE ERROR: Target detected a non-recoverable hardware error\n");
+			break;
+		case 0x5:
+			dprintf(INFO, "ILLEGAL REQUEST: Illegal parameter in the command descriptor block in the command sent\n");
+			break;
+		case 0x6:
+			dprintf(INFO, "UNIT ATTENTION: Unit has been reset/unexpectedly power on/removable media has changed\n");
+			break;
+		case 0x7:
+			dprintf(INFO, "DATA PROTECT: Read/Write operation attempted on a block that is protected from this operation\n");
+			break;
+		case 0x8:
+			dprintf(INFO, "BLANK CHECK: Target encountered blank or unformatted media while reading or writing\n");
+			break;
+		case 0x9:
+			dprintf(INFO, "VENDOR SPECIFIC: Vendor specific error or exceptional conditions\n");
+			break;
+		case 0xB:
+			dprintf(INFO, "ABORTED COMMAND: Target aborted the execution of the command\n");
+			break;
+		case 0xD:
+			dprintf(INFO, "VOLUME OVERFLOW: Buffered peripheral device has reached the end of partition\n");
+			break;
+		case 0xE:
+			dprintf(INFO, "MISCOMPARE: Source data did not match the data read from the media\n");
+			break;
+		default:
+			dprintf(INFO, "INVALID sense key\n");
+	}
+	return key;
+}
+
 int ucs_do_scsi_rpmb_read(struct ufs_dev *dev, uint32_t *req_buf, uint32_t blk_cnt,
                                  uint32_t *resp_buf, uint32_t *resp_len)
 {
@@ -339,6 +394,7 @@
         /* Flush cdb to memory. */
 	dsb();
 	arch_invalidate_cache_range((addr_t) cdb_param, SCSI_CDB_PARAM_LEN);
+	arch_invalidate_cache_range((addr_t) param, sizeof(struct unmap_param_list));
 
 	memset((void*)&req_upiu, 0 , sizeof(struct scsi_req_build_type));
 
diff --git a/platform/msm_shared/ufs.c b/platform/msm_shared/ufs.c
index 0bb7eb5..aa5f90b 100644
--- a/platform/msm_shared/ufs.c
+++ b/platform/msm_shared/ufs.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2014, 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
@@ -167,13 +167,8 @@
 	if(ret)
 	{
 		dprintf(CRITICAL, "UFS erase failed \n");
-		return ret;
 	}
-	ret = dme_set_fpurgeenable((struct ufs_dev *)dev);
-	if (ret)
-	{
-		dprintf(CRITICAL, "UFS purge operation failed after erase\n");
-	}
+
 	return ret;
 }
 
diff --git a/scripts/buildall b/scripts/buildall
index 906ee0c..c355387 100755
--- a/scripts/buildall
+++ b/scripts/buildall
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-PROJECTS="armemu-test sam7ex256-test osk5912-test qemu-arm-test beagle-test surf-test"
+PROJECTS="msm8226 msm8974 apq8084 msm8994 mdm9630 mdm9640 msm8610 msm8916 thulium"
 FAILED=""
 
 for p in $PROJECTS; do
diff --git a/target/init.c b/target/init.c
index c866187..97809cc 100644
--- a/target/init.c
+++ b/target/init.c
@@ -54,6 +54,11 @@
     return (120 * 1024 * 1024);
 }
 
+__WEAK int flash_ubi_img(void)
+{
+    return 0;
+}
+
 __WEAK int target_is_emmc_boot(void)
 {
 #if _EMMC_BOOT
@@ -211,3 +216,13 @@
 {
 	return DDR_CONFIG_VAL;
 }
+
+/* Return Build variant */
+__WEAK bool target_build_variant_user()
+{
+#if USER_BUILD_VARIANT
+	return true;
+#else
+	return false;
+#endif
+}
diff --git a/target/msm8909/init.c b/target/msm8909/init.c
index 7ba0cd6..96232fe 100644
--- a/target/msm8909/init.c
+++ b/target/msm8909/init.c
@@ -471,6 +471,7 @@
 	case MSM8909:
 	case MSM8209:
 	case MSM8208:
+	case MSM8609:
 		board->baseband = BASEBAND_MSM;
 		break;
 
diff --git a/target/msm8909/oem_panel.c b/target/msm8909/oem_panel.c
index 3278248..50aad97 100644
--- a/target/msm8909/oem_panel.c
+++ b/target/msm8909/oem_panel.c
@@ -46,6 +46,7 @@
 #include "include/panel_hx8394d_qhd_video.h"
 
 #define DISPLAY_MAX_PANEL_DETECTION 0
+#define ILI9806E_FWVGA_VIDEO_PANEL_POST_INIT_DELAY 68
 
 enum {
 	QRD_SKUA = 0x00,
@@ -96,6 +97,9 @@
 	 * OEM can keep there panel specific on instructions in this
 	 * function
 	 */
+	if (panel_id == ILI9806E_FWVGA_VIDEO_PANEL)
+		mdelay(ILI9806E_FWVGA_VIDEO_PANEL_POST_INIT_DELAY);
+
 	return NO_ERROR;
 }
 
diff --git a/target/msm8994/include/target/display.h b/target/msm8994/include/target/display.h
index 1b20f99..c426ee2 100644
--- a/target/msm8994/include/target/display.h
+++ b/target/msm8994/include/target/display.h
@@ -81,6 +81,9 @@
 
 #define PWM_BL_LPG_CHAN_ID           4	/* lpg_out<3> */
 
+#define HDMI_PANEL_NAME              "hdmi"
+#define HDMI_CONTROLLER_STRING       "hdmi:0"
+
 #endif
 
 /*---------------------------------------------------------------------------*/
diff --git a/target/msm8994/target_display.c b/target/msm8994/target_display.c
index d8f4bc2..6cf3653 100644
--- a/target/msm8994/target_display.c
+++ b/target/msm8994/target_display.c
@@ -452,8 +452,28 @@
 
 bool target_display_panel_node(char *panel_name, char *pbuf, uint16_t buf_size)
 {
-	return gcdb_display_cmdline_arg(panel_name, pbuf, buf_size);
+	int prefix_string_len = strlen(DISPLAY_CMDLINE_PREFIX);
+	bool ret = true;
 
+	panel_name += strspn(panel_name, " ");
+
+	if (!strcmp(panel_name, HDMI_PANEL_NAME)) {
+		if (buf_size < (prefix_string_len + LK_OVERRIDE_PANEL_LEN +
+				strlen(HDMI_CONTROLLER_STRING))) {
+			dprintf(CRITICAL, "command line argument is greater than buffer size\n");
+			return false;
+		}
+
+		strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size);
+		buf_size -= prefix_string_len;
+		strlcat(pbuf, LK_OVERRIDE_PANEL, buf_size);
+		buf_size -= LK_OVERRIDE_PANEL_LEN;
+		strlcat(pbuf, HDMI_CONTROLLER_STRING, buf_size);
+	} else {
+		ret = gcdb_display_cmdline_arg(panel_name, pbuf, buf_size);
+	}
+
+	return ret;
 }
 
 void target_display_init(const char *panel_name)
@@ -470,6 +490,8 @@
 		dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n",
 			panel_name);
 		return;
+	} else if (!strcmp(panel_name, HDMI_PANEL_NAME)) {
+		return;
 	}
 
 	if (gcdb_display_init(panel_name, MDP_REV_50, (void *)MIPI_FB_ADDR)) {