Merge "include: Add function prototype to detect platform and calculate the boot mask"
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index fcd0ee8..9482806 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -2425,7 +2425,6 @@
 	fastboot_okay("");
 }
 
-static struct fbimage logo_header = {{{0}, 0, 0, 0, {0}}, 0};
 struct fbimage* splash_screen_flash();
 
 int splash_screen_check_header(struct fbimage *logo)
@@ -2442,35 +2441,38 @@
 	struct ptentry *ptn;
 	struct ptable *ptable;
 	struct fbcon_config *fb_display = NULL;
-	struct fbimage *logo = &logo_header;
+	struct fbimage *logo = NULL;
 
 
+	logo = (struct fbimage *) malloc(ROUNDUP(page_size, sizeof(struct fbimage)));
+	ASSERT(logo);
+
 	ptable = flash_get_ptable();
 	if (ptable == NULL) {
 	dprintf(CRITICAL, "ERROR: Partition table not found\n");
-	return NULL;
+	goto err;
 	}
 	ptn = ptable_find(ptable, "splash");
 	if (ptn == NULL) {
 		dprintf(CRITICAL, "ERROR: splash Partition not found\n");
-		return NULL;
+		goto err;
 	}
 
 	if (flash_read(ptn, 0,(unsigned int *) logo, sizeof(logo->header))) {
 		dprintf(CRITICAL, "ERROR: Cannot read boot image header\n");
-		return NULL;
+		goto err;
 	}
 
 	if (splash_screen_check_header(logo)) {
 		dprintf(CRITICAL, "ERROR: Boot image header invalid\n");
-		return NULL;
+		goto err;
 	}
 
 	fb_display = fbcon_display();
 	if (fb_display) {
 		if ((logo->header.width != fb_display->width) || (logo->header.height != fb_display->height)) {
 			dprintf(CRITICAL, "Logo config doesn't match with fb config. Fall back to default logo\n");
-			return NULL;
+			goto err;
 		}
 		uint8_t *base = (uint8_t *) fb_display->base;
 		if (flash_read(ptn + sizeof(logo->header), 0,
@@ -2478,12 +2480,16 @@
 			((((logo->header.width * logo->header.height * fb_display->bpp/8) + 511) >> 9) << 9))) {
 			fbcon_clear();
 			dprintf(CRITICAL, "ERROR: Cannot read splash image from partition\n");
-			return NULL;
+			goto err;
 		}
 		logo->image = base;
 	}
 
 	return logo;
+
+err:
+	free(logo);
+	return NULL;
 }
 
 struct fbimage* splash_screen_mmc()
@@ -2491,7 +2497,10 @@
 	int index = INVALID_PTN;
 	unsigned long long ptn = 0;
 	struct fbcon_config *fb_display = NULL;
-	struct fbimage *logo = &logo_header;
+	struct fbimage *logo = NULL;
+	uint32_t blocksize;
+	uint32_t readsize;
+	uint32_t ptn_size;
 
 	index = partition_get_index("splash");
 	if (index == 0) {
@@ -2505,35 +2514,52 @@
 		return NULL;
 	}
 
-	if (mmc_read(ptn, (uint32_t *) logo, sizeof(logo->header))) {
+	ptn_size = partition_get_size(index);
+	blocksize = mmc_get_device_blocksize();
+	readsize = ROUNDUP(sizeof(logo->header), blocksize);
+
+	logo = (struct fbimage *)memalign(CACHE_LINE, ROUNDUP(readsize, CACHE_LINE));
+	ASSERT(logo);
+
+	if (mmc_read(ptn, (uint32_t *) logo, readsize)) {
 		dprintf(CRITICAL, "ERROR: Cannot read splash image header\n");
-		return NULL;
+		goto err;
 	}
 
 	if (splash_screen_check_header(logo)) {
 		dprintf(CRITICAL, "ERROR: Splash image header invalid\n");
-		return NULL;
+		goto err;
 	}
 
 	fb_display = fbcon_display();
 	if (fb_display) {
 		if ((logo->header.width != fb_display->width) || (logo->header.height != fb_display->height)) {
 			dprintf(CRITICAL, "Logo config doesn't match with fb config. Fall back default logo\n");
-			return NULL;
+			goto err;
 		}
 		uint8_t *base = (uint8_t *) fb_display->base;
-		if (mmc_read(ptn + sizeof(logo->header),
-			(uint32_t *)base,
-			((((logo->header.width * logo->header.height * fb_display->bpp/8) + 511) >> 9) << 9))) {
+		readsize = ROUNDUP((logo->header.width * logo->header.height * fb_display->bpp/8), blocksize);
+
+		if (readsize > ptn_size)
+		{
+			dprintf(CRITICAL, "@%d:Invalid logo header readsize:%u exceeds ptn_size:%u\n", __LINE__, readsize,ptn_size);
+			goto err;
+		}
+
+		if (mmc_read(ptn + sizeof(logo->header),(uint32_t *)base, readsize)) {
 			fbcon_clear();
 			dprintf(CRITICAL, "ERROR: Cannot read splash image from partition\n");
-			return NULL;
+			goto err;
 		}
 
 		logo->image = base;
 	}
 
 	return logo;
+
+err:
+	free(logo);
+	return NULL;
 }
 
 
diff --git a/dev/fbcon/fbcon.c b/dev/fbcon/fbcon.c
index a593a62..395e338 100644
--- a/dev/fbcon/fbcon.c
+++ b/dev/fbcon/fbcon.c
@@ -233,6 +233,8 @@
 	}
 
 	fbcon_putImage(fbimg, flag);
+	if (fbimg)
+		free(fbimg);
 }
 
 void fbcon_putImage(struct fbimage *fbimg, bool flag)
