Merge change Icc8272ed

* changes:
  [msm] Update Copyright markings
diff --git a/platform/msm7x30/ebi.c b/platform/msm7x30/ebi.c
new file mode 100644
index 0000000..d839431
--- /dev/null
+++ b/platform/msm7x30/ebi.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010, Code Aurora Forum. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *   * Neither the name of Code Aurora nor
+ *     the names of its contributors may be used to endorse or promote
+ *     products derived from this software without specific prior written
+ *     permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <reg.h>
+
+#define EBI2_CHIP_SELECT_CFG0 0xA0000000
+#define EBI2_XMEM_CS5_CFG0 0xA001001C
+
+void ebi2_init(void)
+{
+	uint32_t val;
+
+	/* Configure CS 5 and 6 for Eth and FPGA */
+	val = readl(EBI2_CHIP_SELECT_CFG0);
+	val |= 0xB01;
+	writel(val, EBI2_CHIP_SELECT_CFG0);
+
+	/* Add waitstates for SMC9221 access */
+	writel(0x330707FF, EBI2_XMEM_CS5_CFG0);
+}
+
diff --git a/platform/msm7x30/platform.c b/platform/msm7x30/platform.c
index 672d259..ecb7b2c 100644
--- a/platform/msm7x30/platform.c
+++ b/platform/msm7x30/platform.c
@@ -42,6 +42,8 @@
 void uart3_clock_init(void);
 void uart_init(void);
 
+void ebi2_init(void);
+
 struct fbcon_config *lcdc_init(void);
 
 void platform_early_init(void)
@@ -59,6 +61,7 @@
 
 	dprintf(INFO, "platform_init()\n");
 	acpu_clock_init();
+	ebi2_init();
 }
 
 void display_init(void)
diff --git a/platform/msm7x30/rules.mk b/platform/msm7x30/rules.mk
index 237c469..9ab8815 100644
--- a/platform/msm7x30/rules.mk
+++ b/platform/msm7x30/rules.mk
@@ -18,7 +18,8 @@
 	$(LOCAL_DIR)/interrupts.o \
 	$(LOCAL_DIR)/gpio.o \
 	$(LOCAL_DIR)/acpuclock.o \
-	$(LOCAL_DIR)/lcdc.o
+	$(LOCAL_DIR)/lcdc.o \
+	$(LOCAL_DIR)/ebi.o
 
 LINKER_SCRIPT += $(BUILDDIR)/system-onesegment.ld
 
diff --git a/platform/msm_shared/nand.c b/platform/msm_shared/nand.c
index 30dd3b9..6e5a86f 100755
--- a/platform/msm_shared/nand.c
+++ b/platform/msm_shared/nand.c
@@ -132,7 +132,7 @@
 	{0x004000ec, 0xFFFFFFFF, (256<<20), 0, 2048, (2048<<6), 64, 1}, /*Sams*/
 	{0x005c00ec, 0xFFFFFFFF, (256<<20), 0, 2048, (2048<<6), 64, 1}, /*Sams*/
 	{0x005800ec, 0xFFFFFFFF, (256<<20), 0, 2048, (2048<<6), 64, 1}, /*Sams*/
-	{0x6600bcec, 0xFF00FFFF, (1024<<20), 1, 4096, (4096<<6), 128, 0}, /*Sams*/
+	{0x6600bcec, 0xFF00FFFF, (512<<20), 1, 4096, (2048<<6), 128, 0}, /*Sams*/
 	/* Note: Width flag is 0 for 8 bit Flash and 1 for 16 bit flash	  */
 	/* Note: Onenand flag is 0 for NAND Flash and 1 for OneNAND flash	*/
 	/* Note: The First row will be filled at runtime during ONFI probe	*/
diff --git a/target/msm7627_ffa/init.c b/target/msm7627_ffa/init.c
index 2d8ac25..16c3c8a 100644
--- a/target/msm7627_ffa/init.c
+++ b/target/msm7627_ffa/init.c
@@ -39,6 +39,10 @@
 
 #define LINUX_MACHTYPE  1007015
 
