[Feature][ZXW-285]merge P56U05 version

Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No

Change-Id: Ied657102425a179a89ef41847170152e8a5d437c
diff --git a/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_mdl_ab.c b/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_mdl_ab.c
index 50140b7..bf9a900 100755
--- a/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_mdl_ab.c
+++ b/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_mdl_ab.c
@@ -611,11 +611,16 @@
 	
 	if(bootFlags == DUALSYSTEM_STATUS_UNBOOTABLE)
 	{
+#ifdef CONFIG_FORBIDDEN_ROLLBACK
+	    printf("DUALSYSTEM is unbootable.\n");
+        BUG();
+#else
         ret = writeback_flags();
 		if(ret != 0)
 			return -1;
 		system_reset();
 		return 0;
+#endif
 	}
 	else if(bootFlags == DUALSYSTEM_STATUS_BOOTABLE)
 	{
@@ -623,10 +628,15 @@
 	}
 	else if(bootFlags == FLAGS_PARTITION_ERROR)
 	{
+#ifdef CONFIG_FORBIDDEN_ROLLBACK
+		printf("flags partition is err.\n");
+		BUG();
+#else
 		ret = rewrite_flags();
 		if(ret != 0)
 			return -1;
 		return 0;
+#endif
 	}
 }
 
@@ -721,7 +731,10 @@
 #if VERSION_RELEASE
 	if( ret != 0 )
 	{
-		BOOT_PRINTF(UBOOT_ERR, "load images ERROR !!!\n");
+		BOOT_PRINTF(UBOOT_ERR, "load imagefs ERROR !!!\n");
+#ifdef CONFIG_FORBIDDEN_ROLLBACK
+		BUG();
+#endif
 #ifdef CONFIG_ZX297520V3E_MDL_AB
         writeback_flags();
 		system_reset();
diff --git a/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc.c b/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc.c
index bc89988..2f9dde8 100755
--- a/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc.c
+++ b/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc.c
@@ -612,11 +612,16 @@
 	
 	if(bootFlags == DUALSYSTEM_STATUS_UNBOOTABLE)
 	{
+#ifdef CONFIG_FORBIDDEN_ROLLBACK
+	    printf("DUALSYSTEM is unbootable.\n");
+        BUG();
+#else
         ret = writeback_flags();
 		if(ret != 0)
 			return -1;
 		system_reset();
 		return 0;
+#endif
 	}
 	else if(bootFlags == DUALSYSTEM_STATUS_BOOTABLE)
 	{
@@ -624,10 +629,15 @@
 	}
 	else if(bootFlags == FLAGS_PARTITION_ERROR)
 	{
+#ifdef CONFIG_FORBIDDEN_ROLLBACK
+		printf("flags partition is err.\n");
+		BUG();
+#else
 		ret = rewrite_flags();
 		if(ret != 0)
 			return -1;
 		return 0;
+#endif
 	}
 }
 
@@ -735,7 +745,10 @@
 #if VERSION_RELEASE
 	if( ret != 0 )
 	{
-		BOOT_PRINTF(UBOOT_ERR, "load images ERROR !!!\n");
+		BOOT_PRINTF(UBOOT_ERR, "load imagefs ERROR !!!\n");
+#ifdef CONFIG_FORBIDDEN_ROLLBACK
+		BUG();
+#endif
 #ifdef CONFIG_ZX297520V3E_VEHICLE_DC
         writeback_flags();
 		system_reset();
diff --git a/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc_ref.c b/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc_ref.c
index 10c8b7b..934a087 100755
--- a/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc_ref.c
+++ b/boot/common/src/uboot/board/zte/zx297520v3/zx297520v3_vehicle_dc_ref.c
@@ -612,11 +612,16 @@
 	
 	if(bootFlags == DUALSYSTEM_STATUS_UNBOOTABLE)
 	{
+#ifdef CONFIG_FORBIDDEN_ROLLBACK
+	    printf("DUALSYSTEM is unbootable.\n");
+        BUG();
+#else
         ret = writeback_flags();
 		if(ret != 0)
 			return -1;
 		system_reset();
 		return 0;
+#endif
 	}
 	else if(bootFlags == DUALSYSTEM_STATUS_BOOTABLE)
 	{
@@ -624,10 +629,15 @@
 	}
 	else if(bootFlags == FLAGS_PARTITION_ERROR)
 	{
+#ifdef CONFIG_FORBIDDEN_ROLLBACK
+		printf("flags partition is err.\n");
+		BUG();
+#else
 		ret = rewrite_flags();
 		if(ret != 0)
 			return -1;
 		return 0;
+#endif
 	}
 }
 
