platform: msm_shared: Support glink and smd simultaneously.

Support glink and smd support at runtime.

Change-Id: Ib4d9358acc14e85cae551c4fd716d52e7251c991
diff --git a/include/platform.h b/include/platform.h
index 07b1c04..5bc065a 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -88,4 +88,5 @@
 bool platform_is_mdmcalifornium();
 bool platform_is_sdxhedgehog();
 uint64_t platform_get_ddr_start();
+bool platform_is_glink_enabled();
 #endif
diff --git a/platform/init.c b/platform/init.c
index 8280ffb..f429527 100644
--- a/platform/init.c
+++ b/platform/init.c
@@ -162,3 +162,14 @@
 {
 	return SIGNATURE_SIZE;
 }
+
+/* Check if glink is supported or not */
+__WEAK bool platform_is_glink_enabled()
+{
+#if GLINK_SUPPORT
+	return 1;
+#else
+	return 0;
+#endif
+}
+
diff --git a/platform/msm_shared/rpm-ipc.c b/platform/msm_shared/rpm-ipc.c
index 2bd3c51..a8649db 100644
--- a/platform/msm_shared/rpm-ipc.c
+++ b/platform/msm_shared/rpm-ipc.c
@@ -30,11 +30,22 @@
 #include <arch/defines.h>
 #include <stdint.h>
 #include <sys/types.h>
+#include <platform.h>
 #include <rpm-ipc.h>
 #include <rpm-glink.h>
 #include <rpm-smd.h>
 #include <string.h>
 
+__WEAK glink_err_type rpm_glink_send_data(uint32_t *data, uint32_t len, msg_type type)
+{
+	return GLINK_STATUS_API_NOT_SUPPORTED;
+}
+
+__WEAK int rpm_smd_send_data(uint32_t *data, uint32_t len, msg_type type)
+{
+	return -1;
+}
+
 void fill_kvp_object(kvp_data **kdata, uint32_t *data, uint32_t len)
 {
 	*kdata = (kvp_data *) memalign(CACHE_LINE, ROUNDUP(len, CACHE_LINE));
@@ -52,11 +63,13 @@
 int rpm_send_data(uint32_t *data, uint32_t len, msg_type type)
 {
 	int ret = 0;
-#ifdef GLINK_SUPPORT
-	ret = rpm_glink_send_data(data, len, type);
-#else
-	ret = rpm_smd_send_data(data, len, type);
-#endif
+
+	/* Runtime select to call glink or smd */
+	if (platform_is_glink_enabled())
+		ret = rpm_glink_send_data(data, len, type);
+	else
+		ret = rpm_smd_send_data(data, len, type);
+
 	return ret;
 }
 
diff --git a/platform/msm_shared/rules.mk b/platform/msm_shared/rules.mk
index 7a9e688..e18a014 100755
--- a/platform/msm_shared/rules.mk
+++ b/platform/msm_shared/rules.mk
@@ -62,7 +62,6 @@
 
 ifeq ($(ENABLE_GLINK_SUPPORT),1)
 OBJS += \
-		$(LOCAL_DIR)/rpm-ipc.o \
 		$(LOCAL_DIR)/glink/glink_api.o \
 		$(LOCAL_DIR)/glink/glink_core_if.o \
 		$(LOCAL_DIR)/glink/glink_core_internal.o \
@@ -76,6 +75,11 @@
 		$(LOCAL_DIR)/rpm-glink.o
 endif
 
+ifneq ($(ENABLE_SMD_SUPPORT),1)
+OBJS += \
+	$(LOCAL_DIR)/rpm-ipc.o
+endif
+
 ifeq ($(PLATFORM),msm8x60)
 	OBJS += $(LOCAL_DIR)/mipi_dsi.o \
 			$(LOCAL_DIR)/i2c_qup.o \