Merge "target: mdm9640: Update usb mux config for sdxhedgehog"
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/mdm9640/include/platform/iomap.h b/platform/mdm9640/include/platform/iomap.h
index a55687c..6981256 100644
--- a/platform/mdm9640/include/platform/iomap.h
+++ b/platform/mdm9640/include/platform/iomap.h
@@ -219,4 +219,11 @@
 /* Register for finding out if single ended or differential clock enablement */
 #define TCSR_PHY_CLK_SCHEME_SEL     0x01956044
 
+/* RPM MSG RAM */
+#define RPM_SS_MSG_RAM_START_ADDRESS_BASE_PHYS 0x00060000
+#define RPM_SS_MSG_RAM_START_ADDRESS_BASE      RPM_SS_MSG_RAM_START_ADDRESS_BASE_PHYS
+#define RPM_SS_MSG_RAM_START_ADDRESS_BASE_SIZE 0x00006000
+/* notify RPM via IPC interrupt*/
+#define APCS_HLOS_IPC_INTERRUPT_0 APCS_ALIAS0_IPC_INTERRUPT
+
 #endif
diff --git a/platform/mdm9640/include/platform/irqs.h b/platform/mdm9640/include/platform/irqs.h
index a9e8fc5..b1d958b 100644
--- a/platform/mdm9640/include/platform/irqs.h
+++ b/platform/mdm9640/include/platform/irqs.h
@@ -47,6 +47,7 @@
 
 #define SDCC1_PWRCTL_IRQ                       (GIC_SPI_START + 138)
 
+#define GLINK_IPC_IRQ                          (GIC_SPI_START + 168)
 /* Retrofit universal macro names */
 #define INT_USB_HS                             USB1_HS_IRQ
 
diff --git a/platform/mdm9640/platform.c b/platform/mdm9640/platform.c
index fd866a4..3cfced4 100644
--- a/platform/mdm9640/platform.c
+++ b/platform/mdm9640/platform.c
@@ -215,3 +215,10 @@
 		   readl(USB3_PHY_REVISION_ID1) << 8 | readl(USB3_PHY_REVISION_ID0);
 }
 
+bool platform_is_glink_enabled()
+{
+	if (platform_is_sdxhedgehog())
+		return 1;
+	else
+		return 0;
+}
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 \
diff --git a/project/mdm9640.mk b/project/mdm9640.mk
index d72ee16..997f92c 100644
--- a/project/mdm9640.mk
+++ b/project/mdm9640.mk
@@ -50,6 +50,11 @@
 DEFINES += SMD_SUPPORT=1
 endif
 
+ENABLE_GLINK_SUPPORT := 1
+ifeq ($(ENABLE_GLINK_SUPPORT),1)
+DEFINES += GLINK_SUPPORT=1
+endif
+
 # Reset USB clock from target code
 DEFINES += USB_RESET_FROM_CLK=1
 
diff --git a/target/mdm9640/init.c b/target/mdm9640/init.c
index 18be00f..803bef0 100644
--- a/target/mdm9640/init.c
+++ b/target/mdm9640/init.c
@@ -56,6 +56,7 @@
 #include <boot_device.h>
 #include <qmp_phy.h>
 #include <crypto5_wrapper.h>
+#include <rpm-glink.h>
 
 extern void smem_ptable_init(void);
 extern void smem_add_modem_partitions(struct ptable *flash_ptable);
@@ -151,7 +152,14 @@
 
 	spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID);
 	if(!platform_is_sdxhedgehog())
