Merge "project: msm8953: Add macro for PON register"
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 7a63036..bfc31e4 100755
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -186,7 +186,14 @@
 static const char *androidboot_slot_suffix = " androidboot.slot_suffix=";
 static const char *skip_ramfs = " skip_initramfs";
 static const char *sys_path_cmdline = " rootwait ro init=/init";
+
+#if VERITY_LE
+static const char *verity_dev = " root=/dev/dm-0";
+static const char *verity_system_part = " dm=\"system";
+static const char *verity_params = " none ro,0 1 android-verity /dev/mmcblk0p";
+#else
 static const char *sys_path = "  root=/dev/mmcblk0p";
+#endif
 
 #if VERIFIED_BOOT
 static const char *verity_mode = " androidboot.veritymode=";
@@ -353,7 +360,13 @@
 	int system_ptn_index = -1;
 	unsigned int lun = 0;
 	char lun_char_base = 'a';
-	int syspath_buflen = strlen(sys_path) + sizeof(int) + 1; /*allocate buflen for largest possible string*/
+#if VERITY_LE
+	int syspath_buflen = strlen(verity_dev)
+				+ strlen(verity_system_part) + (sizeof(char) * 2) + 2
+				+ strlen(verity_params) + sizeof(int) + 2;
+#else
+        int syspath_buflen = strlen(sys_path) + sizeof(int) + 2; /*allocate buflen for largest possible string*/
+#endif
 	char syspath_buf[syspath_buflen];
 #if VERIFIED_BOOT
 	uint32_t boot_state = RED;
