platform: msm8916: Read TCSR_TZ_WONCE register to determine smem info.

TCSR_TZ_WONCE Register provides smem info like the Magic identifier,
smem address and size of smem. Magic identifier helps to determine
if smem addr can be dynamically read or not.

CRs-Fixed: 664790
Change-Id: Id99b6515993aeebebcd558125a7065100d060baa
diff --git a/platform/msm8916/platform.c b/platform/msm8916/platform.c
index 1b60c18..0820a2c 100644
--- a/platform/msm8916/platform.c
+++ b/platform/msm8916/platform.c
@@ -197,3 +197,20 @@
 
 	return ret;
 }
+
+/* DYNAMIC SMEM REGION feature enables LK to dynamically
+ * read the SMEM addr info from TCSR_TZ_WONCE register.
+ * The first word read, if indicates a MAGIC number, then
+ * Dynamic SMEM is assumed to be enabled. Read the remaining
+ * SMEM info for SMEM Size and Phy_addr from the other bytes.
+ */
+uint32_t platform_get_smem_base_addr()
+{
+	struct smem_addr_info *smem_info = NULL;
+
+	smem_info = (struct smem_addr_info *)readl(TCSR_TZ_WONCE);
+	if(smem_info && (smem_info->identifier == SMEM_TARGET_INFO_IDENTIFIER))
+		return smem_info->phy_addr;
+	else
+		return MSM_SHARED_BASE;
+}