+#define VARIABLE_LENGTH        0x10101010
+#define DIFF_START_ADDR        0xF0F0F0F0
+#define NUM_PAGES_PER_BLOCK    0x40
+
 static struct ptable flash_ptable;
 
 /* for these partitions, start will be offset by either what we get from
@@ -67,13 +71,18 @@
 	},
 	{
 		.start = 704,
-		.length = 40 /* 5MB */,
-		.name = "recovery",
+		.length = VARIABLE_LENGTH,
+		.name = "userdata",
 	},
 	{
-		.start = 744,
-		.length = 720 /* 90MB */,
-		.name = "userdata",
+		.start = DIFF_START_ADDR,
+		.length = 8 /* 1MB */,
+		.name = "persist",
+	},
+	{
+		.start = DIFF_START_ADDR,
+		.length = 40 /* 5MB */,
+		.name = "recovery",
 	},
 };
 static int num_parts = sizeof(board_part_list)/sizeof(struct ptentry);
@@ -89,6 +98,9 @@
 {
 	unsigned offset;
 	struct flash_info *flash_info;
+	unsigned total_num_of_blocks;
+	bool  start_addr_changed = false;
+	unsigned next_ptr_start_adr = 0;
 	int i;
 
 	dprintf(INFO, "target_init()\n");
@@ -112,12 +124,33 @@
 	if (offset == 0xffffffff)
 	        while(1);
 
+	total_num_of_blocks = (flash_info->block_size)/NUM_PAGES_PER_BLOCK;
+
 	for (i = 0; i < num_parts; i++) {
 		struct ptentry *ptn = &board_part_list[i];
 		unsigned len = ptn->length;
 
-		if ((len == 0) && (i == num_parts - 1))
-			len = flash_info->num_blocks - offset - ptn->start;
+		if(len == VARIABLE_LENGTH)
+		{
+		        start_addr_changed = true;
+			unsigned length_for_prt = 0;
+			unsigned j;
+			for (j = i+1; j < num_parts; j++)
+			{
+			        struct ptentry *temp_ptn = &board_part_list[j];
+			        ASSERT(temp_ptn->length != VARIABLE_LENGTH);
+			        length_for_prt += temp_ptn->length;
+			}
+		        len = (total_num_of_blocks - 1) - (offset + ptn->start + length_for_prt);
+			ASSERT(len >= 0);
+		        next_ptr_start_adr = ptn->start + len;
+		}
+		if((ptn->start == DIFF_START_ADDR) && (start_addr_changed))
+		{
+		        ASSERT(next_ptr_start_adr);
+			ptn->start = next_ptr_start_adr;
+			next_ptr_start_adr = ptn->start + ptn->length;
+		}
 		ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
 			   len, ptn->flags);
 	}
diff --git a/target/msm7627_surf/init.c b/target/msm7627_surf/init.c
index d198fe3..0d56db5 100644
--- a/target/msm7627_surf/init.c
+++ b/target/msm7627_surf/init.c
@@ -39,6 +39,10 @@
 
 #define LINUX_MACHTYPE  1007014
 
+#define VARIABLE_LENGTH        0x10101010
+#define DIFF_START_ADDR        0xF0F0F0F0
+#define NUM_PAGES_PER_BLOCK    0x40
+
 static struct ptable flash_ptable;
 
 /* for these partitions, start will be offset by either what we get from
@@ -67,13 +71,18 @@
 	},
 	{
 		.start = 704,
-		.length = 40 /* 5MB */,
-		.name = "recovery",
+		.length = VARIABLE_LENGTH,
+		.name = "userdata",
 	},
 	{
-		.start = 744,
-		.length = 720 /* 90MB */,
-		.name = "userdata",
+		.start = DIFF_START_ADDR,
+		.length = 8 /* 1MB */,
+		.name = "persist",
+	},
+	{
+		.start = DIFF_START_ADDR,
+		.length = 40 /* 5MB */,
+		.name = "recovery",
 	},
 };
 static int num_parts = sizeof(board_part_list)/sizeof(struct ptentry);
