Merge "msm8226: Add Crypto engine support."
diff --git a/platform/msm8974/include/platform/iomap.h b/platform/msm8974/include/platform/iomap.h
index 4d7433e..5e91af2 100644
--- a/platform/msm8974/include/platform/iomap.h
+++ b/platform/msm8974/include/platform/iomap.h
@@ -90,6 +90,7 @@
 
 #define MSM_CE2_BAM_BASE            0xFD444000
 #define MSM_CE2_BASE                0xFD45A000
+#define USB2_PHY_SEL                0xFD4AB000
 
 #define TLMM_BASE_ADDR              0xFD510000
 #define GPIO_CONFIG_ADDR(x)         (TLMM_BASE_ADDR + 0x1000 + (x)*0x10)
diff --git a/platform/msm_shared/display.c b/platform/msm_shared/display.c
index 0bb779e..bd06767 100644
--- a/platform/msm_shared/display.c
+++ b/platform/msm_shared/display.c
@@ -288,6 +288,11 @@
 		return ERR_INVALID_ARGS;
 	};
 
+	if (target_cont_splash_screen()) {
+		dprintf(INFO, "Continuous splash enabled, keeping panel alive.\n");
+		return NO_ERROR;
+	}
+
 	if (pinfo->off)
 		ret = pinfo->off();
 
diff --git a/platform/msm_shared/include/mdp5.h b/platform/msm_shared/include/mdp5.h
index 2091ed1..497b4d0 100644
--- a/platform/msm_shared/include/mdp5.h
+++ b/platform/msm_shared/include/mdp5.h
@@ -100,6 +100,12 @@
 
 #define VBIF_VBIF_DDR_FORCE_CLK_ON              REG_MDP(0x24004)
 #define VBIF_VBIF_DDR_OUT_MAX_BURST             REG_MDP(0x240D8)
+#define VBIF_VBIF_DDR_ARB_CTRL                  REG_MDP(0x240F0)
+#define VBIF_VBIF_DDR_RND_RBN_QOS_ARB           REG_MDP(0x24124)
+#define VBIF_VBIF_DDR_AXI_AMEMTYPE_CONF0        REG_MDP(0x24160)
+#define VBIF_VBIF_DDR_AXI_AMEMTYPE_CONF1        REG_MDP(0x24164)
+#define VBIF_VBIF_DDR_OUT_AOOO_AXI_EN           REG_MDP(0x24178)
+#define VBIF_VBIF_DDR_OUT_AX_AOOO               REG_MDP(0x2417C)
 
 void mdp_set_revision(int rev);
 int mdp_get_revision();
diff --git a/platform/msm_shared/mdp5.c b/platform/msm_shared/mdp5.c
index 54fc33b..468969c 100644
--- a/platform/msm_shared/mdp5.c
+++ b/platform/msm_shared/mdp5.c
@@ -111,19 +111,22 @@
 	/* write active region size*/
 	mdp_rgb_size = (fb->height << 16) + fb->width;
 
-	/* Ping-Pong done Tear Check Read/Write  */
-	/* Underrun(Interface 0/1/2/3) VSYNC Interrupt Enable  */
-	writel(0xFF777713, MDP_INTR_EN);
-
 	access_secure = restore_secure_cfg(SECURE_DEVICE_MDSS);
 
 	mdp_clk_gating_ctrl();
 
-	if (!access_secure) {
+	/* Ignore TZ return value till it's fixed */
+	if (!access_secure || 1) {
 		/* Force VBIF Clocks on  */
 		writel(0x1, VBIF_VBIF_DDR_FORCE_CLK_ON);
 		/* Configure DDR burst length */
 		writel(0x00000707, VBIF_VBIF_DDR_OUT_MAX_BURST);
+		writel(0x00000030, VBIF_VBIF_DDR_ARB_CTRL );
+		writel(0x00000001, VBIF_VBIF_DDR_RND_RBN_QOS_ARB);
+		writel(0x00000FFF, VBIF_VBIF_DDR_OUT_AOOO_AXI_EN);
+		writel(0x0FFF0FFF, VBIF_VBIF_DDR_OUT_AX_AOOO);
+		writel(0x22222222, VBIF_VBIF_DDR_AXI_AMEMTYPE_CONF0);
+		writel(0x00002222, VBIF_VBIF_DDR_AXI_AMEMTYPE_CONF1);
 	}
 
 	/* Allocate SMP blocks */
@@ -211,9 +214,10 @@
 		/* Ping-Pong done Tear Check Read/Write  */
 		/* Underrun(Interface 0/1/2/3) VSYNC Interrupt Enable  */
 		writel(0xFF777713, MDP_INTR_CLEAR);
-		writel(0x00000000, MDP_INTR_EN);
 	}
 
+	writel(0x00000000, MDP_INTR_EN);
+
 	return NO_ERROR;
 }
 
