Merge "msm_shared: display: Setup MDSS/DSI registers for continuous splash support"
diff --git a/platform/mdm9x25/include/platform/iomap.h b/platform/mdm9x25/include/platform/iomap.h
index a19fdd0..c9cc2af 100644
--- a/platform/mdm9x25/include/platform/iomap.h
+++ b/platform/mdm9x25/include/platform/iomap.h
@@ -37,7 +37,7 @@
 /*SDRAM start address */
 #define SDRAM_START_ADDR          0x00000000
 
-#define MSM_SHARED_IMEM_BASE      0xFC42B000
+#define MSM_SHARED_IMEM_BASE      0xFC42A800
 #define RESTART_REASON_ADDR       (MSM_SHARED_IMEM_BASE + 0x65C)
 
 #define MSM_SHARED_IMEM_BASE_V2   0xFE807800
diff --git a/platform/mdm9x25/platform.c b/platform/mdm9x25/platform.c
index 0c7d280..dc903b0 100644
--- a/platform/mdm9x25/platform.c
+++ b/platform/mdm9x25/platform.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2013, 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
@@ -46,10 +46,10 @@
 #define MSM_IOMAP_SIZE                      ((MSM_IOMAP_END - MSM_IOMAP_BASE)/MB)
 
 /* LK memory - Strongly ordered, executable */
-#define LK_MEMORY                             (MMU_MEMORY_TYPE_STRONGLY_ORDERED | \
+#define LK_MEMORY                             (MMU_MEMORY_TYPE_NORMAL | \
                                               MMU_MEMORY_AP_READ_WRITE)
 /* Scratch memory - Strongly ordered, non-executable */
-#define SCRATCH_MEMORY                        (MMU_MEMORY_TYPE_STRONGLY_ORDERED | \
+#define SCRATCH_MEMORY                        (MMU_MEMORY_TYPE_NORMAL | \
                                               MMU_MEMORY_AP_READ_WRITE | MMU_MEMORY_XN)
 /* Peripherals - shared device */
 #define IOMAP_MEMORY                          (MMU_MEMORY_TYPE_DEVICE_SHARED | \
diff --git a/platform/msm8226/gpio.c b/platform/msm8226/gpio.c
index b869367..f184fb0 100644
--- a/platform/msm8226/gpio.c
+++ b/platform/msm8226/gpio.c
@@ -50,6 +50,11 @@
 	return;
 }
 
