[Feature][ZXW-130]merge P50U02 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: I4f29ec5bb7c59385f23738d2b7ca84e67c100f69
diff --git a/boot/common/src/uboot/downloader/cmd_compat_read.c b/boot/common/src/uboot/downloader/cmd_compat_read.c
old mode 100644
new mode 100755
index 04c59cc..aac83a2
--- a/boot/common/src/uboot/downloader/cmd_compat_read.c
+++ b/boot/common/src/uboot/downloader/cmd_compat_read.c
@@ -33,7 +33,7 @@
 /****************************************************************************
 *							Global Function Prototypes
 ****************************************************************************/
-
+extern int g_iftype;
 
 /*******************************************************************************
  * Function:do_compat_read
@@ -74,6 +74,19 @@
 	    return -1;
 	}
 
+	if(g_nor_flag == 1)
+	{
+	    if(memcmp(par,"zloader",7) == 0) {
+			g_iftype = IF_TYPE_NOR;
+			nand_init();
+			ret = do_nor_read(part, par, offset,size); 
+			/*Çл»³õʼ»¯spi_nand*/
+			g_iftype = IF_TYPE_SPI_NAND;
+			nand_init();		
+			return ret;
+		}
+	}
+
 	if((read_boot_flashtype() == IF_TYPE_NOR) 
 		&& (strcmp((const char *)part->part_type,"nand") == 0))
 
diff --git a/boot/common/src/uboot/downloader/cmd_compat_write.c b/boot/common/src/uboot/downloader/cmd_compat_write.c
old mode 100644
new mode 100755
index 8ac27dd..f4db84f
--- a/boot/common/src/uboot/downloader/cmd_compat_write.c
+++ b/boot/common/src/uboot/downloader/cmd_compat_write.c
@@ -32,7 +32,8 @@
 /****************************************************************************
 *							Global Function Prototypes
 ****************************************************************************/
-
+extern int g_iftype;
+extern partition_table_t * g_partition_table_dl;
 /*******************************************************************************
  * Function:do_compat_write
  * Description:
@@ -70,6 +71,24 @@
         downloader_serial_write(ack, strlen(ack)+1);
 	    return -1;
 	}
+	
+#if defined (CONFIG_ZX297520V3E_VEHICLE_DC) || defined (CONFIG_ZX297520V3E_VEHICLE_DC_REF)
+	if(g_nor_flag == 1)
+	{
+        if(memcmp(par,"zloader",7) == 0)
+		{
+			g_iftype = IF_TYPE_NOR;
+			nand_init();
+			ret = do_nor_write(part, par, offset,size);	
+			/*Çл»³õʼ»¯spi_nand*/
+			g_iftype = IF_TYPE_SPI_NAND;
+			nand_init();
+			memcpy((char *)(DOWNLOADER_BUFFER_BASE+0x8000),g_partition_table_dl,4096);
+	        ret = downloader_nand_write(part, 0, 0x9000,(unsigned char *)DOWNLOADER_BUFFER_BASE);
+			return ret;
+		}
+	}
+#endif
 
 	if((read_boot_flashtype() == IF_TYPE_NOR) 
 		&& (strcmp((const char *)part->part_type,"nand") == 0))
diff --git a/boot/common/src/uboot/downloader/cmd_dl_nand.c b/boot/common/src/uboot/downloader/cmd_dl_nand.c
old mode 100644
new mode 100755
index d4b0e04..8105776
--- a/boot/common/src/uboot/downloader/cmd_dl_nand.c
+++ b/boot/common/src/uboot/downloader/cmd_dl_nand.c
@@ -96,9 +96,15 @@
 
         if(memcmp(par,"zloader",7) == 0)    /* ÏÂÔØzloader·ÖÇø£¬Í¬Ê±ÏÂÔØ·ÖÇø±í */
         {
+#if defined (CONFIG_ZX297520V3E_VEHICLE_DC) || defined (CONFIG_ZX297520V3E_VEHICLE_DC_REF)
+            memcpy((char *)(DOWNLOADER_BUFFER_BASE+0xA000),g_partition_table_dl,4096);
+            ret = downloader_nand_write(part, offset_par, 0x3000,  
+										(unsigned char *)(DOWNLOADER_BUFFER_BASE+0x8000));
+#else
             memcpy((char *)(DOWNLOADER_BUFFER_BASE+8192),g_partition_table_dl,4096);
             ret = downloader_nand_write(part, offset_par, 0x3000,  
 										(unsigned char *)DOWNLOADER_BUFFER_BASE);
+#endif
         }
 		else
 		{
@@ -275,6 +281,16 @@
         return EINVAL;	/* Invalid argument */
     }
     leftWriteLength = size;
