[Feature][ZXW-88]merge P50 version

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

Change-Id: I34667719d9e0e7e29e8e4368848601cde0a48408
diff --git a/boot/common/src/uboot/drivers/misc/boot_mode.c b/boot/common/src/uboot/drivers/misc/boot_mode.c
index fafe3c7..2408bbc 100755
--- a/boot/common/src/uboot/drivers/misc/boot_mode.c
+++ b/boot/common/src/uboot/drivers/misc/boot_mode.c
@@ -30,7 +30,7 @@
 
 #define NVRWALL_PATH "/nvrwall.bin"
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 extern int imagefs_flag;
 #endif
 
@@ -47,7 +47,7 @@
 	char cmd[64] = {0};
 
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
     if(imagefs_flag == 1)
 	    sprintf(cmd, "fsload imagefs 0x%x %s", (ulong)CONFIG_SYS_SDRAM_TEMP_BASE, NVRWALL_PATH);
 	else
diff --git a/boot/common/src/uboot/drivers/misc/load.c b/boot/common/src/uboot/drivers/misc/load.c
index c44dc9b..bbb6c27 100755
--- a/boot/common/src/uboot/drivers/misc/load.c
+++ b/boot/common/src/uboot/drivers/misc/load.c
@@ -31,6 +31,7 @@
 #include <asm/arch/cpu.h>
 #include <secure_verify.h>
 #include <linux/mtd/nor_spifc.h>
+#include "pub_flags.h"
 
 #if	LOAD_IMAGE_DEBUG
 #define load_debug_printf(fmt,args...)	printf (fmt ,##args)
@@ -66,7 +67,7 @@
 #endif
 
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 extern int imagefs_flag;
 static uint32_t flags;
 #endif
@@ -305,12 +306,12 @@
 	return 0;
 }
 
