Merge "target: msm8952: enable truly 1200p panel for msm8937 target" into lk.lnx.1.0-dev.1.0
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 1e134ba..cbe9dff 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -170,6 +170,7 @@
 #if !VBOOT_MOTA
 static const char *verity_mode = " androidboot.veritymode=";
 static const char *verified_state= " androidboot.verifiedbootstate=";
+static const char *keymaster_v1= " androidboot.keymaster=1";
 //indexed based on enum values, green is 0 by default
 
 struct verified_boot_verity_mode vbvm[] =
@@ -352,6 +353,7 @@
 		ASSERT(0);
 	}
 	cmdline_len += strlen(verity_mode) + strlen(vbvm[device.verity_mode].name);
+	cmdline_len += strlen(keymaster_v1);
 #endif
 #endif
 
@@ -490,6 +492,9 @@
 		src = vbvm[device.verity_mode].name;
 		if(have_cmdline) -- dst;
 		while ((*dst++ = *src++));
+		src = keymaster_v1;
+		if(have_cmdline) --dst;
+		while ((*dst++ = *src++));
 #endif
 #endif
 		src = usb_sn_cmdline;
diff --git a/dev/vib/include/vibrator.h b/dev/vib/include/vibrator.h
index b6aee2f..364e91b 100644
--- a/dev/vib/include/vibrator.h
+++ b/dev/vib/include/vibrator.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2016, 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
@@ -48,4 +48,5 @@
 void vib_turn_off(void);
 void vib_timed_turn_on(const uint32_t);
 void wait_vib_timeout(void);
+void turn_off_vib_early(void);
 #endif				/* __DEV_VIB_VIBRATOR_H */
diff --git a/dev/vib/vibrator.c b/dev/vib/vibrator.c
index 764300c..03b7a87 100644
--- a/dev/vib/vibrator.c
+++ b/dev/vib/vibrator.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2014-2016, 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
@@ -63,8 +63,10 @@
 static enum handler_return vib_timer_func(struct timer *v_timer, time_t t, void *arg)
 {
 	timer_cancel(&vib_timer);
-	vib_turn_off();
-	vib_timeout=1;
+	if(!vib_timeout){
+		vib_turn_off();
+		vib_timeout = 1;
+	}
 
 	return INT_RESCHEDULE;
 }
@@ -74,8 +76,10 @@
 	while((--vib_time)){
 		thread_sleep(CHECK_VIB_TIMER_FREQUENCY);
 	}
-	vib_turn_off();
-	vib_timeout = 1;
+	if(!vib_timeout){
+		vib_turn_off();
+		vib_timeout = 1;
+	}
 	return 0;
 }
 #endif
@@ -110,3 +114,12 @@
 		thread_sleep(CHECK_VIB_TIMER_FREQUENCY);
 	}
 }
+
+void turn_off_vib_early(void)
+{
+	if(vib_timeout) {
+		return;
+	}
+	vib_turn_off();
+	vib_timeout = 1;
+}
diff --git a/include/platform.h b/include/platform.h
index f97273a..6711836 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -67,8 +67,12 @@
 int platform_is_msm8992();
 int platform_is_msm8937();
 int platform_is_msmgold();
+uint32_t platform_get_apcs_ipc_base();
+int platform_is_msm8952();
 int platform_is_msm8956();
 uint32_t platform_is_msm8976_v_1_1();
+uint32_t platform_get_tz_app_add();
+uint32_t platform_get_tz_app_size();
 int boot_device_mask(int);
 uint32_t platform_detect_panel();
 uint32_t platform_get_max_periph();
diff --git a/platform/msm8952/include/platform/iomap.h b/platform/msm8952/include/platform/iomap.h
index 8409272..8643113 100644
--- a/platform/msm8952/include/platform/iomap.h
+++ b/platform/msm8952/include/platform/iomap.h
@@ -56,7 +56,9 @@
 #define APPS_APCS_QTMR_AC_BASE             (APPS_SS_BASE + 0x00020000)
 #define APPS_APCS_F0_QTMR_V1_BASE          (APPS_SS_BASE + 0x00021000)
 #define QTMR_BASE                          APPS_APCS_F0_QTMR_V1_BASE
-#define APCS_ALIAS0_IPC_INTERRUPT          (APPS_SS_BASE + 0x00111008)
+#define APCS_ALIAS1_IPC_INTERRUPT_1        (APPS_SS_BASE + 0x00011008)
+#define APCS_ALIAS0_IPC_INTERRUPT_2        (APPS_SS_BASE + 0x00111008)
+#define APCS_ALIAS0_IPC_INTERRUPT          platform_get_apcs_ipc_base()
 
 #define PERIPH_SS_BASE                     0x07800000
 
@@ -165,8 +167,12 @@
 #define RPMB_SND_RCV_BUF_SZ         0x1
 
 /* QSEECOM: Secure app region notification */