diff --git a/platform/msm_shared/mipi_dsi.c b/platform/msm_shared/mipi_dsi.c
index 7a1c4eb..64fe03d 100644
--- a/platform/msm_shared/mipi_dsi.c
+++ b/platform/msm_shared/mipi_dsi.c
@@ -862,9 +862,6 @@
 
 int mipi_dsi_off()
 {
-	writel(0x01010101, DSI_INT_CTRL);
-	writel(0x13FF3BFF, DSI_ERR_INT_MASK0);
-
 	if(!target_cont_splash_screen())
 	{
 		writel(0, DSI_CLK_CTRL);
@@ -874,9 +871,12 @@
 		mdelay(10);
 		writel(0x0001, DSI_SOFT_RESET);
 		writel(0x0000, DSI_SOFT_RESET);
+		writel(0x1115501, DSI_INT_CTRL);
 		writel(0, DSI_CTRL);
 	}
 
+	writel(0x1115501, DSI_INT_CTRL);
+
 	return NO_ERROR;
 }
 
diff --git a/platform/msm_shared/scm.c b/platform/msm_shared/scm.c
index dae8723..c46b1eb 100644
--- a/platform/msm_shared/scm.c
+++ b/platform/msm_shared/scm.c
@@ -187,7 +187,7 @@
 	int ret, scm_ret = 0;
 	tz_secure_cfg secure_cfg;
 
-	secure_cfg.id    = 1;
+	secure_cfg.id    = id;
 	secure_cfg.spare = 0;
 
 	ret = scm_call(SVC_MEMORY_PROTECTION, IOMMU_SECURE_CFG, &secure_cfg, sizeof(secure_cfg),
diff --git a/target/msm8974/include/target/display.h b/target/msm8974/include/target/display.h
index 0687d24..cc04e0b 100644
--- a/target/msm8974/include/target/display.h
+++ b/target/msm8974/include/target/display.h
@@ -29,7 +29,7 @@
 #ifndef _TARGET_COPPER_DISPLAY_H
 #define _TARGET_COPPER_DISPLAY_H
 
-#define MIPI_FB_ADDR  0x08400000
+#define MIPI_FB_ADDR  0x0D200000
 
 #define MIPI_HSYNC_PULSE_WIDTH       12
 #define MIPI_HSYNC_BACK_PORCH_DCLK   32
diff --git a/target/msm8974/init.c b/target/msm8974/init.c
index cf76dcd..2bbc017 100644
--- a/target/msm8974/init.c
+++ b/target/msm8974/init.c
@@ -40,6 +40,8 @@
 #include <dev/keys.h>
 #include <pm8x41.h>
 #include <crypto5_wrapper.h>
+#include <hsusb.h>
+#include <clock.h>
 
 extern  bool target_use_signed_kernel(void);
 
@@ -295,15 +297,50 @@
 	dprintf(CRITICAL, "Rebooting failed\n");
 }
 
+/* Do target specific usb initialization */
+void target_usb_init(void)
+{
+	/* Enable secondary USB PHY on DragonBoard8074 */
+	if (board_hardware_id() == HW_PLATFORM_DRAGON) {
+		/* Route ChipIDea to use secondary USB HS port2 */
+		writel_relaxed(1, USB2_PHY_SEL);
+
+		/* Enable access to secondary PHY by clamping the low
+		* voltage interface between DVDD of the PHY and Vddcx
+		* (set bit16 (USB2_PHY_HS2_DIG_CLAMP_N_2) = 1) */
+		writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_SEC_CTRL)
+				| 0x00010000, USB_OTG_HS_PHY_SEC_CTRL);
+
+		/* Perform power-on-reset of the PHY.
+		*  Delay values are arbitrary */
+		writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_CTRL)|1,
+				USB_OTG_HS_PHY_CTRL);
+		thread_sleep(10);
+		writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_CTRL) & 0xFFFFFFFE,
+				USB_OTG_HS_PHY_CTRL);
+		thread_sleep(10);
+
+		/* Enable HSUSB PHY port for ULPI interface,
+		* then configure related parameters within the PHY */
+		writel_relaxed(((readl_relaxed(USB_PORTSC) & 0xC0000000)
+				| 0x8c000004), USB_PORTSC);
+	}
+}
+
 /* Returns 1 if target supports continuous splash screen. */
 int target_cont_splash_screen()
 {
-	switch(board_platform_id())
+	switch(board_hardware_id())
 	{
-	case HW_PLATFORM_SURF:
-	case HW_PLATFORM_FFA:
-	default:
-		return 0;
+		case HW_PLATFORM_SURF:
+		case HW_PLATFORM_MTP:
+		case HW_PLATFORM_FLUID:
+			dprintf(SPEW, "Target_cont_splash=1\n");
+			return 1;
+			break;
+		default:
+			dprintf(SPEW, "Target_cont_splash=0\n");
+			return 0;
 	}
 }
 
diff --git a/target/msm8974/target_display.c b/target/msm8974/target_display.c
index f304494..d4be69c 100644
--- a/target/msm8974/target_display.c
+++ b/target/msm8974/target_display.c
@@ -142,6 +142,7 @@
 	switch (hw_id) {
 	case HW_PLATFORM_MTP:
 	case HW_PLATFORM_FLUID:
+	case HW_PLATFORM_SURF:
 		mipi_toshiba_video_720p_init(&(panel.panel_info));
 		panel.clk_func = msm8974_mdss_dsi_panel_clock;
 		panel.power_func = msm8974_mipi_panel_power;