+	{
 		rpm_smd_init();
+	}
+	else
+	{
+		/* Initialize Glink */
+		rpm_glink_init();
+	}
 
 	if (platform_boot_dev_isemmc()) {
 		target_sdc_init();
@@ -421,7 +429,14 @@
 		crypto_eng_cleanup();
 
 	if(!platform_is_sdxhedgehog())
+	{
 		rpm_smd_uninit();
+	}
+	else
+	{
+		/* Tear down glink channels */
+		rpm_glink_uninit();
+	}
 }
 void target_mux_configure(void)
 {
diff --git a/target/msm8952/target_display.c b/target/msm8952/target_display.c
index bcbf1be..ee001bc 100644
--- a/target/msm8952/target_display.c
+++ b/target/msm8952/target_display.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2017, 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
@@ -51,6 +51,13 @@
 #include "include/display_resource.h"
 #include "gcdb_display.h"
 
+#define TRULY_720P_VID_PANEL "truly_720p_video"
+#define TRULY_720P_CMD_PANEL "truly_720p_cmd"
+
+#define HDMI_ADV_PANEL_STRING "1:dsi:0:qcom,mdss_dsi_adv7533_1080p:1:none:cfg:single_dsi"
+#define TRULY_VID_PANEL_STRING "1:dsi:0:qcom,mdss_dsi_truly_720p_video:1:none:cfg:single_dsi"
+#define TRULY_CMD_PANEL_STRING "1:dsi:0:qcom,mdss_dsi_truly_720p_cmd:1:none:cfg:single_dsi"
+
 /*---------------------------------------------------------------------------*/
 /* GPIO configuration                                                        */
 /*---------------------------------------------------------------------------*/
@@ -569,7 +576,55 @@
 
 bool target_display_panel_node(char *pbuf, uint16_t buf_size)
 {
-	return gcdb_display_cmdline_arg(pbuf, buf_size);
+	int prefix_string_len = strlen(DISPLAY_CMDLINE_PREFIX);
+	bool ret = true;
+	struct oem_panel_data oem = mdss_dsi_get_oem_data();
+	uint32_t platform_subtype = board_hardware_subtype();
+
+	/* default to hdmi for apq iot */
+	if ((HW_PLATFORM_SUBTYPE_SNAP == platform_subtype) ||
+		(HW_PLATFORM_SUBTYPE_SNAP_NOPMI == platform_subtype)) {
+		if (!strcmp(oem.panel, "")) {
+			if (buf_size < (prefix_string_len +
+				strlen(HDMI_ADV_PANEL_STRING))) {
+				dprintf(CRITICAL, "HDMI command line argument \
+					is greater than buffer size\n");
+				return false;
+			}
+			strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size);
+			buf_size -= prefix_string_len;
+			pbuf += prefix_string_len;
+			strlcpy(pbuf, HDMI_ADV_PANEL_STRING, buf_size);
+		} else if (!strcmp(oem.panel, TRULY_720P_VID_PANEL)) {
+			if (buf_size < (prefix_string_len +
+				strlen(TRULY_VID_PANEL_STRING))) {
+				dprintf(CRITICAL, "TRULY VIDEO command line \
+					argument is greater than \
+					buffer size\n");
+				return false;
+			}
+			strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size);
+			buf_size -= prefix_string_len;
+			pbuf += prefix_string_len;
+			strlcpy(pbuf, TRULY_VID_PANEL_STRING, buf_size);
+		} else if (!strcmp(oem.panel, TRULY_720P_CMD_PANEL)) {
+			if (buf_size < (prefix_string_len +
+				strlen(TRULY_CMD_PANEL_STRING))) {
+				dprintf(CRITICAL, "TRULY CMD command line argument \
+					argument is greater than \
+					buffer size\n");
+				return false;
+			}
+			strlcpy(pbuf, DISPLAY_CMDLINE_PREFIX, buf_size);
+			buf_size -= prefix_string_len;
+			pbuf += prefix_string_len;
+			strlcpy(pbuf, TRULY_CMD_PANEL_STRING, buf_size);
+		}
+	} else {
+		ret = gcdb_display_cmdline_arg(pbuf, buf_size);
+	}
+
+	return ret;
 }
 
 void target_display_init(const char *panel_name)
@@ -577,6 +632,7 @@
 	struct oem_panel_data oem;
 	int32_t ret = 0;
 	uint32_t panel_loop = 0;
+	uint32_t platform_subtype = board_hardware_subtype();
 
 	set_panel_cmd_string(panel_name);
 	oem = mdss_dsi_get_oem_data();
@@ -590,6 +646,13 @@
 		return;
 	}
 
+	if ((HW_PLATFORM_SUBTYPE_SNAP == platform_subtype) ||
+		(HW_PLATFORM_SUBTYPE_SNAP_NOPMI == platform_subtype)) {
+		dprintf(INFO, "%s: Platform subtype %d\n",
+			__func__, platform_subtype);
+		return;
+	}
+
 	do {
 		target_force_cont_splash_disable(false);
 		ret = gcdb_display_init(oem.panel, MDP_REV_50, (void *)MIPI_FB_ADDR);