Merge "dev: pmic: Add new API for PM8996 reset configuration"
diff --git a/dev/gcdb/display/include/panel_st7789v2_qvga_spi_cmd.h b/dev/gcdb/display/include/panel_st7789v2_qvga_spi_cmd.h
index 869f536..614e21a 100644
--- a/dev/gcdb/display/include/panel_st7789v2_qvga_spi_cmd.h
+++ b/dev/gcdb/display/include/panel_st7789v2_qvga_spi_cmd.h
@@ -157,13 +157,14 @@
 	{0x0F, st7789v2_qvga_cmd_on_cmd12, 0x00, 0},
 	{0x0F, st7789v2_qvga_cmd_on_cmd13, 0x00, 0},
 	{0x01, st7789v2_qvga_cmd_on_cmd14, 0x00, 0},
-	{0x01, st7789v2_qvga_cmd_on_cmd15, 0x78, 0},
-	{0x05, st7789v2_qvga_cmd_on_cmd16, 0x00, 0},
-	{0x05, st7789v2_qvga_cmd_on_cmd17, 0x00, 0},
 	{0x01, st7789v2_qvga_cmd_on_cmd18, 0x00, 0},
+	{0x01, st7789v2_qvga_cmd_on_cmd15, 0x78, 1},
+	{0x05, st7789v2_qvga_cmd_on_cmd16, 0x00, 1},
+	{0x05, st7789v2_qvga_cmd_on_cmd17, 0x00, 1},
+	{0x01, st7789v2_qvga_cmd_on_cmd18, 0x00, 1},
 };
 
-#define ST7789v2_QVGA_CMD_ON_COMMAND 19
+#define ST7789v2_QVGA_CMD_ON_COMMAND 20
 
 
 static char st7789v2_qvga_cmdoff_cmd0[] = {
diff --git a/platform/msm_shared/display.c b/platform/msm_shared/display.c
index cf4db48..780ecfc 100644
--- a/platform/msm_shared/display.c
+++ b/platform/msm_shared/display.c
@@ -257,6 +257,9 @@
 		ret = mdss_spi_on(pinfo, &(panel->fb));
 		if (ret)
 			goto msm_display_on_out;
+		ret = mdss_spi_cmd_post_on(pinfo);
+		if (ret)
+			goto msm_display_on_out;
 		break;
 #endif
 #ifdef DISPLAY_TYPE_QPIC
diff --git a/platform/msm_shared/include/mdp4.h b/platform/msm_shared/include/mdp4.h
index 8bbb3a7..b27e363 100644
--- a/platform/msm_shared/include/mdp4.h
+++ b/platform/msm_shared/include/mdp4.h
@@ -128,4 +128,5 @@
 int mdss_spi_init(void);
 int mdss_spi_panel_init(struct msm_panel_info *pinfo);
 int mdss_spi_on(struct msm_panel_info *pinfo, struct fbcon_config *fb);
+int mdss_spi_cmd_post_on(struct msm_panel_info *pinfo);
 #endif
diff --git a/platform/msm_shared/mdss_spi.c b/platform/msm_shared/mdss_spi.c
index 4819478..4cd5d4b 100644
--- a/platform/msm_shared/mdss_spi.c
+++ b/platform/msm_shared/mdss_spi.c
@@ -171,3 +171,32 @@
 
 	return ret;
 }
+
+int mdss_spi_cmd_post_on(struct msm_panel_info *pinfo)
+{
+	int cmd_count = 0;
+	char *payload;
+
+	if (!dev) {
+		dprintf(CRITICAL, "SPI has not been initialized\n");
+		return -ENODEV;
+	}
+
+	while (cmd_count < pinfo->spi.num_of_panel_cmds) {
+		if (pinfo->spi.panel_cmds[cmd_count].cmds_post_tg){
+			payload = pinfo->spi.panel_cmds[cmd_count].payload;
+			mdss_spi_write_cmd(payload);
+			if (pinfo->spi.panel_cmds[cmd_count].size > 1)
+				mdss_spi_write_data(payload + 1,
+					pinfo->spi.panel_cmds[cmd_count].size
+						- 1);
+
+			if (pinfo->spi.panel_cmds[cmd_count].wait)
+				mdelay(pinfo->spi.panel_cmds[cmd_count].wait);
+		}
+
+		cmd_count ++;
+	}
+
+	return SUCCESS;
+}
diff --git a/platform/msm_shared/qseecom_lk.c b/platform/msm_shared/qseecom_lk.c
index 717c2a5..d385fd5 100644
--- a/platform/msm_shared/qseecom_lk.c
+++ b/platform/msm_shared/qseecom_lk.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2015,2017 The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2015,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 are
@@ -47,7 +47,7 @@
 #define MAX_SCM_ARGS 10
 #define N_EXT_SCM_ARGS 7
 #define FIRST_EXT_ARG_IDX 3
-
+#define MAX_TA_PARTITION_SIZE 0x00100000
 #define N_REGISTER_ARGS (MAX_SCM_ARGS - N_EXT_SCM_ARGS + 1)
 
 #define QSEE_LOG_BUF_SIZE (4096)
@@ -551,7 +551,7 @@
 	int index = INVALID_PTN;
 	unsigned long long ptn = 0;
 	unsigned long long size = 0;
-	unsigned long long rounded_size = 0;
+	unsigned long rounded_size = 0;
 	void *buf = NULL;
 	void *req = NULL;
 	struct qseecom_load_app_ireq load_req = {0};
@@ -569,8 +569,8 @@
 	mmc_set_lun(lun);
 
 	size = partition_get_size(index);
-	if ((ULLONG_MAX - PAGE_SIZE + 1) < size) {
-		dprintf(CRITICAL, "Integer overflow detected in rounding up the partition size!");
+	if (MAX_TA_PARTITION_SIZE < size) {
+		dprintf(CRITICAL, "Invalid TA partition size!");
 		ret = GENERIC_ERROR;
 		goto err;
 	}
@@ -626,7 +626,7 @@
 	int index = INVALID_PTN;
 	unsigned long long ptn = 0;
 	unsigned long long size = 0;
-	unsigned long long rounded_size = 0;
+	unsigned  long rounded_size = 0;
 	void *buf = NULL;
 	void *req = NULL;
 	struct qseecom_load_app_ireq load_req = {0};
@@ -640,8 +640,8 @@
 	mmc_set_lun(lun);
 
 	size = partition_get_size(index);
-	if ((ULLONG_MAX - PAGE_SIZE + 1) < size) {
-		dprintf(CRITICAL, "Integer overflow detected in rounding up the partition size!");
+	if (MAX_TA_PARTITION_SIZE < size) {
+		dprintf(CRITICAL, "Invalid cmnlib partition size!");
 		ret = GENERIC_ERROR;
 		goto err;
 	}
diff --git a/target/target_display.c b/target/target_display.c
index d32e90d..ff0bff8 100644
--- a/target/target_display.c
+++ b/target/target_display.c
@@ -146,3 +146,8 @@
 {
 	return 0;
 }
+
+__WEAK int mdss_spi_cmd_post_on(struct msm_panel_info *pinfo)
+{
+	return 0;
+}