Merge "msm7627_surf: Add fastboot fix"
diff --git a/app/aboot/fastboot.c b/app/aboot/fastboot.c
index 50b5600..0b3d166 100644
--- a/app/aboot/fastboot.c
+++ b/app/aboot/fastboot.c
@@ -34,6 +34,7 @@
 #include <dev/udc.h>
 
 #define MAX_RSP_SIZE 64
+#define MAX_USBFS_BULK_SIZE (16 * 1024)
 
 void boot_linux(void *bootimg, unsigned sz);
 
@@ -145,7 +146,7 @@
 		goto oops;
 
 	while (len > 0) {
-		xfer = (len > 4096) ? 4096 : len;
+		xfer = (len > MAX_USBFS_BULK_SIZE) ? MAX_USBFS_BULK_SIZE : len;
 		req->buf = buf;
 		req->length = xfer;
 		req->complete = req_complete;
diff --git a/platform/mdm9x15/include/platform/iomap.h b/platform/mdm9x15/include/platform/iomap.h
index e80b78b..f5c9305 100644
--- a/platform/mdm9x15/include/platform/iomap.h
+++ b/platform/mdm9x15/include/platform/iomap.h
@@ -43,6 +43,9 @@
 #define GPIO_IN_OUT_ADDR(x) (TLMM_BASE_ADDR + 0x1004 + (x)*0x10)
 #define MSM_PSHOLD_CTL_SU   (TLMM_BASE_ADDR + 0x820)
 
+#define MSM_SHARED_IMEM_BASE 0x2B000000
+#define RESTART_REASON_ADDR  (MSM_SHARED_IMEM_BASE + 0x65C)
+
 /* QGIC2 */
 #define MSM_GIC_DIST_BASE   0x02000000
 #define MSM_GIC_CPU_BASE    0x02002000
diff --git a/platform/msm_shared/hsusb.c b/platform/msm_shared/hsusb.c
index 71410a2..f81f609 100644
--- a/platform/msm_shared/hsusb.c
+++ b/platform/msm_shared/hsusb.c
@@ -266,6 +266,9 @@
 	item->info = INFO_BYTES(req->req.length) | INFO_IOC | INFO_ACTIVE;
 	item->page0 = phys;
 	item->page1 = (phys & 0xfffff000) + 0x1000;
+	item->page2 = (phys & 0xfffff000) + 0x2000;
+	item->page3 = (phys & 0xfffff000) + 0x3000;
+	item->page4 = (phys & 0xfffff000) + 0x4000;
 
 	enter_critical_section();
 	ept->head->next = (unsigned)item;
diff --git a/target/mdm9615/init.c b/target/mdm9615/init.c
index 1b78074..d1fc7b6 100644
--- a/target/mdm9615/init.c
+++ b/target/mdm9615/init.c
@@ -101,6 +101,17 @@
 	flash_set_ptable(&flash_ptable);
 }
 
