Merge "msm7627a: splash screen support"
diff --git a/platform/msm_shared/nand.c b/platform/msm_shared/nand.c
index 6264220..4529594 100644
--- a/platform/msm_shared/nand.c
+++ b/platform/msm_shared/nand.c
@@ -78,6 +78,7 @@
 static unsigned ECC_BCH_CFG;
 
 static uint32_t enable_bch_ecc;
+static unsigned int *bbtbl;
 
 #define CFG1_WIDE_FLASH (1U << 1)
 
@@ -789,12 +790,33 @@
 	unsigned n;
 	int isbad = 0;
 	unsigned cwperpage;
+	unsigned block = 0;
 	cwperpage = (flash_pagesize >> 9);
 
-	/* Check for bad block and read only from a good block */
-	isbad = flash_nand_block_isbad(cmdlist, ptrlist, page);
-	if (isbad)
+	/* Find the block no for the page */
+	block = page / num_pages_per_blk;
+
+	/* Check the bad block table for each block
+	 * -1: indicates the block needs to be checked if good or bad
+	 * 1 : The block is bad
+	 * 0 : The block is good
+	 */
+	if(bbtbl[block] == -1) {
+		isbad = flash_nand_block_isbad(cmdlist, ptrlist, page);
+		if(isbad) {
+			/* Found bad , set the bad table entry */
+			bbtbl[block] = 1;
+			return -2;
+		} else {
+			/* Found good block , set the table entry &
+			*  continue reading the data
+			*/
+			bbtbl[block] = 0;
+		}
+	} else if(bbtbl[block] == 1) {
+		/* If the block is already identified as bad, return error*/
 		return -2;
+	}
 
 	data->cmd = NAND_CMD_PAGE_READ_ECC;
 	data->addr0 = page << 16;
@@ -3351,6 +3373,7 @@
 
 void flash_init(void)
 {
+	int i = 0;
 	ASSERT(flash_ptable == NULL);
 
 	flash_ptrlist = memalign(32, 1024);
@@ -3366,6 +3389,10 @@
 			ASSERT(0);
 		}
 	}
+	/* Create a bad block table */
+	bbtbl = (unsigned int *) malloc(sizeof(unsigned int) * flash_info.num_blocks);
+	for(i = 0 ; i < flash_info.num_blocks ; i++)
+		bbtbl[i] = -1 ;
 }
 
 struct ptable *flash_get_ptable(void)
diff --git a/platform/msm_shared/smem.h b/platform/msm_shared/smem.h
index 6d1a616..4832c49 100644
--- a/platform/msm_shared/smem.h
+++ b/platform/msm_shared/smem.h
@@ -190,6 +190,7 @@
     HW_PLATFORM_FLUID   = 3,
     HW_PLATFORM_SVLTE   = 4,
     HW_PLATFORM_QT      = 6,
+    HW_PLATFORM_MTP     = 8,
     HW_PLATFORM_LIQUID  = 9,
     HW_PLATFORM_DRAGON  = 10,
     HW_PLATFORM_32BITS  = 0x7FFFFFFF
diff --git a/platform/msm_shared/smem_ptable.c b/platform/msm_shared/smem_ptable.c
index 60d0e26..47e3df1 100644
--- a/platform/msm_shared/smem_ptable.c
+++ b/platform/msm_shared/smem_ptable.c
@@ -147,7 +147,7 @@
 	    smem_ram_ptable->magic[1] != _SMEM_RAM_PTABLE_MAGIC_2)
 		return 0;
 
-	dprintf(INFO, "smem ram ptable found: ver: %d len: %d\n",
+	dprintf(SPEW, "smem ram ptable found: ver: %d len: %d\n",
 		smem_ram_ptable->version, smem_ram_ptable->len);
 
 	return 1;
diff --git a/target/msm8960/atags.c b/target/msm8960/atags.c
index a9154da..540d40c 100644
--- a/target/msm8960/atags.c
+++ b/target/msm8960/atags.c
@@ -44,19 +44,14 @@
 
 	if (smem_ram_ptable_init(&ram_ptable))
 	{
-		/*
-		 * Find lower memory bank (CS0) and strip parts from it that
-		 * will be allocated to peripherals.  Use entire upper
-		 * memory bank (CS1) for kernel.
-		 */
 		for (i = 0; i < ram_ptable.len; i++)
 		{
-			if ((ram_ptable.parts[i].category == EBI1_CS0 ||
-					ram_ptable.parts[i].category == SDRAM) &&
-					ram_ptable.parts[i].start == 0x80000000 &&
-					ram_ptable.parts[i].type == SYS_MEMORY)
+			/* Use only 141M from memory bank starting at 0x80000000 */
+			if (ram_ptable.parts[i].category == SDRAM &&
+					ram_ptable.parts[i].type == SYS_MEMORY &&
+					ram_ptable.parts[i].start == 0x80000000)
 			{
-				ASSERT(ram_ptable.parts[i].size == SIZE_512M);
+				ASSERT(ram_ptable.parts[i].size >= SIZE_256M);
 
 				*ptr++ = 4;
 				*ptr++ = 0x54410002;
@@ -69,10 +64,10 @@
 				*ptr++ = ram_ptable.parts[i].start + SIZE_256M;
 			}
 
-			if ((ram_ptable.parts[i].category == EBI1_CS1 ||
-					ram_ptable.parts[i].category == SDRAM) &&
-					ram_ptable.parts[i].start == 0xA0000000 &&
-					ram_ptable.parts[i].type == SYS_MEMORY)
+			/* Pass along all other usable memory regions to Linux */
+			if (ram_ptable.parts[i].category == SDRAM &&
+					ram_ptable.parts[i].type == SYS_MEMORY &&
+					ram_ptable.parts[i].start != 0x80000000)
 			{
 				*ptr++ = 4;
 				*ptr++ = 0x54410002;
diff --git a/target/msm8960/init.c b/target/msm8960/init.c
index 48482e1..dc2115d 100644
--- a/target/msm8960/init.c
+++ b/target/msm8960/init.c
@@ -146,7 +146,7 @@
 		case HW_PLATFORM_SURF:
 			mach_id = LINUX_MACHTYPE_8960_CDP;
 			break;
-		case HW_PLATFORM_FFA:
+		case HW_PLATFORM_MTP:
 			mach_id = LINUX_MACHTYPE_8960_MTP;
 			break;
 		case HW_PLATFORM_FLUID: