Merge "target: msm8937: Add PWM support to msm8937 target"
diff --git a/dev/gcdb/display/include/panel_auo_390p_cmd.h b/dev/gcdb/display/include/panel_auo_390p_cmd.h
index d886cb2..5c8a860 100644
--- a/dev/gcdb/display/include/panel_auo_390p_cmd.h
+++ b/dev/gcdb/display/include/panel_auo_390p_cmd.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2017-2018, 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
@@ -140,6 +140,21 @@
 	0x52, 0x08, 0x01, 0xff,
 };
 
+static char auo_390p_cmd_on_cmd14[] = {
+	0xfe, 0x01, 0x15, 0x80,
+};
+
+static char auo_390p_cmd_on_cmd15[] = {
+	0x04, 0x00, 0x15, 0x80,
+};
+
+static char auo_390p_cmd_on_cmd16[] = {
+	0xfe, 0x00, 0x15, 0x80,
+};
+
+static char auo_390p_cmd_on_cmd17[] = {
+	0x3a, 0x77, 0x15, 0x80,
+};
 
 static struct mipi_dsi_cmd auo_390p_cmd_on_command[] = {
 	{ 0x4 , auo_390p_cmd_on_cmd0, 0x00},
@@ -156,9 +171,13 @@
 	{ 0x4 , auo_390p_cmd_on_cmd11, 0x00},
 	{ 0xc , auo_390p_cmd_on_cmd12, 0x00},
 	{ 0xc , auo_390p_cmd_on_cmd13, 0x00},
+	{ 0x4 , auo_390p_cmd_on_cmd14, 0x00},
+	{ 0x4 , auo_390p_cmd_on_cmd15, 0x00},
+	{ 0x4 , auo_390p_cmd_on_cmd16, 0x00},
+	{ 0x4 , auo_390p_cmd_on_cmd17, 0x00},
 };
 
