Merge "platform: msm_shared: Add mipi dsi configuration for 8x10"
diff --git a/platform/msm8610/include/platform/iomap.h b/platform/msm8610/include/platform/iomap.h
index d5e758d..79344d7 100644
--- a/platform/msm8610/include/platform/iomap.h
+++ b/platform/msm8610/include/platform/iomap.h
@@ -45,6 +45,10 @@
 #define MSM_SHARED_IMEM_BASE        0xFE805000
 #define RESTART_REASON_ADDR         (MSM_SHARED_IMEM_BASE + 0x65C)
 
+#define BS_INFO_OFFSET              (0x6B0)
+#define BS_INFO_ADDR                (MSM_SHARED_IMEM_BASE + BS_INFO_OFFSET)
+#define MPM2_MPM_SLEEP_TIMETICK_COUNT_VAL    0xFC4A3000
+
 #define MSM_GIC_DIST_BASE           APPS_SS_BASE
 #define MSM_GIC_CPU_BASE            (APPS_SS_BASE + 0x2000)
 #define APPS_APCS_QTMR_AC_BASE      (APPS_SS_BASE + 0x00020000)
diff --git a/platform/msm8610/platform.c b/platform/msm8610/platform.c
index ac74205..40ce82a 100644
--- a/platform/msm8610/platform.c
+++ b/platform/msm8610/platform.c
@@ -36,6 +36,7 @@
 #include <arch/arm/mmu.h>
 #include <smem.h>
 #include <board.h>
+#include <boot_stats.h>
 
 #define MB (1024*1024)
 
@@ -76,6 +77,16 @@
 	dprintf(INFO, "platform_init()\n");
 }
 
