platform: msm_shared: add MDP support for HDMI

Setup pipe, mixer, DSPP and TG for HDMI interface. Currently
only one interface can be active in LK. If HDMI is selected as
primary, LK will boot with HDMI as only interface.

Change-Id: I37c08ccf911d7a1daa065436c617c2c6c7101a4d
diff --git a/platform/msm_shared/include/mdp5.h b/platform/msm_shared/include/mdp5.h
index ac389ee..8ade9c8 100644
--- a/platform/msm_shared/include/mdp5.h
+++ b/platform/msm_shared/include/mdp5.h
@@ -97,6 +97,7 @@
 
 #define MDP_INTF_0_TIMING_ENGINE_EN             REG_MDP(0x12500)
 #define MDP_INTF_1_TIMING_ENGINE_EN             REG_MDP(0x12700)
+#define MDP_INTF_3_TIMING_ENGINE_EN             REG_MDP(0x12B00)
 
 #define MDP_CTL_0_BASE                          REG_MDP(0x600)
 #define MDP_CTL_1_BASE                          REG_MDP(0x700)
@@ -117,6 +118,7 @@
 #define MDP_INTF_0_BASE                         REG_MDP(0x12500)
 #define MDP_INTF_1_BASE                         REG_MDP(0x12700)
 #define MDP_INTF_2_BASE                         REG_MDP(0x12900)
+#define MDP_INTF_3_BASE                         REG_MDP(0x12B00)
 
 #define MDP_HSYNC_CTL                           0x08
 #define MDP_VSYNC_PERIOD_F0                     0x0C
diff --git a/platform/msm_shared/mdp3.c b/platform/msm_shared/mdp3.c
index 2cde8ea..3ce6b03 100644
--- a/platform/msm_shared/mdp3.c
+++ b/platform/msm_shared/mdp3.c
@@ -211,3 +211,18 @@
 {
 	return NO_ERROR;
 }
+
+int mdp_hdmi_config(struct msm_panel_info *pinfo, struct fbcon_config *fb)
+{
+	return NO_ERROR;
+}
+
+int mdp_hdmi_on(void)
+{
+	return NO_ERROR;
+}
+
+int mdp_hdmi_off(void)
+{
+	return NO_ERROR;
+}
diff --git a/platform/msm_shared/mdp4.c b/platform/msm_shared/mdp4.c
index 7b7c0cf..5bc4a84 100644
--- a/platform/msm_shared/mdp4.c
+++ b/platform/msm_shared/mdp4.c
@@ -423,3 +423,18 @@
 {
 	return NO_ERROR;
 }
+
+int mdp_hdmi_config(struct msm_panel_info *pinfo, struct fbcon_config *fb)
+{
+	return NO_ERROR;
+}
+
+int mdp_hdmi_on(void)
+{
+	return NO_ERROR;
+}
+
+int mdp_hdmi_off(void)
+{
+	return NO_ERROR;
+}
diff --git a/platform/msm_shared/mdp5.c b/platform/msm_shared/mdp5.c
index 6e8fea4..3560102 100644
--- a/platform/msm_shared/mdp5.c
+++ b/platform/msm_shared/mdp5.c
@@ -602,6 +602,41 @@
 	return 0;
 }
 
+int mdp_hdmi_config(struct msm_panel_info *pinfo, struct fbcon_config *fb)
+{
+	int ret = NO_ERROR;
+	struct lcdc_panel_info *lcdc = NULL;
+	uint32_t left_pipe, right_pipe;
+
+	mdss_intf_tg_setup(pinfo, MDP_INTF_3_BASE);
+	mdp_select_pipe_type(pinfo, &left_pipe, &right_pipe);
+
+	mdp_clk_gating_ctrl();
+	mdss_vbif_setup();
+
+	mdss_smp_setup(pinfo, left_pipe, right_pipe);
+
+	mdss_qos_remapper_setup();
+
+	mdss_source_pipe_config(fb, pinfo, left_pipe);
+	if (pinfo->lcdc.dual_pipe)
+		mdss_source_pipe_config(fb, pinfo, right_pipe);
+
+	mdss_layer_mixer_setup(fb, pinfo);
+
+	if (pinfo->lcdc.dual_pipe)
+		writel(0x181F40, MDP_CTL_0_BASE + CTL_TOP);
+	else
+		writel(0x40, MDP_CTL_0_BASE + CTL_TOP);
+
+	writel(BIT(24) | BIT(25), MDP_DISP_INTF_SEL);
+	writel(0x1111, MDP_VIDEO_INTF_UNDERFLOW_CTL);
+	writel(0x01, MDP_UPPER_NEW_ROI_PRIOR_RO_START);
+	writel(0x01, MDP_LOWER_NEW_ROI_PRIOR_TO_START);
+
+	return 0;
+}
+
 int mdp_dsi_cmd_config(struct msm_panel_info *pinfo,
                 struct fbcon_config *fb)
 {
@@ -730,6 +765,18 @@
 	return NO_ERROR;
 }
 
+int mdp_hdmi_on(struct msm_panel_info *pinfo)
+{
+	uint32_t ctl0_reg_val, ctl1_reg_val;
+
+	mdss_mdp_set_flush(pinfo, &ctl0_reg_val, &ctl1_reg_val);
+	writel(ctl0_reg_val, MDP_CTL_0_BASE + CTL_FLUSH);
+
+	writel(0x01, MDP_INTF_3_TIMING_ENGINE_EN + mdss_mdp_intf_offset());
+
+	return NO_ERROR;
+}
+
 int mdp_edp_off(void)
 {
 	if (!target_cont_splash_screen()) {