diff --git a/dev/gcdb/display/include/panel_ili9806e_fwvga_video.h b/dev/gcdb/display/include/panel_ili9806e_fwvga_video.h
new file mode 100644
index 0000000..cffc982
--- /dev/null
+++ b/dev/gcdb/display/include/panel_ili9806e_fwvga_video.h
@@ -0,0 +1,814 @@
+/* Copyright (c) 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
+* 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.
+*/
+
+/*---------------------------------------------------------------------------
+ * 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_ILI9806E_FWVGA_VIDEO_H_
+#define _PANEL_ILI9806E_FWVGA_VIDEO_H_
+/*---------------------------------------------------------------------------*/
+/* HEADER files                                                              */
+/*---------------------------------------------------------------------------*/
+#include "panel.h"
+
+/*---------------------------------------------------------------------------*/
+/* Panel configuration                                                       */
+/*---------------------------------------------------------------------------*/
+static struct panel_config ili9806e_fwvga_video_panel_data = {
+	"qcom,mdss_dsi_ili9806e_fwvga_video", "dsi:0:", "qcom,mdss-dsi-panel",
+	10, 0, "DISPLAY_1", 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel resolution                                                          */
+/*---------------------------------------------------------------------------*/
+static struct panel_resolution ili9806e_fwvga_video_panel_res = {
+	480, 854, 52, 100, 24, 0, 8, 20, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel color information                                                   */
+/*---------------------------------------------------------------------------*/
+static struct color_info ili9806e_fwvga_video_color = {
+	24, 0, 0xff, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel on/off command information                                          */
+/*---------------------------------------------------------------------------*/
+static char ili9806e_fwvga_video_on_cmd0[] = {
+	0x06, 0x00, 0x39, 0xC0,
+	0xFF, 0xFF, 0x98, 0x06,
+	0x04, 0x01, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd1[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x08, 0x10, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd2[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x21, 0x01, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd3[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x30, 0x01, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd4[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x31, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd5[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x40, 0x16, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd6[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x41, 0x33, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd7[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x42, 0x03, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd8[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x43, 0x89, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd9[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x44, 0x06, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd10[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x50, 0x80, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd11[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x51, 0x80, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd12[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x52, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd13[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x53, 0x43, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd14[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x60, 0x07, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd15[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x61, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd16[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x62, 0x07, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd17[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x63, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd18[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xA0, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd19[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xA1, 0x01, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd20[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xA2, 0x0A, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd21[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xA3, 0x10, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd22[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xA4, 0x0B, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd23[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xA5, 0x1C, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd24[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xA6, 0x0B, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd25[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xA7, 0x09, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd26[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xA8, 0x05, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd27[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xA9, 0x0B, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd28[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xAA, 0x07, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd29[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xAB, 0x06, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd30[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xAC, 0x0E, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd31[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xAD, 0x29, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd32[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xAE, 0x25, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd33[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xAF, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd34[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xC0, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd35[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xC1, 0x02, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd36[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xC2, 0x07, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd37[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xC3, 0x0C, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd38[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xC4, 0x06, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd39[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xC5, 0x18, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd40[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xC6, 0x0B, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd41[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xC7, 0x0A, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd42[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xC8, 0x02, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd43[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xC9, 0x06, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd44[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xCA, 0x03, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd45[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xCB, 0x03, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd46[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xCC, 0x0B, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd47[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xCD, 0x2A, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd48[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xCE, 0x25, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd49[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xCF, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd50[] = {
+	0x06, 0x00, 0x39, 0xC0,
+	0xFF, 0xFF, 0x98, 0x06,
+	0x04, 0x06, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd51[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x00, 0x20, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd52[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x01, 0x0A, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd53[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x02, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd54[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x03, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd55[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x04, 0x01, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd56[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x05, 0x01, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd57[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x06, 0x98, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd58[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x07, 0x06, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd59[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x08, 0x01, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd60[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x09, 0x80, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd61[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x0A, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd62[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x0B, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd63[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x0C, 0x01, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd64[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x0D, 0x01, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd65[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x0E, 0x05, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd66[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x0F, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd67[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x10, 0xF0, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd68[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x11, 0xF4, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd69[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x12, 0x01, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd70[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x13, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd71[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x14, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd72[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x15, 0xC0, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd73[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x16, 0x08, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd74[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x17, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd75[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x18, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd76[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x19, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd77[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x1A, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd78[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x1B, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd79[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x1C, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd80[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x1D, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd81[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x20, 0x01, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd82[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x21, 0x23, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd83[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x22, 0x45, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd84[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x23, 0x67, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd85[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x24, 0x01, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd86[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x25, 0x23, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd87[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x26, 0x45, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd88[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x27, 0x67, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd89[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x30, 0x11, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd90[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x31, 0x11, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd91[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x32, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd92[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x33, 0xEE, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd93[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x34, 0xFF, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd94[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x35, 0xBB, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd95[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x36, 0xAA, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd96[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x37, 0xDD, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd97[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x38, 0xCC, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd98[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x39, 0x66, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd99[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x3A, 0x77, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd100[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x3B, 0x22, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd101[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x3C, 0x22, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd102[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x3D, 0x22, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd103[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x3E, 0x22, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd104[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x3F, 0x22, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd105[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x40, 0x22, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd106[] = {
+	0x06, 0x00, 0x39, 0xC0,
+	0xFF, 0xFF, 0x98, 0x06,
+	0x04, 0x07, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd107[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x17, 0x22, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd108[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x02, 0x77, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd109[] = {
+	0x06, 0x00, 0x39, 0xC0,
+	0xFF, 0xFF, 0x98, 0x06,
+	0x04, 0x00, 0xFF, 0xFF,
+};
+
+static char ili9806e_fwvga_video_on_cmd110[] = {
+	0x11, 0x00, 0x05, 0x80
+};
+
+static char ili9806e_fwvga_video_on_cmd111[] = {
+	0x29, 0x00, 0x05, 0x80
+};
+
+static struct mipi_dsi_cmd ili9806e_fwvga_video_on_command[] = {
+	{0xc, ili9806e_fwvga_video_on_cmd0, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd1, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd2, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd3, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd4, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd5, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd6, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd7, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd8, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd9, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd10, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd11, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd12, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd13, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd14, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd15, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd16, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd17, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd18, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd19, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd20, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd21, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd22, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd23, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd24, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd25, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd26, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd27, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd28, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd29, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd30, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd31, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd32, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd33, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd34, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd35, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd36, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd37, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd38, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd39, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd40, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd41, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd42, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd43, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd44, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd45, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd46, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd47, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd48, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd49, 0x00},
+	{0xc, ili9806e_fwvga_video_on_cmd50, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd51, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd52, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd53, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd54, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd55, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd56, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd57, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd58, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd59, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd60, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd61, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd62, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd63, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd64, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd65, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd66, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd67, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd68, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd69, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd70, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd71, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd72, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd73, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd74, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd75, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd76, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd77, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd78, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd79, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd80, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd81, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd82, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd83, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd84, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd85, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd86, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd87, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd88, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd89, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd90, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd91, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd92, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd93, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd94, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd95, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd96, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd97, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd98, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd99, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd100, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd101, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd102, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd103, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd104, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd105, 0x00},
+	{0xc, ili9806e_fwvga_video_on_cmd106, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd107, 0x00},
+	{0x8, ili9806e_fwvga_video_on_cmd108, 0x00},
+	{0xc, ili9806e_fwvga_video_on_cmd109, 0x00},
+	{0x4, ili9806e_fwvga_video_on_cmd110, 0x96},
+	{0x4, ili9806e_fwvga_video_on_cmd111, 0x78}
+};
+
+#define ILI9806E_FWVGA_VIDEO_ON_COMMAND 112
+
+
+static char ili9806e_fwvga_videooff_cmd0[] = {
+	0x28, 0x00, 0x05, 0x80
+};
+
+static char ili9806e_fwvga_videooff_cmd1[] = {
+	0x10, 0x00, 0x05, 0x80
+};
+
+static struct mipi_dsi_cmd ili9806e_fwvga_video_off_command[] = {
+	{0x4, ili9806e_fwvga_videooff_cmd0, 0x32},
+	{0x4, ili9806e_fwvga_videooff_cmd1, 0x78}
+};
+
+#define ILI9806E_FWVGA_VIDEO_OFF_COMMAND 2
+
+
+static struct command_state ili9806e_fwvga_video_state = {
+	0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Command mode panel information                                            */
+/*---------------------------------------------------------------------------*/
+static struct commandpanel_info ili9806e_fwvga_video_command_panel = {
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Video mode panel information                                              */
+/*---------------------------------------------------------------------------*/
+static struct videopanel_info ili9806e_fwvga_video_video_panel = {
+	1, 0, 0, 0, 1, 1, 2, 0, 0x9
+};
+
+/*---------------------------------------------------------------------------*/
+/* Lane configuration                                                        */
+/*---------------------------------------------------------------------------*/
+static struct lane_configuration ili9806e_fwvga_video_lane_config = {
+	2, 0, 1, 1, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel timing                                                              */
+/*---------------------------------------------------------------------------*/
+static const uint32_t ili9806e_fwvga_video_timings[] = {
+	0x73, 0x21, 0x1A, 0x00, 0x31, 0x30, 0x1E, 0x23, 0x2B, 0x03, 0x04, 0x00
+};
+
+static struct panel_timing ili9806e_fwvga_video_timing_info = {
+	0, 4, 0x20, 0x2C
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel reset sequence                                                      */
+/*---------------------------------------------------------------------------*/
+static struct panel_reset_sequence ili9806e_fwvga_video_reset_seq = {
+	{1, 0, 1, }, {20, 20, 20, }, 2
+};
+
+/*---------------------------------------------------------------------------*/
+/* Backlight setting                                                         */
+/*---------------------------------------------------------------------------*/
+static struct backlight ili9806e_fwvga_video_backlight = {
+	1, 1, 4095, 100, 1, "PMIC_8941"
+};
+
+#define ILI9806E_FWVGA_VIDEO_SIGNATURE 0xFFFF
+#endif /*_PANEL_ILI9806E_FWVGA_VIDEO_H_*/
diff --git a/dev/gcdb/display/include/panel_jdi_fhd_video.h b/dev/gcdb/display/include/panel_jdi_fhd_video.h
index f869f5a..a301056 100644
--- a/dev/gcdb/display/include/panel_jdi_fhd_video.h
+++ b/dev/gcdb/display/include/panel_jdi_fhd_video.h
@@ -118,11 +118,11 @@
 };
 
 static char jdi_fhd_video_on_cmd13[] = {
-	0x11, 0xFF, 0x05, 0x80
+	0x11, 0x00, 0x05, 0x80
 };
 
 static char jdi_fhd_video_on_cmd14[] = {
-	0x29, 0xFF, 0x05, 0x80
+	0x29, 0x00, 0x05, 0x80
 };
 
 static struct mipi_dsi_cmd jdi_fhd_video_on_command[] = {
diff --git a/include/dev/fbcon.h b/include/dev/fbcon.h
index a817675..2587277 100644
--- a/include/dev/fbcon.h
+++ b/include/dev/fbcon.h
@@ -2,7 +2,7 @@
  * Copyright (c) 2008, Google Inc.
  * All rights reserved.
  *
- * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2009-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
@@ -42,7 +42,6 @@
     uint32_t width; // logo's width, little endian
     uint32_t height; // logo's height, little endian
     uint32_t offset;
-    unsigned char reserved[512-20];
 };
 
 struct fbimage {
diff --git a/lib/debug/debug.c b/lib/debug/debug.c
index f239bbe..e62f806 100644
--- a/lib/debug/debug.c
+++ b/lib/debug/debug.c
@@ -43,6 +43,7 @@
 __stack_chk_fail (void)
 {
 	panic("stack smashing detected.");
+	for(;;);
 }
 
 void spin(uint32_t usecs)
@@ -97,7 +98,7 @@
 	char ts_buf[13];
 	int err;
 
-	snprintf(ts_buf, sizeof(ts_buf), "[%u] ", current_time());
+	snprintf(ts_buf, sizeof(ts_buf), "[%u] ",(unsigned int)current_time());
 	dputs(ALWAYS, ts_buf);
 
 	va_list ap;
diff --git a/lib/libfdt/fdt.c b/lib/libfdt/fdt.c
index 3267a1c..c43b83e 100644
--- a/lib/libfdt/fdt.c
+++ b/lib/libfdt/fdt.c
@@ -91,7 +91,7 @@
 	const char *p;
 
 	if (fdt_version(fdt) >= 0x11)
-		if (((offset + len) < offset)
+		if (((int)(offset + len) < offset)
 		    || ((offset + len) > fdt_size_dt_struct(fdt)))
 			return NULL;
 
@@ -226,7 +226,7 @@
 {
 	FDT_CHECK_HEADER(fdt);
 
-	if (fdt_totalsize(fdt) > bufsize)
+	if (fdt_totalsize(fdt) > (uint32_t)bufsize)
 		return -FDT_ERR_NOSPACE;
 
 	memmove(buf, fdt, fdt_totalsize(fdt));
diff --git a/lib/libfdt/fdt_ro.c b/lib/libfdt/fdt_ro.c
index 02b6d68..1e6b2e7 100644
--- a/lib/libfdt/fdt_ro.c
+++ b/lib/libfdt/fdt_ro.c
@@ -85,7 +85,7 @@
 {
 	const char *p = fdt_string(fdt, stroffset);
 
-	return (strlen(p) == len) && (memcmp(p, s, len) == 0);
+	return (strlen(p) == (size_t)len) && (memcmp(p, s, len) == 0);
 }
 
 int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
@@ -494,7 +494,7 @@
 {
 	int offset;
 
-	if ((phandle == 0) || (phandle == -1))
+	if ((phandle == 0))
 		return -FDT_ERR_BADPHANDLE;
 
 	FDT_CHECK_HEADER(fdt);
diff --git a/lib/libfdt/fdt_strerror.c b/lib/libfdt/fdt_strerror.c
index e6c3cee..f1ce5ad 100644
--- a/lib/libfdt/fdt_strerror.c
+++ b/lib/libfdt/fdt_strerror.c
@@ -85,7 +85,7 @@
 		return "<valid offset/length>";
 	else if (errval == 0)
 		return "<no error>";
-	else if (errval > -FDT_ERRTABSIZE) {
+	else if (errval > (int) -FDT_ERRTABSIZE) {
 		const char *s = fdt_errtable[-errval].str;
 
 		if (s)
diff --git a/lib/libfdt/fdt_sw.c b/lib/libfdt/fdt_sw.c
index 55ebebf..c8d998c 100644
--- a/lib/libfdt/fdt_sw.c
+++ b/lib/libfdt/fdt_sw.c
@@ -78,7 +78,7 @@
 	spaceleft = fdt_totalsize(fdt) - fdt_off_dt_struct(fdt)
 		- fdt_size_dt_strings(fdt);
 
-	if ((offset + len < offset) || (offset + len > spaceleft))
+	if (((int)(offset + len) < offset) || ((int)(offset + len) > spaceleft))
 		return NULL;
 
 	fdt_set_size_dt_struct(fdt, offset + len);
@@ -89,7 +89,7 @@
 {
 	void *fdt = buf;
 
-	if (bufsize < sizeof(struct fdt_header))
+	if (bufsize < (int)sizeof(struct fdt_header))
 		return -FDT_ERR_NOSPACE;
 
 	memset(buf, 0, bufsize);
@@ -180,7 +180,7 @@
 	/* Add it */
 	offset = -strtabsize - len;
 	struct_top = fdt_off_dt_struct(fdt) + fdt_size_dt_struct(fdt);
-	if (fdt_totalsize(fdt) + offset < struct_top)
+	if ((int)(fdt_totalsize(fdt) + offset) < struct_top)
 		return 0; /* no more room :( */
 
 	memcpy(strtab + offset, s, len);
diff --git a/lib/openssl/crypto/asn1/a_int.c b/lib/openssl/crypto/asn1/a_int.c
index c6fd204..3348b87 100644
--- a/lib/openssl/crypto/asn1/a_int.c
+++ b/lib/openssl/crypto/asn1/a_int.c
@@ -273,7 +273,7 @@
 	{
 	ASN1_INTEGER *ret=NULL;
 	const unsigned char *p;
-	unsigned char *to,*s;
+	unsigned char *s;
 	long len;
 	int inf,tag,xclass;
 	int i;
@@ -308,7 +308,6 @@
 		i=ERR_R_MALLOC_FAILURE;
 		goto err;
 		}
-	to=s;
 	ret->type=V_ASN1_INTEGER;
 	if(len) {
 		if ((*p == 0) && (len != 1))
diff --git a/lib/openssl/crypto/asn1/a_strnid.c b/lib/openssl/crypto/asn1/a_strnid.c
index 753021a..f0af42f 100644
--- a/lib/openssl/crypto/asn1/a_strnid.c
+++ b/lib/openssl/crypto/asn1/a_strnid.c
@@ -57,10 +57,12 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <ctype.h>
 #include "cryptlib.h"
 #include <openssl/asn1.h>
 #include <openssl/objects.h>
+#include "../../e_os.h"
 
 
 static STACK_OF(ASN1_STRING_TABLE) *stable = NULL;
diff --git a/lib/openssl/crypto/asn1/ameth_lib.c b/lib/openssl/crypto/asn1/ameth_lib.c
index c52f9c9..5565ba4 100644
--- a/lib/openssl/crypto/asn1/ameth_lib.c
+++ b/lib/openssl/crypto/asn1/ameth_lib.c
@@ -59,6 +59,7 @@
 #include "cryptlib.h"
 #include <openssl/asn1t.h>
 #include <openssl/x509.h>
+#include <string.h>
 #ifndef OPENSSL_NO_ENGINE
 #include <openssl/engine.h>
 #endif
diff --git a/lib/openssl/crypto/asn1/n_pkey.c b/lib/openssl/crypto/asn1/n_pkey.c
index 60bc437..e7d0439 100644
--- a/lib/openssl/crypto/asn1/n_pkey.c
+++ b/lib/openssl/crypto/asn1/n_pkey.c
@@ -242,7 +242,7 @@
 		 int sgckey)
 	{
 	RSA *ret=NULL;
-	const unsigned char *p, *kp;
+	const unsigned char *p;
 	NETSCAPE_ENCRYPTED_PKEY *enckey = NULL;
 
 	p = *pp;
@@ -265,7 +265,6 @@
 		ASN1err(ASN1_F_D2I_RSA_NET,ASN1_R_UNSUPPORTED_ENCRYPTION_ALGORITHM);
 		goto err;
 	}
-	kp = enckey->enckey->digest->data;
 	if (cb == NULL)
 		cb=EVP_read_pw_string;
 	if ((ret=d2i_RSA_NET_2(a, enckey->enckey->digest,cb, sgckey)) == NULL) goto err;
diff --git a/lib/openssl/crypto/asn1/t_crl.c b/lib/openssl/crypto/asn1/t_crl.c
index bdb244c..ee5a687 100644
--- a/lib/openssl/crypto/asn1/t_crl.c
+++ b/lib/openssl/crypto/asn1/t_crl.c
@@ -87,7 +87,7 @@
 	STACK_OF(X509_REVOKED) *rev;
 	X509_REVOKED *r;
 	long l;
-	int i, n;
+	int i;
 	char *p;
 
 	BIO_printf(out, "Certificate Revocation List (CRL):\n");
@@ -107,7 +107,6 @@
 	else BIO_printf(out,"NONE");
 	BIO_printf(out,"\n");
 
-	n=X509_CRL_get_ext_count(x);
 	X509V3_extensions_print(out, "CRL extensions",
 						x->crl->extensions, 0, 8);
 
diff --git a/lib/openssl/crypto/asn1/tasn_dec.c b/lib/openssl/crypto/asn1/tasn_dec.c
index 3bee439..87d7dfd 100644
--- a/lib/openssl/crypto/asn1/tasn_dec.c
+++ b/lib/openssl/crypto/asn1/tasn_dec.c
@@ -168,7 +168,7 @@
 	int i;
 	int otag;
 	int ret = 0;
-	ASN1_VALUE *pchval, **pchptr, *ptmpval;
+	ASN1_VALUE **pchptr, *ptmpval;
 	if (!pval)
 		return 0;
 	if (aux && aux->asn1_cb)
@@ -319,7 +319,6 @@
 			goto err;
 			}
 		/* CHOICE type, try each possibility in turn */
-		pchval = NULL;
 		p = *in;
 		for (i = 0, tt=it->templates; i < it->tcount; i++, tt++)
 			{
diff --git a/lib/openssl/crypto/asn1/x_bignum.c b/lib/openssl/crypto/asn1/x_bignum.c
index 9cf3204..827d7af 100644
--- a/lib/openssl/crypto/asn1/x_bignum.c
+++ b/lib/openssl/crypto/asn1/x_bignum.c
@@ -81,7 +81,8 @@
 	bn_free,
 	0,
 	bn_c2i,
-	bn_i2c
+	bn_i2c,
+	NULL
 };
 
 ASN1_ITEM_start(BIGNUM)
diff --git a/lib/openssl/crypto/bn/bn_mul.c b/lib/openssl/crypto/bn/bn_mul.c
index a0e9ec3..ce7ca1d 100644
--- a/lib/openssl/crypto/bn/bn_mul.c
+++ b/lib/openssl/crypto/bn/bn_mul.c
@@ -551,7 +551,7 @@
 	     int tna, int tnb, BN_ULONG *t)
 	{
 	int i,j,n2=n*2;
-	int c1,c2,neg,zero;
+	int c1,c2,neg;
 	BN_ULONG ln,lo,*p;
 
 # ifdef BN_COUNT
@@ -567,7 +567,7 @@
 	/* r=(a[0]-a[1])*(b[1]-b[0]) */
 	c1=bn_cmp_part_words(a,&(a[n]),tna,n-tna);
 	c2=bn_cmp_part_words(&(b[n]),b,tnb,tnb-n);
-	zero=neg=0;
+	neg=0;
 	switch (c1*3+c2)
 		{
 	case -4:
@@ -575,8 +575,6 @@
 		bn_sub_part_words(&(t[n]),b,      &(b[n]),tnb,n-tnb); /* - */
 		break;
 	case -3:
-		zero=1;
-		/* break; */
 	case -2:
 		bn_sub_part_words(t,      &(a[n]),a,      tna,tna-n); /* - */
 		bn_sub_part_words(&(t[n]),&(b[n]),b,      tnb,tnb-n); /* + */
@@ -585,16 +583,12 @@
 	case -1:
 	case 0:
 	case 1:
-		zero=1;
-		/* break; */
 	case 2:
 		bn_sub_part_words(t,      a,      &(a[n]),tna,n-tna); /* + */
 		bn_sub_part_words(&(t[n]),b,      &(b[n]),tnb,n-tnb); /* - */
 		neg=1;
 		break;
 	case 3:
-		zero=1;
-		/* break; */
 	case 4:
 		bn_sub_part_words(t,      a,      &(a[n]),tna,n-tna);
 		bn_sub_part_words(&(t[n]),&(b[n]),b,      tnb,tnb-n);
@@ -1012,7 +1006,6 @@
 		{
 		if (i >= -1 && i <= 1)
 			{
-			int sav_j =0;
 			/* Find out the power of two lower or equal
 			   to the longest of the two numbers */
 			if (i >= 0)
@@ -1023,7 +1016,6 @@
 				{
 				j = BN_num_bits_word((BN_ULONG)bl);
 				}
-			sav_j = j;
 			j = 1<<(j-1);
 			assert(j <= al || j <= bl);
 			k = j+j;
diff --git a/lib/openssl/crypto/conf/conf_api.c b/lib/openssl/crypto/conf/conf_api.c
index d39503c..586b03c 100644
--- a/lib/openssl/crypto/conf/conf_api.c
+++ b/lib/openssl/crypto/conf/conf_api.c
@@ -65,6 +65,7 @@
 
 #include <assert.h>
 #include <string.h>
+#include <stdlib.h>
 #include <openssl/conf.h>
 #include <openssl/conf_api.h>
 #include <openssl/e_os.h>
diff --git a/lib/openssl/crypto/conf/conf_def.c b/lib/openssl/crypto/conf/conf_def.c
index 0b571b0..5e8506c 100644
--- a/lib/openssl/crypto/conf/conf_def.c
+++ b/lib/openssl/crypto/conf/conf_def.c
@@ -68,6 +68,7 @@
 #include "conf_def.h"
 #include <openssl/buffer.h>
 #include <openssl/err.h>
+#include <bio.h>
 
 static char *eat_ws(CONF *conf, char *p);
 static char *eat_alpha_numeric(CONF *conf, char *p);
@@ -187,9 +188,9 @@
 	BIO *in=NULL;
 
 #ifdef OPENSSL_SYS_VMS
-	in=BIO_new_file(name, "r");
+	in= (BIO *)BIO_new_file(name, "r");
 #else
-	in=BIO_new_file(name, "rb");
+	in= (BIO *)BIO_new_file(name, "rb");
 #endif
 	if (in == NULL)
 		{
@@ -213,13 +214,12 @@
 	int bufnum=0,i,ii;
 	BUF_MEM *buff=NULL;
 	char *s,*p,*end;
-	int again,n;
+	int again;
 	long eline=0;
 	char btmp[DECIMAL_SIZE(eline)+1];
 	CONF_VALUE *v=NULL,*tv;
 	CONF_VALUE *sv=NULL;
 	char *section=NULL,*buf;
-	STACK_OF(CONF_VALUE) *section_sk=NULL,*ts;
 	char *start,*psection,*pname;
 	void *h = (void *)(conf->data);
 
@@ -250,8 +250,6 @@
 					CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
 		goto err;
 		}
-	section_sk=(STACK_OF(CONF_VALUE) *)sv->value;
-
 	bufnum=0;
 	again=0;
 	for (;;)
@@ -309,7 +307,6 @@
 		buf=buff->data;
 
 		clear_comments(conf, buf);
-		n=strlen(buf);
 		s=eat_ws(conf, buf);
 		if (IS_EOF(conf,*s)) continue; /* blank line */
 		if (*s == '[')
@@ -343,7 +340,6 @@
 					CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
 				goto err;
 				}
-			section_sk=(STACK_OF(CONF_VALUE) *)sv->value;
 			continue;
 			}
 		else
@@ -406,12 +402,10 @@
 					   CONF_R_UNABLE_TO_CREATE_NEW_SECTION);
 					goto err;
 					}
-				ts=(STACK_OF(CONF_VALUE) *)tv->value;
 				}
 			else
 				{
 				tv=sv;
-				ts=section_sk;
 				}
 #if 1
 			if (_CONF_add_string(conf, tv, v) == 0)
@@ -465,9 +459,6 @@
 
 static void clear_comments(CONF *conf, char *p)
 	{
-	char *to;
-
-	to=p;
 	for (;;)
 		{
 		if (IS_FCOMMENT(conf,*p))
diff --git a/lib/openssl/crypto/conf/conf_lib.c b/lib/openssl/crypto/conf/conf_lib.c
index 54046de..a82c838 100644
--- a/lib/openssl/crypto/conf/conf_lib.c
+++ b/lib/openssl/crypto/conf/conf_lib.c
@@ -62,6 +62,7 @@
 #include <openssl/conf.h>
 #include <openssl/conf_api.h>
 #include <openssl/lhash.h>
+#include <bio.h>
 
 const char CONF_version[]="CONF" OPENSSL_VERSION_PTEXT;
 
@@ -94,9 +95,9 @@
 	BIO *in=NULL;
 
 #ifdef OPENSSL_SYS_VMS
-	in=BIO_new_file(file, "r");
+	in= (BIO *)BIO_new_file(file, "r");
 #else
-	in=BIO_new_file(file, "rb");
+	in= (BIO *)BIO_new_file(file, "rb");
 #endif
 	if (in == NULL)
 		{
diff --git a/lib/openssl/crypto/err/err.c b/lib/openssl/crypto/err/err.c
index 6237c1b..bd0d402 100644
--- a/lib/openssl/crypto/err/err.c
+++ b/lib/openssl/crypto/err/err.c
@@ -713,7 +713,7 @@
 	 * anyways for now.
 	 */
 #ifdef LK_NO_ERR_STATE
-	return
+	return;
 #endif
 
 #ifdef _OSD_POSIX
diff --git a/lib/openssl/crypto/evp/encode.c b/lib/openssl/crypto/evp/encode.c
index b42c747..28546a8 100644
--- a/lib/openssl/crypto/evp/encode.c
+++ b/lib/openssl/crypto/evp/encode.c
@@ -235,7 +235,7 @@
 int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
 	     const unsigned char *in, int inl)
 	{
-	int seof= -1,eof=0,rv= -1,ret=0,i,v,tmp,n,ln,tmp2,exp_nl;
+	int seof= -1,eof=0,rv= -1,ret=0,i,v,tmp,n,ln,exp_nl;
 	unsigned char *d;
 
 	n=ctx->num;
@@ -319,7 +319,6 @@
 			 * lines.  We process the line and then need to
 			 * accept the '\n' */
 			if ((v != B64_EOF) && (n >= 64)) exp_nl=1;
-			tmp2=v;
 			if (n > 0)
 				{
 				v=EVP_DecodeBlock(out,d,n);
diff --git a/lib/openssl/crypto/evp/m_dss.c b/lib/openssl/crypto/evp/m_dss.c
index 48c2689..7bcc274 100644
--- a/lib/openssl/crypto/evp/m_dss.c
+++ b/lib/openssl/crypto/evp/m_dss.c
@@ -90,6 +90,7 @@
 	EVP_PKEY_DSA_method,
 	SHA_CBLOCK,
 	sizeof(EVP_MD *)+sizeof(SHA_CTX),
+	NULL
 	};
 
 const EVP_MD *EVP_dss(void)
diff --git a/lib/openssl/crypto/evp/m_dss1.c b/lib/openssl/crypto/evp/m_dss1.c
index 4f03fb7..40460b7 100644
--- a/lib/openssl/crypto/evp/m_dss1.c
+++ b/lib/openssl/crypto/evp/m_dss1.c
@@ -91,6 +91,7 @@
 	EVP_PKEY_DSA_method,
 	SHA_CBLOCK,
 	sizeof(EVP_MD *)+sizeof(SHA_CTX),
+	NULL
 	};
 
 const EVP_MD *EVP_dss1(void)
diff --git a/lib/openssl/crypto/evp/m_null.c b/lib/openssl/crypto/evp/m_null.c
index cb07216..b6e6d76 100644
--- a/lib/openssl/crypto/evp/m_null.c
+++ b/lib/openssl/crypto/evp/m_null.c
@@ -85,6 +85,7 @@
 	EVP_PKEY_NULL_method,
 	0,
 	sizeof(EVP_MD *),
+	NULL
 	};
 
 const EVP_MD *EVP_md_null(void)
diff --git a/lib/openssl/crypto/evp/m_ripemd.c b/lib/openssl/crypto/evp/m_ripemd.c
index a1d60ee..fb639d1 100644
--- a/lib/openssl/crypto/evp/m_ripemd.c
+++ b/lib/openssl/crypto/evp/m_ripemd.c
@@ -92,6 +92,7 @@
 	EVP_PKEY_RSA_method,
 	RIPEMD160_CBLOCK,
 	sizeof(EVP_MD *)+sizeof(RIPEMD160_CTX),
+	NULL
 	};
 
 const EVP_MD *EVP_ripemd160(void)
diff --git a/lib/openssl/crypto/evp/m_sha1.c b/lib/openssl/crypto/evp/m_sha1.c
index 9a2790f..bd8c5e3 100644
--- a/lib/openssl/crypto/evp/m_sha1.c
+++ b/lib/openssl/crypto/evp/m_sha1.c
@@ -91,6 +91,7 @@
 	EVP_PKEY_RSA_method,
 	SHA_CBLOCK,
 	sizeof(EVP_MD *)+sizeof(SHA_CTX),
+	NULL
 	};
 
 const EVP_MD *EVP_sha1(void)
@@ -128,6 +129,7 @@
 	EVP_PKEY_RSA_method,
 	SHA256_CBLOCK,
 	sizeof(EVP_MD *)+sizeof(SHA256_CTX),
+	NULL
 	};
 
 const EVP_MD *EVP_sha224(void)
@@ -147,6 +149,7 @@
 	EVP_PKEY_RSA_method,
 	SHA256_CBLOCK,
 	sizeof(EVP_MD *)+sizeof(SHA256_CTX),
+	NULL
 	};
 
 const EVP_MD *EVP_sha256(void)
@@ -178,6 +181,7 @@
 	EVP_PKEY_RSA_method,
 	SHA512_CBLOCK,
 	sizeof(EVP_MD *)+sizeof(SHA512_CTX),
+	NULL
 	};
 
 const EVP_MD *EVP_sha384(void)
@@ -197,6 +201,7 @@
 	EVP_PKEY_RSA_method,
 	SHA512_CBLOCK,
 	sizeof(EVP_MD *)+sizeof(SHA512_CTX),
+	NULL
 	};
 
 const EVP_MD *EVP_sha512(void)
diff --git a/lib/openssl/crypto/mem_dbg.c b/lib/openssl/crypto/mem_dbg.c
index 9a07537..236431e 100644
--- a/lib/openssl/crypto/mem_dbg.c
+++ b/lib/openssl/crypto/mem_dbg.c
@@ -537,7 +537,11 @@
 				m->addr, m->num);
 #endif
 			if (options & V_CRYPTO_MDEBUG_TIME)
+#ifndef LK_NO_TIME
 				m->time=time(NULL);
+#else
+				m->time=0;
+#endif
 			else
 				m->time=0;
 
@@ -753,6 +757,10 @@
 		}
 #endif
 	}
+#else
+static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
+{
+}
 #endif
 
 static IMPLEMENT_LHASH_DOALL_ARG_FN(print_leak, const MEM, MEM_LEAK)
diff --git a/lib/openssl/crypto/modes/cbc128.c b/lib/openssl/crypto/modes/cbc128.c
index 8f8bd56..af2d93a 100644
--- a/lib/openssl/crypto/modes/cbc128.c
+++ b/lib/openssl/crypto/modes/cbc128.c
@@ -176,7 +176,7 @@
 				for(n=0; n<16; n+=sizeof(size_t)) {
 					c = *(size_t *)(in+n);
 					*(size_t *)(out+n) =
-					*(size_t *)(tmp.c+n) ^ *(size_t *)(ivec+n);
+					*(tmp.c+n) ^ *(size_t *)(ivec+n);
 					*(size_t *)(ivec+n) = c;
 				}
 				len -= 16;
diff --git a/lib/openssl/crypto/pkcs7/pk7_doit.c b/lib/openssl/crypto/pkcs7/pk7_doit.c
index 451de84..3bf1a36 100644
--- a/lib/openssl/crypto/pkcs7/pk7_doit.c
+++ b/lib/openssl/crypto/pkcs7/pk7_doit.c
@@ -422,7 +422,6 @@
 	X509_ALGOR *enc_alg=NULL;
 	STACK_OF(X509_ALGOR) *md_sk=NULL;
 	STACK_OF(PKCS7_RECIP_INFO) *rsk=NULL;
-	X509_ALGOR *xalg=NULL;
 	PKCS7_RECIP_INFO *ri=NULL;
 
 	i=OBJ_obj2nid(p7->type);
@@ -445,7 +444,6 @@
 			PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CIPHER_TYPE);
 			goto err;
 			}
-		xalg=p7->d.signed_and_enveloped->enc_data->algorithm;
 		break;
 	case NID_pkcs7_enveloped:
 		rsk=p7->d.enveloped->recipientinfo;
@@ -457,7 +455,6 @@
 			PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CIPHER_TYPE);
 			goto err;
 			}
-		xalg=p7->d.enveloped->enc_data->algorithm;
 		break;
 	default:
 		PKCS7err(PKCS7_F_PKCS7_DATADECODE,PKCS7_R_UNSUPPORTED_CONTENT_TYPE);
diff --git a/lib/openssl/crypto/pkcs7/pk7_lib.c b/lib/openssl/crypto/pkcs7/pk7_lib.c
index 3ca0952..d411269 100644
--- a/lib/openssl/crypto/pkcs7/pk7_lib.c
+++ b/lib/openssl/crypto/pkcs7/pk7_lib.c
@@ -591,7 +591,6 @@
 int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher)
 	{
 	int i;
-	ASN1_OBJECT *objtmp;
 	PKCS7_ENC_CONTENT *ec;
 
 	i=OBJ_obj2nid(p7->type);
@@ -614,7 +613,6 @@
 		PKCS7err(PKCS7_F_PKCS7_SET_CIPHER,PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER);
 		return(0);
 	}
-	objtmp = OBJ_nid2obj(i);
 
 	ec->cipher = cipher;
 	return 1;
diff --git a/lib/openssl/crypto/rsa/rsa_ameth.c b/lib/openssl/crypto/rsa/rsa_ameth.c
index 033e2b6..806c263 100644
--- a/lib/openssl/crypto/rsa/rsa_ameth.c
+++ b/lib/openssl/crypto/rsa/rsa_ameth.c
@@ -352,6 +352,27 @@
 		{
 		EVP_PKEY_RSA2,
 		EVP_PKEY_RSA,
-		ASN1_PKEY_ALIAS
+		ASN1_PKEY_ALIAS,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL,
+		NULL
 		}
 	};
diff --git a/lib/openssl/crypto/rules.mk b/lib/openssl/crypto/rules.mk
index d149473..63c4d0f 100644
--- a/lib/openssl/crypto/rules.mk
+++ b/lib/openssl/crypto/rules.mk
@@ -13,7 +13,8 @@
 			-I$(LOCAL_DIR)/x509 \
 			-I$(LOCAL_DIR)/../.. \
 			-I$(LOCAL_DIR)/../include \
-			-I$(LOCAL_DIR)/../include/openssl
+			-I$(LOCAL_DIR)/../include/openssl \
+			-I$(LOCAL_DIR)/../../openssl
 
 OBJS +=  $(LOCAL_DIR)/bn/asm/armv4-mont.o
 
diff --git a/lib/openssl/crypto/x509/x509_vfy.c b/lib/openssl/crypto/x509/x509_vfy.c
index 16baf47..67a3051 100644
--- a/lib/openssl/crypto/x509/x509_vfy.c
+++ b/lib/openssl/crypto/x509/x509_vfy.c
@@ -155,7 +155,6 @@
 int X509_verify_cert(X509_STORE_CTX *ctx)
 	{
 	X509 *x,*xtmp,*chain_ss=NULL;
-	X509_NAME *xn;
 	int bad_chain = 0;
 	X509_VERIFY_PARAM *param = ctx->param;
 	int depth,i,ok=0;
@@ -207,7 +206,6 @@
 		                         */
 
 		/* If we are self signed, we break */
-		xn=X509_get_issuer_name(x);
 		if (ctx->check_issued(ctx, x,x)) break;
 
 		/* If we were passed a cert chain, use it first */
@@ -244,7 +242,6 @@
 
 	i=sk_X509_num(ctx->chain);
 	x=sk_X509_value(ctx->chain,i-1);
-	xn = X509_get_subject_name(x);
 	if (ctx->check_issued(ctx, x, x))
 		{
 		/* we have a self signed certificate */
@@ -293,7 +290,6 @@
 		if (depth < num) break;
 
 		/* If we are self signed, we break */
-		xn=X509_get_issuer_name(x);
 		if (ctx->check_issued(ctx,x,x)) break;
 
 		ok = ctx->get_issuer(&xtmp, ctx, x);
@@ -311,8 +307,6 @@
 		num++;
 		}
 
-	/* we now have our chain, lets check it... */
-	xn=X509_get_issuer_name(x);
 
 	/* Is last certificate looked up self signed? */
 	if (!ctx->check_issued(ctx,x,x))
diff --git a/lib/openssl/crypto/x509v3/pcy_tree.c b/lib/openssl/crypto/x509v3/pcy_tree.c
index 92f6b24..04e3d59 100644
--- a/lib/openssl/crypto/x509v3/pcy_tree.c
+++ b/lib/openssl/crypto/x509v3/pcy_tree.c
@@ -341,9 +341,7 @@
 				const X509_POLICY_CACHE *cache)
 	{
 	int i;
-	X509_POLICY_LEVEL *last;
 	X509_POLICY_DATA *data;
-	last = curr - 1;
 	for (i = 0; i < sk_X509_POLICY_DATA_num(cache->data); i++)
 		{
 		data = sk_X509_POLICY_DATA_value(cache->data, i);
diff --git a/lib/openssl/crypto/x509v3/v3_ncons.c b/lib/openssl/crypto/x509v3/v3_ncons.c
index ec200ba..d7e9c4c 100644
--- a/lib/openssl/crypto/x509v3/v3_ncons.c
+++ b/lib/openssl/crypto/x509v3/v3_ncons.c
@@ -62,6 +62,7 @@
 #include <openssl/asn1t.h>
 #include <openssl/conf.h>
 #include <openssl/x509v3.h>
+#include <e_os.h>
 
 static void *v2i_NAME_CONSTRAINTS(const X509V3_EXT_METHOD *method,
 				  X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval);
diff --git a/lib/openssl/crypto/x509v3/v3_utl.c b/lib/openssl/crypto/x509v3/v3_utl.c
index e030234..87cfceb 100644
--- a/lib/openssl/crypto/x509v3/v3_utl.c
+++ b/lib/openssl/crypto/x509v3/v3_utl.c
@@ -365,7 +365,7 @@
 	char *tmp, *q;
 	const unsigned char *p;
 	int i;
-	const static char hexdig[] = "0123456789ABCDEF";
+	static const char hexdig[] = "0123456789ABCDEF";
 	if(!buffer || !len) return NULL;
 	if(!(tmp = OPENSSL_malloc(len * 3 + 1))) {
 		X509V3err(X509V3_F_HEX_TO_STRING,ERR_R_MALLOC_FAILURE);
diff --git a/lib/openssl/e_os.h b/lib/openssl/e_os.h
index f527ae9..26f9bac 100644
--- a/lib/openssl/e_os.h
+++ b/lib/openssl/e_os.h
@@ -62,6 +62,7 @@
 #include <openssl/opensslconf.h>
 
 #include <openssl/e_os2.h>
+#include <stdlib.h>
 /* <openssl/e_os2.h> contains what we can justify to make visible
  * to the outside; this file e_os.h is not part of the exported
  * interface. */
@@ -645,7 +646,7 @@
 #  endif
 #endif
 
-#if defined(sun) && !defined(__svr4__) && !defined(__SVR4)
+#if defined(OPENSSL_LK) || defined(sun) && !defined(__svr4__) && !defined(__SVR4)
   /* include headers first, so our defines don't break it */
 #include <stdlib.h>
 #include <string.h>
@@ -679,9 +680,9 @@
 #define IRIX_CC_BUG	/* CDS++ up to V2.0Bsomething suffered from the same bug.*/
 #endif
 
-#if defined(OPENSSL_SYS_WINDOWS)
-#  define strcasecmp _stricmp
-#  define strncasecmp _strnicmp
+#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_LK)
+#  define strcasecmp strcmp
+#  define strncasecmp strnicmp
 #elif defined(OPENSSL_SYS_VMS)
 /* VMS below version 7.0 doesn't have strcasecmp() */
 #  include "o_str.h"
diff --git a/lib/openssl/include/openssl/bio.h b/lib/openssl/include/openssl/bio.h
index 152802f..f7eac3e 100644
--- a/lib/openssl/include/openssl/bio.h
+++ b/lib/openssl/include/openssl/bio.h
@@ -61,7 +61,7 @@
 
 #include <openssl/e_os2.h>
 
-#ifndef OPENSSL_NO_FP_API
+#if !defined(OPENSSL_NO_FP_API)|| defined(OPENSSL_LK)
 # include <stdio.h>
 #endif
 #include <stdarg.h>
@@ -564,7 +564,7 @@
 int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix,
 					asn1_ps_func **psuffix_free);
 
-# ifndef OPENSSL_NO_FP_API
+# if !(defined(OPENSSL_NO_FP_API)) || defined(OPENSSL_LK)
 BIO_METHOD *BIO_s_file(void );
 BIO *BIO_new_file(const char *filename, const char *mode);
 BIO *BIO_new_fp(FILE *stream, int close_flag);
diff --git a/platform/apq8084/include/platform/iomap.h b/platform/apq8084/include/platform/iomap.h
index 67a6f5b..3129ba4 100644
--- a/platform/apq8084/include/platform/iomap.h
+++ b/platform/apq8084/include/platform/iomap.h
@@ -285,6 +285,10 @@
 #define HDMI_BASE               0xFD922100
 #define REG_HDMI(off)           (HDMI_BASE + (off))
 
+#define HDMI_ACR_32_0           REG_HDMI(0xC4)
+#define HDMI_ACR_32_1           REG_HDMI(0xC8)
+#define HDMI_ACR_44_0           REG_HDMI(0xCC)
+#define HDMI_ACR_44_1           REG_HDMI(0xD0)
 #define HDMI_ACR_48_0           REG_HDMI(0xD4)
 #define HDMI_ACR_48_1           REG_HDMI(0xD8)
 #define HDMI_AUDIO_PKT_CTRL2    REG_HDMI(0x44)
@@ -304,6 +308,17 @@
 #define LPASS_LPAIF_RDDMA_PER_LEN0   0xFE152010
 #define LPASS_LPAIF_DEBUG_CTL        0xFE15E004
 
+#define HDMI_DDC_SPEED          REG_HDMI(0x220)
+#define HDMI_DDC_SETUP          REG_HDMI(0x224)
+#define HDMI_DDC_REF            REG_HDMI(0x27C)
+#define HDMI_DDC_DATA           REG_HDMI(0x238)
+#define HDMI_DDC_TRANS0         REG_HDMI(0x228)
+#define HDMI_DDC_TRANS1         REG_HDMI(0x22C)
+#define HDMI_DDC_CTRL           REG_HDMI(0x20C)
+#define HDMI_DDC_INT_CTRL       REG_HDMI(0x214)
+#define HDMI_DDC_SW_STATUS      REG_HDMI(0x218)
+#define HDMI_DDC_ARBITRATION    REG_HDMI(0x210)
+
 #define HDMI_USEC_REFTIMER      REG_HDMI(0x208)
 #define HDMI_CTRL               REG_HDMI(0x000)
 #define HDMI_HPD_INT_STATUS     REG_HDMI(0x250)
diff --git a/platform/msmzirc/acpuclock.c b/platform/mdm9640/acpuclock.c
similarity index 100%
rename from platform/msmzirc/acpuclock.c
rename to platform/mdm9640/acpuclock.c
diff --git a/platform/msmzirc/gpio.c b/platform/mdm9640/gpio.c
similarity index 100%
rename from platform/msmzirc/gpio.c
rename to platform/mdm9640/gpio.c
diff --git a/platform/msmzirc/include/platform/clock.h b/platform/mdm9640/include/platform/clock.h
similarity index 95%
rename from platform/msmzirc/include/platform/clock.h
rename to platform/mdm9640/include/platform/clock.h
index 19efae5..5832086 100644
--- a/platform/msmzirc/include/platform/clock.h
+++ b/platform/mdm9640/include/platform/clock.h
@@ -26,8 +26,8 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef __PLATFORM_MSMZIRC_CLOCK_H
-#define __PLATFORM_MSMZIRC_CLOCK_H
+#ifndef __PLATFORM_MDM9640_CLOCK_H
+#define __PLATFORM_MDM9640_CLOCK_H
 
 #define UART_DM_CLK_RX_TX_BIT_RATE 0xCC
 
diff --git a/platform/msmzirc/include/platform/gpio.h b/platform/mdm9640/include/platform/gpio.h
similarity index 97%
rename from platform/msmzirc/include/platform/gpio.h
rename to platform/mdm9640/include/platform/gpio.h
index 792565f..897043a 100644
--- a/platform/msmzirc/include/platform/gpio.h
+++ b/platform/mdm9640/include/platform/gpio.h
@@ -26,8 +26,8 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef __PLATFORM_MSMZIRC_GPIO_H
-#define __PLATFORM_MSMZIRC_GPIO_H
+#ifndef __PLATFORM_MDM9640_GPIO_H
+#define __PLATFORM_MDM9640_GPIO_H
 
 #include <bits.h>
 #include <gpio.h>
diff --git a/platform/msmzirc/include/platform/iomap.h b/platform/mdm9640/include/platform/iomap.h
similarity index 98%
rename from platform/msmzirc/include/platform/iomap.h
rename to platform/mdm9640/include/platform/iomap.h
index 6cee378..3d63543 100644
--- a/platform/msmzirc/include/platform/iomap.h
+++ b/platform/mdm9640/include/platform/iomap.h
@@ -26,8 +26,8 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef _PLATFORM_MSMZIRC_IOMAP_H_
-#define _PLATFORM_MSMZIRC_IOMAP_H_
+#ifndef _PLATFORM_MDM9640_IOMAP_H_
+#define _PLATFORM_MDM9640_IOMAP_H_
 
 /* NAND */
 #define MSM_NAND_BASE               0x079B0000
diff --git a/platform/msmzirc/include/platform/irqs.h b/platform/mdm9640/include/platform/irqs.h
similarity index 96%
rename from platform/msmzirc/include/platform/irqs.h
rename to platform/mdm9640/include/platform/irqs.h
index a0efe05..a9e8fc5 100644
--- a/platform/msmzirc/include/platform/irqs.h
+++ b/platform/mdm9640/include/platform/irqs.h
@@ -26,8 +26,8 @@
  *
  */
 
-#ifndef __IRQS_MSMZIRC_H
-#define __IRQS_MSMZIRC_H
+#ifndef __IRQS_MDM9640_H
+#define __IRQS_MDM9640_H
 
 /* TBD: The numbers need to be reviewed */
 
@@ -59,4 +59,4 @@
 #define NR_IRQS                                (NR_MSM_IRQS + NR_GPIO_IRQS + \
                                                NR_BOARD_IRQS)
 #define SMD_IRQ                                (GIC_SPI_START + 168)
-#endif /* __IRQS_9635_H */
+#endif /* __IRQS_9640_H */
diff --git a/platform/msmzirc/msmzirc-clock.c b/platform/mdm9640/mdm9640-clock.c
similarity index 98%
rename from platform/msmzirc/msmzirc-clock.c
rename to platform/mdm9640/mdm9640-clock.c
index 497ed35..a03f643 100644
--- a/platform/msmzirc/msmzirc-clock.c
+++ b/platform/mdm9640/mdm9640-clock.c
@@ -368,7 +368,7 @@
 	},
 };
 
-static struct clk_lookup msm_clocks_zirc[] =
+static struct clk_lookup msm_clocks_9640[] =
 {
 	CLK_LOOKUP("sdc1_iface_clk", gcc_sdcc1_ahb_clk.c),
 	CLK_LOOKUP("sdc1_core_clk",  gcc_sdcc1_apps_clk.c),
@@ -389,5 +389,5 @@
 
 void platform_clock_init(void)
 {
-	clk_init(msm_clocks_zirc, ARRAY_SIZE(msm_clocks_zirc));
+	clk_init(msm_clocks_9640, ARRAY_SIZE(msm_clocks_9640));
 }
diff --git a/platform/msmzirc/platform.c b/platform/mdm9640/platform.c
similarity index 100%
rename from platform/msmzirc/platform.c
rename to platform/mdm9640/platform.c
diff --git a/platform/msmzirc/rules.mk b/platform/mdm9640/rules.mk
similarity index 92%
rename from platform/msmzirc/rules.mk
rename to platform/mdm9640/rules.mk
index 91fb286..57427f2 100644
--- a/platform/msmzirc/rules.mk
+++ b/platform/mdm9640/rules.mk
@@ -12,7 +12,7 @@
 	$(LOCAL_DIR)/platform.o \
 	$(LOCAL_DIR)/gpio.o \
 	$(LOCAL_DIR)/acpuclock.o \
-	$(LOCAL_DIR)/msmzirc-clock.o
+	$(LOCAL_DIR)/mdm9640-clock.o
 
 LINKER_SCRIPT += $(BUILDDIR)/system-onesegment.ld
 
diff --git a/platform/msm8226/acpuclock.c b/platform/msm8226/acpuclock.c
index 503ad7b..a6523d5 100755
--- a/platform/msm8226/acpuclock.c
+++ b/platform/msm8226/acpuclock.c
@@ -112,8 +112,7 @@
 /* Configure MMC clock */
 void clock_config_mmc(uint32_t interface, uint32_t freq)
 {
-	int ret;
-	uint32_t reg;
+	int ret = 0;
 	char clk_name[64];
 
 	snprintf(clk_name, 64, "sdc%u_core_clk", interface);
diff --git a/platform/msm8226/include/platform/clock.h b/platform/msm8226/include/platform/clock.h
index 399c765..3ada195 100755
--- a/platform/msm8226/include/platform/clock.h
+++ b/platform/msm8226/include/platform/clock.h
@@ -83,5 +83,10 @@
 void clock_ce_disable(uint8_t instance);
 void mdp_clock_init(void);
 void mdp_gdsc_ctrl(uint8_t enable);
-
+void mdp_clock_disable(void);
+void mdp_clock_enable(void);
+void mmss_bus_clocks_enable(void);
+void mmss_bus_clocks_disable(void);
+void mmss_dsi_clocks_enable(uint8_t pclk0_m, uint8_t pclk0_n, uint8_t pclk0_d);
+void mmss_dsi_clocks_disable(void);
 #endif
diff --git a/platform/msm8226/msm8226-clock.c b/platform/msm8226/msm8226-clock.c
index d79b895..09a854a 100644
--- a/platform/msm8226/msm8226-clock.c
+++ b/platform/msm8226/msm8226-clock.c
@@ -501,7 +501,7 @@
 };
 
 static struct branch_clk mdss_mdp_lut_clk = {
-	.cbcr_reg    = MDP_LUT_CBCR,
+	.cbcr_reg    = (uint32_t *)MDP_LUT_CBCR,
 	.parent      = &mdss_mdp_clk_src.c,
 	.has_sibling = 1,
 
@@ -512,7 +512,7 @@
 };
 
 static struct branch_clk mdss_vsync_clk = {
-	.cbcr_reg    = MDSS_VSYNC_CBCR,
+	.cbcr_reg    = (uint32_t *)MDSS_VSYNC_CBCR,
 	.parent      = &vsync_clk_src.c,
 	.has_sibling = 0,
 
diff --git a/platform/msm8226/platform.c b/platform/msm8226/platform.c
index 1d15a62..9735fba 100644
--- a/platform/msm8226/platform.c
+++ b/platform/msm8226/platform.c
@@ -38,8 +38,6 @@
 #include <board.h>
 #include <boot_stats.h>
 
-#define MB (1024*1024)
-
 #define MSM_IOMAP_SIZE ((MSM_IOMAP_END - MSM_IOMAP_BASE)/MB)
 
 /* LK memory - cacheable, write through */
diff --git a/platform/msm8916/acpuclock.c b/platform/msm8916/acpuclock.c
index bcc65f0..0cdc26f 100644
--- a/platform/msm8916/acpuclock.c
+++ b/platform/msm8916/acpuclock.c
@@ -36,6 +36,7 @@
 #include <clock.h>
 #include <platform/clock.h>
 #include <blsp_qup.h>
+#include <platform.h>
 
 void hsusb_clock_init(void)
 {
@@ -112,8 +113,7 @@
 /* Configure MMC clock */
 void clock_config_mmc(uint32_t interface, uint32_t freq)
 {
-	int ret;
-	uint32_t reg;
+	int ret = 1;
 	char clk_name[64];
 
 	snprintf(clk_name, sizeof(clk_name), "sdc%u_core_clk", interface);
diff --git a/platform/msm8916/gpio.c b/platform/msm8916/gpio.c
index a0af57c..2453b33 100644
--- a/platform/msm8916/gpio.c
+++ b/platform/msm8916/gpio.c
@@ -51,22 +51,6 @@
 	return;
 }
 
-void gpio_set_value(uint32_t gpio, uint32_t value)
-{
-	/* GPIO_OUTPUT */
-	if (value) {
-		writel(GPIO_OUT_VAL(gpio),
-			(uint32_t *)GPIO_OUT_SET_ADDR(gpio));
-	} else {
-		writel(GPIO_OUT_VAL(gpio),
-			(uint32_t *)GPIO_OUT_CLR_ADDR(gpio));
-	}
-	/* GPIO_OE */
-	writel(GPIO_OUT_OE_VAL(gpio),
-			(uint32_t *)GPIO_OUT_OE_SET_ADDR(gpio));
-	return;
-}
-
 uint32_t gpio_status(uint32_t gpio)
 {
 	return readl(GPIO_IN_OUT_ADDR(gpio)) & GPIO_IN;
diff --git a/platform/msm8916/include/platform/clock.h b/platform/msm8916/include/platform/clock.h
index 4b0a5ef..fab6259 100644
--- a/platform/msm8916/include/platform/clock.h
+++ b/platform/msm8916/include/platform/clock.h
@@ -79,7 +79,8 @@
 #define DSI_PIXEL1_D                    REG_MM(0x4D0C8)
 
 void platform_clock_init(void);
-
+void mdp_clock_enable(void);
+void mdp_clock_disable(void);
 void clock_init_mmc(uint32_t interface);
 void clock_config_mmc(uint32_t interface, uint32_t freq);
 void clock_config_uart_dm(uint8_t id);
@@ -87,6 +88,10 @@
 void clock_config_ce(uint8_t instance);
 void mdp_clock_init(void);
 void mdp_gdsc_ctrl(uint8_t enable);
+void mdss_bus_clocks_enable(void);
+void mdss_bus_clocks_disable(void);
+void gcc_dsi_clocks_enable(uint8_t dual_dsi,uint8_t pclk0_m, uint8_t pclk0_n, uint8_t pclk0_d);
+void gcc_dsi_clocks_disable(uint8_t dual_dsi);
 void clock_ce_enable(uint8_t instance);
 void clock_ce_disable(uint8_t instance);
 void clock_config_blsp_i2c(uint8_t blsp_id, uint8_t qup_id);
diff --git a/platform/msm8916/include/platform/gpio.h b/platform/msm8916/include/platform/gpio.h
index 5b4552b..0437aff 100644
--- a/platform/msm8916/include/platform/gpio.h
+++ b/platform/msm8916/include/platform/gpio.h
@@ -69,6 +69,5 @@
 			uint8_t pull,
 			uint8_t drvstr,
 			uint32_t enable);
-void gpio_set_value(uint32_t gpio, uint32_t value);
 void gpio_config_blsp_i2c(uint8_t blsp_id, uint8_t qup_id);
 #endif
diff --git a/platform/msm8916/include/platform/iomap.h b/platform/msm8916/include/platform/iomap.h
index 2532601..05f14dd 100644
--- a/platform/msm8916/include/platform/iomap.h
+++ b/platform/msm8916/include/platform/iomap.h
@@ -159,10 +159,14 @@
 #define DSI1_PHY_BASE               (0x1AA0500)
 #define DSI0_PLL_BASE               (0x1A98300)
 #define DSI1_PLL_BASE               DSI0_PLL_BASE
+#define DSIPHY_PLL_CTRL(x)       REG_DSI(DSI0_PLL_BASE + (x) * 4)
 #define REG_DSI(off)                (MIPI_DSI_BASE + 0x04 + (off))
 #define MDP_BASE                    (0x1A00000)
 #define REG_MDP(off)                (MDP_BASE + (off))
 #define MDP_HW_REV                              REG_MDP(0x1000)
+#define MDP_INTR_EN                             REG_MDP(0x1010)
+#define MDP_INTR_CLEAR                          REG_MDP(0x1018)
+#define MDP_HIST_INTR_EN                        REG_MDP(0x101C)
 #define MDP_VP_0_VIG_0_BASE                     REG_MDP(0x5000)
 #define MDP_VP_0_VIG_1_BASE                     REG_MDP(0x7000)
 #define MDP_VP_0_RGB_0_BASE                     REG_MDP(0x15000)
diff --git a/platform/msm8916/msm8916-clock.c b/platform/msm8916/msm8916-clock.c
index d4289c1..d2b7215 100644
--- a/platform/msm8916/msm8916-clock.c
+++ b/platform/msm8916/msm8916-clock.c
@@ -34,6 +34,7 @@
 #include <clock_lib2.h>
 #include <platform/clock.h>
 #include <platform/iomap.h>
+#include <platform.h>
 
 
 /* Mux source select values */
@@ -44,7 +45,6 @@
 #define gpll1_mm_source_val 1
 struct clk_freq_tbl rcg_dummy_freq = F_END;
 
-
 /* Clock Operations */
 static struct clk_ops clk_ops_branch =
 {
@@ -477,7 +477,7 @@
 };
 
 static struct branch_clk mdss_vsync_clk = {
-	.cbcr_reg    = MDSS_VSYNC_CBCR,
+	.cbcr_reg    = (uint32_t *) MDSS_VSYNC_CBCR,
 	.parent      = &vsync_clk_src.c,
 	.has_sibling = 0,
 
@@ -554,7 +554,7 @@
 };
 
 static struct branch_clk gcc_blsp1_qup2_i2c_apps_clk = {
-	.cbcr_reg = GCC_BLSP1_QUP2_APPS_CBCR,
+	.cbcr_reg = (uint32_t *) GCC_BLSP1_QUP2_APPS_CBCR,
 	.parent   = &gcc_blsp1_qup2_i2c_apps_clk_src.c,
 
 	.c = {
diff --git a/platform/msm8916/platform.c b/platform/msm8916/platform.c
index 0558b35..a367985 100644
--- a/platform/msm8916/platform.c
+++ b/platform/msm8916/platform.c
@@ -30,6 +30,7 @@
 #include <reg.h>
 #include <platform/iomap.h>
 #include <platform/irqs.h>
+#include <platform/clock.h>
 #include <qgic.h>
 #include <qtimer.h>
 #include <mmu.h>
@@ -37,8 +38,7 @@
 #include <smem.h>
 #include <board.h>
 #include <boot_stats.h>
-
-#define MB (1024*1024)
+#include <platform.h>
 
 #define MSM_IOMAP_SIZE ((MSM_IOMAP_END - MSM_IOMAP_BASE)/MB)
 #define A53_SS_SIZE    ((A53_SS_END - A53_SS_BASE)/MB)
@@ -67,7 +67,6 @@
 	{    BASE_ADDR_1,       BASE_ADDR_1,     1024,              COMMON_MEMORY},
 };
 
-static struct smem_ram_ptable ram_ptable;
 
 int platform_is_msm8939();
 
diff --git a/platform/msm8994/acpuclock.c b/platform/msm8994/acpuclock.c
index 5e2d5a6..ba84606 100644
--- a/platform/msm8994/acpuclock.c
+++ b/platform/msm8994/acpuclock.c
@@ -33,6 +33,26 @@
 #include <clock.h>
 #include <platform/clock.h>
 #include <platform/iomap.h>
+#include <rpm-smd.h>
+#include <regulator.h>
+
+#define RPM_CE_CLK_TYPE    0x6563
+#define CE2_CLK_ID         0x1
+#define RPM_SMD_KEY_RATE   0x007A484B
+
+uint32_t CE2_CLK[][8]=
+{
+	{
+		RPM_CE_CLK_TYPE, CE2_CLK_ID,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
+		RPM_SMD_KEY_RATE, 4, 0,
+	},
+	{
+		RPM_CE_CLK_TYPE, CE2_CLK_ID,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
+		RPM_SMD_KEY_RATE, 4, 176128,
+	},
+};
 
 void hsusb_clock_init(void)
 {
@@ -194,14 +214,42 @@
  */
 static void ce_async_reset(uint8_t instance)
 {
+	if (instance == 2)
+	{
+		/* Start the block reset for CE */
+		writel(1, GCC_CE2_BCR);
+		udelay(2);
+		/* Take CE block out of reset */
+		writel(0, GCC_CE2_BCR);
+		udelay(2);
+	}
+	else
+	{
+		dprintf(CRITICAL, "Unsupported CE instance: %u\n", instance);
+		ASSERT(0);
+	}
 }
 
 void clock_ce_enable(uint8_t instance)
 {
+	if (instance == 2)
+		rpm_send_data(&CE2_CLK[GENERIC_ENABLE][0], 24, RPM_REQUEST_TYPE);
+	else
+	{
+		dprintf(CRITICAL, "Unsupported CE instance: %u\n", instance);
+		ASSERT(0);
+	}
 }
 
 void clock_ce_disable(uint8_t instance)
 {
+	if (instance == 2)
+		rpm_send_data(&CE2_CLK[GENERIC_DISABLE][0], 24, RPM_REQUEST_TYPE);
+	else
+	{
+		dprintf(CRITICAL, "Unsupported CE instance: %u\n", instance);
+		ASSERT(0);
+	}
 }
 
 void clock_config_ce(uint8_t instance)
diff --git a/platform/msm8994/include/platform/iomap.h b/platform/msm8994/include/platform/iomap.h
index 341c0a6..db20bf9 100644
--- a/platform/msm8994/include/platform/iomap.h
+++ b/platform/msm8994/include/platform/iomap.h
@@ -197,6 +197,7 @@
 
 #define MSM_CE2_BAM_BASE            0xFD444000
 #define MSM_CE2_BASE                0xFD45A000
+#define  GCC_CE2_BCR                (CLK_CTL_BASE + 0x1080)
 
 #define TLMM_BASE_ADDR              0xFD510000
 #define GPIO_CONFIG_ADDR(x)         (TLMM_BASE_ADDR + 0x1000 + (x)*0x10)
diff --git a/platform/msm8x60/rules.mk b/platform/msm8x60/rules.mk
index 5f58ee1..9b0f4f1 100644
--- a/platform/msm8x60/rules.mk
+++ b/platform/msm8x60/rules.mk
@@ -8,6 +8,7 @@
 
 MMC_SLOT         := 1
 
+DEFINES += DEFINE_GSBI_I2C=1
 DEFINES += WITH_CPU_EARLY_INIT=0 WITH_CPU_WARM_BOOT=0 \
 	   MMC_SLOT=$(MMC_SLOT) MDP4=1 \
 	   SSD_ENABLE TZ_TAMPER_FUSE
diff --git a/platform/msm_shared/board.c b/platform/msm_shared/board.c
index 07d4f8a..538d381 100644
--- a/platform/msm_shared/board.c
+++ b/platform/msm_shared/board.c
@@ -48,6 +48,8 @@
 	struct smem_board_info_v6 board_info_v6;
 	struct smem_board_info_v7 board_info_v7;
 	struct smem_board_info_v8 board_info_v8;
+	struct smem_board_info_v9 board_info_v9;
+	struct smem_board_info_v10 board_info_v10;
 	unsigned int board_info_len = 0;
 	unsigned ret = 0;
 	unsigned format = 0;
@@ -102,10 +104,8 @@
 			board.pmic_info[0].pmic_type = board_info_v7.pmic_type;
 			board.pmic_info[0].pmic_version = board_info_v7.pmic_version;
 		}
-		else if (format_minor >= 8)
+		else if (format_minor == 8)
 		{
-			dprintf(INFO, "Minor socinfo format detected: %u.%u\n", format_major, format_minor);
-
 			board_info_len = sizeof(board_info_v8);
 
 			ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
@@ -145,12 +145,93 @@
 				board.pmic_info[i].pmic_target = (((board_info_v8.pmic_info[i].pmic_version >> 16) & 0xff) << 16) |
 					   ((board_info_v8.pmic_info[i].pmic_version & 0xff) << 8) | (pmic_type & 0xff);
 			}
+		}
+		else if (format_minor == 0x9)
+		{
+			board_info_len = sizeof(board_info_v9);
 
-			if (format_minor == 0x9)
-				board.foundry_id = board_info_v8.foundry_id;
+			ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
+					&board_info_v9,
+					board_info_len);
+			if (ret)
+				return;
 
-			if (format_minor == 0xA)
-				board.chip_serial = board_info_v8.chip_serial;
+			board.platform = board_info_v9.board_info_v3.msm_id;
+			board.platform_version = board_info_v9.board_info_v3.msm_version;
+			board.platform_hw = board_info_v9.board_info_v3.hw_platform;
+			board.platform_subtype = board_info_v9.platform_subtype;
+
+			/*
+			 * fill in board.target with variant_id information
+			 * bit no         |31  24 | 23   16            | 15   8             |7         0|
+			 * board.target = |subtype| plat_hw_ver major  | plat_hw_ver minor  |hw_platform|
+			 *
+			 */
+			board.target = (((board_info_v9.platform_subtype & 0xff) << 24) |
+						   (((board_info_v9.platform_version >> 16) & 0xff) << 16) |
+						   ((board_info_v9.platform_version & 0xff) << 8) |
+						   (board_info_v9.board_info_v3.hw_platform & 0xff));
+
+			for (i = 0; i < SMEM_V8_SMEM_MAX_PMIC_DEVICES; i++) {
+				board.pmic_info[i].pmic_type = board_info_v9.pmic_info[i].pmic_type;
+				board.pmic_info[i].pmic_version = board_info_v9.pmic_info[i].pmic_version;
+
+				/*
+				 * fill in pimc_board_info with pmic type and pmic version information
+				 * bit no  		  	    |31  24   | 23  16 	    | 15   8 	     |7		  0|
+				 * pimc_board_info = |Unused | Major version | Minor version|PMIC_MODEL|
+				 *
+				 */
+				pmic_type = board_info_v9.pmic_info[i].pmic_type == PMIC_IS_INVALID? 0 : board_info_v9.pmic_info[i].pmic_type;
+
+				board.pmic_info[i].pmic_target = (((board_info_v9.pmic_info[i].pmic_version >> 16) & 0xff) << 16) |
+					   ((board_info_v9.pmic_info[i].pmic_version & 0xff) << 8) | (pmic_type & 0xff);
+			}
+			board.foundry_id = board_info_v9.foundry_id;
+		}
+		else if (format_minor >= 0xA)
+		{
+			board_info_len = sizeof(board_info_v10);
+
+			ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
+					&board_info_v10,
+					board_info_len);
+			if (ret)
+				return;
+
+			board.platform = board_info_v10.board_info_v3.msm_id;
+			board.platform_version = board_info_v10.board_info_v3.msm_version;
+			board.platform_hw = board_info_v10.board_info_v3.hw_platform;
+			board.platform_subtype = board_info_v10.platform_subtype;
+
+			/*
+			 * fill in board.target with variant_id information
+			 * bit no         |31  24 | 23   16            | 15   8             |7         0|
+			 * board.target = |subtype| plat_hw_ver major  | plat_hw_ver minor  |hw_platform|
+			 *
+			 */
+			board.target = (((board_info_v10.platform_subtype & 0xff) << 24) |
+						   (((board_info_v10.platform_version >> 16) & 0xff) << 16) |
+						   ((board_info_v10.platform_version & 0xff) << 8) |
+						   (board_info_v10.board_info_v3.hw_platform & 0xff));
+
+			for (i = 0; i < SMEM_V8_SMEM_MAX_PMIC_DEVICES; i++) {
+				board.pmic_info[i].pmic_type = board_info_v10.pmic_info[i].pmic_type;
+				board.pmic_info[i].pmic_version = board_info_v10.pmic_info[i].pmic_version;
+
+				/*
+				 * fill in pimc_board_info with pmic type and pmic version information
+				 * bit no  		  	    |31  24   | 23  16 	    | 15   8 	     |7		  0|
+				 * pimc_board_info = |Unused | Major version | Minor version|PMIC_MODEL|
+				 *
+				 */
+				pmic_type = board_info_v10.pmic_info[i].pmic_type == PMIC_IS_INVALID? 0 : board_info_v10.pmic_info[i].pmic_type;
+
+				board.pmic_info[i].pmic_target = (((board_info_v10.pmic_info[i].pmic_version >> 16) & 0xff) << 16) |
+					   ((board_info_v10.pmic_info[i].pmic_version & 0xff) << 8) | (pmic_type & 0xff);
+			}
+			board.foundry_id = board_info_v10.foundry_id;
+			board.chip_serial = board_info_v10.chip_serial;
 		}
 
 		/* HLOS subtype
diff --git a/platform/msm_shared/include/smd.h b/platform/msm_shared/include/smd.h
index 0daaace..b8f645f 100644
--- a/platform/msm_shared/include/smd.h
+++ b/platform/msm_shared/include/smd.h
@@ -118,7 +118,7 @@
 
 int smd_init(smd_channel_info_t *ch, uint32_t ch_type);
 void smd_uninit(smd_channel_info_t *ch);
-uint8_t* smd_read(smd_channel_info_t *ch, uint32_t *len, int ch_type);
+void smd_read(smd_channel_info_t *ch, uint32_t *len, int ch_type, uint32_t *response);
 int smd_write(smd_channel_info_t *ch, void *data, uint32_t len, int type);
 int smd_get_channel_info(smd_channel_info_t *ch, uint32_t ch_type);
 void smd_get_channel_entry(smd_channel_info_t *ch, uint32_t ch_type);
diff --git a/platform/msm_shared/mipi_dsi.c b/platform/msm_shared/mipi_dsi.c
index 1ac8fbd..1932549 100644
--- a/platform/msm_shared/mipi_dsi.c
+++ b/platform/msm_shared/mipi_dsi.c
@@ -92,7 +92,7 @@
 
 exit_read_signature:
 	/* Keep the non detectable panel at the end and set panel signature 0xFFFF */
-	if (panel_signature == 0xFFFF)
+	if ((panel_signature == 0) || (panel_signature == 0xFFFF))
 		ret = 0;
 #endif
 	return ret;
@@ -487,6 +487,51 @@
 	return 0;
 }
 
+void mdss_dsi_panel_shutdown(struct msm_panel_info *pinfo)
+{
+#if (DISPLAY_TYPE_MDSS == 1)
+	unsigned long read_val = 0;
+	if (pinfo->mipi.panel_off_cmds) {
+		/*
+		 * Once MDP TG is disabled, reset of DSI controller is
+		 * needed before we send panel OFF commands.
+		 */
+		if (pinfo->type == MIPI_VIDEO_PANEL) {
+			read_val = readl(MIPI_DSI0_BASE + CTRL);
+			writel((read_val & ~BIT(0)), MIPI_DSI0_BASE + CTRL);
+			writel(0x0001, MIPI_DSI0_BASE + SOFT_RESET);
+			dsb();
+			writel(0x0000, MIPI_DSI0_BASE + SOFT_RESET);
+			dsb();
+			/* Enable cmd mode only */
+			writel(((read_val & ~BIT(1)) | BIT(2)),
+						MIPI_DSI0_BASE + CTRL);
+		}
+
+		if (pinfo->mipi.broadcast) {
+			if (pinfo->type == MIPI_VIDEO_PANEL) {
+				read_val = readl(MIPI_DSI1_BASE + CTRL);
+				writel((read_val & ~BIT(0)),
+					MIPI_DSI1_BASE + CTRL);
+
+				writel(0x0001, MIPI_DSI1_BASE + SOFT_RESET);
+				dsb();
+				writel(0x0000, MIPI_DSI1_BASE + SOFT_RESET);
+				dsb();
+
+				writel(((read_val & ~BIT(1)) | BIT(2)),
+							MIPI_DSI1_BASE + CTRL);
+			}
+			mdss_dual_dsi_cmds_tx(pinfo->mipi.panel_off_cmds,
+					pinfo->mipi.num_of_panel_off_cmds);
+		} else {
+			mipi_dsi_cmds_tx(pinfo->mipi.panel_off_cmds,
+					pinfo->mipi.num_of_panel_off_cmds);
+		}
+	}
+#endif
+}
+
 int mdss_dsi_panel_initialize(struct mipi_dsi_panel_config *pinfo, uint32_t
 		broadcast)
 {
@@ -515,6 +560,7 @@
 			if (!status && target_panel_auto_detect_enabled())
 				status =
 					mdss_dsi_read_panel_signature(pinfo->signature);
+			dprintf(SPEW, "Read panel signature status = 0x%x \n", status);
 		}
 	}
 #endif
@@ -901,11 +947,8 @@
 {
 	if(!target_cont_splash_screen())
 	{
+		mdss_dsi_panel_shutdown(pinfo);
 		writel(0, DSI_CLK_CTRL);
-		writel(0x1F1, DSI_CTRL);
-		mdelay(10);
-		writel(0x0001, DSI_SOFT_RESET);
-		writel(0x0000, DSI_SOFT_RESET);
 		writel(0, DSI_CTRL);
 	}
 
diff --git a/platform/msm_shared/rpm-smd.c b/platform/msm_shared/rpm-smd.c
index d623542..0756bcd 100644
--- a/platform/msm_shared/rpm-smd.c
+++ b/platform/msm_shared/rpm-smd.c
@@ -133,8 +133,12 @@
 	rpm_ack_msg *resp;
 	msg_type type;
 	uint32_t ret = 0;
+	/* As per the current design rpm response does not exceed 20 bytes */
+	uint32_t response[5];
 
-	resp = (rpm_ack_msg*)smd_read(&ch, len, SMD_APPS_RPM);
+	smd_read(&ch, len, SMD_APPS_RPM, response);
+
+	resp = (rpm_ack_msg *)response;
 
 	arch_invalidate_cache_range((addr_t)resp, sizeof(rpm_gen_hdr));
 
diff --git a/platform/msm_shared/rules.mk b/platform/msm_shared/rules.mk
index c905e23..c22c8e9 100755
--- a/platform/msm_shared/rules.mk
+++ b/platform/msm_shared/rules.mk
@@ -348,7 +348,8 @@
 			$(LOCAL_DIR)/qpic_panel.o
 endif
 
-ifeq ($(PLATFORM),msmzirc)
+ifeq ($(PLATFORM),mdm9640)
+DEFINES += DISPLAY_TYPE_QPIC=1
 	OBJS += $(LOCAL_DIR)/qgic.o \
 			$(LOCAL_DIR)/uart_dm.o \
 			$(LOCAL_DIR)/interrupts.o \
@@ -365,7 +366,10 @@
 			$(LOCAL_DIR)/gpio.o \
 			$(LOCAL_DIR)/scm.o \
 			$(LOCAL_DIR)/qmp_usb30_phy.o \
-			$(LOCAL_DIR)/qusb2_phy.o
+			$(LOCAL_DIR)/qusb2_phy.o \
+			$(LOCAL_DIR)/display.o \
+			$(LOCAL_DIR)/qpic.o \
+			$(LOCAL_DIR)/qpic_panel.o
 endif
 
 ifeq ($(PLATFORM),fsm9900)
diff --git a/platform/msm_shared/smd.c b/platform/msm_shared/smd.c
index ea3732f..3616e2b 100644
--- a/platform/msm_shared/smd.c
+++ b/platform/msm_shared/smd.c
@@ -30,6 +30,7 @@
 #include <smd.h>
 #include <smem.h>
 #include <debug.h>
+#include <kernel/event.h>
 #include <platform/irqs.h>
 #include <platform/iomap.h>
 #include <platform/interrupts.h>
@@ -38,7 +39,7 @@
 #include <bits.h>
 
 smd_channel_alloc_entry_t *smd_channel_alloc_entry;
-
+static event_t smd_closed;
 
 static void smd_write_state(smd_channel_info_t *ch, uint32_t state)
 {
@@ -139,9 +140,12 @@
 
 void smd_uninit(smd_channel_info_t *ch)
 {
+	event_init(&smd_closed, false, EVENT_FLAG_AUTOUNSIGNAL);
 	smd_set_state(ch, SMD_SS_CLOSING, 1);
 
 	smd_notify_rpm();
+	/* Wait for the SMD-RPM channel to be closed */
+	event_wait(&smd_closed);
 }
 
 bool is_channel_open(smd_channel_info_t *ch)
@@ -205,12 +209,10 @@
 	ch_ptr->port_info->ch1.read_index = read_index;
 }
 
-uint8_t* smd_read(smd_channel_info_t *ch, uint32_t *len, int ch_type)
+void smd_read(smd_channel_info_t *ch, uint32_t *len, int ch_type, uint32_t *response)
 {
 	smd_pkt_hdr smd_hdr;
 	uint32_t size = 0;
-	/* Response as per the current design does not exceed 20 bytes */
-	uint32_t response[5];
 
 	/* Read the indices from smem */
 	ch->port_info = smem_get_alloc_entry(SMEM_SMD_BASE_ID + ch->alloc_entry.cid,
@@ -218,7 +220,7 @@
 	if(!ch->port_info->ch1.DTR_DSR)
 	{
 		dprintf(CRITICAL,"%s: DTR is off\n", __func__);
-		return -1;
+		return;
 	}
 
 	/* Wait until the data updated in the smd buffer is equal to smd packet header*/
@@ -243,9 +245,9 @@
 	}
 
 	/* We are good to return the response now */
-	memcpy_from_fifo(ch, response, sizeof(response));
+	memcpy_from_fifo(ch, response, smd_hdr.pkt_size);
 
-	arch_invalidate_cache_range((addr_t)response, sizeof(response));
+	arch_invalidate_cache_range((addr_t)response, smd_hdr.pkt_size);
 
 	return response;
 }
@@ -390,6 +392,7 @@
 	if(ch->current_state == SMD_SS_CLOSED)
 	{
 		free(smd_channel_alloc_entry);
+		event_signal(&smd_closed, false);
 		return INT_NO_RESCHEDULE;
 	}
 
diff --git a/platform/msm_shared/smem.h b/platform/msm_shared/smem.h
index 7760e69..b9cb855 100644
--- a/platform/msm_shared/smem.h
+++ b/platform/msm_shared/smem.h
@@ -184,10 +184,23 @@
 	unsigned fused_chip;
 	unsigned platform_subtype;
 	struct smem_pmic_info pmic_info[SMEM_V8_SMEM_MAX_PMIC_DEVICES];
-	/*
-	 * Need for 8 bytes alignment
-	 * while reading from shared memory
-	 */
+};
+
+struct smem_board_info_v9 {
+	struct smem_board_info_v3 board_info_v3;
+	unsigned platform_version;
+	unsigned fused_chip;
+	unsigned platform_subtype;
+	struct smem_pmic_info pmic_info[SMEM_V8_SMEM_MAX_PMIC_DEVICES];
+	uint32_t foundry_id; /* Used as foundry_id only for v9  */
+};
+
+struct smem_board_info_v10 {
+	struct smem_board_info_v3 board_info_v3;
+	unsigned platform_version;
+	unsigned fused_chip;
+	unsigned platform_subtype;
+	struct smem_pmic_info pmic_info[SMEM_V8_SMEM_MAX_PMIC_DEVICES];
 	uint32_t foundry_id; /* Used as foundry_id only for v9  */
 	uint32_t chip_serial; /* Used as serial number for v10 */
 };
@@ -360,7 +373,7 @@
 	MSM8510  = 225,
 	MSM8512  = 226,
 	MSM8936  = 233,
-	MSMZIRC  = 234,
+	MDM9640  = 234,
 	MSM8939  = 239,
 	APQ8036  = 240,
 	APQ8039  = 241,
@@ -385,6 +398,7 @@
 	MDM9309  = 261,
 	MDM9609  = 262,
 	MSM8239  = 263,
+	APQ8009  = 265,
 };
 
 enum platform {
diff --git a/platform/msm_shared/usb30_udc.c b/platform/msm_shared/usb30_udc.c
index cf27db9..1c4f71a 100644
--- a/platform/msm_shared/usb30_udc.c
+++ b/platform/msm_shared/usb30_udc.c
@@ -636,7 +636,7 @@
 			 * |______|_____________|_____________|
 			 */
 			usb_epnum = (s.index & USB_EP_NUM_MASK);
-			dir = (s.index & USB_EP_DIR_MASK == USB_EP_DIR_IN) ? 0x1 : 0x0;
+			dir = ((s.index & USB_EP_DIR_MASK) == USB_EP_DIR_IN) ? 0x1 : 0x0;
 
 			/*
 			 * Convert the logical ep number to physical before
diff --git a/project/apq8064.mk b/project/apq8064.mk
index 1c483dd..7a105a1 100644
--- a/project/apq8064.mk
+++ b/project/apq8064.mk
@@ -6,7 +6,11 @@
 
 MODULES += app/aboot
 
+ifeq ($(TARGET_BUILD_VARIANT),user)
+DEBUG := 0
+else
 DEBUG := 1
+endif
 
 #DEFINES += WITH_DEBUG_DCC=1
 DEFINES += WITH_DEBUG_UART=1
diff --git a/project/fsm9010.mk b/project/fsm9010.mk
index 1fa0a02..bd48cd7 100644
--- a/project/fsm9010.mk
+++ b/project/fsm9010.mk
@@ -6,7 +6,12 @@
 
 MODULES += app/aboot
 
+ifeq ($(TARGET_BUILD_VARIANT),user)
+DEBUG := 0
+else
 DEBUG := 1
+endif
+
 EMMC_BOOT := 1
 ENABLE_SDHCI_SUPPORT := 0
 
diff --git a/project/fsm9900.mk b/project/fsm9900.mk
index 993b34a..0f91c53 100644
--- a/project/fsm9900.mk
+++ b/project/fsm9900.mk
@@ -6,7 +6,12 @@
 
 MODULES += app/aboot
 
+ifeq ($(TARGET_BUILD_VARIANT),user)
+DEBUG := 0
+else
 DEBUG := 1
+endif
+
 EMMC_BOOT := 1
 ENABLE_SDHCI_SUPPORT := 1
 
diff --git a/project/mdm9625.mk b/project/mdm9625.mk
index b9b72aa..f0c4821 100644
--- a/project/mdm9625.mk
+++ b/project/mdm9625.mk
@@ -6,7 +6,11 @@
 
 MODULES += app/aboot
 
+ifeq ($(TARGET_BUILD_VARIANT),user)
+DEBUG := 0
+else
 DEBUG := 1
+endif
 
 #DEFINES += WITH_DEBUG_DCC=1
 DEFINES += WITH_DEBUG_UART=1
diff --git a/project/mdm9635.mk b/project/mdm9635.mk
index e83f0c1..1be7653 100644
--- a/project/mdm9635.mk
+++ b/project/mdm9635.mk
@@ -6,7 +6,11 @@
 
 MODULES += app/aboot
 
+ifeq ($(TARGET_BUILD_VARIANT),user)
+DEBUG := 0
+else
 DEBUG := 1
+endif
 
 #DEFINES += WITH_DEBUG_DCC=1
 DEFINES += WITH_DEBUG_UART=1
diff --git a/project/msmzirc.mk b/project/mdm9640.mk
similarity index 85%
rename from project/msmzirc.mk
rename to project/mdm9640.mk
index eaad091..c8381c3 100644
--- a/project/msmzirc.mk
+++ b/project/mdm9640.mk
@@ -1,10 +1,15 @@
-# top level project rules for the msmzirc project
+# top level project rules for the mdm9640 project
 #
 LOCAL_DIR := $(GET_LOCAL_DIR)
 
-TARGET := msmzirc
+TARGET := mdm9640
 
+ifeq ($(TARGET_BUILD_VARIANT),user)
+DEBUG := 0
+else
 DEBUG := 1
+endif
+
 ENABLE_USB30_SUPPORT := 1
 ENABLE_SDHCI_SUPPORT := 1
 ENABLE_BOOT_CONFIG_SUPPORT := 1
diff --git a/project/thulium.mk b/project/thulium.mk
index d1ece21..217cf50 100644
--- a/project/thulium.mk
+++ b/project/thulium.mk
@@ -6,7 +6,12 @@
 
 MODULES += app/aboot
 
+ifeq ($(TARGET_BUILD_VARIANT),user)
+DEBUG := 0
+else
 DEBUG := 1
+endif
+
 EMMC_BOOT := 1
 ENABLE_SDHCI_SUPPORT := 1
 ENABLE_UFS_SUPPORT   := 1
diff --git a/target/fsm9900/rules.mk b/target/fsm9900/rules.mk
index 0416f39..e4909eb 100644
--- a/target/fsm9900/rules.mk
+++ b/target/fsm9900/rules.mk
@@ -4,15 +4,15 @@
 
 PLATFORM := fsm9900
 
-MEMBASE := 0x0F900000 # SDRAM
+MEMBASE := 0x1e000000 # SDRAM
 MEMSIZE := 0x00100000 # 1MB
 
-BASE_ADDR        := 0x00000
+BASE_ADDR        := 0x0b600000
 
 TAGS_ADDR        := BASE_ADDR+0x00000100
 KERNEL_ADDR      := BASE_ADDR+0x00008000
 RAMDISK_ADDR     := BASE_ADDR+0x01000000
-SCRATCH_ADDR     := 0x11000000
+SCRATCH_ADDR     := 0x0c000000
 
 MODULES += \
 	dev/keys \
diff --git a/target/msmzirc/init.c b/target/mdm9640/init.c
similarity index 98%
rename from target/msmzirc/init.c
rename to target/mdm9640/init.c
index 9a4d870..a43af16 100644
--- a/target/msmzirc/init.c
+++ b/target/mdm9640/init.c
@@ -160,7 +160,6 @@
 
 		update_ptable_names();
 		flash_set_ptable(&flash_ptable);
-		rpm_smd_init();
 	}
 }
 
@@ -327,9 +326,14 @@
 	}
 }
 
+int target_cont_splash_screen()
+{
+	/* FOR OEMs - Set cont_splash_screen to keep the splash enable after LK.*/
+	return false;
+}
+
 void target_uninit(void)
 {
-	rpm_smd_uninit();
 	if (platform_boot_dev_isemmc())
 	{
 		mmc_put_card_to_sleep(dev);
diff --git a/target/msmzirc/keypad.c b/target/mdm9640/keypad.c
similarity index 100%
rename from target/msmzirc/keypad.c
rename to target/mdm9640/keypad.c
diff --git a/target/msmzirc/meminfo.c b/target/mdm9640/meminfo.c
similarity index 100%
rename from target/msmzirc/meminfo.c
rename to target/mdm9640/meminfo.c
diff --git a/target/mdm9640/qpic_panel_drv.c b/target/mdm9640/qpic_panel_drv.c
new file mode 100755
index 0000000..2c1f776
--- /dev/null
+++ b/target/mdm9640/qpic_panel_drv.c
@@ -0,0 +1,183 @@
+/* Copyright (c) 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 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.
+ */
+
+#include <debug.h>
+#include <err.h>
+#include <endian.h>
+#include <platform/gpio.h>
+#include <platform/clock.h>
+#include <regulator.h>
+#include <rpm-smd.h>
+#include <platform/timer.h>
+
+#include "qpic.h"
+#include "qpic_panel.h"
+
+#define GPIOMUX_FUNC_2 2
+#define GPIOMUX_FUNC_GPIO 0
+
+#define RST_GPIO_ID 23
+#define CS_GPIO_ID 21
+#define AD8_GPIO_ID 20
+#define TE_GPIO_ID 22
+#define BL_GPIO_ID 68
+
+#define MEM_ACCESS_MODE 0x48
+#define MEM_ACCESS_FORMAT 0x66
+
+static uint32_t ldo6[][11] = {
+	{
+		LDOA_RES_TYPE, 6,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
+		KEY_LDO_SOFTWARE_MODE, 4, SW_MODE_LDO_IPEAK,
+		KEY_MICRO_VOLT, 4, 0,
+	},
+	{
+		LDOA_RES_TYPE, 6,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
+		KEY_LDO_SOFTWARE_MODE, 4, SW_MODE_LDO_IPEAK,
+		KEY_MICRO_VOLT, 4, 1800000,
+	},
+};
+
+static uint32_t ldo12[][11] = {
+	{
+		LDOA_RES_TYPE, 12,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_DISABLE,
+		KEY_LDO_SOFTWARE_MODE, 4, SW_MODE_LDO_IPEAK,
+		KEY_MICRO_VOLT, 4, 0,
+	},
+	{
+		LDOA_RES_TYPE, 12,
+		KEY_SOFTWARE_ENABLE, 4, GENERIC_ENABLE,
+		KEY_LDO_SOFTWARE_MODE, 4, SW_MODE_LDO_IPEAK,
+		KEY_MICRO_VOLT, 4, 2700000,
+	},
+};
+
+static void panel_io_off(struct qpic_panel_io_desc *qpic_panel_io)
+{
+	/* Turning off all gpios */
+	gpio_tlmm_config(RST_GPIO_ID, GPIOMUX_FUNC_2, GPIO_INPUT, GPIO_NO_PULL,
+				GPIO_10MA, GPIO_DISABLE);
+	gpio_tlmm_config(CS_GPIO_ID, GPIOMUX_FUNC_2, GPIO_INPUT, GPIO_NO_PULL,
+				GPIO_10MA, GPIO_DISABLE);
+	gpio_tlmm_config(AD8_GPIO_ID, GPIOMUX_FUNC_2, GPIO_INPUT, GPIO_NO_PULL,
+				GPIO_10MA, GPIO_DISABLE);
+	gpio_tlmm_config(TE_GPIO_ID, GPIOMUX_FUNC_2, GPIO_INPUT, GPIO_NO_PULL,
+				GPIO_10MA, GPIO_DISABLE);
+	gpio_tlmm_config(BL_GPIO_ID, GPIOMUX_FUNC_GPIO, GPIO_INPUT,GPIO_NO_PULL,
+				GPIO_10MA, GPIO_ENABLE);
+	gpio_set(BL_GPIO_ID, 0x0);
+
+	/* Disabling vdd & avdd voltage */
+	rpm_send_data(&ldo6[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE);
+	rpm_send_data(&ldo12[GENERIC_DISABLE][0], 36, RPM_REQUEST_TYPE);
+
+	return;
+}
+
+static int panel_io_on(struct qpic_panel_io_desc *qpic_panel_io)
+{
+	int rc = 0;
+
+	/* Setting vdd & avdd voltage */
+	rpm_send_data(&ldo6[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
+	rpm_send_data(&ldo12[GENERIC_ENABLE][0], 36, RPM_REQUEST_TYPE);
+
+	/* Turning on all gpios */
+	gpio_tlmm_config(RST_GPIO_ID, GPIOMUX_FUNC_2, GPIO_INPUT,GPIO_NO_PULL,
+			GPIO_10MA, GPIO_ENABLE);
+	gpio_tlmm_config(CS_GPIO_ID, GPIOMUX_FUNC_2, GPIO_INPUT,GPIO_NO_PULL,
+			GPIO_10MA, GPIO_ENABLE);
+	gpio_tlmm_config(AD8_GPIO_ID, GPIOMUX_FUNC_2, GPIO_INPUT,GPIO_NO_PULL,
+			GPIO_10MA, GPIO_ENABLE);
+	gpio_tlmm_config(TE_GPIO_ID, GPIOMUX_FUNC_2, GPIO_INPUT,GPIO_NO_PULL,
+			GPIO_10MA, GPIO_ENABLE);
+	gpio_tlmm_config(BL_GPIO_ID, GPIOMUX_FUNC_GPIO, GPIO_INPUT, GPIO_NO_PULL,
+			GPIO_10MA, GPIO_DISABLE);
+	gpio_set(BL_GPIO_ID, 0x2);
+	mdelay(20);
+	return rc;
+}
+
+void ili9341_off(struct qpic_panel_io_desc *qpic_panel_io)
+{
+	panel_io_off(qpic_panel_io);
+}
+
+int ili9341_on(struct qpic_panel_io_desc *qpic_panel_io)
+{
+	uint8_t param[4];
+	int ret;
+
+	ret = panel_io_on(qpic_panel_io);
+	if (ret)
+		return ret;
+	qpic_send_pkt(OP_SOFT_RESET, NULL, 0);
+	/* wait for 120 ms after reset as panel spec suggests */
+	mdelay(120);
+	qpic_send_pkt(OP_SET_DISPLAY_OFF, NULL, 0);
+	/* wait for 20 ms after disply off */
+	mdelay(20);
+
+	/* set memory access control */
+	param[0] = MEM_ACCESS_MODE;
+	qpic_send_pkt(OP_SET_ADDRESS_MODE, param, 1);
+	/* wait for 20 ms after command sent as panel spec suggests */
+	mdelay(20);
+
+	param[0] = MEM_ACCESS_FORMAT;
+	qpic_send_pkt(OP_SET_PIXEL_FORMAT, param, 1);
+	mdelay(20);
+
+	/* set interface */
+	param[0] = 1;
+	param[1] = 0;
+	param[2] = 0;
+	qpic_send_pkt(OP_ILI9341_INTERFACE_CONTROL, param, 3);
+	mdelay(20);
+
+	qpic_send_pkt(OP_EXIT_SLEEP_MODE, NULL, 0);
+	mdelay(20);
+
+	qpic_send_pkt(OP_ENTER_NORMAL_MODE, NULL, 0);
+	mdelay(20);
+
+	qpic_send_pkt(OP_SET_DISPLAY_ON, NULL, 0);
+	mdelay(20);
+
+	param[0] = 0;
+	qpic_send_pkt(OP_ILI9341_TEARING_EFFECT_LINE_ON, param, 1);
+
+	param[0] = qpic_read_data(OP_GET_PIXEL_FORMAT, 1);
+
+	return 0;
+}
+
diff --git a/target/msmzirc/rules.mk b/target/mdm9640/rules.mk
similarity index 88%
rename from target/msmzirc/rules.mk
rename to target/mdm9640/rules.mk
index 7a19970..f8c6d35 100644
--- a/target/msmzirc/rules.mk
+++ b/target/mdm9640/rules.mk
@@ -2,7 +2,7 @@
 
 INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared
 
-PLATFORM := msmzirc
+PLATFORM := mdm9640
 
 MEMBASE                             := 0x81200000
 MEMSIZE                             := 0x00100000 # 1MB
@@ -15,15 +15,17 @@
 KERNEL_REGION                       := 0x80000000
 KERNEL_REGION_SIZE                  := 0x01200000 # 18MB
 
-
+DEFINES += DISPLAY_SPLASH_SCREEN=0
 DEFINES += NO_KEYPAD_DRIVER=1
 DEFINES += PERIPH_BLK_BLSP=1
 
+DEVS += fbcon
 MODULES += \
 	dev/keys \
 	lib/ptable \
 	dev/pmic/pm8x41 \
-	lib/libfdt
+	lib/libfdt \
+	dev/fbcon
 
 DEFINES += \
 	MEMBASE=$(MEMBASE) \
@@ -41,4 +43,6 @@
 OBJS += \
 	$(LOCAL_DIR)/init.o \
 	$(LOCAL_DIR)/meminfo.o \
+	$(LOCAL_DIR)/target_display.o \
+	$(LOCAL_DIR)/qpic_panel_drv.o \
 	$(LOCAL_DIR)/keypad.o
diff --git a/target/mdm9640/target_display.c b/target/mdm9640/target_display.c
new file mode 100644
index 0000000..d3a2fb8
--- /dev/null
+++ b/target/mdm9640/target_display.c
@@ -0,0 +1,74 @@
+/* Copyright (c) 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 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.
+ */
+
+#include <debug.h>
+#include <err.h>
+#include <msm_panel.h>
+#include "splash.h"
+
+/* PANEL INFO */
+#define HVGA_PANEL_XRES 320
+#define HVGA_PANEL_YRES 480
+#define BPP_16 16
+
+/* FB Base Address */
+#define QPIC_FB_ADDR  0x80000000
+
+static struct msm_fb_panel_data panel;
+
+void target_display_init(const char *panel_name)
+{
+	uint32_t ret = 0;
+	dprintf(SPEW, "%s: Panel name = %s\n", __func__, panel_name);
+
+	/* Setting panel info */
+	panel.panel_info.xres = HVGA_PANEL_XRES;
+	panel.panel_info.yres = HVGA_PANEL_YRES;
+	panel.panel_info.bpp = BPP_16;
+	panel.panel_info.type = QPIC_PANEL;
+
+	/* Setting FB info */
+	panel.fb.width =  panel.panel_info.xres;
+	panel.fb.height =  panel.panel_info.yres;
+	panel.fb.stride =  panel.panel_info.xres;
+	panel.fb.bpp =  panel.panel_info.bpp;
+	panel.fb.format = FB_FORMAT_RGB565;
+	panel.fb.base = QPIC_FB_ADDR;
+
+	rpm_smd_init();
+	ret = msm_display_init(&panel);
+	if (ret)
+		dprintf(CRITICAL, "%s: ERROR: Display init failed\n", __func__);
+}
+
+void target_display_shutdown(void)
+{
+	msm_display_off();
+	rpm_smd_uninit();
+}
diff --git a/target/msmzirc/tools/makefile b/target/mdm9640/tools/makefile
similarity index 100%
rename from target/msmzirc/tools/makefile
rename to target/mdm9640/tools/makefile
diff --git a/target/msm8909/init.c b/target/msm8909/init.c
index b190cb4..32e4813 100644
--- a/target/msm8909/init.c
+++ b/target/msm8909/init.c
@@ -506,6 +506,7 @@
 		switch (board_hardware_id()) {
 		case HW_PLATFORM_SURF:
 		case HW_PLATFORM_MTP:
+		case HW_PLATFORM_QRD:
 			splash_screen = 1;
 			break;
 		default:
diff --git a/target/msm8909/oem_panel.c b/target/msm8909/oem_panel.c
index f59ebc1..014a012 100644
--- a/target/msm8909/oem_panel.c
+++ b/target/msm8909/oem_panel.c
@@ -40,6 +40,7 @@
 #include "include/panel_hx8394d_720p_video.h"
 #include "include/panel_hx8379a_fwvga_skua_video.h"
 #include "include/panel_sharp_qhd_video.h"
+#include "include/panel_ili9806e_fwvga_video.h"
 
 #define DISPLAY_MAX_PANEL_DETECTION 0
 
@@ -58,6 +59,7 @@
 	HX8394D_720P_VIDEO_PANEL,
 	HX8379A_FWVGA_SKUA_VIDEO_PANEL,
 	SHARP_QHD_VIDEO_PANEL,
+	ILI9806E_FWVGA_VIDEO_PANEL,
 	UNKNOWN_PANEL
 };
 
@@ -68,7 +70,8 @@
 static struct panel_list supp_panels[] = {
 	{"hx8394d_720p_video", HX8394D_720P_VIDEO_PANEL},
 	{"hx8379a_fwvga_skua_video", HX8379A_FWVGA_SKUA_VIDEO_PANEL},
-	{"sharp_qhd_video", SHARP_QHD_VIDEO_PANEL}
+	{"sharp_qhd_video", SHARP_QHD_VIDEO_PANEL},
+	{"ili9806e_fwvga_video",ILI9806E_FWVGA_VIDEO_PANEL},
 };
 
 static uint32_t panel_id;
@@ -141,10 +144,14 @@
 		panelstruct->panelresetseq
 					 = &hx8379a_fwvga_skua_video_reset_seq;
 		panelstruct->backlightinfo = &hx8379a_fwvga_skua_video_backlight;
-		pinfo->mipi.panel_cmds
+		pinfo->mipi.panel_on_cmds
 					= hx8379a_fwvga_skua_video_on_command;
-		pinfo->mipi.num_of_panel_cmds
+		pinfo->mipi.num_of_panel_on_cmds
 					= HX8379A_FWVGA_SKUA_VIDEO_ON_COMMAND;
+		pinfo->mipi.panel_off_cmds
+					= hx8379a_fwvga_skua_video_off_command;
+		pinfo->mipi.num_of_panel_off_cmds
+					= HX8379A_FWVGA_SKUA_VIDEO_OFF_COMMAND;
 		memcpy(phy_db->timing,
 				hx8379a_fwvga_skua_video_timings, TIMING_SIZE);
 		pinfo->mipi.signature = HX8379A_FWVGA_SKUA_VIDEO_SIGNATURE;
@@ -172,6 +179,31 @@
 					= SHARP_QHD_VIDEO_OFF_COMMAND;
 		memcpy(phy_db->timing, sharp_qhd_video_timings, TIMING_SIZE);
 		break;
+	case ILI9806E_FWVGA_VIDEO_PANEL:
+                panelstruct->paneldata    = &ili9806e_fwvga_video_panel_data;
+                panelstruct->panelres     = &ili9806e_fwvga_video_panel_res;
+                panelstruct->color        = &ili9806e_fwvga_video_color;
+                panelstruct->videopanel   = &ili9806e_fwvga_video_video_panel;
+                panelstruct->commandpanel = &ili9806e_fwvga_video_command_panel;
+                panelstruct->state        = &ili9806e_fwvga_video_state;
+                panelstruct->laneconfig   = &ili9806e_fwvga_video_lane_config;
+                panelstruct->paneltiminginfo
+                                         = &ili9806e_fwvga_video_timing_info;
+                panelstruct->panelresetseq
+                                         = &ili9806e_fwvga_video_reset_seq;
+                panelstruct->backlightinfo = &ili9806e_fwvga_video_backlight;
+                pinfo->mipi.panel_on_cmds
+                                        = ili9806e_fwvga_video_on_command;
+                pinfo->mipi.num_of_panel_on_cmds
+                                        = ILI9806E_FWVGA_VIDEO_ON_COMMAND;
+                pinfo->mipi.panel_off_cmds
+                                        = ili9806e_fwvga_video_off_command;
+                pinfo->mipi.num_of_panel_off_cmds
+                                        = ILI9806E_FWVGA_VIDEO_OFF_COMMAND;
+                memcpy(phy_db->timing,
+                                ili9806e_fwvga_video_timings, TIMING_SIZE);
+                pinfo->mipi.signature = ILI9806E_FWVGA_VIDEO_SIGNATURE;
+                break;
 	case UNKNOWN_PANEL:
 	default:
 		memset(panelstruct, 0, sizeof(struct panel_struct));
@@ -229,6 +261,8 @@
 				panel_id = HX8379A_FWVGA_SKUA_VIDEO_PANEL;
 				break;
 			case QRD_SKUC:
+				panel_id = ILI9806E_FWVGA_VIDEO_PANEL;
+				break;
 			case QRD_SKUE:
 			default:
 				dprintf(CRITICAL, "QRD Display not enabled for %d type\n",
diff --git a/target/msm8916/include/target/display.h b/target/msm8916/include/target/display.h
old mode 100755
new mode 100644
index 5b90130..d58aff8
--- a/target/msm8916/include/target/display.h
+++ b/target/msm8916/include/target/display.h
@@ -49,6 +49,14 @@
   "msmgpio", 98, 3, 1, 0, 1
 };
 
+static struct gpio_pin bkl_gpio_1 = {
+  "msmgpio", 75, 3, 1, 0, 1
+};
+
+static struct gpio_pin bkl_gpio_2 = {
+  "msmgpio", 77, 3, 1, 0, 1
+};
+
 static struct gpio_pin enp_gpio = {
   "msmgpio", 97, 3, 1, 0, 1
 };
@@ -81,6 +89,10 @@
   "msmgpio", 8, 3, 1, 0, 1
 };
 
+static struct gpio_pin enable_gpio_skut2 = {
+  "msmgpio", 22, 3, 1, 0, 1
+};
+
 /*---------------------------------------------------------------------------*/
 /* Target Physical configuration                                             */
 /*---------------------------------------------------------------------------*/
@@ -133,10 +145,33 @@
 enum qrd_subtype
 {
 	HW_PLATFORM_SUBTYPE_DEFAULT = 0,
+	HW_PLATFORM_SUBTYPE_CDP_1 = 1,
+	HW_PLATFORM_SUBTYPE_MTP_3 = 3,
 	HW_PLATFORM_SUBTYPE_SKUH = 4,
 	HW_PLATFORM_SUBTYPE_SKUI = 5, /* msm8916 */
 	HW_PLATFORM_SUBTYPE_SKUK = 5, /* msm8939 */
 	HW_PLATFORM_SUBTYPE_SKUT1 = 0x40, /* msm8916 */
 };
 
+
+enum {
+	JDI_1080P_VIDEO_PANEL,
+	NT35590_720P_VIDEO_PANEL,
+	NT35590_720P_CMD_PANEL,
+	INNOLUX_720P_VIDEO_PANEL,
+	OTM8019A_FWVGA_VIDEO_PANEL,
+	OTM1283A_720P_VIDEO_PANEL,
+	NT35596_1080P_VIDEO_PANEL,
+	SHARP_WQXGA_DUALDSI_VIDEO_PANEL,
+	JDI_FHD_VIDEO_PANEL,
+	HX8379A_FWVGA_VIDEO_PANEL,
+	HX8394D_720P_VIDEO_PANEL,
+	NT35521_WXGA_VIDEO_PANEL,
+	SAMSUNG_WXGA_VIDEO_PANEL,
+	HX8279A_WSVGA_VIDEO_PANEL,
+	UNKNOWN_PANEL
+};
+
+uint32_t get_panel_id(void);
+
 #endif
diff --git a/target/msm8916/init.c b/target/msm8916/init.c
index 8e0d26f..0289973 100644
--- a/target/msm8916/init.c
+++ b/target/msm8916/init.c
@@ -369,17 +369,17 @@
 	/* Drive strength configs for sdc pins */
 	struct tlmm_cfgs sdc1_hdrv_cfg[] =
 	{
-		{ SDC1_CLK_HDRV_CTL_OFF,  TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK },
-		{ SDC1_CMD_HDRV_CTL_OFF,  TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK },
-		{ SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_6MA, TLMM_HDRV_MASK },
+		{ SDC1_CLK_HDRV_CTL_OFF,  TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK, 0},
+		{ SDC1_CMD_HDRV_CTL_OFF,  TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK, 0},
+		{ SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_6MA, TLMM_HDRV_MASK , 0},
 	};
 
 	/* Pull configs for sdc pins */
 	struct tlmm_cfgs sdc1_pull_cfg[] =
 	{
-		{ SDC1_CLK_PULL_CTL_OFF,  TLMM_NO_PULL, TLMM_PULL_MASK },
-		{ SDC1_CMD_PULL_CTL_OFF,  TLMM_PULL_UP, TLMM_PULL_MASK },
-		{ SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK },
+		{ SDC1_CLK_PULL_CTL_OFF,  TLMM_NO_PULL, TLMM_PULL_MASK, 0},
+		{ SDC1_CMD_PULL_CTL_OFF,  TLMM_PULL_UP, TLMM_PULL_MASK, 0},
+		{ SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0},
 	};
 
 	/* Set the drive strength & pull control values */
diff --git a/target/msm8916/oem_panel.c b/target/msm8916/oem_panel.c
old mode 100755
new mode 100644
index 44abdf7..d322d2a
--- a/target/msm8916/oem_panel.c
+++ b/target/msm8916/oem_panel.c
@@ -53,10 +53,13 @@
 #include "include/panel_hx8379a_fwvga_video.h"
 #include "include/panel_hx8394d_720p_video.h"
 #include "include/panel_nt35521_wxga_video.h"
+#include "include/panel_samsung_wxga_video.h"
+#include "include/panel_hx8279a_wsvga_video.h"
 
 #define DISPLAY_MAX_PANEL_DETECTION 2
 #define OTM8019A_FWVGA_VIDEO_PANEL_ON_DELAY 50
 #define NT35590_720P_CMD_PANEL_ON_DELAY 40
+#define SAMSUNG_WXGA_VIDEO_PANEL_ON_DELAY 100
 
 /*---------------------------------------------------------------------------*/
 /* static panel selection variable                                           */
@@ -67,22 +70,6 @@
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 };
 
-enum {
-JDI_1080P_VIDEO_PANEL,
-NT35590_720P_VIDEO_PANEL,
-NT35590_720P_CMD_PANEL,
-INNOLUX_720P_VIDEO_PANEL,
-OTM8019A_FWVGA_VIDEO_PANEL,
-OTM1283A_720P_VIDEO_PANEL,
-NT35596_1080P_VIDEO_PANEL,
-SHARP_WQXGA_DUALDSI_VIDEO_PANEL,
-JDI_FHD_VIDEO_PANEL,
-HX8379A_FWVGA_VIDEO_PANEL,
-HX8394D_720P_VIDEO_PANEL,
-NT35521_WXGA_VIDEO_PANEL,
-UNKNOWN_PANEL
-};
-
 /*
  * The list of panels that are supported on this target.
  * Any panel in this list can be selected using fastboot oem command.
@@ -99,7 +86,9 @@
 	{"jdi_fhd_video", JDI_FHD_VIDEO_PANEL},
 	{"hx8379a_wvga_video", HX8379A_FWVGA_VIDEO_PANEL},
 	{"hx8394d_720p_video", HX8394D_720P_VIDEO_PANEL},
-	{"nt35521_wxga_video", NT35521_WXGA_VIDEO_PANEL}
+	{"nt35521_wxga_video", NT35521_WXGA_VIDEO_PANEL},
+	{"samsung_wxga_video", SAMSUNG_WXGA_VIDEO_PANEL},
+	{"hx8279a_wsvga_video", HX8279A_WSVGA_VIDEO_PANEL}
 };
 
 static uint32_t panel_id;
@@ -121,6 +110,9 @@
 	} else if (panel_id == NT35590_720P_CMD_PANEL) {
 		/* needs extra delay to avoid snow screen artifacts */
 		mdelay(NT35590_720P_CMD_PANEL_ON_DELAY);
+	} else if (panel_id == SAMSUNG_WXGA_VIDEO_PANEL) {
+		/* needs extra delay to avoid unexpected artifacts */
+		mdelay(SAMSUNG_WXGA_VIDEO_PANEL_ON_DELAY);
 	}
 
 	return NO_ERROR;
@@ -134,6 +126,11 @@
 	return NO_ERROR;
 }
 
+uint32_t get_panel_id(void)
+{
+	return panel_id;
+}
+
 static int init_panel_data(struct panel_struct *panelstruct,
 			struct msm_panel_info *pinfo,
 			struct mdss_dsi_phy_ctrl *phy_db)
@@ -434,6 +431,54 @@
 		memcpy(phy_db->timing,
 				nt35521_wxga_video_timings, TIMING_SIZE);
 		break;
+	case SAMSUNG_WXGA_VIDEO_PANEL:
+		panelstruct->paneldata    = &samsung_wxga_video_panel_data;
+		panelstruct->panelres     = &samsung_wxga_video_panel_res;
+		panelstruct->color        = &samsung_wxga_video_color;
+		panelstruct->videopanel   = &samsung_wxga_video_video_panel;
+		panelstruct->commandpanel = &samsung_wxga_video_command_panel;
+		panelstruct->state        = &samsung_wxga_video_state;
+		panelstruct->laneconfig   = &samsung_wxga_video_lane_config;
+		panelstruct->paneltiminginfo
+					= &samsung_wxga_video_timing_info;
+		panelstruct->panelresetseq
+					= &samsung_wxga_video_reset_seq;
+		panelstruct->backlightinfo = &samsung_wxga_video_backlight;
+		pinfo->mipi.panel_on_cmds
+					= samsung_wxga_video_on_command;
+		pinfo->mipi.num_of_panel_on_cmds
+					= SAMSUNG_WXGA_VIDEO_ON_COMMAND;
+		pinfo->mipi.panel_off_cmds
+					= samsung_wxga_video_off_command;
+		pinfo->mipi.num_of_panel_off_cmds
+					= SAMSUNG_WXGA_VIDEO_OFF_COMMAND;
+		memcpy(phy_db->timing,
+				samsung_wxga_video_timings, TIMING_SIZE);
+		break;
+	case HX8279A_WSVGA_VIDEO_PANEL:
+		panelstruct->paneldata    = &hx8279a_wsvga_video_panel_data;
+		panelstruct->panelres     = &hx8279a_wsvga_video_panel_res;
+		panelstruct->color        = &hx8279a_wsvga_video_color;
+		panelstruct->videopanel   = &hx8279a_wsvga_video_video_panel;
+		panelstruct->commandpanel = &hx8279a_wsvga_video_command_panel;
+		panelstruct->state        = &hx8279a_wsvga_video_state;
+		panelstruct->laneconfig   = &hx8279a_wsvga_video_lane_config;
+		panelstruct->paneltiminginfo
+					= &hx8279a_wsvga_video_timing_info;
+		panelstruct->panelresetseq
+					= &hx8279a_wsvga_video_reset_seq;
+		panelstruct->backlightinfo = &hx8279a_wsvga_video_backlight;
+		pinfo->mipi.panel_on_cmds
+					= hx8279a_wsvga_video_on_command;
+		pinfo->mipi.num_of_panel_on_cmds
+					= HX8279A_WSVGA_VIDEO_ON_COMMAND;
+		pinfo->mipi.panel_off_cmds
+					= hx8279a_wsvga_video_off_command;
+		pinfo->mipi.num_of_panel_off_cmds
+					= HX8279A_WSVGA_VIDEO_OFF_COMMAND;
+		memcpy(phy_db->timing,
+				hx8279a_wsvga_video_timings, TIMING_SIZE);
+		break;
 	case UNKNOWN_PANEL:
 	default:
 		memset(panelstruct, 0, sizeof(struct panel_struct));
@@ -485,22 +530,28 @@
 	switch (hw_id) {
 	case HW_PLATFORM_MTP:
 		panel_id = JDI_1080P_VIDEO_PANEL;
+		if (hw_subtype == HW_PLATFORM_SUBTYPE_MTP_3)
+			panel_id = JDI_FHD_VIDEO_PANEL;
 		break;
 	case HW_PLATFORM_SURF:
-		panel_id = JDI_1080P_VIDEO_PANEL;
-		switch (auto_pan_loop) {
-		case 0:
+		if (hw_subtype == HW_PLATFORM_SUBTYPE_CDP_1) {
+			panel_id = JDI_FHD_VIDEO_PANEL;
+		} else {
 			panel_id = JDI_1080P_VIDEO_PANEL;
-			break;
-		case 1:
-			panel_id = NT35590_720P_VIDEO_PANEL;
-			break;
-		default:
-			panel_id = UNKNOWN_PANEL;
-			dprintf(CRITICAL, "Unknown panel\n");
-			return PANEL_TYPE_UNKNOWN;
+			switch (auto_pan_loop) {
+			case 0:
+				panel_id = JDI_1080P_VIDEO_PANEL;
+				break;
+			case 1:
+				panel_id = NT35590_720P_VIDEO_PANEL;
+				break;
+			default:
+				panel_id = UNKNOWN_PANEL;
+				dprintf(CRITICAL, "Unknown panel\n");
+				return PANEL_TYPE_UNKNOWN;
+			}
+			auto_pan_loop++;
 		}
-		auto_pan_loop++;
 		break;
 	case HW_PLATFORM_QRD:
 		target_id = board_target_id();
@@ -533,8 +584,15 @@
 					panel_id = HX8379A_FWVGA_VIDEO_PANEL;
 				break;
 			case HW_PLATFORM_SUBTYPE_SKUT1:
-				/* qrd SKUT1 */
-				panel_id = NT35521_WXGA_VIDEO_PANEL;
+				if ((plat_hw_ver_major & 0x0F) == 0x1)
+					/* qrd SKUT1 */
+					panel_id = NT35521_WXGA_VIDEO_PANEL;
+				else if ((plat_hw_ver_major & 0x0F) == 0x2)
+					/* qrd SKUT2 */
+					panel_id = SAMSUNG_WXGA_VIDEO_PANEL;
+				else if ((plat_hw_ver_major & 0x0F) == 0x3)
+					/* qrd SKUT3 */
+					panel_id = HX8279A_WSVGA_VIDEO_PANEL;
 				break;
 			default:
 				dprintf(CRITICAL, "Invalid subtype id %d for QRD HW\n",
diff --git a/target/msm8916/target_display.c b/target/msm8916/target_display.c
old mode 100755
new mode 100644
index ea69e86..45baa2b
--- a/target/msm8916/target_display.c
+++ b/target/msm8916/target_display.c
@@ -290,13 +290,21 @@
 	int ret = NO_ERROR;
 	uint32_t hw_id = board_hardware_id();
 	uint32_t hw_subtype = board_hardware_subtype();
+	uint32_t panel_id = get_panel_id();
+	uint32_t target_id, plat_hw_ver_major;
 
 	if (enable) {
 		if (pinfo->mipi.use_enable_gpio) {
 			/* set enable gpio pin for SKUT1 */
 			if ((hw_id == HW_PLATFORM_QRD) &&
-				 (hw_subtype == HW_PLATFORM_SUBTYPE_SKUT1))
-				enable_gpio = enable_gpio_skut1;
+				 (hw_subtype == HW_PLATFORM_SUBTYPE_SKUT1)) {
+				target_id = board_target_id();
+				plat_hw_ver_major = ((target_id >> 16) & 0xFF);
+				if ((plat_hw_ver_major & 0x0F) == 0x1)
+					enable_gpio = enable_gpio_skut1;
+				else
+					enable_gpio = enable_gpio_skut2;
+			}
 			gpio_tlmm_config(enable_gpio.pin_id, 0,
 				enable_gpio.pin_direction, enable_gpio.pin_pull,
 				enable_gpio.pin_strength,
@@ -317,10 +325,29 @@
 
 		if (hw_id == HW_PLATFORM_MTP || hw_id == HW_PLATFORM_SURF) {
 			/* configure backlight gpio for MTP & CDP */
-			gpio_tlmm_config(bkl_gpio.pin_id, 0,
-				bkl_gpio.pin_direction, bkl_gpio.pin_pull,
-				bkl_gpio.pin_strength, bkl_gpio.pin_state);
-			gpio_set_dir(bkl_gpio.pin_id, 2);
+			/*JDI incell panel requires two additional GPIO's in 75->98->77 order*/
+			if (panel_id == JDI_FHD_VIDEO_PANEL) {
+				dprintf(INFO, "panel_id = %d \n", panel_id);
+				gpio_tlmm_config(bkl_gpio_1.pin_id, 0,
+					bkl_gpio_1.pin_direction, bkl_gpio_1.pin_pull,
+					bkl_gpio_1.pin_strength, bkl_gpio_1.pin_state);
+				gpio_set_dir(bkl_gpio_1.pin_id, 2);
+
+				gpio_tlmm_config(bkl_gpio.pin_id, 0,
+					bkl_gpio.pin_direction, bkl_gpio.pin_pull,
+					bkl_gpio.pin_strength, bkl_gpio.pin_state);
+				gpio_set_dir(bkl_gpio.pin_id, 2);
+
+				gpio_tlmm_config(bkl_gpio_2.pin_id, 0,
+					bkl_gpio_2.pin_direction, bkl_gpio_2.pin_pull,
+					bkl_gpio_2.pin_strength, bkl_gpio_2.pin_state);
+				gpio_set_dir(bkl_gpio_2.pin_id, 2);
+			} else {
+				gpio_tlmm_config(bkl_gpio.pin_id, 0,
+					bkl_gpio.pin_direction, bkl_gpio.pin_pull,
+					bkl_gpio.pin_strength, bkl_gpio.pin_state);
+				gpio_set_dir(bkl_gpio.pin_id, 2);
+			}
 		}
 
 		gpio_tlmm_config(reset_gpio.pin_id, 0,
diff --git a/target/msm8994/init.c b/target/msm8994/init.c
index bb3198e..886f232 100644
--- a/target/msm8994/init.c
+++ b/target/msm8994/init.c
@@ -151,7 +151,10 @@
 	}
 
 	if (crypto_initialized())
+	{
 		crypto_eng_cleanup();
+		clock_ce_disable(CE_INSTANCE);
+	}
 
 	rpm_smd_uninit();
 }
@@ -212,7 +215,7 @@
 
 	if (slot == 0x1)
 	{
-		clk = TLMM_CUR_VAL_16MA;
+		clk = TLMM_CUR_VAL_10MA;
 		cmd = TLMM_CUR_VAL_8MA;
 		dat = TLMM_CUR_VAL_8MA;
 		reg = SDC1_HDRV_PULL_CTL;
@@ -359,6 +362,7 @@
 			case HW_PLATFORM_MTP:
 			case HW_PLATFORM_FLUID:
 			case HW_PLATFORM_LIQUID:
+			case HW_PLATFORM_DRAGON:
 				dprintf(SPEW, "Target_cont_splash=1\n");
 				splash_screen = 1;
 				break;
@@ -403,12 +407,9 @@
 
 void target_serialno(unsigned char *buf)
 {
-	uint32_t serialno;
+	unsigned int serialno;
 	if (target_is_emmc_boot()) {
-		if (platform_boot_dev_isemmc())
-			serialno = mmc_get_psn();
-		else
-			serialno = board_chip_serial();
+		serialno = mmc_get_psn();
 		snprintf((char *)buf, 13, "%x", serialno);
 	}
 }
diff --git a/target/msm8994/oem_panel.c b/target/msm8994/oem_panel.c
index 19fb5c7..ec7a940 100644
--- a/target/msm8994/oem_panel.c
+++ b/target/msm8994/oem_panel.c
@@ -45,6 +45,7 @@
 #include "include/panel_jdi_qhd_dualdsi_cmd.h"
 #include "include/panel_jdi_4k_dualdsi_video.h"
 #include "include/panel_jdi_1080p_video.h"
+#include "include/panel_hx8379a_truly_fwvga_video.h"
 
 /*---------------------------------------------------------------------------*/
 /* static panel selection variable                                           */
@@ -55,6 +56,7 @@
 JDI_QHD_DUALDSI_CMD_PANEL,
 JDI_4K_DUALDSI_VIDEO_PANEL,
 JDI_1080P_VIDEO_PANEL,
+HX8379A_TRULY_FWVGA_VIDEO_PANEL,
 UNKNOWN_PANEL
 };
 
@@ -68,6 +70,7 @@
 	{"jdi_qhd_dualdsi_cmd", JDI_QHD_DUALDSI_CMD_PANEL},
 	{"jdi_4k_dualdsi_video", JDI_4K_DUALDSI_VIDEO_PANEL},
 	{"jdi_1080p_video", JDI_1080P_VIDEO_PANEL},
+	{"hx8379a_truly_fwvga_video", HX8379A_TRULY_FWVGA_VIDEO_PANEL},
 };
 
 static uint32_t panel_id;
@@ -215,6 +218,7 @@
 			jdi_4k_dualdsi_video_timings, TIMING_SIZE);
 		memcpy(&panelstruct->fbcinfo, &jdi_4k_dualdsi_video_fbc,
 				sizeof(struct fb_compression));
+		break;
 	case JDI_1080P_VIDEO_PANEL:
 		pan_type = PANEL_TYPE_DSI;
 		pinfo->lcd_reg_en = 1;
@@ -241,6 +245,33 @@
 		memcpy(phy_db->timing,
 			jdi_1080p_video_timings, TIMING_SIZE);
 		break;
+	case HX8379A_TRULY_FWVGA_VIDEO_PANEL:
+		pan_type = PANEL_TYPE_DSI;
+		pinfo->lcd_reg_en = 1;
+		panelstruct->paneldata    = &hx8379a_truly_fwvga_video_panel_data;
+		panelstruct->panelres     = &hx8379a_truly_fwvga_video_panel_res;
+		panelstruct->color        = &hx8379a_truly_fwvga_video_color;
+		panelstruct->videopanel   = &hx8379a_truly_fwvga_video_video_panel;
+		panelstruct->commandpanel = &hx8379a_truly_fwvga_video_command_panel;
+		panelstruct->state        = &hx8379a_truly_fwvga_video_state;
+		panelstruct->laneconfig   = &hx8379a_truly_fwvga_video_lane_config;
+		panelstruct->paneltiminginfo
+			= &hx8379a_truly_fwvga_video_timing_info;
+		panelstruct->panelresetseq
+			= &hx8379a_truly_fwvga_video_reset_seq;
+		panelstruct->backlightinfo = &hx8379a_truly_fwvga_video_backlight;
+		pinfo->mipi.panel_on_cmds
+			= hx8379a_truly_fwvga_video_on_command;
+		pinfo->mipi.num_of_panel_on_cmds
+			= HX8379A_TRULY_FWVGA_VIDEO_ON_COMMAND;
+		pinfo->mipi.panel_off_cmds
+			= hx8379a_truly_fwvga_video_off_command;
+		pinfo->mipi.num_of_panel_off_cmds
+			= HX8379A_TRULY_FWVGA_VIDEO_OFF_COMMAND;
+		pinfo->mipi.broadcast = 0;
+		memcpy(phy_db->timing,
+					hx8379a_truly_fwvga_video_timings, TIMING_SIZE);
+		break;
 	default:
 	case UNKNOWN_PANEL:
 		pan_type = PANEL_TYPE_UNKNOWN;
@@ -282,6 +313,9 @@
 	case HW_PLATFORM_LIQUID:
 		panel_id = JDI_4K_DUALDSI_VIDEO_PANEL;
 		break;
+	case HW_PLATFORM_DRAGON:
+		panel_id = HX8379A_TRULY_FWVGA_VIDEO_PANEL;
+		break;
 	default:
 		dprintf(CRITICAL, "Display not enabled for %d HW type\n"
 					, hw_id);
@@ -289,7 +323,7 @@
 	}
 
 panel_init:
-	if (panel_id == JDI_4K_DUALDSI_VIDEO_PANEL)
+	if (panel_id == JDI_4K_DUALDSI_VIDEO_PANEL || panel_id == HX8379A_TRULY_FWVGA_VIDEO_PANEL)
 		phy_db->regulator_mode = DSI_PHY_REGULATOR_LDO_MODE;
 	return init_panel_data(panelstruct, pinfo, phy_db);
 }
diff --git a/target/msm8994/target_display.c b/target/msm8994/target_display.c
index bb22fa4..171f3d6 100644
--- a/target/msm8994/target_display.c
+++ b/target/msm8994/target_display.c
@@ -110,10 +110,8 @@
 {
 	uint8_t slave_id = 3;	/* pmi */
 
-	if (enable) {
-		pm8x41_wled_config_slave_id(slave_id);
-		qpnp_wled_enable_backlight(enable);
-	}
+	pm8x41_wled_config_slave_id(slave_id);
+	qpnp_wled_enable_backlight(enable);
 	qpnp_ibb_enable(enable);
 	return NO_ERROR;
 }