+uint32_t gpio_status(uint32_t gpio)
+{
+	return readl(GPIO_IN_OUT_ADDR(gpio)) & GPIO_IN;
+}
+
 /* Configure gpio for blsp uart 2 */
 void gpio_config_uart_dm(uint8_t id)
 {
diff --git a/platform/msm8226/include/platform/gpio.h b/platform/msm8226/include/platform/gpio.h
index 51a1ce0..ac554da 100644
--- a/platform/msm8226/include/platform/gpio.h
+++ b/platform/msm8226/include/platform/gpio.h
@@ -29,6 +29,8 @@
 #ifndef __PLATFORM_MSM8226_GPIO_H
 #define __PLATFORM_MSM8226_GPIO_H
 
+#include <bits.h>
+
 /* GPIO TLMM: Direction */
 #define GPIO_INPUT      0
 #define GPIO_OUTPUT     1
@@ -53,6 +55,17 @@
 #define GPIO_ENABLE     0
 #define GPIO_DISABLE    1
 
+/* GPIO_IN_OUT register shifts. */
+#define GPIO_IN         BIT(0)
+#define GPIO_OUT        BIT(1)
+
 void gpio_config_uart_dm(uint8_t id);
+uint32_t gpio_status(uint32_t gpio);
+void gpio_tlmm_config(uint32_t gpio,
+                      uint8_t func,
+                      uint8_t dir,
+                      uint8_t pull,
+                      uint8_t drvstr,
+                      uint32_t enable);
 
 #endif
diff --git a/platform/msm_shared/hsusb.h b/platform/msm_shared/hsusb.h
index 657b830..c26748a 100644
--- a/platform/msm_shared/hsusb.h
+++ b/platform/msm_shared/hsusb.h
@@ -2,7 +2,7 @@
  * Copyright (c) 2008, Google Inc.
  * All rights reserved.
  *
- * Copyright (c) 2009-2010, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2009-2013, 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
@@ -11,7 +11,7 @@
  *    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 
+ *    the documentation and/or other materials provided with the
  *    distribution.
  *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
@@ -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
@@ -69,6 +69,8 @@
 #define USB_ENDPTSTAT        (MSM_USB_BASE + 0x01B8)
 #define USB_ENDPTCOMPLETE    (MSM_USB_BASE + 0x01BC)
 #define USB_ENDPTCTRL(n)     (MSM_USB_BASE + 0x01C0 + (4 * (n)))
+#define USB_OTG_HS_PHY_CTRL  (MSM_USB_BASE + 0x0240)
+#define USB_OTG_HS_PHY_SEC_CTRL (MSM_USB_BASE + 0x0278)
 
 #define USBCMD_RESET   2
 #define USBCMD_ATTACH  1
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/include/scm.h b/platform/msm_shared/include/scm.h
index 418574b..8f7c235 100644
--- a/platform/msm_shared/include/scm.h
+++ b/platform/msm_shared/include/scm.h
@@ -66,7 +66,7 @@
 #define SSD_DECRYPT_ID              0x01
 #define SSD_ENCRYPT_ID              0x02
 
-#define SCM_SVC_SSD                 0x0C
+#define SVC_MEMORY_PROTECTION       0x0C
 #define IOMMU_SECURE_CFG            0x02
 
 #define SECURE_DEVICE_MDSS          1
diff --git a/platform/msm_shared/mdp5.c b/platform/msm_shared/mdp5.c
index 48a26bc..468969c 100644
--- a/platform/msm_shared/mdp5.c
+++ b/platform/msm_shared/mdp5.c
@@ -115,11 +115,18 @@
 
 	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 */
diff --git a/platform/msm_shared/partition_parser.c b/platform/msm_shared/partition_parser.c
index cd11632..7172425 100644
--- a/platform/msm_shared/partition_parser.c
+++ b/platform/msm_shared/partition_parser.c
@@ -255,7 +255,7 @@
 	}
 	partition_0 = GET_LLWORD_FROM_BYTE(&data[PARTITION_ENTRIES_OFFSET]);
 	/* Read GPT Entries */
