Merge "target: msm8994: hdmi display init for hdmi primary"
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index e163a20..0bd1eb7 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -875,6 +875,7 @@
 	unsigned imagesize_actual;
 	unsigned second_actual = 0;
 
+	unsigned int dtb_size = 0;
 	unsigned int out_len = 0;
 	unsigned int out_avai_len = 0;
 	unsigned char *out_addr = NULL;
@@ -889,6 +890,7 @@
 	unsigned dt_table_offset;
 	uint32_t dt_actual;
 	uint32_t dt_hdr_size;
+	unsigned char *best_match_dt_addr = NULL;
 #endif
 	struct kernel64_hdr *kptr = NULL;
 
@@ -1034,17 +1036,17 @@
 	{
 		out_addr = (unsigned char *)(image_addr + imagesize_actual + page_size);
 		out_avai_len = target_get_max_flash_size() - imagesize_actual - page_size;
-		dprintf(INFO, "decompress image start\n");
+		dprintf(SPEW, "decompress image start\n");
 		rc = decompress((unsigned char *)(image_addr + page_size),
 				hdr->kernel_size, out_addr, out_avai_len,
 				&dtb_offset, &out_len);
 		if (rc)
 		{
-			dprintf(INFO, "decompress image failed!!!\n");
+			dprintf(CRITICAL, "decompress image failed!!!\n");
 			ASSERT(0);
 		}
 
-		dprintf(INFO, "decompressed image finished.\n");
+		dprintf(SPEW, "decompressed image finished.\n");
 		kptr = (struct kernel64_hdr *)out_addr;
 		kernel_start_addr = out_addr;
 		kernel_size = out_len;
@@ -1103,14 +1105,36 @@
 			return -1;
 		}
 
+		if (is_gzip_package((unsigned char *)dt_table_offset + dt_entry.offset, dt_entry.size))
+		{
+			unsigned int compressed_size = 0;
+			out_addr += out_len;
+			out_avai_len -= out_len;
+			dprintf(SPEW, "decompress dtb start\n");
+			rc = decompress((unsigned char *)dt_table_offset + dt_entry.offset,
+					dt_entry.size, out_addr, out_avai_len,
+					&compressed_size, &dtb_size);
+			if (rc)
+			{
+				dprintf(CRITICAL, "decompress dtb failed!!!\n");
+				ASSERT(0);
+			}
+
+			dprintf(SPEW, "decompressed dtb finished.\n");
+			best_match_dt_addr = out_addr;
+		} else {
+			best_match_dt_addr = (unsigned char *)dt_table_offset + dt_entry.offset;
+			dtb_size = dt_entry.size;
+		}
+
 		/* Validate and Read device device tree in the tags_addr */
-		if (check_aboot_addr_range_overlap(hdr->tags_addr, dt_entry.size))
+		if (check_aboot_addr_range_overlap(hdr->tags_addr, dtb_size))
 		{
 			dprintf(CRITICAL, "Device tree addresses overlap with aboot addresses.\n");
 			return -1;
 		}
 
-		memmove((void *)hdr->tags_addr, (char *)dt_table_offset + dt_entry.offset, dt_entry.size);
+		memmove((void *)hdr->tags_addr, (char *)best_match_dt_addr, dtb_size);
 	} else {
 		/* Validate the tags_addr */
 		if (check_aboot_addr_range_overlap(hdr->tags_addr, kernel_actual))
@@ -1619,13 +1643,19 @@
 }
 
 #if DEVICE_TREE
-int copy_dtb(uint8_t *boot_image_start)
+int copy_dtb(uint8_t *boot_image_start, unsigned int scratch_offset)
 {
 	uint32 dt_image_offset = 0;
 	uint32_t n;
 	struct dt_table *table;
 	struct dt_entry dt_entry;
 	uint32_t dt_hdr_size;
+	unsigned int compressed_size = 0;
+	unsigned int dtb_size = 0;
+	unsigned int out_avai_len = 0;
+	unsigned char *out_addr = NULL;
+	unsigned char *best_match_dt_addr = NULL;
+	int rc;
 
 	struct boot_img_hdr *hdr = (struct boot_img_hdr *) (boot_image_start);
 
@@ -1658,17 +1688,35 @@
 			return -1;
 		}
 