-#define APP_REGION_ADDR 0x85E00000
-#define APP_REGION_SIZE 0x500000
+#define APP_REGION_ADDR platform_get_tz_app_add()
+#define APP_REGION_SIZE platform_get_tz_app_size()
+#define APP_REGION_ADDR_8952 0x85E00000
+#define APP_REGION_SIZE_8952 0x500000
+#define APP_REGION_ADDR_8937 0x85B00000
+#define APP_REGION_SIZE_8937 0x800000
 
 /* MDSS */
 #define MIPI_DSI_BASE               (0x1A98000)
diff --git a/platform/msm8952/platform.c b/platform/msm8952/platform.c
index 180d34b..1851c22 100644
--- a/platform/msm8952/platform.c
+++ b/platform/msm8952/platform.c
@@ -215,6 +215,24 @@
 	return ret;
 }
 
+int platform_is_msm8952()
+{
+	uint32_t platform = board_platform_id();
+	uint32_t ret = 0;
+
+	switch(platform)
+	{
+	case MSM8952:
+	case APQ8052:
+		ret = 1;
+		break;
+	default:
+		ret = 0;
+	};
+
+	return ret;
+}
+
 int platform_is_msm8956()
 {
 	uint32_t platform = board_platform_id();
@@ -235,6 +253,30 @@
 	return ret;
 }
 
+uint32_t platform_get_tz_app_add()
+{
+	if(platform_is_msm8937())
+		return APP_REGION_ADDR_8937;
+	else
+		return APP_REGION_ADDR_8952;
+}
+
+uint32_t platform_get_tz_app_size()
+{
+	if(platform_is_msm8937())
+		return APP_REGION_SIZE_8937;
+	else
+		return APP_REGION_SIZE_8952;
+}
+
+uint32_t platform_get_apcs_ipc_base()
+{
+	if(platform_is_msmgold())
+		return APCS_ALIAS1_IPC_INTERRUPT_1;
+	else
+		return APCS_ALIAS0_IPC_INTERRUPT_2;
+}
+
 uint32_t platform_is_msm8976_v_1_1()
 {
 	uint32_t soc_ver = board_soc_version();
diff --git a/platform/msmtitanium/include/platform/iomap.h b/platform/msmtitanium/include/platform/iomap.h
index 6177043..b742d81 100644
--- a/platform/msmtitanium/include/platform/iomap.h
+++ b/platform/msmtitanium/include/platform/iomap.h
@@ -207,12 +207,12 @@
  * as device memory, define the start address
  * and size in MB
  */
-#define RPMB_SND_RCV_BUF            0x90000000
+#define RPMB_SND_RCV_BUF            0xA0000000
 #define RPMB_SND_RCV_BUF_SZ         0x1
 
 /* QSEECOM: Secure app region notification */
-#define APP_REGION_ADDR 0x85E00000
-#define APP_REGION_SIZE 0x500000
+#define APP_REGION_ADDR 0x85B00000
+#define APP_REGION_SIZE 0x800000
 
 /* MDSS */
 #define MIPI_DSI_BASE               (0x1A94000)
diff --git a/target/init.c b/target/init.c
index 7f8a432..d8d8073 100644
--- a/target/init.c
+++ b/target/init.c
@@ -270,6 +270,10 @@
 			break;
 		case MSM8937:
 		case APQ8037:
+		case MSMGOLD:
+		case MSMGOLD2:
+		case MSMGOLD3:
+		case APQGOLD:
 			config->vib_type = VIB_LRA_TYPE;
 			config->hap_rate_cfg1 = QPNP_HAP_RATE_CFG1_41;
 			config->hap_rate_cfg2 = QPNP_HAP_RATE_CFG2_03;
diff --git a/target/msm8952/init.c b/target/msm8952/init.c
index 1d577d6..43e1b2e 100644
--- a/target/msm8952/init.c
+++ b/target/msm8952/init.c
@@ -518,6 +518,9 @@
 
 void target_uninit(void)
 {
+#if PON_VIB_SUPPORT
+	turn_off_vib_early();
+#endif
 	mmc_put_card_to_sleep(dev);
 	sdhci_mode_disable(&dev->host);
 	if (crypto_initialized())
diff --git a/target/msmtitanium/rules.mk b/target/msmtitanium/rules.mk
index dbb0a14..fe575b6 100644
--- a/target/msmtitanium/rules.mk
+++ b/target/msmtitanium/rules.mk
@@ -9,7 +9,7 @@
 MEMSIZE := 0x00400000 # 1MB
 
 BASE_ADDR        := 0x80000000
-SCRATCH_ADDR     := 0xA0000000
+SCRATCH_ADDR     := 0xA0100000
 
 DEFINES += PMI_CONFIGURED=1
 DEFINES += DISPLAY_SPLASH_SCREEN=1