@@ -736,6 +746,10 @@
 	if( ret != 0 )
 	{
 		BOOT_PRINTF(UBOOT_ERR, "load imagefs ERROR !!!\n");
+#ifdef CONFIG_FORBIDDEN_ROLLBACK
+		BUG();
+#endif
+
 #ifdef CONFIG_ZX297520V3E_VEHICLE_DC_REF
         writeback_flags();
 		system_reset();
diff --git a/boot/common/src/uboot/drivers/mtd/partition/partition.c b/boot/common/src/uboot/drivers/mtd/partition/partition.c
index 89105cc..a6eb7e3 100755
--- a/boot/common/src/uboot/drivers/mtd/partition/partition.c
+++ b/boot/common/src/uboot/drivers/mtd/partition/partition.c
@@ -57,7 +57,7 @@
 extern struct fsl_qspi spi_nor_flash;
 extern unsigned int guiOtpStatus;
 extern unsigned int guiEfuseStatus;
-
+extern unsigned int g_pmu_type;
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
 #if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 extern int imagefs_flag;
@@ -281,6 +281,9 @@
 		sprintf((char *)bootargs_cmd_cap + strlen(bootargs_cmd_cap), " system=system_b ubi.mtd=caprootfs2");
 #endif
 	}	
+	
+	sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " pmu_type=%d", g_pmu_type);
+	sprintf((char *)bootargs_cmd_cap + strlen(bootargs_cmd_cap), " pmu_type=%d", g_pmu_type);
 
 	/* save */
 	setenv("bootargs", (char *)bootargs_cmd);
diff --git a/boot/common/src/uboot/drivers/power/zx234290.c b/boot/common/src/uboot/drivers/power/zx234290.c
index e8f083f..6e82f81 100755
--- a/boot/common/src/uboot/drivers/power/zx234290.c
+++ b/boot/common/src/uboot/drivers/power/zx234290.c
@@ -36,6 +36,7 @@
 #define GPIO_PSHOLD_FUNC_SEL    GPIO24_GPIO24
 
 static boot_reason_t s_boot_reason = UNKNOWN_BOOT_REASON;
+unsigned int g_pmu_type = PMU_TYPE_MAX;
 
 /*******************************************************************************
  * Function:    zx234290_i2c_read_reg
@@ -394,6 +395,7 @@
 {
     int ret = 0;
 	uchar reg_val = 0;
+	uchar reg_val1 = 0;
     struct pmu_opt pmu = {NULL};
 
     /* GPIO init */
@@ -420,6 +422,7 @@
 
 	ret = zx234290_get_boot_reason_prev();
 	ret +=zx234290_i2c_read_reg(ZX234297_REG_ADDR_SINK_CONTROL,&reg_val);
+	ret +=zx234290_i2c_read_reg(ZX234290_REG_ADDR_TYPE,&reg_val1);
 	if(reg_val==0x7f){//means 296G C
 		reg_val = 0xff;//define to 296
 		ret+=zx234290_i2c_write_reg(ZX234297_REG_ADDR_SINK_CONTROL,&reg_val);
@@ -428,8 +431,23 @@
 	if (ret != SUCCESS)
 	{
 		printf( "[%s]set 0x29 error ret=0x%x!\n", __FUNCTION__,ret);
+		return ret;
 	}
 	
+	if(0xff == reg_val)//296&296G
+	{
+		if(0==reg_val1)
+			g_pmu_type = PMU_TYPE_296G;
+		else
+			g_pmu_type = PMU_TYPE_296;			
+	}
+	else//297
+	{
+		if(0==reg_val1)
+			g_pmu_type = PMU_TYPE_296H;
+		else
+			g_pmu_type = PMU_TYPE_297;			
+	}
     return ret;
 }
 
diff --git a/boot/common/src/uboot/include/zx234290.h b/boot/common/src/uboot/include/zx234290.h
index d0dc5a7..2bfe209 100755
--- a/boot/common/src/uboot/include/zx234290.h
+++ b/boot/common/src/uboot/include/zx234290.h
@@ -94,6 +94,7 @@
 /* sink control */
 #define ZX234297_REG_ADDR_SINK_CONTROL	0x29
 #define ZX234290_REG_ADDR_LDO_EN2		0x22	/* [xx xx]BUCK4-1, [0xx0]LDO10-9*/
+#define ZX234290_REG_ADDR_TYPE			0xb0	/*used for pmu type*/
 
 /* 0x22 */
 #define ZX234297_SINK1_ON_LSH			(2)
@@ -104,6 +105,12 @@
 #define ZX234297_SINK2_CURRENT_LSH		(4)
 #define ZX234297_SINK_CURRENT_WID		(4)
 
+#define PMU_TYPE_296	1
+#define PMU_TYPE_296G	2
+#define PMU_TYPE_297	3
+#define PMU_TYPE_296H	4
+#define PMU_TYPE_MAX	0xf
+
 typedef enum _T_ZX234290_SINK
 {
 	SINK_1 = 0,