-#ifdef CONFIG_ZX297520V3E_VEHICLE_DC
+#if defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 int fs_load_dtb_image(void)
 {
     char    cmd[64] = {0};
     /*1¡¢½«dtbÎļþloadµ½ÁÙʱµØÖ·*/
-#ifdef CONFIG_ZX297520V3E_VEHICLE_DC
+#if defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
     if(imagefs_flag == 1)
 		sprintf(cmd, "fsload imagefs 0x%x %s", (ulong)CONFIG_SYS_SDRAM_TEMP_BASE, DTB_IMAGE_PATH);
 	else
@@ -342,7 +343,7 @@
 
 	/*1¡¢½«m0 imgÎļþloadµ½ÁÙʱµØÖ·*/
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
     if(imagefs_flag == 1)
 		sprintf(cmd, "fsload imagefs 0x%x %s", (ulong)CONFIG_SYS_SDRAM_TEMP_BASE, M0_IMAGE_PATH);
 	else
@@ -427,7 +428,7 @@
 	{
 		/* ½«zsp imgÎļþloadµ½ÁÙʱµØÖ·*/
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)  || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
         if(imagefs_flag == 1)
 		    sprintf(cmd, "fsload imagefs 0x%x cpuphy_%02d.lzma", 
 				(ulong)CONFIG_SYS_SDRAM_TEMP_BASE, 
@@ -529,7 +530,7 @@
 	{
 		/*1¡¢½«ap imgÎļþloadµ½ÁÙʱµØÖ·*/
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
         if(imagefs_flag == 1)
 			sprintf(cmd, "fsload imagefs 0x%x /%s_%02d.lzma", 
 				(ulong)CONFIG_SYS_SDRAM_TEMP_BASE, image_name, apimagenum);
@@ -683,7 +684,7 @@
 	BOOT_PRINTF(UBOOT_NOTICE, "zsp image load begin...\n");
 	image_tmp_buf = CONFIG_SYS_SDRAM_TEMP_BASE;
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 	if(imagefs_flag == 1)
         sprintf(cmd, "fsload imagefs 0x%x %s", (ulong)image_tmp_buf, ZSP_IMAGE_PATH);
 	else
@@ -721,7 +722,7 @@
 
 	/*1¡¢½«ap imgÎļþloadµ½ÁÙʱµØÖ·*/
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 	if(imagefs_flag == 1)
 		sprintf(cmd, "fsload imagefs 0x%x /ap_%s.bin", 
 				(ulong)CONFIG_SYS_SDRAM_TEMP_BASE, image_name);
@@ -890,8 +891,8 @@
 }
 
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
-int load_flags(T_FOTA_FLAG_INFO *fotaFlagInfo)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
+int load_flags(T_FLAGS_INFO *fotaFlagInfo)
 {
 	int ret = 0;
 	int type = 0;
@@ -907,7 +908,7 @@
 	uint32_t work_area_offset = 0;
 	uint32_t backup_area_offset = 0;
 	uint32_t flag_one = 0;
-	uint32_t  fota_size = sizeof(T_FOTA_FLAG_INFO);
+	uint32_t  fota_size = sizeof(T_FLAGS_INFO);
 	nand_info_t *nand = &nand_info[nand_curr_device];
 	struct fsl_qspi *nor = &spi_nor_flash;
 
@@ -966,7 +967,7 @@
 			return 1;
 		}
 		
-		if(fotaFlagInfo->boot_flag.magic != FLAGS_MAGIC)
+		if(fotaFlagInfo->magic_start != FLAGS_MAGIC)
 		{	
 			flush_dcache_all();
 			ret = flash->read(nand,(loff_t)backup_area_offset,
@@ -978,7 +979,7 @@
 				return -1;
 			}
 			
-			if(fotaFlagInfo->boot_flag.magic != FLAGS_MAGIC)
+			if(fotaFlagInfo->magic_start != FLAGS_MAGIC)
 			{
 	            printf("flags magic err.\n");
 			    return -1;
@@ -996,7 +997,7 @@
 			BOOT_PRINTF(UBOOT_ERR, "[%s]: read the flags error!\n", part_name);
 			return -1;
 		}
-		if(fotaFlagInfo->boot_flag.magic != FLAGS_MAGIC)
+		if(fotaFlagInfo->magic_start != FLAGS_MAGIC)
 		{
             flush_dcache_all();
 			ret = nand_read(&(nor->nor[0].mtd), (loff_t)backup_area_offset, 
@@ -1008,7 +1009,7 @@
 				return -1;
 			}
 			
-			if(fotaFlagInfo->boot_flag.magic != FLAGS_MAGIC)
+			if(fotaFlagInfo->magic_start != FLAGS_MAGIC)
 			{
 	            printf("flags magic err.\n");
 			    return -1;
@@ -1033,7 +1034,7 @@
 {
 	char cmd[64] = {0};
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 	if(imagefs_flag == 1)
 	    sprintf(cmd, "fsload imagefs 0x%x %s", (ulong)CONFIG_SYS_SDRAM_TEMP_BASE, FOTAFLAG_PATH);
 	else
diff --git a/boot/common/src/uboot/drivers/mtd/partition/partition.c b/boot/common/src/uboot/drivers/mtd/partition/partition.c
index 80b0362..0da27ea 100755
--- a/boot/common/src/uboot/drivers/mtd/partition/partition.c
+++ b/boot/common/src/uboot/drivers/mtd/partition/partition.c
@@ -52,7 +52,7 @@
 extern partition_table_t * g_partition_table_dl;
 extern struct fsl_qspi spi_nor_flash;
 //#ifdef CONFIG_ZX297520V3E_MDL_AB
-#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+#if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
 extern int imagefs_flag;
 #endif
 
@@ -60,7 +60,7 @@
  *  add_partition_to_bootargs  :  Ôö¼Ó·ÖÇøÐÅÏ¢µ½ bootargs
  */
 // #ifdef CONFIG_ZX297520V3E_MDL_AB
- #if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC)
+ #if defined(CONFIG_ZX297520V3E_MDL_AB) || defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)
  void add_partition_to_bootargs( void )
 {
 	int ret = 0;
@@ -192,20 +192,30 @@
 
 	if(imagefs_flag == 1)    
    	{
+#ifdef DM_VERITY
+        sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " system=system_a");
+		sprintf((char *)bootargs_cmd_cap + strlen(bootargs_cmd_cap), " system=system_a");
+#else
 		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " system=system_a");
 		sprintf((char *)bootargs_cmd_cap + strlen(bootargs_cmd_cap), " system=system_a ubi.mtd=caprootfs");
+#endif
 	}
 	else if(imagefs_flag == 2)   
 	{
+#ifdef DM_VERITY
+		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " system=system_b");
+		sprintf((char *)bootargs_cmd_cap + strlen(bootargs_cmd_cap), " system=system_b");
+#else
 		sprintf((char *)bootargs_cmd + strlen(bootargs_cmd), " system=system_b");
 		sprintf((char *)bootargs_cmd_cap + strlen(bootargs_cmd_cap), " system=system_b ubi.mtd=caprootfs2");
+#endif
 	}	
 
 	/* save */
 	setenv("bootargs", (char *)bootargs_cmd);
 	setenv("bootargs_cap", (char *)bootargs_cmd_cap);
 }
- #else
+#else
 void add_partition_to_bootargs( void )
 {
 	int ret = 0;
diff --git a/boot/common/src/uboot/drivers/peripheral/Makefile b/boot/common/src/uboot/drivers/peripheral/Makefile
index 8ecd566..103b373 100755
--- a/boot/common/src/uboot/drivers/peripheral/Makefile
+++ b/boot/common/src/uboot/drivers/peripheral/Makefile
@@ -41,6 +41,7 @@
 COBJS-$(CONFIG_ZX297520V3E_UFI_MINI)	+= peripheral.o
 COBJS-$(CONFIG_ZX297520V3E_MDL_AB)	+= peripheral.o
 COBJS-$(CONFIG_ZX297520V3E_VEHICLE_DC)	+= peripheral.o
+COBJS-$(CONFIG_ZX297520V3E_VEHICLE_DC_REF)	+= peripheral.o
 
 COBJS	:= $(sort $(COBJS-y))
 SRCS	:= $(COBJS:.o=.c)
diff --git a/boot/common/src/uboot/drivers/peripheral/peripheral.c b/boot/common/src/uboot/drivers/peripheral/peripheral.c
index 4394c7b..3646130 100755
--- a/boot/common/src/uboot/drivers/peripheral/peripheral.c
+++ b/boot/common/src/uboot/drivers/peripheral/peripheral.c
@@ -25,6 +25,7 @@
 #include <linux/types.h>

 #include <zx234290.h>

 #include <led.h>

+#include <drvs_gpio.h>

 #include "common.h"

 //#include <gpio.h>

 

@@ -68,34 +69,32 @@
 

 /*lcd*/

 

-	/* jtagµ÷ÊÔ */

+	/* jtag调试 */

 #if 0

 	jtag_init();

 #endif

 

 //#if 0//ref need ldo8 2.85V

-#ifdef CONFIG_ZX297520V3E_VEHICLE_DC

+#if defined(CONFIG_ZX297520V3E_VEHICLE_DC) || defined(CONFIG_ZX297520V3E_VEHICLE_DC_REF)

 /*set mmc io and vccQ*/	

 	zx234290_set_ldo8_voltage(VLDOD_1_800);

 	zx234290_set_ldo8_sleep_voltage(VLDOD_1_800);

 	zx234290_ldo8_enable(1);

 	

 	REG32(SD1_IO_1V8_EN) |=(1<<1);

-#endif

 //xf.li@20230412 add for enable GNSS start

-#if 1 //enable GNSS

 	REG32(ZX_TOP_CRM_BASE + 0x34) |= (0x1<<5);

 	zDrvGpio_SetFunc(GPIO15,GPIO15_CLK_OUT0);

-

-	zDrvGpio_SetFunc(GPIO86,GPIO86_GPIO86);

-	zDrvGpio_SetDirection(GPIO86,GPIO_OUT);

-	zDrvGpio_SetOutputValue(GPIO86,GPIO_HIGH);

+	/*关闭gps电源*/

+	zDrvGpio_SetFunc(GPIO86, GPIO86_GPIO86);

+	zDrvGpio_SetDirection(GPIO86, GPIO_OUT);

+	zDrvGpio_SetOutputValue(GPIO86, GPIO_LOW);

 

 	zDrvGpio_SetFunc(GPIO126,GPIO126_GPIO126);

 	zDrvGpio_SetDirection(GPIO126,GPIO_OUT);

 	zDrvGpio_SetOutputValue(GPIO126,GPIO_LOW);

-#endif

 //xf.li@20230412 add for enable GNSS end

+#endif

 	zx234502_charger_enable();

 

 	return ret ;