@@ -89,6 +98,9 @@
 {
 	unsigned offset;
 	struct flash_info *flash_info;
+	unsigned total_num_of_blocks;
+	bool  start_addr_changed = false;
+	unsigned next_ptr_start_adr = 0;
 	int i;
 
 	dprintf(INFO, "target_init()\n");
@@ -112,12 +124,33 @@
 	if (offset == 0xffffffff)
 	        while(1);
 
+	total_num_of_blocks = (flash_info->block_size)/NUM_PAGES_PER_BLOCK;
+
 	for (i = 0; i < num_parts; i++) {
 		struct ptentry *ptn = &board_part_list[i];
 		unsigned len = ptn->length;
 
-		if ((len == 0) && (i == num_parts - 1))
-			len = flash_info->num_blocks - offset - ptn->start;
+		if(len == VARIABLE_LENGTH)
+		{
+		        start_addr_changed = true;
+			unsigned length_for_prt = 0;
+			unsigned j;
+			for (j = i+1; j < num_parts; j++)
+			{
+			        struct ptentry *temp_ptn = &board_part_list[j];
+			        ASSERT(temp_ptn->length != VARIABLE_LENGTH);
+			        length_for_prt += temp_ptn->length;
+			}
+		        len = (total_num_of_blocks - 1) - (offset + ptn->start + length_for_prt);
+			ASSERT(len >= 0);
+		        next_ptr_start_adr = ptn->start + len;
+		}
+		if((ptn->start == DIFF_START_ADDR) && (start_addr_changed))
+		{
+		        ASSERT(next_ptr_start_adr);
+			ptn->start = next_ptr_start_adr;
+			next_ptr_start_adr = ptn->start + ptn->length;
+		}
 		ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
 			   len, ptn->flags);
 	}
diff --git a/target/msm7630_surf/init.c b/target/msm7630_surf/init.c
index 1f1136c..2ad8fb2 100644
--- a/target/msm7630_surf/init.c
+++ b/target/msm7630_surf/init.c
@@ -51,6 +51,10 @@
     HW_PLATFORM_32BITS  = 0x7FFFFFFF
 };
 
+#define VARIABLE_LENGTH        0x10101010
+#define DIFF_START_ADDR        0xF0F0F0F0
+#define NUM_PAGES_PER_BLOCK    0x40
+
 static struct ptable flash_ptable;
 
 /* for these partitions, start will be offset by either what we get from
@@ -69,24 +73,29 @@
 	},
 	{
 		.start = 20,
-		.length = 320 /* 80MB */,
+		.length = 340 /* 85MB */,
 		.name = "system",
 	},
 	{
-		.start = 340,
-		.length = 20 /* 5MB */,
-		.name = "cache",
-	},
-	{
 		.start = 360,
 		.length = 20 /* 5MB */,
-		.name = "recovery",
+		.name = "cache",
 	},
 	{
 		.start = 380,
-		.length = 400 /* 100MB */,
+		.length = VARIABLE_LENGTH,
 		.name = "userdata",
 	},
+	{
+		.start = DIFF_START_ADDR,
+		.length = 4 /* 1MB */,
+		.name = "persist",
+	},
+	{
+		.start = DIFF_START_ADDR,
+		.length = 20 /* 5MB */,
+		.name = "recovery",
+	},
 };
 static int num_parts = sizeof(board_part_list)/sizeof(struct ptentry);
 
@@ -102,6 +111,9 @@
 {
 	unsigned offset;
 	struct flash_info *flash_info;
+	unsigned total_num_of_blocks;
+	bool  start_addr_changed = false;
+	unsigned next_ptr_start_adr = 0;
 	int i;
 
 	dprintf(INFO, "target_init()\n");
@@ -125,12 +137,33 @@
 	if (offset == 0xffffffff)
 	        while(1);
 
+	total_num_of_blocks = (flash_info->block_size)/NUM_PAGES_PER_BLOCK;
+
 	for (i = 0; i < num_parts; i++) {
 		struct ptentry *ptn = &board_part_list[i];
 		unsigned len = ptn->length;
 
-		if ((len == 0) && (i == num_parts - 1))
-			len = flash_info->num_blocks - offset - ptn->start;
+		if(len == VARIABLE_LENGTH)
+		{
+		        start_addr_changed = true;
+			unsigned length_for_prt = 0;
+			unsigned j;
+			for (j = i+1; j < num_parts; j++)
+			{
+			        struct ptentry *temp_ptn = &board_part_list[j];
+			        ASSERT(temp_ptn->length != VARIABLE_LENGTH);
+			        length_for_prt += temp_ptn->length;
+			}
+		        len = (total_num_of_blocks - 1) - (offset + ptn->start + length_for_prt);
+			ASSERT(len >= 0);
+		        next_ptr_start_adr = ptn->start + len;
+		}
+		if((ptn->start == DIFF_START_ADDR) && (start_addr_changed))
+		{
+		        ASSERT(next_ptr_start_adr);
+			ptn->start = next_ptr_start_adr;
+			next_ptr_start_adr = ptn->start + ptn->length;
+		}
 		ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
 			   len, ptn->flags);
 	}