Merge "target: msm8994: Enable regulators required for MSM8994 display."
diff --git a/dev/gcdb/display/gcdb_display.c b/dev/gcdb/display/gcdb_display.c
index 5a060c4..16a5d3e 100755
--- a/dev/gcdb/display/gcdb_display.c
+++ b/dev/gcdb/display/gcdb_display.c
@@ -160,6 +160,33 @@
 	return ret;
 }
 
+static bool mdss_dsi_set_panel_node(char *panel_name, char **dsi_id,
+		char **panel_node, char **slave_panel_node, int *panel_mode)
+{
+	if (!strcmp(panel_name, SIM_VIDEO_PANEL)) {
+		*dsi_id = SIM_DSI_ID;
+		*panel_node = SIM_VIDEO_PANEL_NODE;
+		*panel_mode = 0;
+	} else if (!strcmp(panel_name, SIM_DUALDSI_VIDEO_PANEL)) {
+		*dsi_id = SIM_DSI_ID;
+		*panel_node = SIM_DUALDSI_VIDEO_PANEL_NODE;
+		*slave_panel_node = SIM_DUALDSI_VIDEO_SLAVE_PANEL_NODE;
+		*panel_mode = 1;
+	} else if (!strcmp(panel_name, SIM_CMD_PANEL)) {
+		*dsi_id = SIM_DSI_ID;
+		*panel_node = SIM_CMD_PANEL_NODE;
+		*panel_mode = 0;
+	} else if (!strcmp(panel_name, SIM_DUALDSI_CMD_PANEL)) {
+		*dsi_id = SIM_DSI_ID;
+		*panel_node = SIM_DUALDSI_CMD_PANEL_NODE;
+		*slave_panel_node = SIM_DUALDSI_CMD_SLAVE_PANEL_NODE;
+		*panel_mode = 1;
+	} else {
+		return false;
+	}
+	return true;
+}
+
 bool gcdb_display_cmdline_arg(char *panel_name, char *pbuf, uint16_t buf_size)
 {
 	char *dsi_id = NULL;
@@ -168,43 +195,43 @@
 	uint16_t dsi_id_len = 0, panel_node_len = 0, slave_panel_node_len = 0;
 	uint32_t arg_size = 0;
 	bool ret = true;
+	bool rc;
 	char *default_str;
 	int panel_mode = SPLIT_DISPLAY_FLAG | DUAL_PIPE_FLAG | DST_SPLIT_FLAG;
 	int prefix_string_len = strlen(DISPLAY_CMDLINE_PREFIX);
 
-	if (!strcmp(panel_name, SIM_VIDEO_PANEL)) {
-		dsi_id = SIM_DSI_ID;
-		panel_mode = 0;
-		panel_node = SIM_VIDEO_PANEL_NODE;
-	}  else if (!strcmp(panel_name, SIM_DUALDSI_VIDEO_PANEL)) {
-		dsi_id = SIM_DSI_ID;
-		panel_mode = 1;
-		panel_node = SIM_DUALDSI_VIDEO_PANEL_NODE;
-		slave_panel_node = SIM_DUALDSI_VIDEO_SLAVE_PANEL_NODE;
-	} else if (panelstruct.paneldata && target_cont_splash_screen()) {
-		dsi_id = panelstruct.paneldata->panel_controller;
-		panel_node = panelstruct.paneldata->panel_node_id;
-		panel_mode = panelstruct.paneldata->panel_operating_mode &
-							panel_mode;
-		slave_panel_node = panelstruct.paneldata->slave_panel_node_id;
-	} else {
-		if (target_is_edp())
-			default_str = "0:edp:";
-		else
-			default_str = "0:dsi:0:";
+	panel_name += strspn(panel_name, " ");
 
-		arg_size = prefix_string_len + strlen(default_str);
-		if (buf_size < arg_size) {
-			dprintf(CRITICAL, "display command line buffer is small\n");
-			return false;
+	rc = mdss_dsi_set_panel_node(panel_name, &dsi_id, &panel_node,
+			&slave_panel_node, &panel_mode);
+	if (!rc) {
+		if (panelstruct.paneldata && target_cont_splash_screen()) {
+			dsi_id = panelstruct.paneldata->panel_controller;
+			panel_node = panelstruct.paneldata->panel_node_id;
+			panel_mode =
+				panelstruct.paneldata->panel_operating_mode &
+								panel_mode;
+			slave_panel_node =
+				panelstruct.paneldata->slave_panel_node_id;
+		} else {
+			if (target_is_edp())
+				default_str = "0:edp:";
+			else
+				default_str = "0:dsi:0:";
+
+			arg_size = prefix_string_len + strlen(default_str);
+			if (buf_size < arg_size) {
+				dprintf(CRITICAL, "display command line buffer is small\n");
+				return false;
+			}
+
+			strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size);
+			pbuf += prefix_string_len;
+			buf_size -= prefix_string_len;
+
+			strlcpy(pbuf, default_str, buf_size);
+			return true;
 		}
-
-		strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size);
-		pbuf += prefix_string_len;
-		buf_size -= prefix_string_len;
-
-		strlcpy(pbuf, default_str, buf_size);
-		return true;
 	}
 
 	if (dsi_id == NULL || panel_node == NULL) {
diff --git a/dev/gcdb/display/include/display_resource.h b/dev/gcdb/display/include/display_resource.h
index ce95769..ca392ff 100755
--- a/dev/gcdb/display/include/display_resource.h
+++ b/dev/gcdb/display/include/display_resource.h
@@ -45,11 +45,16 @@
 #define NO_PANEL_CONFIG "none"
 #define SIM_VIDEO_PANEL "sim_video_panel"
 #define SIM_DUALDSI_VIDEO_PANEL "sim_dualdsi_video_panel"
+#define SIM_CMD_PANEL "sim_cmd_panel"
+#define SIM_DUALDSI_CMD_PANEL "sim_dualdsi_cmd_panel"
 
 #define SIM_DSI_ID "dsi:0:"
 #define SIM_VIDEO_PANEL_NODE "qcom,mdss_dsi_sim_video"
 #define SIM_DUALDSI_VIDEO_PANEL_NODE "qcom,mdss_dsi_sim_video_0"
 #define SIM_DUALDSI_VIDEO_SLAVE_PANEL_NODE "qcom,mdss_dsi_sim_video_1"
+#define SIM_CMD_PANEL_NODE "qcom,mdss_dsi_sim_cmd"
+#define SIM_DUALDSI_CMD_PANEL_NODE "qcom,mdss_dsi_sim_cmd_0"
+#define SIM_DUALDSI_CMD_SLAVE_PANEL_NODE "qcom,mdss_dsi_sim_cmd_1"
 
 /*---------------------------------------------------------------------------*/
 /* Structure definition                                                      */
diff --git a/dev/gcdb/display/include/panel_jdi_4k_dualdsi_video.h b/dev/gcdb/display/include/panel_jdi_4k_dualdsi_video.h
new file mode 100644
index 0000000..f1831ff
--- /dev/null
+++ b/dev/gcdb/display/include/panel_jdi_4k_dualdsi_video.h
@@ -0,0 +1,165 @@
+/* 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.
+ */
+
+/*---------------------------------------------------------------------------
+ * 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_JDI_4K_DUALDSI_VIDEO_H_
+#define _PANEL_JDI_4K_DUALDSI_VIDEO_H_
+/*---------------------------------------------------------------------------*/
+/* HEADER files                                                              */
+/*---------------------------------------------------------------------------*/
+#include "panel.h"
+
+/*---------------------------------------------------------------------------*/
+/* Panel configuration                                                       */
+/*---------------------------------------------------------------------------*/
+static struct panel_config jdi_4k_dualdsi_video_panel_data = {
+	"qcom,dsi_jdi_4k_video_0", "dsi:0:", "qcom,mdss-dsi-panel",
+	10, 0, "DISPLAY_1", 0, 0, 60, 0, 0, 1, 0, 0, 0, 0, 0, 11, 0, 0,
+	"qcom,dsi_jdi_4k_video_1",
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel resolution                                                          */
+/*---------------------------------------------------------------------------*/
+static struct panel_resolution jdi_4k_dualdsi_video_panel_res = {
+	3840, 2160, 100, 80, 12, 0, 16, 16, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel color information                                                   */
+/*---------------------------------------------------------------------------*/
+static struct color_info jdi_4k_dualdsi_video_color = {
+	24, 0, 0xff, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel on/off command information                                          */
+/*---------------------------------------------------------------------------*/
+static char jdi_4k_dualdsi_video_on_cmd0[] = {
+	0x51, 0xff, 0x15, 0x80,
+};
+
+static char jdi_4k_dualdsi_video_on_cmd1[] = {
+	0x53, 0x24, 0x15, 0x80,
+};
+
+static char jdi_4k_dualdsi_video_on_cmd2[] = {
+	0x11, 0x00, 0x05, 0x80
+};
+
+static char jdi_4k_dualdsi_video_on_cmd3[] = {
+	0x29, 0x00, 0x05, 0x80
+};
+
+static struct mipi_dsi_cmd jdi_4k_dualdsi_video_on_command[] = {
+	{0x4, jdi_4k_dualdsi_video_on_cmd0, 0x78, 1},
+	{0x4, jdi_4k_dualdsi_video_on_cmd1, 0x78, 1},
+	{0x4, jdi_4k_dualdsi_video_on_cmd2, 0x78, 1},
+	{0x4, jdi_4k_dualdsi_video_on_cmd3, 0x78, 1}
+};
+
+#define JDI_4K_DUALDSI_VIDEO_ON_COMMAND 4
+
+
+static char jdi_4k_dualdsi_videooff_cmd0[] = {
+	0x28, 0x00, 0x05, 0x80
+};
+
+static char jdi_4k_dualdsi_videooff_cmd1[] = {
+	0x10, 0x00, 0x05, 0x80
+};
+
+static struct mipi_dsi_cmd jdi_4k_dualdsi_video_off_command[] = {
+	{0x4, jdi_4k_dualdsi_videooff_cmd0, 0x32},
+	{0x4, jdi_4k_dualdsi_videooff_cmd1, 0x78}
+};
+
+#define JDI_4K_DUALDSI_VIDEO_OFF_COMMAND 2
+
+
+static struct command_state jdi_4k_dualdsi_video_state = {
+	0, 1
+};
+
+/*---------------------------------------------------------------------------*/
+/* Command mode panel information                                            */
+/*---------------------------------------------------------------------------*/
+static struct commandpanel_info jdi_4k_dualdsi_video_command_panel = {
+	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/*---------------------------------------------------------------------------*/
+/* Video mode panel information                                              */
+/*---------------------------------------------------------------------------*/
+static struct videopanel_info jdi_4k_dualdsi_video_video_panel = {
+	0, 0, 0, 0, 1, 1, 1, 0, 0x9
+};
+
+/*---------------------------------------------------------------------------*/
+/* Lane configuration                                                        */
+/*---------------------------------------------------------------------------*/
+static struct lane_configuration jdi_4k_dualdsi_video_lane_config = {
+	4, 0, 1, 1, 1, 1
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel timing                                                              */
+/*---------------------------------------------------------------------------*/
+static const uint32_t jdi_4k_dualdsi_video_timings[] = {
+	0x3e, 0x38, 0x26, 0x00, 0x68, 0x6e, 0x2a, 0x3c, 0x2c, 0x03, 0x04, 0x00
+};
+
+static struct panel_timing jdi_4k_dualdsi_video_timing_info = {
+	0x0, 0x04, 0x03, 0x27
+};
+
+/*---------------------------------------------------------------------------*/
+/* Panel reset sequence                                                      */
+/*---------------------------------------------------------------------------*/
+static struct panel_reset_sequence jdi_4k_dualdsi_video_reset_seq = {
+	{1, 0, 1, }, {200, 200, 200, }, 2
+};
+
+/*---------------------------------------------------------------------------*/
+/* Backlight setting                                                         */
+/*---------------------------------------------------------------------------*/
+static struct backlight jdi_4k_dualdsi_video_backlight = {
+	0, 1, 4095, 100, 1, "PMIC_8941"
+};
+
+static struct fb_compression jdi_4k_dualdsi_video_fbc = {
+	1, 2, 1, 1, 2, 1, 1, 1, 1200, 5, 91, 0x200, 192, 4, 3
+};
+
+#endif /*_PANEL_JDI_4K_DUALDSI_VIDEO_H_*/
diff --git a/platform/msm8994/acpuclock.c b/platform/msm8994/acpuclock.c
index 46129d8..5e2d5a6 100644
--- a/platform/msm8994/acpuclock.c
+++ b/platform/msm8994/acpuclock.c
@@ -348,20 +348,12 @@
 		dprintf(CRITICAL, "failed to set mdp_clk ret = %d\n", ret);
 		ASSERT(0);
 	}
-
-	ret = clk_get_set_enable("mdss_mdp_lut_clk", 0, 1);
-	if(ret)
-	{
-		dprintf(CRITICAL, "failed to set lut_mdp clk ret = %d\n", ret);
-		ASSERT(0);
-	}
 }
 
 void mdp_clock_disable()
 {
 	clk_disable(clk_get("mdss_vsync_clk"));
 	clk_disable(clk_get("mdss_mdp_clk"));
-	clk_disable(clk_get("mdss_mdp_lut_clk"));
 	clk_disable(clk_get("mdss_mdp_clk_src"));
 	clk_disable(clk_get("mdp_ahb_clk"));
 
diff --git a/platform/msm_shared/display.c b/platform/msm_shared/display.c
index 9681de0..aac82c0 100644
--- a/platform/msm_shared/display.c
+++ b/platform/msm_shared/display.c
@@ -172,6 +172,11 @@
 		ret = mdp_dsi_video_on(pinfo);
 		if (ret)
 			goto msm_display_on_out;
+
+		ret = mdss_dsi_post_on(panel);
+		if (ret)
+			goto msm_display_on_out;
+
 		ret = mipi_dsi_on();
 		if (ret)
 			goto msm_display_on_out;
@@ -188,6 +193,11 @@
 			if (ret)
 				goto msm_display_on_out;
 		}
+
+		ret = mdss_dsi_post_on(panel);
+		if (ret)
+			goto msm_display_on_out;
+
 		break;
 	case LCDC_PANEL:
 		dprintf(INFO, "Turn on LCDC PANEL.\n");
diff --git a/platform/msm_shared/include/mipi_dsi.h b/platform/msm_shared/include/mipi_dsi.h
index cabafbf..84d5b44 100644
--- a/platform/msm_shared/include/mipi_dsi.h
+++ b/platform/msm_shared/include/mipi_dsi.h
@@ -79,6 +79,10 @@
 
 #define DSI_LANE_CTRL                         REG_DSI(0x0A8)
 
+#define DSI_VIDEO_MODE_DONE_MASK              BIT(17)
+#define DSI_VIDEO_MODE_DONE_AK                BIT(16)
+#define DSI_VIDEO_MODE_DONE_STAT              BIT(16)
+
 /**********************************************************
   DSI register configuration options
  **********************************************************/
@@ -200,6 +204,7 @@
 	int size;
 	char *payload;
 	int wait;
+	uint8_t cmds_post_tg;
 };
 
 struct mipi_dsi_panel_config {
@@ -214,6 +219,7 @@
 	struct mipi_dsi_cmd *panel_cmds;
 	int num_of_panel_cmds;
 	uint32_t signature;
+	char cmds_post_tg;
 };
 
 static char read_id_a1h_cmd[4] = { 0xA1, 0x00, 0x06, 0xA0 };	/* DTYPE_DCS_READ */
diff --git a/platform/msm_shared/include/msm_panel.h b/platform/msm_shared/include/msm_panel.h
index 651cc53..6944f09 100755
--- a/platform/msm_shared/include/msm_panel.h
+++ b/platform/msm_shared/include/msm_panel.h
@@ -154,6 +154,7 @@
 };
 
 struct mipi_panel_info {
+	char cmds_post_tg;	/* send on commands after tg on */
 	char mode;		/* video/cmd */
 	char interleave_mode;
 	int eof_bllp_power;
diff --git a/platform/msm_shared/mipi_dsi.c b/platform/msm_shared/mipi_dsi.c
index 2a29a7f..fef1a0f 100644
--- a/platform/msm_shared/mipi_dsi.c
+++ b/platform/msm_shared/mipi_dsi.c
@@ -158,6 +158,35 @@
 	return status;
 }
 
+int mdss_dsi_wait4_video_done()
+{
+	unsigned long read;
+	unsigned long count = 0;
+	int status = 0;
+
+	read = readl(DSI_INT_CTRL);
+	/* Enable VIDEO MODE DONE MASK and clear the interrupt */
+	read = read | DSI_VIDEO_MODE_DONE_MASK | DSI_VIDEO_MODE_DONE_AK;
+	writel(read, DSI_INT_CTRL);
+	dsb();
+	read = readl(DSI_INT_CTRL) & DSI_VIDEO_MODE_DONE_STAT;
+	while (!read) {
+		read = readl(DSI_INT_CTRL) & DSI_VIDEO_MODE_DONE_STAT;
+		count++;
+		if (count > 0xffff) {
+			status = FAIL;
+			dprintf(CRITICAL,
+				"Panel CMD: Did not recieve video mode done interrupt\n");
+			return status;
+		}
+	}
+
+	writel((readl(DSI_INT_CTRL) | 0x01000001), DSI_INT_CTRL);
+	dprintf(SPEW, "Panel wait_4_video_done: Recieved video mode done ack\n");
+	return status;
+
+}
+
 int mdss_dual_dsi_cmds_tx(struct mipi_dsi_cmd *cmds, int count)
 {
 	int ret = 0;
@@ -176,6 +205,16 @@
 
 	cm = cmds;
 	for (i = 0; i < count; i++) {
+		if (cmds->cmds_post_tg) {
+			/* Wait for VIDEO_MODE_DONE */
+			ret = mdss_dsi_wait4_video_done();
+			if (ret)
+				goto wait4video_error;
+
+			/* Skip BLLP 4ms */
+			mdelay(4);
+		}
+
 		memcpy((void *)off, (cm->payload), cm->size);
 		writel(off, MIPI_DSI0_BASE + DMA_CMD_OFFSET);
 		writel(cm->size, MIPI_DSI0_BASE + DMA_CMD_LENGTH);	// reg 0x48 for this build
@@ -190,6 +229,7 @@
 		cm++;
 	}
 #endif
+wait4video_error:
 	return ret;
 }
 
@@ -262,6 +302,15 @@
 
 	cm = cmds;
 	for (i = 0; i < count; i++) {
+		if (cmds->cmds_post_tg) {
+			/* Wait for VIDEO_MODE_DONE */
+			ret = mdss_dsi_wait4_video_done();
+			if (ret)
+				goto mipi_cmds_error;
+
+			/* Skip BLLP 4ms */
+			mdelay(4);
+		}
 		memcpy((void *)off, (cm->payload), cm->size);
 		writel(off, DSI_DMA_CMD_OFFSET);
 		writel(cm->size, DSI_DMA_CMD_LENGTH);	// reg 0x48 for this build
@@ -274,6 +323,7 @@
 			udelay(80);
 		cm++;
 	}
+mipi_cmds_error:
 	return ret;
 }
 
@@ -365,6 +415,7 @@
 	uint8_t lane_swap = 0;
 	uint32_t timing_ctl = 0;
 	uint32_t lane_swap_dsi1 = 0;
+	uint32_t ctrl_mode = 0x105;	//Default is command mode to send cmds.
 
 #if (DISPLAY_TYPE_MDSS == 1)
 	switch (pinfo->num_of_lanes) {
@@ -387,6 +438,14 @@
 	lane_swap = pinfo->lane_swap;
 	timing_ctl = ((pinfo->t_clk_post << 8) | pinfo->t_clk_pre);
 
+	if (pinfo->cmds_post_tg) {
+		/*
+		 * Need to send pixel data before sending the ON commands
+		 * so need to configure controller to VIDEO MODE.
+		 */
+		ctrl_mode = 0x103;
+	}
+
 	if (dual_dsi) {
 		writel(0x0001, MIPI_DSI1_BASE + SOFT_RESET);
 		writel(0x0000, MIPI_DSI1_BASE + SOFT_RESET);
@@ -395,7 +454,7 @@
 		writel(DMA_STREAM1 << 8 | 0x04, MIPI_DSI1_BASE + TRIG_CTRL);	// reg 0x80 dma trigger: sw
 		// trigger 0x4; dma stream1
 
-		writel(0 << 30 | DLNx_EN << 4 | 0x105, MIPI_DSI1_BASE + CTRL);	// reg 0x00 for this
+		writel(0 << 30 | DLNx_EN << 4 | ctrl_mode, MIPI_DSI1_BASE + CTRL);	// reg 0x00 for this
 		// build
 		writel(broadcast << 31 | EMBED_MODE1 << 28 | POWER_MODE2 << 26
 				| PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1,
@@ -416,7 +475,7 @@
 	writel(DMA_STREAM1 << 8 | 0x04, MIPI_DSI0_BASE + TRIG_CTRL);	// reg 0x80 dma trigger: sw
 	// trigger 0x4; dma stream1
 
-	writel(0 << 30 | DLNx_EN << 4 | 0x105, MIPI_DSI0_BASE + CTRL);	// reg 0x00 for this
+	writel(0 << 30 | DLNx_EN << 4 | ctrl_mode, MIPI_DSI0_BASE + CTRL);	// reg 0x00 for this
 	// build
 	writel(broadcast << 31 | EMBED_MODE1 << 28 | POWER_MODE2 << 26
 	       | PACK_TYPE1 << 24 | VC1 << 22 | DT1 << 16 | WC1,
@@ -433,17 +492,27 @@
 		broadcast)
 {
 	int status = 0;
+	uint32_t ctrl_mode = 0;
 
 #if (DISPLAY_TYPE_MDSS == 1)
 	if (pinfo->panel_cmds) {
 
+		ctrl_mode = readl(MIPI_DSI0_BASE + CTRL);
 		if (broadcast) {
+			/* Enable command mode before sending the commands. */
+			writel(ctrl_mode | 0x04, MIPI_DSI0_BASE + CTRL);
+			writel(ctrl_mode | 0x04, MIPI_DSI1_BASE + CTRL);
 			status = mdss_dual_dsi_cmds_tx(pinfo->panel_cmds,
 					pinfo->num_of_panel_cmds);
+			writel(ctrl_mode, MIPI_DSI0_BASE + CTRL);
+			writel(ctrl_mode, MIPI_DSI1_BASE + CTRL);
 
 		} else {
+			/* Enable command mode before sending the commands. */
+			writel(ctrl_mode | 0x04, MIPI_DSI0_BASE + CTRL);
 			status = mipi_dsi_cmds_tx(pinfo->panel_cmds,
 					pinfo->num_of_panel_cmds);
+			writel(ctrl_mode, MIPI_DSI0_BASE + CTRL);
 			if (!status && target_panel_auto_detect_enabled())
 				status =
 					mdss_dsi_read_panel_signature(pinfo->signature);
@@ -681,6 +750,7 @@
 	mipi_pinfo.t_clk_pre = pinfo->mipi.t_clk_pre;
 	mipi_pinfo.t_clk_post = pinfo->mipi.t_clk_post;
 	mipi_pinfo.signature = pinfo->mipi.signature;
+	mipi_pinfo.cmds_post_tg = pinfo->mipi.cmds_post_tg;
 
 	mdss_dsi_phy_init(&mipi_pinfo, MIPI_DSI0_BASE, DSI0_PHY_BASE);
 	if (pinfo->mipi.dual_dsi)
@@ -703,10 +773,12 @@
 		}
 	}
 
-	ret = mdss_dsi_panel_initialize(&mipi_pinfo, pinfo->mipi.broadcast);
-	if (ret) {
-		dprintf(CRITICAL, "dsi panel init error\n");
-		goto error;
+	if (!mipi_pinfo.cmds_post_tg) {
+		ret = mdss_dsi_panel_initialize(&mipi_pinfo, pinfo->mipi.broadcast);
+		if (ret) {
+			dprintf(CRITICAL, "dsi panel init error\n");
+			goto error;
+		}
 	}
 
 	if (pinfo->rotate && panel->rotate)
@@ -717,6 +789,25 @@
 	return ret;
 }
 
+int mdss_dsi_post_on(struct msm_fb_panel_data *panel)
+{
+	int ret = 0;
+	struct msm_panel_info *pinfo = &(panel->panel_info);
+	struct mipi_dsi_panel_config mipi_pinfo;
+
+	if (pinfo->mipi.cmds_post_tg) {
+		mipi_pinfo.panel_cmds = pinfo->mipi.panel_cmds;
+		mipi_pinfo.num_of_panel_cmds = pinfo->mipi.num_of_panel_cmds;
+		mipi_pinfo.signature = pinfo->mipi.signature;
+
+		ret = mdss_dsi_panel_initialize(&mipi_pinfo, pinfo->mipi.broadcast);
+		if (ret) {
+			dprintf(CRITICAL, "dsi panel init error\n");
+		}
+	}
+	return ret;
+}
+
 int mdss_dsi_cmd_mode_config(uint16_t disp_width,
 	uint16_t disp_height,
 	uint16_t img_width,
diff --git a/target/apq8084/target_display.c b/target/apq8084/target_display.c
index 334cb32..b077038 100755
--- a/target/apq8084/target_display.c
+++ b/target/apq8084/target_display.c
@@ -509,11 +509,13 @@
 
 	panel_name += strspn(panel_name, " ");
 
-	if ((!strcmp(panel_name, NO_PANEL_CONFIG))
-			|| (!strcmp(panel_name, SIM_VIDEO_PANEL))
-			|| (!strcmp(panel_name, SIM_DUALDSI_VIDEO_PANEL))) {
+	if (!strcmp(panel_name, NO_PANEL_CONFIG)
+		|| !strcmp(panel_name, SIM_VIDEO_PANEL)
+		|| !strcmp(panel_name, SIM_DUALDSI_VIDEO_PANEL)
+		|| !strcmp(panel_name, SIM_CMD_PANEL)
+		|| !strcmp(panel_name, SIM_DUALDSI_CMD_PANEL)) {
 		dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n",
-								panel_name);
+			panel_name);
 		return;
 	} else if (!strcmp(panel_name, HDMI_PANEL_NAME)) {
 		dprintf(INFO, "%s: HDMI is primary\n", __func__);
diff --git a/target/msm8226/target_display.c b/target/msm8226/target_display.c
index d385340..ca4623c 100755
--- a/target/msm8226/target_display.c
+++ b/target/msm8226/target_display.c
@@ -398,10 +398,11 @@
         uint32_t ret = 0;
 	uint32_t fb_addr = MIPI_FB_ADDR;
 
-	if ((!strcmp(panel_name, NO_PANEL_CONFIG))
-			|| (!strcmp(panel_name, SIM_VIDEO_PANEL))) {
+	if (!strcmp(panel_name, NO_PANEL_CONFIG)
+		|| !strcmp(panel_name, SIM_VIDEO_PANEL)
+		|| !strcmp(panel_name, SIM_CMD_PANEL)) {
 		dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n",
-								panel_name);
+			panel_name);
 		return;
 	}
 
diff --git a/target/msm8916/target_display.c b/target/msm8916/target_display.c
index b47f1e0..ea69e86 100755
--- a/target/msm8916/target_display.c
+++ b/target/msm8916/target_display.c
@@ -376,10 +376,12 @@
 	uint32_t ret = 0;
 
 	panel_name += strspn(panel_name, " ");
-	if ((!strcmp(panel_name, NO_PANEL_CONFIG))
-			|| (!strcmp(panel_name, SIM_VIDEO_PANEL))) {
+
+	if (!strcmp(panel_name, NO_PANEL_CONFIG)
+		|| !strcmp(panel_name, SIM_VIDEO_PANEL)
+		|| !strcmp(panel_name, SIM_CMD_PANEL)) {
 		dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n",
-								panel_name);
+			panel_name);
 		return;
 	}
 
diff --git a/target/msm8974/target_display.c b/target/msm8974/target_display.c
index 6e8a9f4..fbfaeb8 100755
--- a/target/msm8974/target_display.c
+++ b/target/msm8974/target_display.c
@@ -399,11 +399,13 @@
 
 	panel_name += strspn(panel_name, " ");
 
-	if ((!strcmp(panel_name, NO_PANEL_CONFIG))
-			|| (!strcmp(panel_name, SIM_VIDEO_PANEL))
-			|| (!strcmp(panel_name, SIM_DUALDSI_VIDEO_PANEL))) {
-		dprintf(INFO, "Selected panel: %s\nSkip panel configuration",
-								panel_name);
+	if (!strcmp(panel_name, NO_PANEL_CONFIG)
+		|| !strcmp(panel_name, SIM_VIDEO_PANEL)
+		|| !strcmp(panel_name, SIM_DUALDSI_VIDEO_PANEL)
+		|| !strcmp(panel_name, SIM_CMD_PANEL)
+		|| !strcmp(panel_name, SIM_DUALDSI_CMD_PANEL)) {
+		dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n",
+			panel_name);
 		return;
 	} else if (!strcmp(panel_name, HDMI_PANEL_NAME)) {
 		dprintf(INFO, "%s: HDMI is primary\n", __func__);
diff --git a/target/msm8994/target_display.c b/target/msm8994/target_display.c
index 2463515..9f3d611 100644
--- a/target/msm8994/target_display.c
+++ b/target/msm8994/target_display.c
@@ -375,11 +375,15 @@
 
 void target_display_init(const char *panel_name)
 {
-	if ((!strcmp(panel_name, NO_PANEL_CONFIG))
-			|| (!strcmp(panel_name, SIM_VIDEO_PANEL))
-			|| (!strcmp(panel_name, SIM_DUALDSI_VIDEO_PANEL))) {
+	panel_name += strspn(panel_name, " ");
+
+	if (!strcmp(panel_name, NO_PANEL_CONFIG)
+		|| !strcmp(panel_name, SIM_VIDEO_PANEL)
+		|| !strcmp(panel_name, SIM_DUALDSI_VIDEO_PANEL)
+		|| !strcmp(panel_name, SIM_CMD_PANEL)
+		|| !strcmp(panel_name, SIM_DUALDSI_CMD_PANEL)) {
 		dprintf(INFO, "Selected panel: %s\nSkip panel configuration\n",
-				panel_name);
+			panel_name);
 		return;
 	}
 	if (gcdb_display_init(panel_name, MDP_REV_50, MIPI_FB_ADDR)) {