platform: Add new api to get MSM_SHARED_BASE

Add a new api to get MSM_SHARED_BASE address from platform.
MSM_SHARED_BASE address is dependent on platform subtype and
hence is different for some platform variants.

Change-Id: I307d2110984e788aeeac2bcaa9f185ce2e2c92f4
diff --git a/include/platform.h b/include/platform.h
index 2c9383b..58e0d32 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -1,6 +1,8 @@
 /*
  * Copyright (c) 2008 Travis Geiselbrecht
  *
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files
  * (the "Software"), to deal in the Software without restriction,
@@ -57,4 +59,5 @@
 uint32_t platform_get_sclk_count(void);
 void clock_config_cdc(uint32_t interface);
 int platform_is_msm8939();
+uint32_t platform_get_smem_base_addr();
 #endif
diff --git a/platform/init.c b/platform/init.c
index e02adc3..89381cf 100644
--- a/platform/init.c
+++ b/platform/init.c
@@ -1,6 +1,8 @@
 /*
  * Copyright (c) 2008 Travis Geiselbrecht
  *
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ *
  * Permission is hereby granted, free of charge, to any person obtaining
  * a copy of this software and associated documentation files
  * (the "Software"), to deal in the Software without restriction,
@@ -24,6 +26,7 @@
 #include <debug.h>
 #include <platform.h>
 #include <boot_stats.h>
+#include <platform/iomap.h>
 
 /*
  * default implementations of these routines, if the platform code
@@ -106,3 +109,8 @@
 {
 
 }
+
+__WEAK uint32_t platform_get_smem_base_addr()
+{
+	return (uint32_t)MSM_SHARED_BASE;
+}
diff --git a/platform/msm_shared/smem.c b/platform/msm_shared/smem.c
index 00a1872..dc1b141 100644
--- a/platform/msm_shared/smem.c
+++ b/platform/msm_shared/smem.c
@@ -2,6 +2,8 @@
  * Copyright (c) 2009, Google Inc.
  * All rights reserved.
  *
+ * Copyright (c) 2014, 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:
@@ -33,7 +35,7 @@
 
 #include "smem.h"
 
-static struct smem *smem = (void *)(MSM_SHARED_BASE);
+static struct smem *smem;
 
 /* buf MUST be 4byte aligned, and len MUST be a multiple of 8. */
 unsigned smem_read_alloc_entry(smem_mem_type_t type, void *buf, int len)
@@ -42,6 +44,11 @@
 	unsigned *dest = buf;
 	unsigned src;
 	unsigned size;
+	uint32_t smem_addr = 0;
+
+	smem_addr = platform_get_smem_base_addr();
+
+	smem = (struct smem *)smem_addr;
 
 	if (((len & 0x3) != 0) || (((unsigned)buf & 0x3) != 0))
 		return 1;
@@ -59,7 +66,7 @@
 	if (size != (unsigned)((len + 7) & ~0x00000007))
 		return 1;
 
-	src = MSM_SHARED_BASE + readl(&ainfo->offset);
+	src = smem_addr + readl(&ainfo->offset);
 	for (; len > 0; src += 4, len -= 4)
 		*(dest++) = readl(src);
 
@@ -74,6 +81,11 @@
 	unsigned *dest = buf;
 	unsigned src;
 	unsigned size = len;
+	uint32_t smem_addr = 0;
+
+	smem_addr = platform_get_smem_base_addr();
+
+	smem = (struct smem *)smem_addr;
 
 	if (((len & 0x3) != 0) || (((unsigned)buf & 0x3) != 0))
 		return 1;
@@ -85,7 +97,7 @@
 	if (readl(&ainfo->allocated) == 0)
 		return 1;
 
-	src = MSM_SHARED_BASE + readl(&ainfo->offset) + offset;
+	src = smem_addr + readl(&ainfo->offset) + offset;
 	for (; size > 0; src += 4, size -= 4)
 		*(dest++) = readl(src);
 
diff --git a/platform/msm_shared/smem.h b/platform/msm_shared/smem.h
index e287c8e..a5e97fb 100755
--- a/platform/msm_shared/smem.h
+++ b/platform/msm_shared/smem.h
@@ -37,6 +37,8 @@
 #define SMEM_V8_SMEM_MAX_PMIC_DEVICES   3
 #define SMEM_MAX_PMIC_DEVICES           SMEM_V8_SMEM_MAX_PMIC_DEVICES
 
+#define SMEM_TARGET_INFO_IDENTIFIER     0x49494953
+
 struct smem_proc_comm {
 	unsigned command;
 	unsigned status;