+unsigned check_reboot_mode(void)
+{
+	unsigned restart_reason = 0;
+
+	/* Read reboot reason and scrub it */
+	restart_reason = readl(RESTART_REASON_ADDR);
+	writel(0x00, RESTART_REASON_ADDR);
+
+	return restart_reason;
+}
+
 void board_info(void)
 {
 	struct smem_board_info_v4 board_info_v4;
@@ -142,6 +153,9 @@
 
 void reboot_device(unsigned reboot_reason)
 {
+	/* Write reboot reason */
+	writel(reboot_reason, RESTART_REASON_ADDR);
+
 	/* Actually reset the chip */
 	pm8921_config_reset_pwr_off(1);
 	writel(0, MSM_PSHOLD_CTL_SU);
diff --git a/target/msm7627a/atags.c b/target/msm7627a/atags.c
index 7ada101..f96c34e 100644
--- a/target/msm7627a/atags.c
+++ b/target/msm7627a/atags.c
@@ -70,5 +70,5 @@
 
 unsigned target_get_max_flash_size(void)
 {
-	return (180 * 1024 * 1024);
+	return (208 * 1024 * 1024);
 }
diff --git a/target/msm7627a/init.c b/target/msm7627a/init.c
index 011dd1c..476df5f 100644
--- a/target/msm7627a/init.c
+++ b/target/msm7627a/init.c
@@ -70,7 +70,7 @@
  * this altogether.
  *
  */
-static struct ptentry board_part_list_default[] = {
+static struct ptentry board_part_list[] = {
 	{
 	 .start = 0,
 	 .length = 10 /* In MB */ ,
@@ -78,7 +78,7 @@
 	 },
 	{
 	 .start = DIFF_START_ADDR,
-	 .length = 180 /* In MB */ ,
+	 .length = 208 /* In MB */ ,
 	 .name = "system",
 	 },
 	{
@@ -108,49 +108,7 @@
 	 },
 };
 
-static int num_parts = sizeof(board_part_list_default) / sizeof(struct ptentry);
-
-/*
- * Define partition table for Bch ecc NAND and increase the cache partition size
- * to 8MB
- */
-static struct ptentry board_part_list_bchecc[] = {
-	{
-	 .start = 0,
-	 .length = 10 /* In MB */ ,
-	 .name = "boot",
-	 },
-	{
-	 .start = DIFF_START_ADDR,
-	 .length = 180 /* In MB */ ,
-	 .name = "system",
-	 },
-	{
-	 .start = DIFF_START_ADDR,
-	 .length = 40 /* In MB */ ,
-	 .name = "cache",
-	 },
-	{
-	 .start = DIFF_START_ADDR,
-	 .length = 4 /* In MB */ ,
-	 .name = "misc",
-	 },
-	{
-	 .start = DIFF_START_ADDR,
-	 .length = VARIABLE_LENGTH,
-	 .name = "userdata",
-	 },
-	{
-	 .start = DIFF_START_ADDR,
-	 .length = 4 /* In MB */ ,
-	 .name = "persist",
-	 },
-	{
-	 .start = DIFF_START_ADDR,
-	 .length = 10 /* In MB */ ,
-	 .name = "recovery",
-	 },
-};
+static int num_parts = sizeof(board_part_list) / sizeof(struct ptentry);
 
 void smem_ptable_init(void);
 unsigned smem_get_apps_flash_start(void);
@@ -163,7 +121,6 @@
 {
 	unsigned offset;
 	struct flash_info *flash_info;
-	struct ptentry *board_part_list;
 	unsigned total_num_of_blocks;
 	unsigned next_ptr_start_adr = 0;
 	unsigned blocks_per_1MB = 8;	/* Default value of 2k page size on 256MB flash drive */
@@ -209,11 +166,6 @@
 	total_num_of_blocks = flash_info->num_blocks;
 	blocks_per_1MB = (1 << 20) / (flash_info->block_size);
 
-	if (flash_ecc_bch_enabled())
-		board_part_list = board_part_list_bchecc;
-	else
-		board_part_list = board_part_list_default;
-
 	for (i = 0; i < num_parts; i++) {
 		struct ptentry *ptn = &board_part_list[i];
 		unsigned len = ((ptn->length) * blocks_per_1MB);
diff --git a/target/msm7630_surf/atags.c b/target/msm7630_surf/atags.c
index 9c564b5..c90f94d 100644
--- a/target/msm7630_surf/atags.c
+++ b/target/msm7630_surf/atags.c
@@ -101,5 +101,5 @@
 
 unsigned target_get_max_flash_size(void)
 {
-	return (180 * 1024 * 1024);
+	return (256 * 1024 * 1024);
 }
diff --git a/target/msm7630_surf/init.c b/target/msm7630_surf/init.c
index 4a59275..234cc25 100644
--- a/target/msm7630_surf/init.c
+++ b/target/msm7630_surf/init.c
@@ -73,7 +73,7 @@
 	 },
 	{
 	 .start = DIFF_START_ADDR,
-	 .length = 180 /* In MB */ ,
+	 .length = 256 /* In MB */ ,
 	 .name = "system",
 	 },
 	{
diff --git a/target/msm7630_surf/rules.mk b/target/msm7630_surf/rules.mk
index fee18a0..8b377ed 100644
--- a/target/msm7630_surf/rules.mk
+++ b/target/msm7630_surf/rules.mk
@@ -13,7 +13,7 @@
 KERNEL_ADDR          := BASE_ADDR+0x00008000
 RAMDISK_ADDR         := BASE_ADDR+0x01000000
 SCRATCH_ADDR         := 0x08008000
-FASTBOOT_BUF_SIZE    := 0x0B000000
+FASTBOOT_BUF_SIZE    := 0x10000000
 
 KEYS_USE_GPIO_KEYPAD := 1