Merge "dev: gcdb: display: add jdi 4k video nofbc panel support"
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index df9a6be..759bc22 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -3199,6 +3199,8 @@
 #endif
 		dprintf(SPEW, "Display Init: Start\n");
 #if ENABLE_WBC
+		/* Wait if the display shutdown is in progress */
+		while(pm_app_display_shutdown_in_prgs());
 		if (!pm_appsbl_display_init_done())
 			target_display_init(device.display_panel);
 		else
diff --git a/dev/gcdb/display/gcdb_display.c b/dev/gcdb/display/gcdb_display.c
index d4fe865..4aa95b0 100644
--- a/dev/gcdb/display/gcdb_display.c
+++ b/dev/gcdb/display/gcdb_display.c
@@ -412,16 +412,19 @@
 {
 	struct oem_panel_data *oem_data = mdss_dsi_get_oem_data_ptr();
 
-	if (panelstruct.paneldata->panel_operating_mode & USE_DSI1_PLL_FLAG)
+	/* Set PLL_SRC to PLL1 for non dual-DSI cases only */
+	if (!is_dsi_config_dual() &&
+		(panelstruct.paneldata->panel_operating_mode &
+		USE_DSI1_PLL_FLAG))
 		oem_data->dsi_pll_src = DSI_PLL1;
 
-	if (strcmp(oem_data->sec_panel, "")) {
+	if (is_dsi_config_dual()) {
 		if (oem_data->dsi_pll_src != DSI_PLL_DEFAULT) {
 			dprintf(CRITICAL, "Dual DSI config detected!"
 				"Use default PLL\n");
 			oem_data->dsi_pll_src = DSI_PLL_DEFAULT;
 		}
-	} else if (panelstruct.paneldata->slave_panel_node_id) {
+	} else if (is_dsi_config_split()) {
 		if((dsi_video_mode_phy_db.pll_type != DSI_PLL_TYPE_THULIUM)
 			&& (oem_data->dsi_pll_src == DSI_PLL1)) {
 			dprintf(CRITICAL, "Split DSI on 28nm/20nm!"
@@ -441,10 +444,9 @@
 	if (oem_data->dsi_pll_src == DSI_PLL1)
 		panelstruct.paneldata->panel_operating_mode |=
 			USE_DSI1_PLL_FLAG;
-	else
+	else if (oem_data->dsi_pll_src == DSI_PLL0)
 		panelstruct.paneldata->panel_operating_mode &=
 			~USE_DSI1_PLL_FLAG;
-
 }
 
 int gcdb_display_init(const char *panel_name, uint32_t rev, void *base)
diff --git a/dev/gcdb/display/gcdb_display.h b/dev/gcdb/display/gcdb_display.h
index 088aa05..c71abbf 100755
--- a/dev/gcdb/display/gcdb_display.h
+++ b/dev/gcdb/display/gcdb_display.h
@@ -83,4 +83,30 @@
     DSI_PLL1,
 };
 
+static inline bool is_dsi_config_split(void)
+{
+	struct panel_struct panelstruct = mdss_dsi_get_panel_data();
+
+	return panelstruct.paneldata->panel_node_id &&
+		panelstruct.paneldata->slave_panel_node_id &&
+		(panelstruct.paneldata->panel_operating_mode & (DUAL_DSI_FLAG |
+		SPLIT_DISPLAY_FLAG | DST_SPLIT_FLAG));
+}
+
+static inline bool is_dsi_config_dual(void)
+{
+	struct oem_panel_data *oem_data = mdss_dsi_get_oem_data_ptr();
+
+	return !is_dsi_config_split() && oem_data->sec_panel &&
+		strcmp(oem_data->sec_panel, "");
+}
+
+static inline bool is_dsi_config_single()
+{
+	struct panel_struct panelstruct = mdss_dsi_get_panel_data();
+
+	return panelstruct.paneldata->panel_node_id && !is_dsi_config_split()
+		&& !is_dsi_config_dual();
+}
+
 #endif /*_GCDB_DISPLAY_H_ */
diff --git a/dev/gcdb/display/include/panel_fl10802_fwvga_video.h b/dev/gcdb/display/include/panel_fl10802_fwvga_video.h
index 80c64bd..4a511df 100644
--- a/dev/gcdb/display/include/panel_fl10802_fwvga_video.h
+++ b/dev/gcdb/display/include/panel_fl10802_fwvga_video.h
@@ -328,7 +328,7 @@
 /* Backlight setting                                                         */
 /*---------------------------------------------------------------------------*/
 static struct backlight fl10802_fwvga_video_backlight = {
-  1, 1, 255, 100, 2, "PMIC_8941"
+  BL_DCS, 1, 255, 100, 2, "PMIC_8941"
 };
 
 #define FL10802_FWVGA_VIDEO_SIGNATURE 0xFFFF
diff --git a/dev/gcdb/display/include/panel_r69007_wqxga_cmd.h b/dev/gcdb/display/include/panel_r69007_wqxga_cmd.h
new file mode 100644
index 0000000..ab68848
--- /dev/null
+++ b/dev/gcdb/display/include/panel_r69007_wqxga_cmd.h
@@ -0,0 +1,381 @@
+/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ *       copyright notice, this list of conditions and the following
+ *       disclaimer in the documentation and/or other materials provided
+ *       with the distribution.
+ *     * Neither the name of The Linux Foundation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _PANEL_R69007_WQXGA_CMD_H_
+#define _PANEL_R69007_WQXGA_CMD_H_
+/*---------------------------------------------------------------------------*/
+/* HEADER files                                                              */
+/*---------------------------------------------------------------------------*/
+#include "panel.h"
+
+/*---------------------------------------------------------------------------*/
+/* Panel configuration                                                       */
+/*---------------------------------------------------------------------------*/
+static struct panel_config r69007_wqxga_cmd_panel_data = {
+	"qcom,mdss_dsi_r69007_wqxga_cmd", "dsi:0:", "qcom,mdss-dsi-panel",
+	10, 1, "DISPLAY_1", 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0,
+	"qcom,mdss_dsi_r69007_wqxga_cmd"
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel resolution                                                          */
+/*---------------------------------------------------------------------------*/
+static struct panel_resolution r69007_wqxga_cmd_panel_res = {
+	1440, 2560, 112, 70, 10, 0, 9, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel color information                                                   */
+/*---------------------------------------------------------------------------*/
+static struct color_info r69007_wqxga_cmd_color = {
+	24, 0, 0xff, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel on/off command information                                          */
+/*---------------------------------------------------------------------------*/
+static char r69007_wqxga_cmd_on_cmd0[] = {
+	0x02, 0x00, 0x29, 0xC0,
+	0xB0, 0x00, 0xFF, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd1[] = {
+	0x04, 0x00, 0x29, 0xC0,
+	0xB3, 0x00, 0x00, 0x00,
+};
+
+static char r69007_wqxga_cmd_on_cmd2[] = {
+	0x04, 0x00, 0x29, 0xC0,
+	0xB6, 0x3b, 0xd3, 0x00,
+};
+
+static char r69007_wqxga_cmd_on_cmd3[] = {
+	0x28, 0x00, 0x29, 0xC0,
+	0xC1, 0x80, 0x08, 0x11,
+	0x1F, 0xFC, 0xF2, 0xC9,
+	0x1F, 0x5F, 0x98, 0xB3,
+	0xFE, 0xFF, 0xF7, 0xFE,
+	0xFF, 0xD7, 0x31, 0xF1,
+	0xCB, 0x3F, 0x3F, 0xFD,
+	0xEF, 0x03, 0x24, 0x69,
+	0x18, 0xAA, 0x40, 0x01,
+	0x42, 0x02, 0x08, 0x00,
+	0x01, 0x00, 0x01, 0x00,
+};
+
+static char r69007_wqxga_cmd_on_cmd4[] = {
+	0x0F, 0x00, 0x29, 0xC0,
+	0xC2, 0x01, 0xFA, 0x00,
+	0x04, 0x64, 0x08, 0x00,
+	0x60, 0x00, 0x38, 0x70,
+	0x00, 0x00, 0x00, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd5[] = {
+	0x09, 0x00, 0x29, 0xC0,
+	0xC3, 0x07, 0x01, 0x08,
+	0x01, 0x00, 0x00, 0x00,
+	0x00, 0xFF, 0xFF, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd6[] = {
+	0x12, 0x00, 0x29, 0xC0,
+	0xC4, 0x70, 0x00, 0x00,
+	0x00, 0x02, 0x00, 0x00,
+	0x00, 0x00, 0x02, 0x01,
+	0x00, 0x01, 0x01, 0x00,
+	0x00, 0x00, 0xFF, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd7[] = {
+	0x11, 0x00, 0x29, 0xC0,
+	0xC6, 0x3C, 0x00, 0x3C,
+	0x02, 0x37, 0x01, 0x0E,
+	0x01, 0x02, 0x01, 0x02,
+	0x03, 0x0F, 0x04, 0x3C,
+	0x46, 0xFF, 0xFF, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd8[] = {
+	0x1F, 0x00, 0x29, 0xC0,
+	0xC7, 0x00, 0x16, 0x22,
+	0x2C, 0x3B, 0x48, 0x51,
+	0x5D, 0x40, 0x47, 0x53,
+	0x61, 0x6A, 0x71, 0x78,
+	0x00, 0x16, 0x22, 0x2C,
+	0x3B, 0x48, 0x51, 0x5D,
+	0x40, 0x47, 0x53, 0x61,
+	0x6A, 0x71, 0x78, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd9[] = {
+	0x14, 0x00, 0x29, 0xC0,
+	0xC8, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0xFC, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0xFC, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0xFC, 0x00,
+};
+
+static char r69007_wqxga_cmd_on_cmd10[] = {
+	0x14, 0x00, 0x29, 0xC0,
+	0xC9, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0xFC, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0xFC, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0xFC, 0x00,
+};
+
+static char r69007_wqxga_cmd_on_cmd11[] = {
+	0x14, 0x00, 0x29, 0xC0,
+	0xCB, 0xAA, 0x1E, 0xE3,
+	0x55, 0xF1, 0xFF, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+	0x00, 0x00, 0x00, 0x00,
+};
+
+static char r69007_wqxga_cmd_on_cmd12[] = {
+	0x02, 0x00, 0x29, 0xC0,
+	0xCC, 0x07, 0xFF, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd13[] = {
+	0x0B, 0x00, 0x29, 0xC0,
+	0xCD, 0x3A, 0x86, 0x3A,
+	0x86, 0x8D, 0x8D, 0x04,
+	0x04, 0x00, 0x00, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd14[] = {
+	0x11, 0x00, 0x29, 0xC0,
+	0xD0, 0x2A, 0x01, 0x91,
+	0x6A, 0xDC, 0x59, 0x19,
+	0x00, 0x00, 0x00, 0x19,
+	0x99, 0x04, 0x00, 0x00,
+	0x00, 0xFF, 0xFF, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd15[] = {
+	0x21, 0x00, 0x29, 0xC0,
+	0xD3, 0x1B, 0x3B, 0xBB,
+	0x77, 0x77, 0x77, 0xBB,
+	0xB3, 0x33, 0x00, 0x80,
+	0xA7, 0xAF, 0x5B, 0x5B,
+	0x33, 0x33, 0x33, 0xC0,
+	0x00, 0xF2, 0x0F, 0x7D,
+	0x7C, 0xFF, 0x0F, 0x99,
+	0x00, 0x33, 0x00, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd16[] = {
+	0x06, 0x00, 0x29, 0xC0,
+	0xD4, 0x57, 0x33, 0x05,
+	0x00, 0xF4, 0xFF, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd17[] = {
+	0x0C, 0x00, 0x29, 0xC0,
+	0xD5, 0x66, 0x00, 0x00,
+	0x01, 0x3D, 0x01, 0x3D,
+	0x00, 0x38, 0x00, 0x38,
+};
+
+static char r69007_wqxga_cmd_on_cmd18[] = {
+	0x22, 0x00, 0x29, 0xC0,
+	0xD7, 0x04, 0xff, 0x23,
+	0x15, 0x75, 0xa4, 0xc3,
+	0x1f, 0xc3, 0x1f, 0xd9,
+	0x07, 0x1c, 0x1f, 0x30,
+	0x8e, 0x87, 0xc7, 0xe3,
+	0xf1, 0xcc, 0xf0, 0x1f,
+	0xf0, 0x0d, 0x70, 0x00,
+	0x2A, 0x00, 0x7e, 0x1d,
+	0x07, 0x00, 0xFF, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd19[] = {
+	0x05, 0x00, 0x29, 0xC0,
+	0xDE, 0x00, 0x3f, 0xff,
+	0x10, 0xFF, 0xFF, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd20[] = {
+	0x02, 0x00, 0x29, 0xC0,
+	0xD6, 0x01, 0xFF, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd21[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x35, 0x00, 0xFF, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd22[] = {
+	0x05, 0x00, 0x39, 0xC0,
+	0x2A, 0x00, 0x00, 0x05,
+	0x9F, 0xFF, 0xFF, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd23[] = {
+	0x05, 0x00, 0x39, 0xC0,
+	0x2B, 0x00, 0x00, 0x09,
+	0xFF, 0xFF, 0xFF, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd24[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x2C, 0x00, 0xFF, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd25[] = {
+	0x02, 0x00, 0x39, 0xC0,
+	0x36, 0x40, 0xFF, 0xFF,
+};
+
+static char r69007_wqxga_cmd_on_cmd26[] = {
+	0x29, 0x00, 0x05, 0x80
+};
+
+static char r69007_wqxga_cmd_on_cmd27[] = {
+	0x11, 0x00, 0x05, 0x80
+};
+
+static struct mipi_dsi_cmd r69007_wqxga_cmd_on_command[] = {
+	{0x8, r69007_wqxga_cmd_on_cmd0, 0x00},
+	{0x8, r69007_wqxga_cmd_on_cmd1, 0x00},
+	{0x8, r69007_wqxga_cmd_on_cmd2, 0x00},
+	{0x2c, r69007_wqxga_cmd_on_cmd3, 0x00},
+	{0x14, r69007_wqxga_cmd_on_cmd4, 0x00},
+	{0x10, r69007_wqxga_cmd_on_cmd5, 0x00},
+	{0x18, r69007_wqxga_cmd_on_cmd6, 0x00},
+	{0x18, r69007_wqxga_cmd_on_cmd7, 0x00},
+	{0x24, r69007_wqxga_cmd_on_cmd8, 0x00},
+	{0x18, r69007_wqxga_cmd_on_cmd9, 0x00},
+	{0x18, r69007_wqxga_cmd_on_cmd10, 0x00},
+	{0x18, r69007_wqxga_cmd_on_cmd11, 0x00},
+	{0x8, r69007_wqxga_cmd_on_cmd12, 0x00},
+	{0x10, r69007_wqxga_cmd_on_cmd13, 0x00},
+	{0x18, r69007_wqxga_cmd_on_cmd14, 0x00},
+	{0x28, r69007_wqxga_cmd_on_cmd15, 0x00},
+	{0xc, r69007_wqxga_cmd_on_cmd16, 0x00},
+	{0x10, r69007_wqxga_cmd_on_cmd17, 0x00},
+	{0x28, r69007_wqxga_cmd_on_cmd18, 0x00},
+	{0xc, r69007_wqxga_cmd_on_cmd19, 0x00},
+	{0x8, r69007_wqxga_cmd_on_cmd20, 0x00},
+	{0x8, r69007_wqxga_cmd_on_cmd21, 0x00},
+	{0xc, r69007_wqxga_cmd_on_cmd22, 0x00},
+	{0xc, r69007_wqxga_cmd_on_cmd23, 0x00},
+	{0x8, r69007_wqxga_cmd_on_cmd24, 0x00},
+	{0x8, r69007_wqxga_cmd_on_cmd25, 0x00},
+	{0x4, r69007_wqxga_cmd_on_cmd26, 0x78},
+	{0x4, r69007_wqxga_cmd_on_cmd27, 0x14}
+};
+
+#define R69007_WQXGA_CMD_ON_COMMAND 28
+
+
+static char r69007_wqxga_cmdoff_cmd0[] = {
+	0x28, 0x00, 0x05, 0x80
+};
+
+static char r69007_wqxga_cmdoff_cmd1[] = {
+	0x10, 0x00, 0x05, 0x80
+};
+
+static struct mipi_dsi_cmd r69007_wqxga_cmd_off_command[] = {
+	{0x4, r69007_wqxga_cmdoff_cmd0, 0x32},
+	{0x4, r69007_wqxga_cmdoff_cmd1, 0x78}
+};
+
+#define R69007_WQXGA_CMD_OFF_COMMAND 2
+
+
+static struct command_state r69007_wqxga_cmd_state = {
+	0, 1
+};
+
+/*---------------------------------------------------------------------------*/
+/* Command mode panel information                                            */
+/*---------------------------------------------------------------------------*/
+static struct commandpanel_info r69007_wqxga_cmd_command_panel = {
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Video mode panel information                                              */
+/*---------------------------------------------------------------------------*/
+static struct videopanel_info r69007_wqxga_cmd_video_panel = {
+	1, 0, 0, 0, 1, 1, 2, 0, 0x9
+};
+
+/*---------------------------------------------------------------------------*/
+/* Lane configuration                                                        */
+/*---------------------------------------------------------------------------*/
+static struct lane_configuration r69007_wqxga_cmd_lane_config = {
+	4, 0, 1, 1, 1, 1, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel timing                                                              */
+/*---------------------------------------------------------------------------*/
+static const uint32_t r69007_wqxga_cmd_timings[] = {
+	0xDA, 0x34, 0x24, 0x00, 0x64, 0x68, 0x28, 0x38, 0x2A, 0x03, 0x04, 0x00
+};
+
+static const uint32_t r69007_wqxga_thulium_cmd_timings[] = {
+	0x23, 0x1F, 0x07, 0x09, 0x05, 0x03, 0x04, 0xa0,
+	0x23, 0x1F, 0x07, 0x09, 0x05, 0x03, 0x04, 0xa0,
+	0x23, 0x1F, 0x07, 0x09, 0x05, 0x03, 0x04, 0xa0,
+	0x23, 0x1F, 0x07, 0x09, 0x05, 0x03, 0x04, 0xa0,
+	0x23, 0x19, 0x08, 0x08, 0x05, 0x03, 0x04, 0xa0
+};
+
+static struct panel_timing r69007_wqxga_cmd_timing_info = {
+	0x0, 0x04, 0x03, 0x29
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel reset sequence                                                      */
+/*---------------------------------------------------------------------------*/
+static struct panel_reset_sequence r69007_wqxga_cmd_reset_seq = {
+	{1, 0, 1, }, {2, 5, 120, }, 2
+};
+
+static struct labibb_desc r69007_wqxga_cmd_labibb = {
+	0, 1, 5500000, 5500000, 5500000, 5500000, 3, 3, 1
+};
+
+/*---------------------------------------------------------------------------*/
+/* Backlight setting                                                         */
+/*---------------------------------------------------------------------------*/
+static struct backlight r69007_wqxga_cmd_backlight = {
+	1, 1, 4095, 100, 1, "PMIC_8941"
+};
+
+#endif /*_PANEL_R69007_WQXGA_CMD_H_*/
diff --git a/dev/pmic/pmi8994/include/pm_app_smbchg.h b/dev/pmic/pmi8994/include/pm_app_smbchg.h
index bfc12ca..81a7b39 100644
--- a/dev/pmic/pmi8994/include/pm_app_smbchg.h
+++ b/dev/pmic/pmi8994/include/pm_app_smbchg.h
@@ -201,5 +201,6 @@
 bool pm_appsbl_display_init_done();
 bool pm_appsbl_charging_in_progress();
 pm_err_flag_type pm_appsbl_set_dcin_suspend();
+bool pm_app_display_shutdown_in_prgs();
 #endif  //PM_APP_SMBCHG__H
 
diff --git a/dev/pmic/pmi8994/pm_app_smbchg.c b/dev/pmic/pmi8994/pm_app_smbchg.c
index d3d1d6b..4b9693b 100644
--- a/dev/pmic/pmi8994/pm_app_smbchg.c
+++ b/dev/pmic/pmi8994/pm_app_smbchg.c
@@ -40,11 +40,12 @@
 #include "pm_smbchg_driver.h"
 #include "pm_comm.h"
 #include "pm_smbchg_dc_chgpth.h"
+#include <kernel/thread.h>
 #include <debug.h>
 #include <platform/timer.h>
 #include <sys/types.h>
 #include <target.h>
-
+#include <pm8x41.h>
 
 /*===========================================================================
 
@@ -64,16 +65,27 @@
 #define  PM_MIN_ADC_READY_DELAY             1 * 1000  //1ms
 #define  PM_MAX_ADC_READY_DELAY     2000              //2s
 #define SBL_PACKED_SRAM_CONFIG_SIZE 3
-
+#define  PM_CHARGE_DISPLAY_TIMEOUT       5 * 1000 //5 secs
 #define boot_log_message(...) dprintf(CRITICAL, __VA_ARGS__)
 
 static pm_smbchg_bat_if_low_bat_thresh_type pm_dbc_bootup_volt_threshold;
+/* Need to maintain flags to track
+ * 1. charge_in_progress: Charging progress and exit the loop once charging is completed.
+ * 2. display_initialized: Track if the display is already initialized to make sure display
+ *    thread does not reinitialize the display again.
+ * 3. display_shutdown_in_prgs: To avoid race condition between regualr display initialization and
+ *    display shutdown in display thread.
+ */
+
 static bool display_initialized;
 static bool charge_in_progress;
+static bool display_shutdown_in_prgs;
+
 char panel_name[256];
 
 pm_err_flag_type pm_smbchg_get_charger_path(uint32 device_index, pm_smbchg_usb_chgpth_pwr_pth_type* charger_path);
 pm_err_flag_type pm_appsbl_chg_config_vbat_low_threshold(uint32 device_index, pm_smbchg_specific_data_type *chg_param_ptr);
+static void display_thread_initialize();
 
 /*===========================================================================
 
@@ -173,6 +185,7 @@
             vbatt_weak_status = FALSE;
             break; //bootup
          }
+		dprintf(INFO, "Vbatt Level: %u\n", vbat_adc);
    }
    else
    {
@@ -227,14 +240,11 @@
 
       charge_in_progress = true;
 #if DISPLAY_SPLASH_SCREEN
-      if (!display_initialized)
-         target_display_init(panel_name);
-      display_initialized = true;
+	display_thread_initialize();
 #endif
       /* Wait for 500 msecs before looking for vbat */
       udelay(PM_WEAK_BATTERY_CHARGING_DELAY); //500ms
 
-
       //Check if Charging in progress
       err_flag |= pm_smbchg_chgr_get_chgr_sts(device_index, &vbatt_chging_status);
       if ( err_flag != PM_ERR_FLAG__SUCCESS )  { break;}
@@ -584,3 +594,83 @@
 
 	return err_flag;
 }
+
+static bool is_power_key_pressed()
+{
+	int count = 0;
+
+	if (pm8x41_get_pwrkey_is_pressed())
+	{
+		while(count++ < 10 && pm8x41_get_pwrkey_is_pressed())
+			thread_sleep(100);
+
+		dprintf(INFO, "Power Key Pressed\n");
+		return true;
+	}
+
+	return false;
+}
+
+bool pm_app_display_shutdown_in_prgs()
+{
+	return display_shutdown_in_prgs;
+}
+
+static int display_charger_screen()
+{
+	static bool display_init_first_time;
+
+	/* By default first time display the charger screen
+	 * Wait for 5 seconds and turn off the display
+	 * If user presses power key & charging is in progress display the charger screen
+	 */
+	do {
+		if (!display_init_first_time || (is_power_key_pressed() && charge_in_progress))
+		{
+			/* Display charger screen */
+			target_display_init(panel_name);
+			/* wait for 5 seconds to show the charger screen */
+			display_initialized = true;
+			thread_sleep(PM_CHARGE_DISPLAY_TIMEOUT);
+			/* Shutdown the display: If the charging is complete
+			 * continue boot up with display on
+			 */
+			if (charge_in_progress)
+			{
+				display_shutdown_in_prgs = true;
+				target_display_shutdown();
+				display_shutdown_in_prgs = false;
+				display_initialized = false;
+			}
+			display_init_first_time = true;
+		}
+		/* Wait for 100ms before reading the pmic interrupt status
+		 * again, reading the pmic interrupt status in a loop without delays
+		 * reports false key presses */
+		thread_sleep(100);
+	} while (charge_in_progress);
+
+	return 0;
+}
+
+/* Create a thread to monitor power key press events
+ * and turn on/off the display for battery
+ */
+static void display_thread_initialize()
+{
+	thread_t *thr = NULL;
+	static bool is_thread_start;
+
+	if (!is_thread_start)
+	{
+		thr = thread_create("display_charger_screen", &display_charger_screen, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE);
+		if (!thr)
+		{
+			dprintf(CRITICAL, "Error: Could not create display charger screen thread\n");
+			return;
+		}
+		thread_resume(thr);
+
+		is_thread_start = true;
+	}
+}
diff --git a/platform/mdm9640/include/platform/iomap.h b/platform/mdm9640/include/platform/iomap.h
index 5803acd..f92f556 100644
--- a/platform/mdm9640/include/platform/iomap.h
+++ b/platform/mdm9640/include/platform/iomap.h
@@ -180,6 +180,8 @@
 /* SS QMP (Qulacomm Multi Protocol) */
 #define QMP_PHY_BASE                0x78000
 
+#define AHB2_PHY_BASE               0x0007e000
+#define PERIPH_SS_AHB2PHY_TOP_CFG   (AHB2_PHY_BASE + 0x10)
 /* QMP register offset */
 #define PLATFORM_QMP_OFFSET         0x8
 
diff --git a/platform/msm8996/include/platform/iomap.h b/platform/msm8996/include/platform/iomap.h
index 2ae1d17..d3ba81a 100644
--- a/platform/msm8996/include/platform/iomap.h
+++ b/platform/msm8996/include/platform/iomap.h
@@ -78,6 +78,9 @@
 #define QUSB2_PHY_BASE              0x7411000
 #define GCC_QUSB2_PHY_BCR           (CLK_CTL_BASE + 0x00012038)
 
+#define AHB2_PHY_BASE               0x7416000
+#define PERIPH_SS_AHB2PHY_TOP_CFG   (AHB2_PHY_BASE + 0x10)
+
 /* Clocks */
 #define CLK_CTL_BASE                0x300000
 
diff --git a/platform/msm_shared/mipi_dsi.c b/platform/msm_shared/mipi_dsi.c
index 06c4804..0474f37 100644
--- a/platform/msm_shared/mipi_dsi.c
+++ b/platform/msm_shared/mipi_dsi.c
@@ -781,7 +781,7 @@
 		writel(data, ctl_base + COMMAND_MODE_MDP_STREAM1_TOTAL);
 
 		if (dsc->dsi_dsc_config)
-			dsc->dsi_dsc_config(pinfo->mipi.ctl_base, DSI_VIDEO_MODE, dsc);
+			dsc->dsi_dsc_config(pinfo->mipi.ctl_base, DSI_CMD_MODE, dsc);
 	} else {
 
 		writel((img_width * ystride + 1) << 16 | 0x0039,
diff --git a/platform/msm_shared/qusb2_phy.c b/platform/msm_shared/qusb2_phy.c
index fab6e09..871bbcc 100644
--- a/platform/msm_shared/qusb2_phy.c
+++ b/platform/msm_shared/qusb2_phy.c
@@ -25,7 +25,7 @@
  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-
+#include <arch/defines.h>
 #include <platform/iomap.h>
 #include <qusb2_phy.h>
 #include <reg.h>
@@ -55,6 +55,10 @@
 	udelay(10);
 	writel(val & ~BIT(0), GCC_QUSB2_PHY_BCR);
 
+	/* configure the abh2 phy to wait state */
+	writel(0x11, PERIPH_SS_AHB2PHY_TOP_CFG);
+	dmb();
+
 	/* set CLAMP_N_EN and stay with disabled USB PHY */
 	writel(0x23, QUSB2PHY_PORT_POWERDOWN);
 
diff --git a/target/msm8996/init.c b/target/msm8996/init.c
index 418178a..9f49ceb 100644
--- a/target/msm8996/init.c
+++ b/target/msm8996/init.c
@@ -326,6 +326,7 @@
 			case HW_PLATFORM_SURF:
 			case HW_PLATFORM_MTP:
 			case HW_PLATFORM_FLUID:
+			case HW_PLATFORM_QRD:
 				dprintf(SPEW, "Target_cont_splash=1\n");
 				splash_screen = 1;
 				break;
diff --git a/target/msm8996/oem_panel.c b/target/msm8996/oem_panel.c
index 3fbb979..25ef683 100644
--- a/target/msm8996/oem_panel.c
+++ b/target/msm8996/oem_panel.c
@@ -53,6 +53,7 @@
 #include "include/panel_sharp_wqxga_dualdsi_video.h"
 #include "include/panel_jdi_qhd_dualdsi_video.h"
 #include "include/panel_jdi_qhd_dualdsi_cmd.h"
+#include "include/panel_r69007_wqxga_cmd.h"
 
 /*---------------------------------------------------------------------------*/
 /* static panel selection variable                                           */
@@ -65,6 +66,7 @@
 	NT35597_WQXGA_DSC_CMD_PANEL,
 	JDI_QHD_DUALDSI_VIDEO_PANEL,
 	JDI_QHD_DUALDSI_CMD_PANEL,
+	R69007_WQXGA_CMD_PANEL,
 	UNKNOWN_PANEL
 };
 
@@ -80,6 +82,7 @@
 	{"nt35597_wqxga_dsc_cmd", NT35597_WQXGA_DSC_CMD_PANEL},
 	{"jdi_qhd_dualdsi_video", JDI_QHD_DUALDSI_VIDEO_PANEL},
 	{"jdi_qhd_dualdsi_cmd", JDI_QHD_DUALDSI_CMD_PANEL},
+	{"r69007_wqxga_cmd", R69007_WQXGA_CMD_PANEL},
 };
 
 static uint32_t panel_id;
@@ -341,6 +344,36 @@
 			jdi_qhd_dualdsi_thulium_video_timings,
 			MAX_TIMING_CONFIG * sizeof(uint32_t));
 		break;
+	case R69007_WQXGA_CMD_PANEL:
+		pan_type = PANEL_TYPE_DSI;
+		pinfo->lcd_reg_en = 0;
+		panelstruct->paneldata    = &r69007_wqxga_cmd_panel_data;
+		panelstruct->panelres     = &r69007_wqxga_cmd_panel_res;
+		panelstruct->color        = &r69007_wqxga_cmd_color;
+		panelstruct->videopanel   = &r69007_wqxga_cmd_video_panel;
+		panelstruct->commandpanel = &r69007_wqxga_cmd_command_panel;
+		panelstruct->state        = &r69007_wqxga_cmd_state;
+		panelstruct->laneconfig   = &r69007_wqxga_cmd_lane_config;
+		panelstruct->paneltiminginfo
+			= &r69007_wqxga_cmd_timing_info;
+		panelstruct->panelresetseq
+					 = &r69007_wqxga_cmd_reset_seq;
+		panelstruct->backlightinfo = &r69007_wqxga_cmd_backlight;
+
+		pinfo->labibb = &r69007_wqxga_cmd_labibb;
+
+		pinfo->mipi.panel_on_cmds
+			= r69007_wqxga_cmd_on_command;
+		pinfo->mipi.num_of_panel_on_cmds
+			= R69007_WQXGA_CMD_ON_COMMAND;
+		pinfo->mipi.panel_off_cmds
+			= r69007_wqxga_cmd_off_command;
+		pinfo->mipi.num_of_panel_off_cmds
+			= R69007_WQXGA_CMD_OFF_COMMAND;
+		memcpy(phy_db->timing,
+			r69007_wqxga_thulium_cmd_timings,
+			MAX_TIMING_CONFIG * sizeof(uint32_t));
+		break;
 	default:
 	case UNKNOWN_PANEL:
 		pan_type = PANEL_TYPE_UNKNOWN;
@@ -381,6 +414,9 @@
 	case HW_PLATFORM_SURF:
 		panel_id = SHARP_WQXGA_DUALDSI_VIDEO_PANEL;
 		break;
+	case HW_PLATFORM_QRD:
+		panel_id = R69007_WQXGA_CMD_PANEL;
+		break;
 	default:
 		dprintf(CRITICAL, "Display not enabled for %d HW type\n"
 					, hw_id);