+		best_match_dt_addr = (unsigned char *)boot_image_start + dt_image_offset + dt_entry.offset;
+		if (is_gzip_package(best_match_dt_addr, dt_entry.size))
+		{
+			out_addr = (unsigned char *)target_get_scratch_address() + scratch_offset;
+			out_avai_len = target_get_max_flash_size() - scratch_offset;
+			dprintf(SPEW, "decompress dtb start\n");
+			rc = decompress(best_match_dt_addr,
+					dt_entry.size, out_addr, out_avai_len,
+					&compressed_size, &dtb_size);
+			if (rc)
+			{
+				dprintf(CRITICAL, "decompress dtb failed!!!\n");
+				ASSERT(0);
+			}
+
+			dprintf(SPEW, "decompressed dtb finished.\n");
+			best_match_dt_addr = out_addr;
+		} else {
+			dtb_size = dt_entry.size;
+		}
 		/* Validate and Read device device tree in the "tags_add */
-		if (check_aboot_addr_range_overlap(hdr->tags_addr, dt_entry.size))
+		if (check_aboot_addr_range_overlap(hdr->tags_addr, dtb_size))
 		{
 			dprintf(CRITICAL, "Device tree addresses overlap with aboot addresses.\n");
 			return -1;
 		}
 
 		/* Read device device tree in the "tags_add */
-		memmove((void*) hdr->tags_addr,
-				boot_image_start + dt_image_offset +  dt_entry.offset,
-				dt_entry.size);
+		memmove((void*) hdr->tags_addr, (void *)best_match_dt_addr, dtb_size);
 	} else
 		return -1;
 
@@ -1695,6 +1743,7 @@
 	uint32_t dtb_offset = 0;
 	unsigned char *kernel_start_addr = NULL;
 	unsigned int kernel_size = 0;
+	unsigned int scratch_offset = 0;
 
 
 #ifdef MDTP_SUPPORT
@@ -1763,17 +1812,17 @@
 		out_addr = (unsigned char *)target_get_scratch_address();
 		out_addr = (unsigned char *)(out_addr + image_actual + page_size);
 		out_avai_len = target_get_max_flash_size() - image_actual - page_size;
-		dprintf(INFO, "decompress image start\n");
+		dprintf(SPEW, "decompress image start\n");
 		ret = decompress((unsigned char *)(ptr + page_size),
 				hdr->kernel_size, out_addr, out_avai_len,
 				&dtb_offset, &out_len);
 		if (ret)
 		{
-			dprintf(INFO, "decompress image failed!!!\n");
+			dprintf(CRITICAL, "decompress image failed!!!\n");
 			ASSERT(0);
 		}
 
-		dprintf(INFO, "decompressed image finished.\n");
+		dprintf(SPEW, "decompressed image finished.\n");
 		kptr = (struct kernel64_hdr *)out_addr;
 		kernel_start_addr = out_addr;
 		kernel_size = out_len;
@@ -1805,8 +1854,9 @@
 	}
 
 #if DEVICE_TREE
+	scratch_offset = image_actual + page_size + out_len;
 	/* find correct dtb and copy it to right location */
-	ret = copy_dtb(data);
+	ret = copy_dtb(data, scratch_offset);
 
 	dtb_copied = !ret ? 1 : 0;
 #else
diff --git a/platform/msm_shared/clock.c b/platform/msm_shared/clock.c
index 35ed5c6..22d8de2 100644
--- a/platform/msm_shared/clock.c
+++ b/platform/msm_shared/clock.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012, 2014-2015, 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:
@@ -157,7 +157,7 @@
 		}
 	}
 
-	dprintf(CRITICAL, "Alert!! Requested clock \"%s\" is not supported!", cid);
+	dprintf(CRITICAL, "Alert!! Requested clock \"%s\" is not supported!\n", cid);
 	return NULL;
 }
 
diff --git a/target/msm8952/init.c b/target/msm8952/init.c
index b8e1882..3e6afd9 100644
--- a/target/msm8952/init.c
+++ b/target/msm8952/init.c
@@ -111,9 +111,15 @@
 		{ SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK, 0},
 	};
 
+	struct tlmm_cfgs sdc1_rclk_cfg[] =
+	{
+		{ SDC1_RCLK_PULL_CTL_OFF, TLMM_PULL_DOWN, TLMM_PULL_MASK, 0},
+	};
+
 	/* Set the drive strength & pull control values */
 	tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg));
 	tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg));
+	tlmm_set_pull_ctrl(sdc1_rclk_cfg, ARRAY_SIZE(sdc1_rclk_cfg));
 }
 
 void target_sdc_init()