@@ -511,8 +524,27 @@
 		system_ptn_index = partition_get_index("system");
 		if (platform_boot_dev_isemmc())
 		{
-			snprintf(syspath_buf, syspath_buflen, " root=/dev/mmcblk0p%d",
-				system_ptn_index + 1);
+#if VERITY_LE
+			/*
+			  Condition 4: Verity and A/B both enabled
+			  Eventual command line looks like:
+			  ... androidboot.slot_suffix=<slot_suffix>  ... rootfstype=ext4 ...
+			  ... root=/dev/dm-0  dm="system_<slot_suffix>  none ro,0 1 android-verity /dev/mmcblk0p<NN>"
+			*/
+			snprintf(syspath_buf, syspath_buflen, " %s %s%s %s%d\"",
+				verity_dev,
+				verity_system_part, suffix_slot[current_active_slot],
+				verity_params, system_ptn_index + 1);
+#else
+			/*
+			  Condition 5: A/B enabled, but verity disabled
+			  Eventual command line looks like:
+			  ... androidboot.slot_suffix=<slot_suffix>  ... rootfstype=ext4 ...
+			  ... root=/dev/mmcblk0p<NN> ...
+			*/
+			snprintf(syspath_buf, syspath_buflen, " %s%d",
+					sys_path, system_ptn_index + 1);
+#endif
 		}
 		else
 		{
diff --git a/dev/fbcon/fbcon.c b/dev/fbcon/fbcon.c
index adc5e29..c9d0df6 100644
--- a/dev/fbcon/fbcon.c
+++ b/dev/fbcon/fbcon.c
@@ -21,7 +21,7 @@
  * 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 
+ * 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
@@ -183,8 +183,13 @@
 	unsigned i, j;
 	uint32_t bg_color, check_color, tmp_color, tmp1_color;
 	char *pixels;
-	unsigned count = config->width * (FONT_HEIGHT * (y_end - y_start) - 1);
+	unsigned count;
 
+	/* ignore anything that happens before fbcon is initialized */
+	if (!config)
+		return;
+
+	count = config->width * (FONT_HEIGHT * (y_end - y_start) - 1);
 	pixels = config->base;
 	pixels += y_start * ((config->bpp / 8) * FONT_HEIGHT * config->width);
 
@@ -221,6 +226,10 @@
 	unsigned total_x, total_y;
 	unsigned bytes_per_bpp;
 
+	/* ignore anything that happens before fbcon is initialized */
+	if (!config)
+		return;
+
 	if (config->update_start)
 		config->update_start();
 	if (config->update_done)
@@ -235,9 +244,17 @@
 /* TODO: Take stride into account */
 static void fbcon_scroll_up(void)
 {
-	unsigned short *dst = config->base;
-	unsigned short *src = dst + (config->width * FONT_HEIGHT);
-	unsigned count = config->width * (config->height - FONT_HEIGHT);
+	unsigned short *dst = NULL;
+	unsigned short *src = NULL;
+	unsigned count = 0;
+
+	/* ignore anything that happens before fbcon is initialized */
+	if (!config)
+		return;
+
+	dst = config->base;
+	src = dst + (config->width * FONT_HEIGHT);
+	count = config->width * (config->height - FONT_HEIGHT);
 
 	while(count--) {
 		*dst++ = *src++;
@@ -257,6 +274,10 @@
 	uint32_t line_color, tmp_color;
 	int i, j;
 
+	/* ignore anything that happens before fbcon is initialized */
+	if (!config)
+		return;
+
 	/* set line's color via diffrent type */
 	line_color = fb_color_formats[type].fg;
 
@@ -291,10 +312,17 @@
 void fbcon_clear(void)
 {
 	unsigned long i = 0, j = 0;
-	unsigned char *pixels = config->base;
-	unsigned count = config->width * config->height;
+	unsigned char *pixels = NULL;
+	unsigned count;
 	uint32_t bg_color;
 
+	/* ignore anything that happens before fbcon is initialized */
+	if (!config)
+		return;
+
+	pixels = config->base;
+	count =  config->width * config->height;
+
 	fbcon_set_colors(FBCON_COMMON_MSG);
 	for (i = 0; i < count; i++) {
 		bg_color = BGCOLOR;
diff --git a/dev/gcdb/display/fastboot_oem_display.h b/dev/gcdb/display/fastboot_oem_display.h
index 4c749db..95c9147 100644
--- a/dev/gcdb/display/fastboot_oem_display.h
+++ b/dev/gcdb/display/fastboot_oem_display.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2018, 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
@@ -111,6 +111,7 @@
 	{"sharp_120hz_1080p_cmd", "qcom,mdss_dual_sharp_1080p_120hz_cmd",
 		true},
 	{"mirrorlake1_hdplus_video", "qcom,mdss_dsi_icn9706_720_1440p_video", false},
+	{"hx8399c_truly_video", "qcom,mdss_dsi_hx8399c_truly_video", false},
 };
 
 struct sim_lookup_list lookup_sim[] = {
diff --git a/dev/gcdb/display/include/panel_hx8399c_fhd_pluse_video.h b/dev/gcdb/display/include/panel_hx8399c_fhd_pluse_video.h
new file mode 100644
index 0000000..9331755
--- /dev/null
+++ b/dev/gcdb/display/include/panel_hx8399c_fhd_pluse_video.h
@@ -0,0 +1,343 @@
+/* Copyright (c) 2018, 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.
+ */
+
+#ifndef _PANEL_HX8399C_FHD_PLUSE_VIDEO_H_
+
+#define _PANEL_HX8399C_FHD_PLUSE_VIDEO_H_
+/*---------------------------------------------------------------------------*/
+/* HEADER files                                                              */
+/*---------------------------------------------------------------------------*/
+#include "panel.h"
+
+/*---------------------------------------------------------------------------*/
+/* Panel configuration                                                       */
+/*---------------------------------------------------------------------------*/
+static struct panel_config hx8399c_fhd_pluse_video_panel_data = {
+	"qcom,mdss_dsi_hx8399c_truly_video", "dsi:0:", "qcom,mdss-dsi-panel",
+	10, 0, "DISPLAY_1", 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel resolution                                                          */
+/*---------------------------------------------------------------------------*/
+static struct panel_resolution hx8399c_fhd_pluse_video_panel_res = {
+	1080, 2160, 24, 24, 16, 0, 36, 40, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel color information                                                   */
+/*---------------------------------------------------------------------------*/
+static struct color_info hx8399c_fhd_pluse_video_color = {
+	24, 0, 0xff, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel on/off command information                                          */
+/*---------------------------------------------------------------------------*/
+static char hx8399c_fhd_pluse_video_on_cmd0[] = {
+	0x04, 0x00, 0x39, 0xC0,
+	0xB9, 0xFF, 0x83, 0x99,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd1[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xD2, 0x88, 0xFF, 0xFF,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd2[] = {
+	0x10, 0x00, 0x39, 0xC0,
+	0xB1, 0x02, 0x04, 0x74,
+	0x94, 0x01, 0x32, 0x33,
+	0x11, 0x11, 0xE6, 0x5D,
+	0x56, 0x73, 0x02, 0x02,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd3[] = {
+	0x10, 0x00, 0x39, 0xC0,
+	0xB2, 0x00, 0x80, 0x80,
+	0xCC, 0x05, 0x07, 0x5A,
+	0x11, 0x10, 0x10, 0x00,
+	0x1E, 0x70, 0x03, 0xD4,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd4[] = {
+	0x2D, 0x00, 0x39, 0xC0,
+	0xB4, 0x00, 0xFF, 0x59,
+	0x59, 0x0C, 0xAC, 0x00,
+	0x00, 0x0C, 0x00, 0x07,
+	0x0A, 0x00, 0x28, 0x07,
+	0x08, 0x0C, 0x21, 0x03,
+	0x00, 0x00, 0x00, 0xAE,
+	0x87, 0x59, 0x59, 0x0C,
+	0xAC, 0x00, 0x00, 0x0C,
+	0x00, 0x07, 0x0A, 0x00,
+	0x28, 0x07, 0x08, 0x0C,
+	0x01, 0x00, 0x00, 0xAE,
+	0x01, 0xFF, 0xFF, 0xFF,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd5[] = {
+	0x22, 0x00, 0x39, 0xC0,
+	0xD3, 0x00, 0x00, 0x01,
+	0x01, 0x00, 0x00, 0x10,
+	0x10, 0x00, 0x00, 0x03,
+	0x00, 0x03, 0x00, 0x08,
+	0x78, 0x08, 0x78, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x24, 0x02, 0x05, 0x05,
+	0x03, 0x00, 0x00, 0x00,
+	0x05, 0x40, 0xFF, 0xFF,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd6[] = {
+	0x21, 0x00, 0x39, 0xC0,
+	0xD5, 0x20, 0x20, 0x19,
+	0x19, 0x18, 0x18, 0x02,
+	0x03, 0x00, 0x01, 0x24,
+	0x24, 0x18, 0x18, 0x18,
+	0x18, 0x24, 0x24, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x2F,
+	0x2F, 0x30, 0x30, 0x31,
+	0x31, 0xFF, 0xFF, 0xFF,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd7[] = {
+	0x21, 0x00, 0x39, 0xC0,
+	0xD6, 0x24, 0x24, 0x18,
+	0x18, 0x19, 0x19, 0x01,
+	0x00, 0x03, 0x02, 0x24,
+	0x24, 0x18, 0x18, 0x18,
+	0x18, 0x20, 0x20, 0x40,
+	0x40, 0x40, 0x40, 0x40,
+	0x40, 0x40, 0x40, 0x2F,
+	0x2F, 0x30, 0x30, 0x31,
+	0x31, 0xFF, 0xFF, 0xFF,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd8[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xBD, 0x00, 0xFF, 0xFF,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd9[] = {
+	0x11, 0x00, 0x39, 0xC0,
+	0xD8, 0xAA, 0xAA, 0xAA,
+	0xAA, 0xAA, 0xAA, 0xAA,
+	0xAA, 0xAA, 0xBA, 0xAA,
+	0xAA, 0xAA, 0xBA, 0xAA,
+	0xAA, 0xFF, 0xFF, 0xFF,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd10[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xBD, 0x01, 0xFF, 0xFF,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd11[] = {
+	0x11, 0x00, 0x39, 0xC0,
+	0xD8, 0x82, 0xEA, 0xAA,
+	0xAA, 0x82, 0xEA, 0xAA,
+	0xAA, 0x82, 0xEA, 0xAA,
+	0xAA, 0x82, 0xEA, 0xAA,
+	0xAA, 0xFF, 0xFF, 0xFF,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd12[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xBD, 0x02, 0xFF, 0xFF,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd13[] = {
+	0x09, 0x00, 0x39, 0xC0,
+	0xD8, 0xFF, 0xFF, 0xC0,
+	0x3F, 0xFF, 0xFF, 0xC0,
+	0x3F, 0xFF, 0xFF, 0xFF,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd14[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xBD, 0x00, 0xFF, 0xFF,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd15[] = {
+	0x37, 0x00, 0x39, 0xC0,
+	0xE0, 0x08, 0x2A, 0x39,
+	0x35, 0x74, 0x7C, 0x87,
+	0x7F, 0x84, 0x8A, 0x8E,
+	0x91, 0x93, 0x96, 0x9B,
+	0x9C, 0x9E, 0xA5, 0xA6,
+	0xAE, 0xA1, 0xAF, 0xB2,
+	0x5C, 0x58, 0x63, 0x74,
+	0x08, 0x2A, 0x39, 0x35,
+	0x74, 0x7C, 0x87, 0x7F,
+	0x84, 0x8A, 0x8E, 0x91,
+	0x93, 0x96, 0x9B, 0x9C,
+	0x9E, 0xA5, 0xA6, 0xAE,
+	0xA1, 0xAF, 0xB2, 0x5C,
+	0x58, 0x63, 0x74, 0xFF,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd16[] = {
+	0x03, 0x00, 0x39, 0xC0,
+	0xB6, 0x7E, 0x7E, 0xFF,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd17[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0xCC, 0x08, 0xFF, 0xFF,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd18[] = {
+	0x06, 0x00, 0x39, 0xC0,
+	0xC7, 0x00, 0x08, 0x00,
+	0x01, 0x08, 0xFF, 0x00,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd19[] = {
+	0x03, 0x00, 0x39, 0xC0,
+	0xC0, 0x25, 0x5A, 0xFF,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd20[] = {
+	0x11, 0x00, 0x05, 0x80,
+};
+
+static char hx8399c_fhd_pluse_video_on_cmd21[] = {
+	0x29, 0x00, 0x05, 0x80,
+};
+
+static struct mipi_dsi_cmd hx8399c_fhd_pluse_video_on_command[] = {
+	{0x08, hx8399c_fhd_pluse_video_on_cmd0, 0x00},
+	{0x08, hx8399c_fhd_pluse_video_on_cmd1, 0x00},
+	{0x14, hx8399c_fhd_pluse_video_on_cmd2, 0x00},
+	{0x14, hx8399c_fhd_pluse_video_on_cmd3, 0x00},
+	{0x34, hx8399c_fhd_pluse_video_on_cmd4, 0x00},
+	{0x28, hx8399c_fhd_pluse_video_on_cmd5, 0x05},
+	{0x28, hx8399c_fhd_pluse_video_on_cmd6, 0x05},
+	{0x28, hx8399c_fhd_pluse_video_on_cmd7, 0x05},
+	{0x08, hx8399c_fhd_pluse_video_on_cmd8, 0x00},
+	{0x18, hx8399c_fhd_pluse_video_on_cmd9, 0x00},
+	{0x08, hx8399c_fhd_pluse_video_on_cmd10, 0x00},
+	{0x18, hx8399c_fhd_pluse_video_on_cmd11, 0x00},
+	{0x08, hx8399c_fhd_pluse_video_on_cmd12, 0x00},
+	{0x10, hx8399c_fhd_pluse_video_on_cmd13, 0x00},
+	{0x08, hx8399c_fhd_pluse_video_on_cmd14, 0x00},
+	{0x3C, hx8399c_fhd_pluse_video_on_cmd15, 0x05},
+	{0x08, hx8399c_fhd_pluse_video_on_cmd16, 0x00},
+	{0x08, hx8399c_fhd_pluse_video_on_cmd17, 0x00},
+	{0x0C, hx8399c_fhd_pluse_video_on_cmd18, 0x00},
+	{0x08, hx8399c_fhd_pluse_video_on_cmd19, 0x00},
+	{0x04, hx8399c_fhd_pluse_video_on_cmd20, 0x78},
+	{0x04, hx8399c_fhd_pluse_video_on_cmd21, 0x14}
+};
+
+#define HX8399C_FHD_PLUSE_VIDEO_ON_COMMAND 22
+
+
+static char hx8399c_fhd_pluse_videooff_cmd0[] = {
+	0x28, 0x00, 0x05, 0x80
+};
+
+static char hx8399c_fhd_pluse_videooff_cmd1[] = {
+	0x10, 0x00, 0x05, 0x80
+};
+
+static struct mipi_dsi_cmd hx8399c_fhd_pluse_video_off_command[] = {
+	{0x4, hx8399c_fhd_pluse_videooff_cmd0, 0x32},
+	{0x4, hx8399c_fhd_pluse_videooff_cmd1, 0x78}
+};
+
+#define HX8399C_FHD_PLUSE_VIDEO_OFF_COMMAND 2
+
+
+static struct command_state hx8399c_fhd_pluse_video_state = {
+	0, 1
+};
+
+/*---------------------------------------------------------------------------*/
+/* Command mode panel information                                            */
+/*---------------------------------------------------------------------------*/
+static struct commandpanel_info hx8399c_fhd_pluse_video_command_panel = {
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Video mode panel information                                              */
+/*---------------------------------------------------------------------------*/
+static struct videopanel_info hx8399c_fhd_pluse_video_video_panel = {
+	1, 0, 0, 0, 1, 1, 2, 0, 0x9
+};
+
+/*---------------------------------------------------------------------------*/
+/* Lane configuration                                                        */
+/*---------------------------------------------------------------------------*/
+static struct lane_configuration hx8399c_fhd_pluse_video_lane_config = {
+	4, 0, 1, 1, 1, 1, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel timing                                                              */
+/*---------------------------------------------------------------------------*/
+static const uint32_t hx8399c_fhd_pluse_video_timings[] = {
+	0x24, 0x1C, 0x34, 0x00, 0x58, 0x4d, 0x36, 0x3f, 0x53, 0x03, 0x04, 0x00
+};
+
+static const uint32_t hx8399c_fhd_pluse_14nm_video_timings[] = {
+	0x24, 0x1f, 0x08, 0x09, 0x05, 0x03, 0x04, 0xa0,
+	0x24, 0x1f, 0x08, 0x09, 0x05, 0x03, 0x04, 0xa0,
+	0x24, 0x1f, 0x08, 0x09, 0x05, 0x03, 0x04, 0xa0,
+	0x24, 0x1f, 0x08, 0x09, 0x05, 0x03, 0x04, 0xa0,
+	0x24, 0x1c, 0x08, 0x09, 0x05, 0x03, 0x04, 0xa0,
+};
+static struct panel_timing hx8399c_fhd_pluse_video_timing_info = {
+	0, 4, 0x0e, 0x31
+};
+
+static struct labibb_desc hx8399c_fhd_pluse_video_labibb = {
+	0, 1, 5700000, 5700000, 5700000, 5700000, 3, 3, 1, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel reset sequence                                                      */
+/*---------------------------------------------------------------------------*/
+static struct panel_reset_sequence hx8399c_fhd_pluse_video_panel_reset_seq = {
+	{1, 0, 1, }, {20, 2, 20, }, 2
+};
+
+/*---------------------------------------------------------------------------*/
+/* Backlight setting                                                         */
+/*---------------------------------------------------------------------------*/
+static struct backlight hx8399c_fhd_pluse_video_backlight = {
+	1, 1, 4095, 100, 1, "PMIC_8941"
+};
+
+#define HX8399C_FHD_PLUSE_VIDEO_SIGNATURE 0xA0000
+
+#endif /*_PANEL_HX8399C_FHD_PLUSE_VIDEO_H_*/
diff --git a/dev/pmic/pm8x41/include/pm8x41.h b/dev/pmic/pm8x41/include/pm8x41.h
index 0fc517b..e289623 100644
--- a/dev/pmic/pm8x41/include/pm8x41.h
+++ b/dev/pmic/pm8x41/include/pm8x41.h
@@ -232,6 +232,7 @@
 uint8_t pm8x41_get_pon_reason();
 uint8_t pm660_get_pon_reason();
 uint8_t pm8950_get_pon_reason();
+uint8_t pmi632_get_pon_reason();
 uint8_t pm8x41_get_pon_poff_reason1();
 uint8_t pm8x41_get_pon_poff_reason2();
 uint32_t pm8x41_get_pwrkey_is_pressed();
diff --git a/dev/pmic/pm8x41/include/pm8x41_hw.h b/dev/pmic/pm8x41/include/pm8x41_hw.h
index d213582..d719243 100644
--- a/dev/pmic/pm8x41/include/pm8x41_hw.h
+++ b/dev/pmic/pm8x41/include/pm8x41_hw.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2015, 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2015, 2017-2018, 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
@@ -109,6 +109,10 @@
 #define USBIN_ACTIVE_PWR_SRC                  BIT(0)
 #define DCIN_ACTIVE_PWR_SRC                   BIT(1)
 
+/* USB Status registers */
+#define SCHG_USB_INT_RT_STS		      0x1310
+#define USBIN_PLUGIN_RT_STS		      BIT(4)
+
 /* MPP registers */
 #define MPP_DIG_VIN_CTL                       0x41
 #define MPP_MODE_CTL                          0x40
diff --git a/dev/pmic/pm8x41/pm8x41.c b/dev/pmic/pm8x41/pm8x41.c
index 442bc35..ba723b4 100644
--- a/dev/pmic/pm8x41/pm8x41.c
+++ b/dev/pmic/pm8x41/pm8x41.c
@@ -637,6 +637,18 @@
 	return pon_reason;
 }
 
+uint8_t pmi632_get_pon_reason()
+{
+	uint8_t pon_reason = 0;
+
+	pon_reason = REG_READ(SCHG_USB_INT_RT_STS|PMI8950_SLAVE_ID);
+	/* Check USBIN status on PMI and set the corresponding bits for pon */
+	pon_reason = (pon_reason & USBIN_PLUGIN_RT_STS);
+	pon_reason |= REG_READ(PON_PON_REASON1);
+
+	return pon_reason;
+}
+
 uint8_t pm8x41_get_pon_poff_reason1()
 {
 	return REG_READ(PON_POFF_REASON1);
diff --git a/platform/msm_shared/display_menu.c b/platform/msm_shared/display_menu.c
index 391e5ff..8b74c9a 100644
--- a/platform/msm_shared/display_menu.c
+++ b/platform/msm_shared/display_menu.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2018, 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
@@ -201,14 +201,10 @@
 			for (i = 0; i < diff; i++) {
 				strlcat(str_target, " ", max_x);
 			}
-			strlcat(str_target, str, max_x);
-			return str_target;
-		} else {
-			free(str_target);
-			return str;
 		}
+		strlcat(str_target, str, max_x);
 	}
-	return str;
+	return str_target;
 }
 
 /* msg_lock need to be holded when call this function. */
diff --git a/target/init.c b/target/init.c
index b842eaf..e8189cc 100644
--- a/target/init.c
+++ b/target/init.c
@@ -435,7 +435,6 @@
 			}
 			break;
 		case PMIC_IS_PM660:
-		case PMIC_IS_PMI632:
 			value = REG_READ(BAT_IF_INT_RT_STS);
 			/* If BAT_TERMINAL_MISSING_RT_STS BIT(5) or BAT_THERM_OR_ID_MISSING_RT_STS BIT(4)
 			   are set, battery is not present. */
@@ -444,6 +443,15 @@
 			else
 				return true;
 			break;
+		case PMIC_IS_PMI632:
+			value = REG_READ(PMIC_SLAVE_ID|BAT_IF_INT_RT_STS);
+			/* If BAT_TERMINAL_MISSING_RT_STS BIT(5) or BAT_THERM_OR_ID_MISSING_RT_STS BIT(4)
+			   are set, battery is not present. */
+			if (value & (BIT(5) | BIT(4)))
+				return false;
+			else
+				return true;
+			break;
 		default:
 			dprintf(CRITICAL, "ERROR: Couldn't get the pmic type\n");
 			break;
diff --git a/target/msm8953/init.c b/target/msm8953/init.c
index c2f1eb6..0e185d3 100644
--- a/target/msm8953/init.c
+++ b/target/msm8953/init.c
@@ -239,26 +239,22 @@
 {
 	uint32_t pmic = target_get_pmic();
 	uint8_t pon_reason = 0;
-	uint8_t is_cold_boot = 0;
 	bool usb_present_sts = 1;
 
 	if (pmic == PMIC_IS_PMI632)
 	{
-		pon_reason = pm660_get_pon_reason();
-		is_cold_boot = pm660_get_is_cold_boot();
+		pon_reason = pmi632_get_pon_reason();
 		usb_present_sts = !(USBIN_UV_RT_STS_PMI632 &
 				pm8x41_reg_read(SMBCHG_USB_RT_STS));
 	}
 	else
 	{
 		pon_reason = pm8950_get_pon_reason();
-		is_cold_boot = pm8x41_get_is_cold_boot();
-		if (target_is_pmi_enabled())
-			usb_present_sts = !(USBIN_UV_RT_STS &
+		usb_present_sts = !(USBIN_UV_RT_STS &
 				pm8x41_reg_read(SMBCHG_USB_RT_STS));
 	}
 
-	if (is_cold_boot && ((pon_reason == KPDPWR_N) ||
+	if (pm8x41_get_is_cold_boot() && ((pon_reason == KPDPWR_N) ||
 				(pon_reason == (KPDPWR_N|PON1))))
 		return 1;
 	else if ((pon_reason == PON1) && (!usb_present_sts))
@@ -415,22 +411,16 @@
 unsigned target_pause_for_battery_charge(void)
 {
 	uint32_t pmic = target_get_pmic();
-	uint8_t pon_reason = 0;
-	uint8_t is_cold_boot = 0;
+	uint8_t pon_reason = pm8x41_get_pon_reason();
+	uint8_t is_cold_boot = pm8x41_get_is_cold_boot();
 	bool usb_present_sts = 1;
 
-	if (pmic == PMIC_IS_PMI632)
+	if (target_is_pmi_enabled())
 	{
-		pon_reason = pm660_get_pon_reason();
-		is_cold_boot = pm660_get_is_cold_boot();
-		usb_present_sts = !(USBIN_UV_RT_STS_PMI632 &
+		if (pmic == PMIC_IS_PMI632)
+			usb_present_sts = !(USBIN_UV_RT_STS_PMI632 &
 				pm8x41_reg_read(SMBCHG_USB_RT_STS));
-	}
-	else
-	{
-		pon_reason = pm8x41_get_pon_reason();
-		is_cold_boot = pm8x41_get_is_cold_boot();
-		if (target_is_pmi_enabled())
+		else
 			usb_present_sts = !(USBIN_UV_RT_STS &
 				pm8x41_reg_read(SMBCHG_USB_RT_STS));
 	}
diff --git a/target/msm8953/oem_panel.c b/target/msm8953/oem_panel.c
index 9a4658e..f035b6f 100644
--- a/target/msm8953/oem_panel.c
+++ b/target/msm8953/oem_panel.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2016,2018, 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
@@ -50,7 +50,7 @@
 #include "include/panel_r69006_1080p_video.h"
 #include "include/panel_r69006_1080p_cmd.h"
 #include "include/panel_truly_wuxga_video.h"
-
+#include "include/panel_hx8399c_fhd_pluse_video.h"
 
 /*---------------------------------------------------------------------------*/
 /* static panel selection variable                                           */
@@ -61,6 +61,7 @@
 	R69006_1080P_VIDEO_PANEL,
 	R69006_1080P_CMD_PANEL,
 	TRULY_WUXGA_VIDEO_PANEL,
+	HX8399C_FHD_PLUSE_VIDEO_PANEL,
 	UNKNOWN_PANEL
 };
 
@@ -74,6 +75,7 @@
 	{"r69006_1080p_video", R69006_1080P_VIDEO_PANEL},
 	{"r69006_1080p_cmd", R69006_1080P_CMD_PANEL},
 	{"truly_wuxga_video", TRULY_WUXGA_VIDEO_PANEL},
+	{"hx8399c_fhd_pluse_video", HX8399C_FHD_PLUSE_VIDEO_PANEL},
 };
 
 static uint32_t panel_id;
@@ -249,6 +251,35 @@
 		pinfo->dfps.panel_dfps = truly_wuxga_video_dfps;
 		pinfo->mipi.signature 	= TRULY_WUXGA_VIDEO_SIGNATURE;
 		break;
+	case HX8399C_FHD_PLUSE_VIDEO_PANEL:
+		panelstruct->paneldata    = &hx8399c_fhd_pluse_video_panel_data;
+		panelstruct->panelres     = &hx8399c_fhd_pluse_video_panel_res;
+		panelstruct->color        = &hx8399c_fhd_pluse_video_color;
+		panelstruct->videopanel   =
+				&hx8399c_fhd_pluse_video_video_panel;
+		panelstruct->commandpanel =
+				&hx8399c_fhd_pluse_video_command_panel;
+		panelstruct->state        = &hx8399c_fhd_pluse_video_state;
+		panelstruct->laneconfig   =
+				&hx8399c_fhd_pluse_video_lane_config;
+		panelstruct->paneltiminginfo
+				= &hx8399c_fhd_pluse_video_timing_info;
+		panelstruct->panelresetseq
+				= &hx8399c_fhd_pluse_video_panel_reset_seq;
+		panelstruct->backlightinfo = &hx8399c_fhd_pluse_video_backlight;
+		pinfo->labibb = &hx8399c_fhd_pluse_video_labibb;
+		pinfo->mipi.panel_on_cmds
+				= hx8399c_fhd_pluse_video_on_command;
+		pinfo->mipi.num_of_panel_on_cmds
+				= HX8399C_FHD_PLUSE_VIDEO_ON_COMMAND;
+		pinfo->mipi.panel_off_cmds
+				= hx8399c_fhd_pluse_video_off_command;
+		pinfo->mipi.num_of_panel_off_cmds
+				= HX8399C_FHD_PLUSE_VIDEO_OFF_COMMAND;
+		memcpy(phy_db->timing,
+			hx8399c_fhd_pluse_14nm_video_timings, MAX_TIMING_CONFIG * sizeof(uint32_t));
+		pinfo->mipi.signature    = HX8399C_FHD_PLUSE_VIDEO_SIGNATURE;
+		break;
 	case UNKNOWN_PANEL:
 	default:
 		memset(panelstruct, 0, sizeof(struct panel_struct));
@@ -278,6 +309,7 @@
 			struct mdss_dsi_phy_ctrl *phy_db)
 {
 	uint32_t hw_id = board_hardware_id();
+	uint32_t platform_subtype = board_hardware_subtype();
 	int32_t panel_override_id;
 	phy_db->pll_type = DSI_PLL_TYPE_THULIUM;
 
@@ -300,12 +332,20 @@
 
 	switch (hw_id) {
 	case HW_PLATFORM_MTP:
+		panel_id = TRULY_1080P_VIDEO_PANEL;
+		if (platform_subtype == 0x03)
+			panel_id = HX8399C_FHD_PLUSE_VIDEO_PANEL;
+		break;
 	case HW_PLATFORM_SURF:
 	case HW_PLATFORM_RCM:
 		panel_id = TRULY_1080P_VIDEO_PANEL;
+		if (platform_subtype == 0x02)
+			 panel_id = HX8399C_FHD_PLUSE_VIDEO_PANEL;
 		break;
 	case HW_PLATFORM_QRD:
 		panel_id = R69006_1080P_CMD_PANEL;
+		if (platform_subtype == 0x01)
+			panel_id = HX8399C_FHD_PLUSE_VIDEO_PANEL;
 		break;
 	default:
 		dprintf(CRITICAL, "Display not enabled for %d HW type\n",