-	for (i = 0; i < ROUNDUP(max_partition_count, 4); i++) {
+	for (i = 0; i < (ROUNDUP(max_partition_count, 4)) / 4; i++) {
 		ASSERT(partition_count < NUM_PARTITIONS);
 		ret = mmc_boot_read_from_card(mmc_host, mmc_card,
 					      (partition_0 * BLOCK_SIZE) +
diff --git a/platform/msm_shared/scm.c b/platform/msm_shared/scm.c
index 68b2792..c46b1eb 100644
--- a/platform/msm_shared/scm.c
+++ b/platform/msm_shared/scm.c
@@ -190,7 +190,7 @@
 	secure_cfg.id    = id;
 	secure_cfg.spare = 0;
 
-	ret = scm_call(SCM_SVC_SSD, IOMMU_SECURE_CFG, &secure_cfg, sizeof(secure_cfg),
+	ret = scm_call(SVC_MEMORY_PROTECTION, IOMMU_SECURE_CFG, &secure_cfg, sizeof(secure_cfg),
 			&scm_ret, sizeof(scm_ret));
 
 	if (ret || scm_ret) {
diff --git a/platform/msm_shared/smem.h b/platform/msm_shared/smem.h
index 837f0d2..58ca387 100755
--- a/platform/msm_shared/smem.h
+++ b/platform/msm_shared/smem.h
@@ -237,6 +237,7 @@
 	MSM8930AA = 142,
 	MSM8630AA = 143,
 	MSM8230AA = 144,
+	MSM8626   = 145,
 	MDM9225   = 149,
 	MDM9225M  = 150,
 	MDM9625M  = 152,
@@ -245,12 +246,17 @@
 	MSM8630AB = 155,
 	MSM8230AB = 156,
 	APQ8030AB = 157,
+	MSM8226   = 158,
+	MSM8826   = 159,
 	APQ8030AA = 160,
 	MSM8125   = 167,
 	APQ8064AA = 172, /* aka V2 SLOW_PRIME */
 	MSM8130   = 179,
 	MSM8130AA = 180,
 	MSM8130AB = 181,
+	MSM8627AA = 182,
+	MSM8227AA = 183,
+	APQ8074   = 184,
 };
 
 enum platform {
diff --git a/target/msm8226/init.c b/target/msm8226/init.c
index 52539a0..a1c322a 100644
--- a/target/msm8226/init.c
+++ b/target/msm8226/init.c
@@ -35,6 +35,9 @@
 #include <mmc.h>
 #include <spmi.h>
 #include <board.h>
+#include <smem.h>
+#include <baseband.h>
+#include <pm8x41.h>
 
 #define PMIC_ARB_CHANNEL_NUM    0
 #define PMIC_ARB_OWNER_ID       0
@@ -80,6 +83,55 @@
 	}
 }
 
+/* Do any target specific intialization needed before entering fastboot mode */
+void target_fastboot_init(void)
+{
+	/* Set the BOOT_DONE flag in PM8026 */
+	pm8x41_set_boot_done();
+}
+
+/* Detect the target type */
+void target_detect(struct board_data *board)
+{
+	board->target = LINUX_MACHTYPE_UNKNOWN;
+}
+
+/* Detect the modem type */
+void target_baseband_detect(struct board_data *board)
+{
+	uint32_t platform;
+	uint32_t platform_subtype;
+
+	platform         = board->platform;
+	platform_subtype = board->platform_subtype;
+
+	/*
+	 * Look for platform subtype if present, else
+	 * check for platform type to decide on the
+	 * baseband type
+	 */
+	switch(platform_subtype)
+	{
+	case HW_PLATFORM_SUBTYPE_UNKNOWN:
+		break;
+	default:
+		dprintf(CRITICAL, "Platform Subtype : %u is not supported\n", platform_subtype);
+		ASSERT(0);
+	};
+
+	switch(platform)
+	{
+	case MSM8826:
+	case MSM8626:
+	case MSM8226:
+		board->baseband = BASEBAND_MSM;
+		break;
+	default:
+		dprintf(CRITICAL, "Platform type: %u is not supported\n", platform);
+		ASSERT(0);
+	};
+}
+
 void target_serialno(unsigned char *buf)
 {
 	uint32_t serialno;
diff --git a/target/msm8960/init.c b/target/msm8960/init.c
index d0c15fc..c53db3e 100755
--- a/target/msm8960/init.c
+++ b/target/msm8960/init.c
@@ -381,7 +381,8 @@
 		default:
 			target_id = LINUX_MACHTYPE_8930_CDP;
 		}
-	} else if ((platform == MSM8227) || (platform == MSM8627)) {
+	} else if ((platform == MSM8227) || (platform == MSM8627) ||
+			   (platform == MSM8227AA) || (platform == MSM8627AA)) {
 		switch (platform_hw) {
 		case HW_PLATFORM_SURF:
 			target_id = LINUX_MACHTYPE_8627_CDP;
diff --git a/target/msm8974/init.c b/target/msm8974/init.c
index 35f00e6..cf76dcd 100644
--- a/target/msm8974/init.c
+++ b/target/msm8974/init.c
@@ -200,11 +200,36 @@
 /* Detect the modem type */
 void target_baseband_detect(struct board_data *board)
 {
-	/* Check for baseband variants. Default to MSM */
-	if (board->platform_subtype == HW_PLATFORM_SUBTYPE_MDM)
-		board->baseband = BASEBAND_MDM;
-	else
+	uint32_t platform;
+	uint32_t platform_subtype;
+
+	platform = board->platform;
+	platform_subtype = board->platform_subtype;
+
+	/*
+	 * Look for platform subtype if present, else
+	 * check for platform type to decide on the
+	 * baseband type
+	 */
+	switch(platform_subtype) {
+	case HW_PLATFORM_SUBTYPE_UNKNOWN:
+		break;
+	default:
+		dprintf(CRITICAL, "Platform Subtype : %u is not supported\n",platform_subtype);
+		ASSERT(0);
+	};
+
+	switch(platform) {
+	case MSM8974:
 		board->baseband = BASEBAND_MSM;
+		break;
+	case APQ8074:
+		board->baseband = BASEBAND_APQ;
+		break;
+	default:
+		dprintf(CRITICAL, "Platform type: %u is not supported\n",platform);
+		ASSERT(0);
+	};
 }
 
 void target_serialno(unsigned char *buf)