+	
+	if(g_nor_flag == 1)
+	{
+        ret = get_nor_null_slice_flag(&null_slice_flag);
+	    if(ret)
+	    {
+			printf ("nor flash read null_slice_flag error.\n");
+			return 1; 
+	    }
+	}
 
 	if(null_slice_flag == 1)
 	{
@@ -297,8 +313,17 @@
 
         if(memcmp(par,"zloader",7) == 0)    /* ÏÂÔØzloader·ÖÇø£¬Í¬Ê±ÏÂÔØ·ÖÇø±í */
         {
-            memcpy((char *)(DOWNLOADER_BUFFER_BASE+8192),g_partition_table_dl,4096);
-            ret = downloader_nor_write( part, offset_par, 0x3000,  (unsigned char *)DOWNLOADER_BUFFER_BASE);
+			if(g_nor_flag == 1)
+			{
+			    memset((char *)(DOWNLOADER_BUFFER_BASE+0x8000), 0, 4096);
+			    memcpy((char *)(DOWNLOADER_BUFFER_BASE+0x8000),g_partition_table_dl,4096);
+                ret = downloader_nor_write( part, offset_par, 0x9000,  (unsigned char *)DOWNLOADER_BUFFER_BASE);
+			}
+			else
+			{
+			    memcpy((char *)(DOWNLOADER_BUFFER_BASE+8192),g_partition_table_dl,4096);
+                ret = downloader_nor_write( part, offset_par, 0x3000,  (unsigned char *)DOWNLOADER_BUFFER_BASE);
+            }
         }
 		else
 		{
diff --git a/boot/common/src/uboot/downloader/cmd_efuse_program.c b/boot/common/src/uboot/downloader/cmd_efuse_program.c
old mode 100644
new mode 100755
index 3f931ba..ffd2e8f
--- a/boot/common/src/uboot/downloader/cmd_efuse_program.c
+++ b/boot/common/src/uboot/downloader/cmd_efuse_program.c
@@ -243,7 +243,9 @@
 		board_type = BOARD_TYPE_ZX297520V3E64M;
 	}
 	else if((chip_flag == ZX297520V3ECOSC_GW_NYC_2G_DDR)
-			||(chip_flag == ZX297520V3ECOGG_GW_NYC_2G_DDR))
+			||(chip_flag == ZX297520V3ECOGG_GW_NYC_2G_DDR)
+			||(chip_flag == ZX297520V3ECOGG_GW_NYC_NOR_2G_DDR)
+			||(chip_flag == ZX297520V3ECOSC_GW_NYC_NOR_2G_DDR))
 	{
 		printf("chip_flag=0x%x board_type is V3E.\n", chip_flag);
 		board_type = BOARD_TYPE_ZX297520V3E256M;
diff --git a/boot/common/src/uboot/downloader/downloader_nand.c b/boot/common/src/uboot/downloader/downloader_nand.c
old mode 100644
new mode 100755
index d28cfbc..fe24aaa
--- a/boot/common/src/uboot/downloader/downloader_nand.c
+++ b/boot/common/src/uboot/downloader/downloader_nand.c
@@ -476,7 +476,7 @@
  *

  * Others:

  ********************************************************************************/

-int 	downloader_nand_write(partition_entry_t * part, uint offset,  uint size,  unchar * buffer)

+int downloader_nand_write(partition_entry_t * part, uint offset,  uint size,  unchar * buffer)

 {

 	nand_info_t * pNandInfo = NULL;

 	uint  nandPhyBase = 0;

@@ -502,24 +502,40 @@
 	

     /* רÃÅдZ-LOADʱʹÓ㬲»Ê¹ÓÃECC*/

     if( strcmp((const char *)part->part_name , "zloader") == 0 )

-    {   

-        if( size != 12*1024 )

-        {

-            printf("downloader_nand_write z-load size != 12k...\n");

-			return -1;

-        } 

-        int times = 12*1024/pNandInfo->writesize;

-        int i = 0;

+    { 

+        if(g_nor_flag == 1)

+		{

+            int times = 0x9000/pNandInfo->writesize;

+	        int i = 0;

 

-        for(; i<times; i++)

-        {

-            

-            ret += nand_write_page_with_ecc(pNandInfo, 

-											((loff_t)i*(pNandInfo->writesize)),

-											buf );

-            buf += pNandInfo->writesize;

-        }

-        

+	        for(; i<times; i++)

+	        {

+	            

+	            ret += nand_write_page_with_ecc(pNandInfo, 

+												((loff_t)i*(pNandInfo->writesize)),

+												buf );

+	            buf += pNandInfo->writesize;

+	        }

+		}

+		else

+		{

+            if( size != 12*1024 )

+	        {

+	            printf("downloader_nand_write z-load size != 12k...\n");

+				return -1;

+	        } 

+	        int times = 12*1024/pNandInfo->writesize;

+	        int i = 0;

+

+	        for(; i<times; i++)

+	        {

+	            

+	            ret += nand_write_page_with_ecc(pNandInfo, 

+												((loff_t)i*(pNandInfo->writesize)),

+												buf );

+	            buf += pNandInfo->writesize;

+	        }

+		}

     }

         

     else

diff --git a/boot/common/src/uboot/downloader/downloader_nand.h b/boot/common/src/uboot/downloader/downloader_nand.h
old mode 100644
new mode 100755
index ec638d4..806700e
--- a/boot/common/src/uboot/downloader/downloader_nand.h
+++ b/boot/common/src/uboot/downloader/downloader_nand.h
@@ -41,6 +41,7 @@
 /****************************************************************************

 * 	                         Global  Variables

 ****************************************************************************/

+extern unsigned char g_nor_flag;

 

 /****************************************************************************

 * 	                         Function Prototypes