+uint32_t platform_get_sclk_count(void)
+{
+	return readl(MPM2_MPM_SLEEP_TIMETICK_COUNT_VAL);
+}
+
+addr_t get_bs_info_addr()
+{
+	return ((addr_t)BS_INFO_ADDR);
+}
+
 void platform_uninit(void)
 {
 	qtimer_uninit();
diff --git a/platform/msm_shared/board.c b/platform/msm_shared/board.c
index dcc750d..3e93888 100644
--- a/platform/msm_shared/board.c
+++ b/platform/msm_shared/board.c
@@ -103,6 +103,20 @@
 		board.platform_hw = board_info_v8.board_info_v3.hw_platform;
 		board.platform_subtype = board_info_v8.platform_subtype;
 
+		/*
+		* fill in board.target with variant_id information
+		*                 bit no |31  24 | 23   16| 15   8 |7         0|
+		*          board.target =|subtype| major  | minor  |hw_platform|
+		* Have QRD board.target =| OEM   | EVT/DVT|Reserved| QRD        |
+		*
+		*/
+		if (board_info_v8.board_info_v3.hw_platform == HW_PLATFORM_QRD) {
+			board.target = (((board_info_v8.platform_subtype & 0xff) << 24) |
+					(((board_info_v8.platform_version >> 16) & 0xff) << 16) |
+					((board_info_v8.platform_version & 0xff) << 8) |
+					((board_info_v8.board_info_v3.hw_platform & 0xff) << 0));
+		}
+
 		for (i = 0; i < SMEM_V8_SMEM_MAX_PMIC_DEVICES; i++) {
 			board.pmic_info[i].pmic_type = board_info_v8.pmic_info[i].pmic_type;
 			board.pmic_info[i].pmic_version = board_info_v8.pmic_info[i].pmic_version;
diff --git a/platform/msm_shared/dev_tree.c b/platform/msm_shared/dev_tree.c
index de5384b..3d7d23f 100644
--- a/platform/msm_shared/dev_tree.c
+++ b/platform/msm_shared/dev_tree.c
@@ -134,6 +134,8 @@
 	return 0;
 }
 
+static int __dev_tree_get_entry_info(struct dt_table *table, struct dt_entry *dt_entry_info, uint32_t target_variant_id);
+
 /* Function to obtain the index information for the correct device tree
  *  based on the platform data.
  *  If a matching device tree is found, the information is returned in the
@@ -142,6 +144,25 @@
  */
 int dev_tree_get_entry_info(struct dt_table *table, struct dt_entry *dt_entry_info)
 {
+	uint32_t target_variant_id;
+
+	if(board_hardware_id() == HW_PLATFORM_QRD) {
+		target_variant_id = board_target_id();
+		if (__dev_tree_get_entry_info(table, dt_entry_info, target_variant_id) == 0) {
+			return 0;
+		}
+	}
+	/*
+	* for compatible with version 1 and version 2 dtbtool
+	* will compare the subtype inside the variant id
+	*/
+	target_variant_id = board_hardware_id() | ((board_hardware_subtype() & 0xff) << 24);
+
+	return __dev_tree_get_entry_info(table, dt_entry_info, target_variant_id);
+}
+
+static int __dev_tree_get_entry_info(struct dt_table *table, struct dt_entry *dt_entry_info, uint32_t target_variant_id)
+{
 	uint32_t i;
 	unsigned char *table_ptr;
 	struct dt_entry dt_entry_buf_1;
@@ -191,13 +212,11 @@
 		 * than or equal to actual hardware
 		 */
 		if((cur_dt_entry->platform_id == board_platform_id()) &&
-		   (cur_dt_entry->variant_id == board_hardware_id()) &&
-		   (cur_dt_entry->board_hw_subtype == board_hardware_subtype()))
+		   ((cur_dt_entry->variant_id | ((cur_dt_entry->board_hw_subtype & 0xff) << 24)) == target_variant_id))
 		{
 			if(cur_dt_entry->soc_rev == board_soc_version()) {
-				/* copy structure */
-				*dt_entry_info = *cur_dt_entry;
-				return 0;
+				best_match_dt_entry = cur_dt_entry;
+				break;
 			} else if (cur_dt_entry->soc_rev < board_soc_version()){
 				/* Keep this as the next best candidate. */
 				if (!best_match_dt_entry) {
@@ -215,9 +234,17 @@
 
 	if (best_match_dt_entry) {
 		*dt_entry_info = *best_match_dt_entry;
+		dprintf(INFO, "Using DTB entry %u/%08x/%u/%u for device %u/%08x/%u/%u\n",
+				dt_entry_info->platform_id, dt_entry_info->soc_rev,
+				dt_entry_info->variant_id, dt_entry_info->board_hw_subtype,
+				board_platform_id(), board_soc_version(),
+				board_hardware_id(), board_hardware_subtype());
 		return 0;
 	}
 
+	dprintf(CRITICAL, "ERROR: Unable to find suitable device tree for device (%u/0x%08x/%u/%u)\n",
+			board_platform_id(), board_soc_version(),
+			board_hardware_id(), board_hardware_subtype());
 	return -1;
 }
 
@@ -362,3 +389,4 @@
 
 	return ret;
 }
+
diff --git a/platform/msm_shared/mdp5.c b/platform/msm_shared/mdp5.c
index 690c955..e86c8df 100644
--- a/platform/msm_shared/mdp5.c
+++ b/platform/msm_shared/mdp5.c
@@ -59,13 +59,10 @@
 	uint32_t mdss_mdp_intf_off;
 	uint32_t mdss_mdp_rev = readl(MDP_HW_REV);
 
-	if (mdss_mdp_rev ==  MDSS_MDP_HW_REV_100
-		|| mdss_mdp_rev ==  MDSS_MDP_HW_REV_102)
+	if (mdss_mdp_rev >= MDSS_MDP_HW_REV_102)
 		mdss_mdp_intf_off = 0;
-	else if (mdss_mdp_rev ==  MDSS_MDP_HW_REV_101)
-		mdss_mdp_intf_off = 0xEC00;
 	else
-		mdss_mdp_intf_off = 0;
+		mdss_mdp_intf_off = 0xEC00;
 
 	return mdss_mdp_intf_off;
 }
@@ -131,7 +128,7 @@
 		writel(0x1, VBIF_VBIF_DDR_FORCE_CLK_ON);
 
 		if (mdp_hw_rev == MDSS_MDP_HW_REV_100
-			|| mdp_hw_rev == MDSS_MDP_HW_REV_102) {
+			|| mdp_hw_rev >= MDSS_MDP_HW_REV_102) {
 			/* Configure DDR burst length */
 			writel(0x00000707, VBIF_VBIF_DDR_OUT_MAX_BURST);
 			writel(0x00000030, VBIF_VBIF_DDR_ARB_CTRL );
@@ -140,7 +137,7 @@
 			writel(0x0FFF0FFF, VBIF_VBIF_DDR_OUT_AX_AOOO);
 			writel(0x22222222, VBIF_VBIF_DDR_AXI_AMEMTYPE_CONF0);
 			writel(0x00002222, VBIF_VBIF_DDR_AXI_AMEMTYPE_CONF1);
-		} else if (mdp_hw_rev == MDSS_MDP_HW_REV_101) {
+		} else if (mdp_hw_rev >= MDSS_MDP_HW_REV_101) {
 			writel(0x00000707, VBIF_VBIF_DDR_OUT_MAX_BURST);
 			writel(0x00000003, VBIF_VBIF_DDR_ARB_CTRL);
 		}
@@ -158,12 +155,11 @@
 	xres = pinfo->xres;
 	bpp = pinfo->bpp;
 
-	if (mdss_mdp_rev == MDSS_MDP_HW_REV_101) {
-		rgb0_client_id = MMSS_MDP_1_1_CLIENT_ID_RGB0;
-	} else if (mdss_mdp_rev == MDSS_MDP_HW_REV_100
-		|| mdss_mdp_rev == MDSS_MDP_HW_REV_102) {
+	if (mdss_mdp_rev == MDSS_MDP_HW_REV_100
+		|| mdss_mdp_rev >= MDSS_MDP_HW_REV_102)
 		rgb0_client_id = MMSS_MDP_1_2_CLIENT_ID_RGB0;
-	}
+	else if (mdss_mdp_rev >= MDSS_MDP_HW_REV_101)
+		rgb0_client_id = MMSS_MDP_1_1_CLIENT_ID_RGB0;
 
 	if (pinfo->lcdc.dual_pipe) {
 		/* Each pipe driving half the screen */
diff --git a/target/msm8226/init.c b/target/msm8226/init.c
index 19568cb..641a16f 100644
--- a/target/msm8226/init.c
+++ b/target/msm8226/init.c
@@ -59,6 +59,12 @@
 
 #define TLMM_VOL_UP_BTN_GPIO    106
 
+enum target_subtype {
+	HW_PLATFORM_SUBTYPE_SKUAA = 1,
+	HW_PLATFORM_SUBTYPE_SKUF = 2,
+	HW_PLATFORM_SUBTYPE_SKUAB = 3,
+};
+
 static uint32_t mmc_sdhci_base[] =
 	{ MSM_SDC1_SDHCI_BASE, MSM_SDC2_SDHCI_BASE, MSM_SDC3_SDHCI_BASE };
 
@@ -197,7 +203,9 @@
 /* Detect the target type */
 void target_detect(struct board_data *board)
 {
-	board->target = LINUX_MACHTYPE_UNKNOWN;
+	/*
+	* already fill the board->target on board.c
+	*/
 }
 
 /* Detect the modem type */
@@ -218,6 +226,12 @@
 	{
 	case HW_PLATFORM_SUBTYPE_UNKNOWN:
 		break;
+	case HW_PLATFORM_SUBTYPE_SKUAA:
+		break;
+	case HW_PLATFORM_SUBTYPE_SKUF:
+		break;
+	case HW_PLATFORM_SUBTYPE_SKUAB:
+		break;
 	default:
 		dprintf(CRITICAL, "Platform Subtype : %u is not supported\n", platform_subtype);
 		ASSERT(0);
diff --git a/target/msm8226/rules.mk b/target/msm8226/rules.mk
index c5b9059..3b24362 100644
--- a/target/msm8226/rules.mk
+++ b/target/msm8226/rules.mk
@@ -14,7 +14,7 @@
 RAMDISK_ADDR     := BASE_ADDR+0x01000000
 SCRATCH_ADDR     := 0x10000000
 
-DEFINES += DISPLAY_SPLASH_SCREEN=0
+DEFINES += DISPLAY_SPLASH_SCREEN=1
 DEFINES += DISPLAY_TYPE_MIPI=1
 DEFINES += DISPLAY_TYPE_DSI6G=1
 DEFINES += DISPLAY_TYPE_CMD_MODE=0
diff --git a/target/msm8610/init.c b/target/msm8610/init.c
index 6537a4d..6c364c3 100644
--- a/target/msm8610/init.c
+++ b/target/msm8610/init.c
@@ -48,6 +48,12 @@
 
 #define TLMM_VOL_UP_BTN_GPIO    72
 
+enum target_subtype {
+	HW_PLATFORM_SUBTYPE_SKUAA = 1,
+	HW_PLATFORM_SUBTYPE_SKUF = 2,
+	HW_PLATFORM_SUBTYPE_SKUAB = 3,
+};
+
 static uint32_t mmc_sdc_base[] =
 	{ MSM_SDC1_BASE, MSM_SDC2_BASE };
 
@@ -131,7 +137,10 @@
 /* Detect the target type */
 void target_detect(struct board_data *board)
 {
-	board->target = LINUX_MACHTYPE_UNKNOWN;
+	/*
+	* already fill the board->target on board.c
+	*/
+
 }
 
 /* Detect the modem type */
@@ -152,6 +161,12 @@
 	{
 	case HW_PLATFORM_SUBTYPE_UNKNOWN:
 		break;
+	case HW_PLATFORM_SUBTYPE_SKUAA:
+		break;
+	case HW_PLATFORM_SUBTYPE_SKUF:
+		break;
+	case HW_PLATFORM_SUBTYPE_SKUAB:
+		break;
 	default:
 		dprintf(CRITICAL, "Platform Subtype : %u is not supported\n", platform_subtype);
 		ASSERT(0);