-#define AUO_390P_CMD_ON_COMMAND 14
+#define AUO_390P_CMD_ON_COMMAND 18
 
 
 static char auo_390p_cmd_off_cmd0[] = {
diff --git a/dev/qpnp_haptic/qpnp_vib.c b/dev/qpnp_haptic/qpnp_vib.c
index fecb794..097e486 100644
--- a/dev/qpnp_haptic/qpnp_vib.c
+++ b/dev/qpnp_haptic/qpnp_vib.c
@@ -31,7 +31,7 @@
 
 void pm_vib_turn_on()
 {
-	if ((board_pmic_target(1) & 0xffff) == PMIC_IS_PMI632)
+	if ((board_pmic_target(1) & PMIC_TYPE_MASK) == PMIC_IS_PMI632)
 		pm_vib_ldo_turn_on();
 	else
 		pm_haptic_vib_turn_on();
@@ -39,7 +39,7 @@
 
 void pm_vib_turn_off()
 {
-	if ((board_pmic_target(1) & 0xffff) == PMIC_IS_PMI632)
+	if ((board_pmic_target(1) & PMIC_TYPE_MASK) == PMIC_IS_PMI632)
 		pm_vib_ldo_turn_off();
 	else
 		pm_haptic_vib_turn_off();
diff --git a/platform/msm_shared/avb/VerifiedBoot.c b/platform/msm_shared/avb/VerifiedBoot.c
index a23e15d..df10f35 100644
--- a/platform/msm_shared/avb/VerifiedBoot.c
+++ b/platform/msm_shared/avb/VerifiedBoot.c
@@ -115,7 +115,7 @@
 	if (!partition_multislot_is_supported())
 		return ERR_INVALID_ARGS;
 
-	strncpy(CurrentSlot->Suffix,
+	strlcpy(CurrentSlot->Suffix,
 			SUFFIX_SLOT(partition_find_active_slot()),
 			MAX_SLOT_SUFFIX_SZ);
 	return 0;
@@ -137,7 +137,7 @@
 	int idx = partition_find_active_slot();
 	if (idx != INVALID)
 	{
-		strncpy(ActiveSlot->Suffix,
+		strlcpy(ActiveSlot->Suffix,
 			SUFFIX_SLOT(partition_find_active_slot()),
 			MAX_SLOT_SUFFIX_SZ);
 		return 0;
@@ -205,8 +205,8 @@
 		return 0;
 	}
 
-	strncpy(PartitionName, "system", strlen("system") + 1);
-	strncat(PartitionName, CurSlot.Suffix, MAX_GPT_NAME_SIZE - 1);
+	strlcpy(PartitionName, "system", strlen("system") + 1);
+	strlcat(PartitionName, CurSlot.Suffix, MAX_GPT_NAME_SIZE - 1);
 
 	Index = partition_get_index(PartitionName);
 	if (Index == INVALID_PTN || Index >= NUM_PARTITIONS) {
@@ -304,7 +304,7 @@
 	}
 	Info->num_loaded_images = 1;
 	Info->images[0].name = malloc(strlen(Info->pname) + 1);
-	strncpy(Info->images[0].name, Info->pname, strlen(Info->pname)); //FIXME
+	strlcpy(Info->images[0].name, Info->pname, strlen(Info->pname)); //FIXME
 	return Status;
 }
 
@@ -325,13 +325,13 @@
 	DevInfo_vb.is_unlocked = !is_device_locked();
 	DevInfo_vb.is_unlock_critical = !is_device_locked_critical();
 
-	strncpy(StrPname, "/", strlen("/"));
-	strncpy(Pname, Info->pname, strlen(Info->pname));
+	strlcpy(StrPname, "/", strlen("/"));
+	strlcpy(Pname, Info->pname, strlen(Info->pname));
 	if (Info->multi_slot_boot) {
-		strncat(StrPname, Pname,
+		strlcat(StrPname, Pname,
 	              strlen(Pname) - (MAX_SLOT_SUFFIX_SZ - 1));
 	} else {
-		strncat(StrPname, Pname, strlen(Pname));
+		strlcat(StrPname, Pname, strlen(Pname));
 	}
 
 	Status = boot_verify_image((UINT8 *)Info->images[0].image_buffer,
@@ -433,7 +433,7 @@
 		goto out;
 	}
 	if(Info->multi_slot_boot) {
-	strncpy(Pname, Info->pname, strlen(Info->pname));
+	strlcpy(Pname, Info->pname, strlen(Info->pname));
 	if ((MAX_SLOT_SUFFIX_SZ + 1) > strlen(Pname)) {
 		dprintf(CRITICAL, "ERROR: Can not determine slot suffix\n");
 		Status = EFI_INVALID_PARAMETER;
@@ -681,10 +681,10 @@
 	if (!Info->multi_slot_boot) {
 		if (Info->bootinto_recovery) {
 			dprintf(INFO, "Booting Into Recovery Mode\n");
-			strncpy(Info->pname, "recovery", strlen("recovery"));
+			strlcpy(Info->pname, "recovery", strlen("recovery"));
 		} else {
 			dprintf(INFO, "Booting Into Mission Mode\n");
-			strncpy(Info->pname, "boot", strlen("boot"));
+			strlcpy(Info->pname, "boot", strlen("boot"));
 		}
 	} else {
 		Slot CurrentSlot = {{0}};
@@ -694,8 +694,8 @@
 			dprintf(CRITICAL, "No bootable slot\n");
 			return EFI_LOAD_ERROR;
 		}
-		strncpy(Info->pname, "boot", strlen("boot"));
-		strncat(Info->pname, CurrentSlot.Suffix, strlen(CurrentSlot.Suffix));
+		strlcpy(Info->pname, "boot", strlen("boot"));
+		strlcat(Info->pname, CurrentSlot.Suffix, strlen(CurrentSlot.Suffix));
 	}
 
 	dprintf(DEBUG, "MultiSlot %s, partition name %s\n",
diff --git a/platform/msm_shared/include/board.h b/platform/msm_shared/include/board.h
index 866fba2..90f7081 100644
--- a/platform/msm_shared/include/board.h
+++ b/platform/msm_shared/include/board.h
@@ -36,6 +36,8 @@
 #define BOARD_SOC_VERSION2     0x20000
 #define MAX_PMIC_DEVICES       SMEM_MAX_PMIC_DEVICES
 
+#define PMIC_TYPE_MASK 0xff
+
 struct board_pmic_data {
 	uint32_t pmic_type;
 	uint32_t pmic_version;
diff --git a/target/init.c b/target/init.c
index 517793d..5ec4ab6 100644
--- a/target/init.c
+++ b/target/init.c
@@ -43,8 +43,8 @@
 #include <pm_fg_adc_usr.h>
 #endif
 
-#include <partition_parser.h>
 #if VERIFIED_BOOT || VERIFIED_BOOT_2
+#include <partition_parser.h>
 #include <ab_partition_parser.h>
 #endif
 
@@ -300,7 +300,7 @@
 	}
 	return ret;
 }
-
+#if VERIFIED_BOOT || VERIFIED_BOOT_2
 int target_get_vb_version()
 {
 	if (vb_version == INVALID)
@@ -315,6 +315,12 @@
 	}
 	return vb_version;
 }
+#else
+int target_get_vb_version()
+{
+	return vb_version;
+}
+#endif
 
 #if VERIFIED_BOOT_LE
 int verified_boot_le = 1;
diff --git a/target/msm8952/init.c b/target/msm8952/init.c
index a7c3469..b748803 100644
--- a/target/msm8952/init.c
+++ b/target/msm8952/init.c
@@ -294,7 +294,7 @@
 			uint8_t pmi_rev = 0;
 			uint32_t pmi_type = 0;
 
-			pmi_type = board_pmic_target(1) & 0xffff;
+			pmi_type = board_pmic_target(1) & PMIC_TYPE_MASK;
 			if(pmi_type == PMIC_IS_PMI8950)
 			{
 				/* read pmic spare register for rev */
@@ -725,7 +725,7 @@
 uint32_t target_get_pmic()
 {
 	if (target_is_pmi_enabled()) {
-		uint32_t pmi_type = board_pmic_target(1) & 0xffff;
+		uint32_t pmi_type = board_pmic_target(1) & PMIC_TYPE_MASK;
 		if (pmi_type == PMIC_IS_PMI632)
 			return PMIC_IS_PMI632;
 		else
diff --git a/target/msm8953/include/target/display.h b/target/msm8953/include/target/display.h
index 07b3f26..a70edf1 100755
--- a/target/msm8953/include/target/display.h
+++ b/target/msm8953/include/target/display.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2015-2016, 2018, 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
@@ -66,7 +66,7 @@
 /*---------------------------------------------------------------------------*/
 #define DISPLAY_CMDLINE_PREFIX " mdss_mdp.panel="
 
-#define MIPI_FB_ADDR 0x90100000
+#define MIPI_FB_ADDR 0x90000000
 
 #define MIPI_HSYNC_PULSE_WIDTH       12
 #define MIPI_HSYNC_BACK_PORCH_DCLK   32
diff --git a/target/msm8953/init.c b/target/msm8953/init.c
index d09b5c8..2195f83 100644
--- a/target/msm8953/init.c
+++ b/target/msm8953/init.c
@@ -75,6 +75,9 @@
 #define PMIC_ARB_OWNER_ID       0
 #define TLMM_VOL_UP_BTN_GPIO    85
 
+#define PRI_PMIC_SLAVE_ID	0
+#define SEC_PMIC_SLAVE_ID	2
+
 #define FASTBOOT_MODE           0x77665500
 #define RECOVERY_MODE           0x77665502
 #define PON_SOFT_RB_SPARE       0x88F
@@ -691,7 +694,7 @@
 uint32_t target_get_pmic()
 {
 	if (target_is_pmi_enabled()) {
-		uint32_t pmi_type = board_pmic_target(1) & 0xffff;
+		uint32_t pmi_type = board_pmic_target(1) & PMIC_TYPE_MASK;
 		if (pmi_type == PMIC_IS_PMI632)
 			return PMIC_IS_PMI632;
 		else
@@ -705,12 +708,21 @@
 void pmic_reset_configure(uint8_t reset_type)
 {
 	uint32_t pmi_type;
+	uint8_t sec_reset_type = reset_type;
 
 	pmi_type = target_get_pmic();
 	if (pmi_type == PMIC_IS_PMI632)
+	{
 		pmi632_reset_configure(reset_type);
+	}
 	else
-		pm8994_reset_configure(reset_type);
+	{
+		if (reset_type == PON_PSHOLD_HARD_RESET)
+			sec_reset_type = PON_PSHOLD_SHUTDOWN;
+
+		pm8996_reset_configure(PRI_PMIC_SLAVE_ID, reset_type);
+		pm8996_reset_configure(SEC_PMIC_SLAVE_ID, sec_reset_type);
+	}
 }
 
 struct qmp_reg qmp_settings[] =