Merge "kernel/lk: Add new target msm7627_6x"
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index fabccb1..d318ced 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -81,6 +81,7 @@
 static const char *baseband_msm     = " androidboot.baseband=msm";
 static const char *baseband_csfb    = " androidboot.baseband=csfb";
 static const char *baseband_svlte2a = " androidboot.baseband=svlte2a";
+static const char *baseband_mdm     = " androidboot.baseband=mdm";
 
 /* Assuming unauthorized kernel image by default */
 static int auth_kernel_img = 0;
@@ -208,6 +209,10 @@
 		case BASEBAND_SVLTE2A:
 			cmdline_len += strlen(baseband_svlte2a);
 			break;
+
+		case BASEBAND_MDM:
+			cmdline_len += strlen(baseband_mdm);
+			break;
 	}
 
 	if (cmdline_len > 0) {
@@ -276,6 +281,12 @@
 				if (have_cmdline) --dst;
 				while ((*dst++ = *src++));
 				break;
+
+			case BASEBAND_MDM:
+				src = baseband_mdm;
+				if (have_cmdline) --dst;
+				while ((*dst++ = *src++));
+				break;
 		}
 		ptr += (n / 4);
 	}
@@ -912,6 +923,7 @@
 	chunk_header_t *chunk_header;
 	uint32_t total_blocks = 0;
 	unsigned long long ptn = 0;
+	unsigned long long size = 0;
 	int index = INVALID_PTN;
 
 	index = partition_get_index(arg);
@@ -921,6 +933,12 @@
 		return;
 	}
 
+	size = partition_get_size(index);
+	if (ROUND_TO_PAGE(sz,511) > size) {
+		fastboot_fail("size too large");
+		return;
+	}
+
 	/* Read and skip over sparse image header */
 	sparse_header = (sparse_header_t *) data;
 	data += sparse_header->file_hdr_sz;
diff --git a/app/aboot/fastboot.c b/app/aboot/fastboot.c
index f096a49..50b5600 100644
--- a/app/aboot/fastboot.c
+++ b/app/aboot/fastboot.c
@@ -270,7 +270,7 @@
 		return;
 	}
 
-	sprintf(response,"DATA%08x", len);
+	snprintf(response, MAX_RSP_SIZE, "DATA%08x", len);
 	if (usb_write(response, strlen(response)) < 0)
 		return;
 
diff --git a/app/aboot/recovery.c b/app/aboot/recovery.c
index 898ccb6..2cbde6a 100644
--- a/app/aboot/recovery.c
+++ b/app/aboot/recovery.c
@@ -310,22 +310,22 @@
 			if(!ret && (update_status & 0x01))
 			{
 				dprintf(INFO,"radio update success\n");
-				strcpy(msg.status, "OKAY");
+				strlcpy(msg.status, "OKAY", sizeof(msg.status));
 			}
 			else
 			{
 				dprintf(INFO,"radio update failed\n");
-				strcpy(msg.status, "failed-update");
+				strlcpy(msg.status, "failed-update", sizeof(msg.status));
 			}
-			strcpy(msg.command, "");	// clearing recovery command
+			strlcpy(msg.command, "", sizeof(msg.command));	// clearing recovery command
 			set_recovery_message(&msg);	// send recovery message
 			boot_into_recovery = 1;		// Boot in recovery mode
 			return 0;
 		}
 
 		valid_command = 1;
-		strcpy(msg.command, "");	// to safe against multiple reboot into recovery
-		strcpy(msg.status, "OKAY");
+		strlcpy(msg.command, "", sizeof(msg.command));	// to safe against multiple reboot into recovery
+		strlcpy(msg.status, "OKAY", sizeof(msg.status));
 		set_recovery_message(&msg);	// send recovery message
 		boot_into_recovery = 1;		// Boot in recovery mode
 		return 0;
@@ -334,7 +334,7 @@
 	if (!strcmp("update-radio",msg.command)) {
 		dprintf(INFO,"start radio update\n");
 		valid_command = 1;
-		strcpy(partition_name, "FOTA");
+		strlcpy(partition_name, "FOTA", sizeof(partition_name));
 	}
 
 	//Todo: Add support for bootloader update too.
@@ -346,29 +346,29 @@
 
 #ifdef OLD_FOTA_UPGRADE
 	if (read_update_header_for_bootloader(&header)) {
-		strcpy(msg.status, "invalid-update");
+		strlcpy(msg.status, "invalid-update", sizeof(msg.status));
 		goto SEND_RECOVERY_MSG;
 	}
 
 	if (update_firmware_image (&header, partition_name)) {
-		strcpy(msg.status, "failed-update");
+		strlcpy(msg.status, "failed-update", sizeof(msg.status));
 		goto SEND_RECOVERY_MSG;
 	}
 #else
 	if (set_ssd_radio_update(partition_name)) {
 		/* If writing to FOTA partition fails */
-		strcpy(msg.command, "");
-		strcpy(msg.status, "failed-update");
+		strlcpy(msg.command, "", sizeof(msg.command));
+		strlcpy(msg.status, "failed-update", sizeof(msg.status));
 		goto SEND_RECOVERY_MSG;
 	}
 	else {
 		/* Setting this to check the radio update status */
-		strcpy(msg.command, "boot-recovery");
-		strcpy(msg.status, "RADIO");
+		strlcpy(msg.command, "boot-recovery", sizeof(msg.command));
+		strlcpy(msg.status, "RADIO", sizeof(msg.status));
 		goto SEND_RECOVERY_MSG;
 	}
 #endif
-	strcpy(msg.status, "OKAY");
+	strlcpy(msg.status, "OKAY", sizeof(msg.status));
 
 SEND_RECOVERY_MSG:
 	set_recovery_message(&msg);	// send recovery message
@@ -442,12 +442,12 @@
 		if(!ret && (update_status & 0x01))
 		{
 			dprintf(INFO,"radio update success\n");
-			strcpy(msg.status, "OKAY");
+			strlcpy(msg.status, "OKAY", sizeof(msg.status));
 		}
 		else
 		{
 			dprintf(INFO,"radio update failed\n");
-			strcpy(msg.status, "failed-update");
+			strlcpy(msg.status, "failed-update", sizeof(msg.status));
 		}
 		boot_into_recovery = 1;		// Boot in recovery mode
 	}
@@ -462,7 +462,7 @@
 	else
 		return 0;	// do nothing
 
-	strcpy(msg.command, "");	// clearing recovery command
+	strlcpy(msg.command, "", sizeof(msg.command));	// clearing recovery command
 	emmc_set_recovery_msg(&msg);	// send recovery message
 	return 0;
 }
diff --git a/app/stringtests/string_tests.c b/app/stringtests/string_tests.c
index 6664346..d3a4df9 100644
--- a/app/stringtests/string_tests.c
+++ b/app/stringtests/string_tests.c
@@ -133,6 +133,40 @@
 	}
 }
 
+static void validate_memcpy_overlap(void)
+{
+	size_t srcalign, dstalign, size;
+	const size_t maxsize = 256;
+	int comp;
+
+	printf("testing memcpy for correctness in overlap cases\n");
+
+	for (dstalign = 0; dstalign < 64; dstalign++) {
+		for (size = 0; size < maxsize; size++) {
+
+			fillbuf(src, maxsize * 2, 567);
+			fillbuf(src2, maxsize * 2, 567);
+
+			/* Case one will check cpy memory is the same - fwd*/
+			memcpy(src + dstalign, src, size);
+			comp = memcmp(src + dstalign, src2, size);
+			if (comp != 0) {
+				printf("ERROR (Case1): dstalign %zu, size %zu, ret %d\n", dstalign, size, comp);
+			}
+
+			fillbuf(src, maxsize * 2, 8588485);
+			fillbuf(src2, maxsize * 2, 8588485);
+
+			/* Case two will check cpy memory is the same - bkwd*/
+			memcpy(src, src + dstalign, size);
+			comp = memcmp(src, src2 + dstalign, size);
+			if (comp != 0) {
+				printf("ERROR (Case2): dstalign %zu, size %zu, ret %d\n", dstalign, size, comp);
+			}
+		}
+	}
+}
+
 static time_t bench_memset_routine(void *memset_routine(void *, int, size_t), size_t dstalign)
 {
 	int i;
@@ -218,6 +252,8 @@
 			validate_memcpy();
 		} else if (!strcmp(argv[2].str, "memset")) {
 			validate_memset();
+		} else if (!strcmp(argv[2].str, "memcpy_overlap")) {
+			validate_memcpy_overlap();
 		}
 	} else if (!strcmp(argv[1].str, "bench")) {
 		if (!strcmp(argv[2].str, "memcpy")) {
diff --git a/lib/libc/string/arch/arm/memcpy.S b/lib/libc/string/arch/arm/memcpy.S
index 3b7816d..925f46e 100644
--- a/lib/libc/string/arch/arm/memcpy.S
+++ b/lib/libc/string/arch/arm/memcpy.S
@@ -165,6 +165,8 @@
 	// do a bytewise reverse copy for now
 	add		r1, r1, r2
 	add		r0, r0, r2
+	sub		r1, r1, #1
+	sub		r0, r0, #1
 
 .L_bytewisereverse:
 	// simple bytewise reverse copy
diff --git a/lib/ptable/ptable.c b/lib/ptable/ptable.c
index 80feedf..895ed50 100644
--- a/lib/ptable/ptable.c
+++ b/lib/ptable/ptable.c
@@ -51,7 +51,7 @@
 	ASSERT(ptable && ptable->count < MAX_PTABLE_PARTS);
 
 	ptn = &ptable->parts[ptable->count++];
-	strncpy(ptn->name, name, MAX_PTENTRY_NAME);
+	strlcpy(ptn->name, name, MAX_PTENTRY_NAME);
 	ptn->start = start;
 	ptn->length = length;
 	ptn->flags = flags;
diff --git a/platform/apq8064/clock.c b/platform/apq8064/clock.c
deleted file mode 100644
index 76e50f5..0000000
--- a/platform/apq8064/clock.c
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2011, 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>
-#include <debug.h>
-#include <platform/iomap.h>
-#include <platform/clock.h>
-#include <gsbi.h>
-#include <mmc.h>
-#include <uart_dm.h>
-
-/* Set rate and enable the clock */
-void clock_config(uint32_t ns, uint32_t md, uint32_t ns_addr, uint32_t md_addr)
-{
-	unsigned int val = 0;
-
-	/* Activate the reset for the M/N Counter */
-	val = 1 << 7;
-	writel(val, ns_addr);
-
-	/* Write the MD value into the MD register */
-	writel(md, md_addr);
-
-	/* Write the ns value, and active reset for M/N Counter, again */
-	val = 1 << 7;
-	val |= ns;
-	writel(val, ns_addr);
-
-	/* De-activate the reset for M/N Counter */
-	val = 1 << 7;
-	val = ~val;
-	val = val & readl(ns_addr);
-	writel(val, ns_addr);
-
-	/* Enable the Clock Root */
-	val = 1 << 11;
-	val = val | readl(ns_addr);
-	writel(val, ns_addr);
-
-	/* Enable the Clock Branch */
-	val = 1 << 9;
-	val = val | readl(ns_addr);
-	writel(val, ns_addr);
-
-	/* Enable the M/N Counter */
-	val = 1 << 8;
-	val = val | readl(ns_addr);
-	writel(val, ns_addr);
-}
-
-void hsusb_clock_init(void)
-{
-	/* Setup XCVR clock */
-	clock_config(USB_XCVR_CLK_NS_VAL,
-				 USB_XCVR_CLK_MD_VAL,
-				 USB_HS1_XCVR_FS_CLK_NS,
-				 USB_HS1_XCVR_FS_CLK_MD);
-}
-
-/* Configure UART clock - based on the gsbi id */
-void clock_config_uart_dm(uint8_t id)
-{
-	/* Enable gsbi_uart_clk */
-	clock_config(UART_DM_CLK_NS_115200,
-				 UART_DM_CLK_MD_115200,
-				 GSBIn_QUP_APPS_NS(id),
-				 GSBIn_QUP_APPS_MD(id));
-
-	/* Configure clock selection register for tx and rx rates.
-	 * Selecting 115.2k for both RX and TX.
-	 */
-	writel(UART_DM_CLK_RX_TX_BIT_RATE, MSM_BOOT_UART_DM_CSR(id));
-
-	/* Enable gsbi_pclk */
-	writel(GSBI_HCLK_CTL_CLK_ENA << GSBI_HCLK_CTL_S, GSBIn_HCLK_CTL(id));
-}
-
-
-/* Intialize MMC clock */
-void clock_init_mmc(uint32_t interface)
-{
-	/* Nothing to be done. */
-}
-
-/* Configure MMC clock */
-void clock_config_mmc(uint32_t interface, uint32_t freq)
-{
-	uint32_t reg = 0;
-
-	switch(freq)
-	{
-	case MMC_CLK_400KHZ:
-		clock_config(SDC_CLK_NS_400KHZ,
-					 SDC_CLK_MD_400KHZ,
-					 SDC_NS(interface),
-					 SDC_MD(interface));
-		break;
-	case MMC_CLK_48MHZ:
-	case MMC_CLK_50MHZ: /* Max supported is 48MHZ */
-		clock_config(SDC_CLK_NS_48MHZ,
-					 SDC_CLK_MD_48MHZ,
-					 SDC_NS(interface),
-					 SDC_MD(interface));
-		break;
-	default:
-		ASSERT(0);
-
-	}
-
-	reg |= MMC_BOOT_MCI_CLK_ENABLE;
-	reg |= MMC_BOOT_MCI_CLK_ENA_FLOW;
-	reg |= MMC_BOOT_MCI_CLK_IN_FEEDBACK;
-	writel( reg, MMC_BOOT_MCI_CLK );
-}
-
diff --git a/platform/apq8064/gpio.c b/platform/apq8064/gpio.c
deleted file mode 100644
index 2a10c8d..0000000
--- a/platform/apq8064/gpio.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Copyright (c) 2011, 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 Forum, Inc. 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 "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>
-#include <debug.h>
-#include <gsbi.h>
-#include <platform/iomap.h>
-#include <platform/gpio.h>
-
-void gpio_tlmm_config(uint32_t gpio,
-					  uint8_t func,
-					  uint8_t dir,
-					  uint8_t pull,
-					  uint8_t drvstr,
-					  uint32_t enable)
-{
-	uint32_t val = 0;
-
-	val |= pull;
-	val |= func << 2;
-	val |= drvstr << 6;
-	val |= enable << 9;
-
-	writel(val, GPIO_CONFIG_ADDR(gpio));
-}
-
-void gpio_set(uint32_t gpio, uint32_t dir)
-{
-	writel(dir, GPIO_IN_OUT_ADDR(gpio));
-}
-
-/* Configure gpio for uart - based on gsbi id */
-void gpio_config_uart_dm(uint8_t id)
-{
-	switch (id)
-	{
-	case GSBI_ID_3:
-
-		/* configure rx gpio */
-		gpio_tlmm_config(15, 1, GPIO_INPUT, GPIO_NO_PULL,
-						 GPIO_8MA, GPIO_DISABLE);
-
-		/* configure tx gpio */
-		gpio_tlmm_config(14, 1, GPIO_OUTPUT, GPIO_NO_PULL,
-						 GPIO_8MA, GPIO_DISABLE);
-		break;
-
-	default:
-		ASSERT(0);
-	}
-}
-
diff --git a/platform/apq8064/include/platform/clock.h b/platform/apq8064/include/platform/clock.h
deleted file mode 100644
index 6267940..0000000
--- a/platform/apq8064/include/platform/clock.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * * Copyright (c) 2011, 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 Forum, Inc. 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 "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.
- */
-#ifndef __PLATFORM_APQ8064_CLOCK_H
-#define __PLATFORM_APQ8064_CLOCK_H
-
-/* NS/MD value for USB XCVR */
-#define USB_XCVR_CLK_NS_VAL        0x00E400C3
-#define USB_XCVR_CLK_MD_VAL        0x000500DF
-
-/* NS/MD value for UART */
-#define UART_DM_CLK_NS_115200      0xFFE40040
-#define UART_DM_CLK_MD_115200      0x0002FFE2
-
-#define UART_DM_CLK_RX_TX_BIT_RATE 0xFF
-
-/* NS/MD value for MMC */
-#define SDC_CLK_NS_400KHZ          0x00440040
-#define SDC_CLK_MD_400KHZ          0x00010043
-
-#define SDC_CLK_NS_48MHZ           0x00FE005B
-#define SDC_CLK_MD_48MHZ           0x000100FD
-
-#endif
diff --git a/platform/apq8064/include/platform/gpio.h b/platform/apq8064/include/platform/gpio.h
deleted file mode 100644
index 93d81de..0000000
--- a/platform/apq8064/include/platform/gpio.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright (c) 2011, 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 Forum, Inc. 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 "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.
- */
-
-#ifndef __PLATFORM_APQ8064_GPIO_H
-#define __PLATFORM_APQ8064_GPIO_H
-
-
-/* GPIO TLMM: Direction */
-#define GPIO_INPUT      0
-#define GPIO_OUTPUT     1
-
-/* GPIO TLMM: Pullup/Pulldown */
-#define GPIO_NO_PULL    0
-#define GPIO_PULL_DOWN  1
-#define GPIO_KEEPER     2
-#define GPIO_PULL_UP    3
-
-/* GPIO TLMM: Drive Strength */
-#define GPIO_2MA        0
-#define GPIO_4MA        1
-#define GPIO_6MA        2
-#define GPIO_8MA        3
-#define GPIO_10MA       4
-#define GPIO_12MA       5
-#define GPIO_14MA       6
-#define GPIO_16MA       7
-
-/* GPIO TLMM: Status */
-#define GPIO_ENABLE     0
-#define GPIO_DISABLE    1
-
-
-void gpio_config_uart_dm(uint8_t id);
-
-#endif
diff --git a/platform/apq8064/include/platform/iomap.h b/platform/apq8064/include/platform/iomap.h
deleted file mode 100644
index b86b7ac..0000000
--- a/platform/apq8064/include/platform/iomap.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2011, 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 Google, Inc. 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 AND FITNESS
- * FOR A PARTICULAR PURPOSE 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.
- */
-
-#ifndef _PLATFORM_APQ8064_IOMAP_H_
-#define _PLATFORM_APQ8064_IOMAP_H_
-
-#define MSM_IOMAP_BASE      0x00100000
-#define MSM_IOMAP_END       0x28000000
-
-/* Shared memory */
-#define MSM_SHARED_BASE       0x80000000
-#define MSM_SHARED_IMEM_BASE  0x2A03F000
-#define RESTART_REASON_ADDR  (MSM_SHARED_IMEM_BASE + 0x65C)
-
-/* Peripherals */
-#define TLMM_BASE_ADDR           0x00800000
-
-/* GPIO */
-#define GPIO_CONFIG_ADDR(x)     (TLMM_BASE_ADDR + 0x1000 + (x)*0x10)
-#define GPIO_IN_OUT_ADDR(x)     (TLMM_BASE_ADDR + 0x1004 + (x)*0x10)
-
-/* CLK CTL */
-#define CLK_CTL_BASE             0x00900000
-#define SDC_MD(n)               (CLK_CTL_BASE + 0x2828 + (32 * ((n) - 1)))
-#define SDC_NS(n)               (CLK_CTL_BASE + 0x282C + (32 * ((n) - 1)))
-#define USB_HS1_HCLK_CTL        (CLK_CTL_BASE + 0x2900)
-#define USB_HS1_XCVR_FS_CLK_MD  (CLK_CTL_BASE + 0x2908)
-#define USB_HS1_XCVR_FS_CLK_NS  (CLK_CTL_BASE + 0x290C)
-#define GSBIn_HCLK_CTL(n)       (CLK_CTL_BASE + 0x29C0 + (32 * ((n) - 1)))
-#define GSBIn_HCLK_FS(n)        (CLK_CTL_BASE + 0x29C4 + (32 * ((n) - 1)))
-#define GSBIn_QUP_APPS_MD(n)    (CLK_CTL_BASE + 0x29C8 + (32 * ((n) - 1)))
-#define GSBIn_QUP_APPS_NS(n)    (CLK_CTL_BASE + 0x29CC + (32 * ((n) - 1)))
-#define GSBIn_UART_APPS_MD(n)   (CLK_CTL_BASE + 0x29D0 + (32 * ((n) - 1)))
-#define GSBIn_UART_APPS_NS(n)   (CLK_CTL_BASE + 0x29D4 + (32 * ((n) - 1)))
-#define MSM_BOOT_PLL8_STATUS    (CLK_CTL_BASE + 0x3158)
-#define MSM_BOOT_PLL_ENABLE_SC0 (CLK_CTL_BASE + 0x34C0)
-
-/* GIC */
-#define MSM_GIC_DIST_BASE        0x02000000
-#define MSM_GIC_CPU_BASE         0x02002000
-
-/* TMR */
-#define MSM_TMR_BASE             0x0200A000
-#define MSM_GPT_BASE            (MSM_TMR_BASE + 0x04)
-#define MSM_DGT_BASE            (MSM_TMR_BASE + 0x24)
-#define MSM_WDT0_RST            (MSM_TMR_BASE + 0x38)
-#define MSM_WDT0_EN             (MSM_TMR_BASE + 0x40)
-#define MSM_WDT0_BT             (MSM_TMR_BASE + 0x4C)
-#define SPSS_TIMER_STATUS       (MSM_TMR_BASE + 0x88)
-
-#define GPT_REG(off)            (MSM_GPT_BASE + (off))
-#define DGT_REG(off)            (MSM_DGT_BASE + (off))
-
-#define GPT_MATCH_VAL            GPT_REG(0x0000)
-#define GPT_COUNT_VAL            GPT_REG(0x0004)
-#define GPT_ENABLE               GPT_REG(0x0008)
-#define GPT_CLEAR                GPT_REG(0x000C)
-
-#define DGT_MATCH_VAL            DGT_REG(0x0000)
-#define DGT_COUNT_VAL            DGT_REG(0x0004)
-#define DGT_ENABLE               DGT_REG(0x0008)
-#define DGT_CLEAR                DGT_REG(0x000C)
-#define DGT_CLK_CTL              DGT_REG(0x0010)
-
-#define MSM_USB_BASE             0x12500000
-#define MSM_TCSR_BASE            0x1A400000
-#define MSM_TCSR_WDOG_CFG       (MSM_TCSR_BASE + 0x30)
-
-/* SDCC */
-#define MSM_SDC1_BASE            0x12400000
-#define MSM_SDC2_BASE            0x12140000
-#define MSM_SDC3_BASE            0x12180000
-#define MSM_SDC4_BASE            0x121C0000
-
-
-/* GSBI/QUP/UART_DM */
-#define GSBI_BASE(id)           ((id) <= 7 ? (0x16000000 + (((id)-1) << 20)) : \
-                                             (0x1A000000 + (((id)-8) << 20)))
-#define GSBI_UART_DM_BASE(id)   (GSBI_BASE(id) + 0x40000)
-#define QUP_BASE(id)            (GSBI_BASE(id) + 0x80000)
-
-#endif
diff --git a/platform/apq8064/include/platform/irqs.h b/platform/apq8064/include/platform/irqs.h
deleted file mode 100644
index 48a8a96..0000000
--- a/platform/apq8064/include/platform/irqs.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Copyright (c) 2009-2011, 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.
- *
- */
-
-#ifndef __IRQS_APQ8064_H
-#define __IRQS_APQ8064_H
-
-/* MSM ACPU Interrupt Numbers */
-
-/* 0-15:  STI/SGI (software triggered/generated interrupts)
- * 16-31: PPI (private peripheral interrupts)
- * 32+:   SPI (shared peripheral interrupts)
- */
-
-#define GIC_PPI_START 16
-#define GIC_SPI_START 32
-
-#define INT_DEBUG_TIMER_EXP     (GIC_PPI_START + 1)
-
-#define USB1_HS_BAM_IRQ         (GIC_SPI_START + 94)
-#define USB1_HS_IRQ             (GIC_SPI_START + 100)
-#define USB2_IRQ                (GIC_SPI_START + 141)
-#define USB1_IRQ                (GIC_SPI_START + 142)
-
-#define GSBI_QUP_IRQ(id)        ((id) <= 8 ? (GIC_SPI_START + 145 + 2*(id)) : \
-                                             (GIC_SPI_START + 187 + 2*((id)-8)))
-
-
-/* Retrofit universal macro names */
-#define INT_USB_HS                  USB1_HS_IRQ
-
-#define NR_MSM_IRQS                 256
-#define NR_GPIO_IRQS                173
-#define NR_BOARD_IRQS               0
-
-#define NR_IRQS (NR_MSM_IRQS + NR_GPIO_IRQS + NR_BOARD_IRQS)
-
-#endif
diff --git a/platform/apq8064/platform.c b/platform/apq8064/platform.c
deleted file mode 100644
index af1e2f4..0000000
--- a/platform/apq8064/platform.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (c) 2011, 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 Google, Inc. 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 AND FITNESS
- * FOR A PARTICULAR PURPOSE 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>
-#include <debug.h>
-#include <uart_dm.h>
-#include <qgic.h>
-#include <platform/iomap.h>
-#include <mmu.h>
-#include <qgic.h>
-#include <arch/arm/mmu.h>
-
-extern void platform_init_timer(void);
-extern uint8_t target_uart_gsbi(void);
-
-static uint32_t ticks_per_sec = 0;
-
-#define MB (1024*1024)
-#define MSM_IOMAP_SIZE ((MSM_IOMAP_END - MSM_IOMAP_BASE)/MB)
-
-/* Scratch region - cacheable, write through */
-#define CACHEABLE_MEMORY  (MMU_MEMORY_TYPE_NORMAL_WRITE_THROUGH   | \
-                           MMU_MEMORY_AP_READ_WRITE)
-
-/* Peripherals - non-shared device */
-#define IOMAP_MEMORY      (MMU_MEMORY_TYPE_DEVICE_NON_SHARED | \
-                           MMU_MEMORY_AP_READ_WRITE)
-
-mmu_section_t mmu_section_table[] = {
-/*  Physical addr,    Virtual addr,    Size (in MB),    Flags */
-    {MEMBASE,         MEMBASE,         (MEMSIZE/MB),    CACHEABLE_MEMORY},
-    {SCRATCH_ADDR,    SCRATCH_ADDR,    SCRATCH_SIZE,    CACHEABLE_MEMORY},
-    {MSM_IOMAP_BASE,  MSM_IOMAP_BASE,  MSM_IOMAP_SIZE,  IOMAP_MEMORY},
-};
-
-void platform_early_init(void)
-{
-	uart_init(target_uart_gsbi());
-	qgic_init();
-	platform_init_timer();
-}
-
-void platform_init(void)
-{
-	dprintf(INFO, "platform_init()\n");
-}
-
-/* Setup memory for this platform */
-void platform_init_mmu_mappings(void)
-{
-	uint32_t i;
-	uint32_t sections;
-	uint32_t table_size = ARRAY_SIZE(mmu_section_table);
-
-	for (i = 0; i < table_size; i++)
-	{
-		sections = mmu_section_table[i].num_of_sections;
-
-		while (sections--)
-		{
-			arm_mmu_map_section(mmu_section_table[i].paddress + sections*MB,
-								mmu_section_table[i].vaddress + sections*MB,
-								mmu_section_table[i].flags);
-		}
-	}
-}
-
-/* Initialize DGT timer */
-void platform_init_timer(void)
-{
-	/* disable timer */
-	writel(0, DGT_ENABLE);
-
-	/* DGT uses LPXO source which is 27MHz.
-	 * Set clock divider to 4.
-	 */
-	writel(3, DGT_CLK_CTL);
-
-	ticks_per_sec = 6750000; /* (27 MHz / 4) */
-}
-
-/* Returns timer ticks per sec */
-uint32_t platform_tick_rate(void)
-{
-	return ticks_per_sec;
-}
diff --git a/platform/apq8064/rules.mk b/platform/apq8064/rules.mk
deleted file mode 100644
index 9447f04..0000000
--- a/platform/apq8064/rules.mk
+++ /dev/null
@@ -1,22 +0,0 @@
-LOCAL_DIR := $(GET_LOCAL_DIR)
-
-ARCH     := arm
-ARM_CPU  := cortex-a8
-CPU      := generic
-
-DEFINES  += ARM_CPU_CORE_KRAIT
-
-INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared/include
-
-DEVS += fbcon
-MODULES += dev/fbcon
-
-OBJS += \
-	$(LOCAL_DIR)/platform.o \
-	$(LOCAL_DIR)/clock.o \
-	$(LOCAL_DIR)/gpio.o \
-
-LINKER_SCRIPT += $(BUILDDIR)/system-onesegment.ld
-
-include platform/msm_shared/rules.mk
-
diff --git a/platform/msm7x27a/include/platform/iomap.h b/platform/msm7x27a/include/platform/iomap.h
index 8c25723..1a9ce81 100644
--- a/platform/msm7x27a/include/platform/iomap.h
+++ b/platform/msm7x27a/include/platform/iomap.h
@@ -84,7 +84,6 @@
 /* Range 0 - 19 */
 #define DSIPHY_PLL_CTRL(x)       REG_DSI(DSIPHY_PLL_BASE + (x) * 4)
 
-#define DSI_CMD_DMA_MEM_START_ADDR_PANEL      (0x2E000000)
 #define MDP_DMA_P_CONFIG 		      (0xAA290000)
 #define MDP_DMA_P_OUT_XY                      (0xAA290010)
 #define MDP_DMA_P_SIZE                        (0xAA290004)
diff --git a/platform/msm8960/gpio.c b/platform/msm8960/gpio.c
index b9aa637..f46da1f 100644
--- a/platform/msm8960/gpio.c
+++ b/platform/msm8960/gpio.c
@@ -58,6 +58,16 @@
 {
 	switch (id)
 	{
+
+	case GSBI_ID_3:
+		/* configure rx gpio */
+		gpio_tlmm_config(15, 1, GPIO_INPUT, GPIO_NO_PULL,
+						 GPIO_8MA, GPIO_DISABLE);
+		/* configure tx gpio */
+		gpio_tlmm_config(14, 1, GPIO_OUTPUT, GPIO_NO_PULL,
+						 GPIO_8MA, GPIO_DISABLE);
+		break;
+
 	case GSBI_ID_5:
 		/* configure rx gpio */
 		gpio_tlmm_config(23, 1, GPIO_INPUT, GPIO_NO_PULL,
@@ -66,6 +76,7 @@
 		gpio_tlmm_config(22, 1, GPIO_OUTPUT, GPIO_NO_PULL,
 						 GPIO_8MA, GPIO_DISABLE);
 		break;
+
 	default:
 		ASSERT(0);
 	}
diff --git a/platform/msm8960/include/platform/iomap.h b/platform/msm8960/include/platform/iomap.h
index 04f15e0..dadf70d 100644
--- a/platform/msm8960/include/platform/iomap.h
+++ b/platform/msm8960/include/platform/iomap.h
@@ -130,9 +130,6 @@
 /* Range 0 - 19 */
 #define DSIPHY_PLL_CTRL(x)       REG_DSI(DSIPHY_PLL_BASE + (x) * 4)
 
-//TODO: Use mem on the stack
-#define DSI_CMD_DMA_MEM_START_ADDR_PANEL      (0x90000000)
-
 #define MDP_BASE                              (0x05100000)
 #define REG_MDP(off)                          (MDP_BASE + (off))
 
diff --git a/platform/msm8960/platform.c b/platform/msm8960/platform.c
index b931bbf..9e41329 100644
--- a/platform/msm8960/platform.c
+++ b/platform/msm8960/platform.c
@@ -46,7 +46,6 @@
 extern void mmss_clock_init(void);
 extern struct fbcon_config *mipi_init(void);
 extern void mipi_dsi_shutdown(void);
-extern uint8_t target_uart_gsbi(void);
 
 static uint32_t ticks_per_sec = 0;
 
@@ -81,7 +80,6 @@
 
 void platform_early_init(void)
 {
-    uart_init(target_uart_gsbi());
     qgic_init();
     platform_init_timer();
 }
diff --git a/platform/msm_shared/include/baseband.h b/platform/msm_shared/include/baseband.h
index 433f783..d5b916d 100644
--- a/platform/msm_shared/include/baseband.h
+++ b/platform/msm_shared/include/baseband.h
@@ -36,6 +36,7 @@
     BASEBAND_CSFB    = 2,
     BASEBAND_SVLTE1  = 3,
     BASEBAND_SVLTE2A = 4,
+    BASEBAND_MDM     = 5,
     BASEBAND_32BITS  = 0x7FFFFFFF
 };
 
diff --git a/platform/msm_shared/include/partition_parser.h b/platform/msm_shared/include/partition_parser.h
index bad8698..1a6732c 100644
--- a/platform/msm_shared/include/partition_parser.h
+++ b/platform/msm_shared/include/partition_parser.h
@@ -140,8 +140,8 @@
                                    struct mmc_boot_card * mmc_card);
 unsigned int partition_parse_gpt_header(unsigned char * buffer,
                                         unsigned long long * first_usable_lba,
-                                        unsigned long * partition_entry_size,
-                                        unsigned long * header_size,
+                                        unsigned int * partition_entry_size,
+                                        unsigned int * header_size,
                                         unsigned int * max_partition_count);
 
 /* For Debugging */
diff --git a/platform/msm_shared/mipi_dsi.c b/platform/msm_shared/mipi_dsi.c
index 80c47a9..04cf933 100644
--- a/platform/msm_shared/mipi_dsi.c
+++ b/platform/msm_shared/mipi_dsi.c
@@ -168,9 +168,11 @@
         off += 4;
     }
 
+#if DISPLAY_MIPI_PANEL_RENESAS
     if(machine_is_7x25a()) {
        pd->pll[10] |=0x8;
     }
+#endif
     off = 0x0204;               /* pll ctrl 1, skip 0 */
     for (i = 1; i < 21; i++) {
         writel(pd->pll[i], MIPI_DSI_BASE + off);
@@ -235,11 +237,12 @@
     int ret = 0;
     struct mipi_dsi_cmd *cm;
     int i = 0;
+    char pload[256];
 
     cm = cmds;
     for (i = 0; i < count; i++) {
-        memcpy((void *) DSI_CMD_DMA_MEM_START_ADDR_PANEL, (cm->payload), cm->size);
-        writel(DSI_CMD_DMA_MEM_START_ADDR_PANEL, DSI_DMA_CMD_OFFSET);
+        memcpy((void *) pload, (cm->payload), cm->size);
+        writel(pload, DSI_DMA_CMD_OFFSET);
         writel(cm->size, DSI_DMA_CMD_LENGTH);   // reg 0x48 for this build
         ret += dsi_cmd_dma_trigger_for_panel();
         udelay(80);
diff --git a/platform/msm_shared/partition_parser.c b/platform/msm_shared/partition_parser.c
index 621aa90..e99d2ee 100644
--- a/platform/msm_shared/partition_parser.c
+++ b/platform/msm_shared/partition_parser.c
@@ -333,8 +333,9 @@
             /* if already assigned last name available then return */
             if(!strcmp((const char *)vfat_partitions[vfat_count], "NONE"))
                 return;
-            strcpy((char *)partition_ent->name,
-                    (const char *)vfat_partitions[vfat_count]);
+            strlcpy((char *)partition_ent->name,
+                    (const char *)vfat_partitions[vfat_count],
+                    sizeof(partition_ent->name));
             vfat_count++;
             break;
         case MBR_SBL1_TYPE:
@@ -370,8 +371,9 @@
         case MBR_USERDATA_TYPE:
             if (ext3_count == sizeof(ext3_partitions) / sizeof(char*))
                 return;
-            strcpy((char *)partition_ent->name,
-                    (const char *)ext3_partitions[ext3_count]);
+            strlcpy((char *)partition_ent->name,
+                    (const char *)ext3_partitions[ext3_count],
+                    sizeof(partition_ent->name));
             ext3_count++;
             break;
         case MBR_RECOVERY_TYPE:
@@ -517,8 +519,8 @@
  */
 unsigned int partition_parse_gpt_header(unsigned char * buffer,
                                         unsigned long long * first_usable_lba,
-                                        unsigned long * partition_entry_size,
-                                        unsigned long * header_size,
+                                        unsigned int * partition_entry_size,
+                                        unsigned int * header_size,
                                         unsigned int * max_partition_count)
 {
     /* Check GPT Signature */
diff --git a/platform/msm_shared/proc_comm.c b/platform/msm_shared/proc_comm.c
index b7e7844..c6d078d 100644
--- a/platform/msm_shared/proc_comm.c
+++ b/platform/msm_shared/proc_comm.c
@@ -2,7 +2,7 @@
  * Copyright (c) 2008, Google Inc.
  * All rights reserved.
  *
- * Copyright (c) 2009-2010, Code Aurora Forum. All rights reserved.
+ * Copyright (c) 2009-2011, 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
@@ -168,12 +168,16 @@
 		/* XXX check for A9 reset */
 	}
 
-	writel(cmd, APP_COMMAND);
 	if (data1)
 		writel(*data1, APP_DATA1);
 	if (data2)
 		writel(*data2, APP_DATA2);
 
+	/*
+	 * As per the specs write data, cmd, interrupt for
+	 * proc comm processing
+	 */
+	writel(cmd, APP_COMMAND);
 //	dprintf(INFO, "proc_comm tx\n");
 	notify_other_proc_comm();
 	while (readl(APP_COMMAND) != PCOM_CMD_DONE) {
@@ -189,6 +193,12 @@
 		if (data2)
 			*data2 = readl(APP_DATA2);
 		ret = 0;
+	/*
+	 * Write command idle to indicate non HLOS that
+	 * apps has finished reading the status & data
+	 * of proc comm command
+	 */
+		writel(PCOM_CMD_IDLE, APP_COMMAND);
 	}
 
 	return ret;
diff --git a/platform/msm_shared/rules.mk b/platform/msm_shared/rules.mk
index ba2af26..b463a05 100644
--- a/platform/msm_shared/rules.mk
+++ b/platform/msm_shared/rules.mk
@@ -33,11 +33,6 @@
 			$(LOCAL_DIR)/image_verify.o
 endif
 
-ifeq ($(PLATFORM),apq8064)
-	OBJS += $(LOCAL_DIR)/qgic.o \
-			$(LOCAL_DIR)/uart_dm.o
-endif
-
 ifeq ($(PLATFORM),msm8960)
 	OBJS += $(LOCAL_DIR)/mipi_dsi.o \
 			$(LOCAL_DIR)/i2c_qup.o \
diff --git a/platform/msm_shared/smem.h b/platform/msm_shared/smem.h
index c3eeb7a..9b1415e 100644
--- a/platform/msm_shared/smem.h
+++ b/platform/msm_shared/smem.h
@@ -181,6 +181,14 @@
     MSM7227A = 90,
     MSM7627A = 91,
     ESM7227A = 92,
+    ESM7225A = 96,
+    ESM7627A = 97,
+    MSM7225AA = 98,
+    MSM7625AA = 99,
+    ESM7225AA = 100,
+    MSM7227AA = 101,
+    MSM7627AA = 102,
+    ESM7227AA = 103,
     APQ8064 = 109,
     MSM8930 = 116,
 };
@@ -202,6 +210,7 @@
 enum platform_subtype
 {
     HW_PLATFORM_SUBTYPE_UNKNOWN = 0,
+    HW_PLATFORM_SUBTYPE_MDM     = 1,
     HW_PLATFORM_SUBTYPE_CSFB    = 1,
     HW_PLATFORM_SUBTYPE_SVLTE1  = 2,
     HW_PLATFORM_SUBTYPE_SVLTE2A = 3,
diff --git a/project/msm8960.mk b/project/msm8960.mk
index 0de2066..689b0db 100644
--- a/project/msm8960.mk
+++ b/project/msm8960.mk
@@ -6,8 +6,8 @@
 
 MODULES += app/aboot
 
-DEBUG := 1
+DEBUG := 0
 
 #DEFINES += WITH_DEBUG_DCC=1
-DEFINES += WITH_DEBUG_UART=1
+#DEFINES += WITH_DEBUG_UART=1
 #DEFINES += WITH_DEBUG_FBCON=1
diff --git a/target/apq8064/atags.c b/target/apq8064/atags.c
deleted file mode 100644
index f686bf6..0000000
--- a/target/apq8064/atags.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright (c) 2009-2011, 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 <sys/types.h>
-
-#define SIZE_1M                (1024*1024)
-#define SIZE_141M              (141*SIZE_1M)
-
-#define KERNEL_MEM_ADDR_1       0x80200000
-
-uint32_t* target_atag_mem(uint32_t* ptr)
-{
-	/* ATAG_MEM */
-	*ptr++ = 4;
-	*ptr++ = 0x54410002;
-	*ptr++ = SIZE_141M;
-	*ptr++ = KERNEL_MEM_ADDR_1;
-
-	return ptr;
-}
-
-void *target_get_scratch_address(void)
-{
-	return((void *)KERNEL_MEM_ADDR_1);
-}
-
-uint32_t target_get_max_flash_size(void)
-{
-	return (SIZE_141M);
-}
diff --git a/target/apq8064/init.c b/target/apq8064/init.c
deleted file mode 100644
index 5bea927..0000000
--- a/target/apq8064/init.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (c) 2011, 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 Google, Inc. 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 AND FITNESS
- * FOR A PARTICULAR PURPOSE 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>
-#include <debug.h>
-#include <smem.h>
-#include <uart_dm.h>
-#include <gsbi.h>
-#include <baseband.h>
-#include <dev/keys.h>
-#include <dev/pm8921.h>
-#include <dev/ssbi.h>
-#include <platform/iomap.h>
-#include <lib/ptable.h>
-
-#define LINUX_MACHTYPE_APQ8064_SIM     3572
-
-extern unsigned int mmc_boot_main(unsigned char slot, unsigned int base);
-extern void mdelay(unsigned msecs);
-extern void keypad_init(void);
-
-static unsigned mmc_sdc_base[] =
-{
-	MSM_SDC1_BASE,
-	MSM_SDC2_BASE,
-	MSM_SDC3_BASE,
-	MSM_SDC4_BASE
-};
-
-static pm8921_dev_t pmic;
-static const uint8_t uart_gsbi_id  = GSBI_ID_3;
-
-void target_init(void)
-{
-	uint32_t base_addr;
-	uint8_t slot;
-	dprintf(INFO, "target_init()\n");
-
-	/* Initialize PMIC driver */
-	pmic.read  = pa1_ssbi2_read_bytes;
-	pmic.write = pa1_ssbi2_write_bytes;
-
-	pm8921_init(&pmic);
-
-	/* Keypad init */
-	keys_init();
-	keypad_init();
-
-	/* Trying Slot 1 first */
-	slot = 1;
-	base_addr = mmc_sdc_base[slot-1];
-	if(mmc_boot_main(slot, base_addr))
-	{
-		/* Trying Slot 3 next */
-		slot = 3;
-		base_addr = mmc_sdc_base[slot-1];
-		if(mmc_boot_main(slot, base_addr))
-		{
-			dprintf(CRITICAL, "mmc init failed!");
-			ASSERT(0);
-		}
-	}
-}
-
-uint32_t board_machtype(void)
-{
-	struct smem_board_info_v6 board_info_v6;
-	uint32_t board_info_len = 0;
-	uint32_t smem_status = 0;
-	uint32_t format = 0;
-	uint32_t id = HW_PLATFORM_UNKNOWN;
-	uint32_t mach_id;
-
-
-	smem_status = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION,
-											   &format, sizeof(format), 0);
-	if(!smem_status)
-	{
-		if (format == 6)
-		{
-			board_info_len = sizeof(board_info_v6);
-
-			smem_status = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
-												&board_info_v6, board_info_len);
-			if(!smem_status)
-			{
-				id = board_info_v6.board_info_v3.hw_platform;
-			}
-		}
-	}
-
-	/* Detect the board we are running on */
-	switch(id)
-	{
-		/* APQ8064 machine id not yet defined for CDP etc.
-		 * default to simulator.
-		 */
-		case HW_PLATFORM_SURF:
-		case HW_PLATFORM_FFA:
-		case HW_PLATFORM_FLUID:
-		default:
-			mach_id = LINUX_MACHTYPE_APQ8064_SIM;
-	};
-
-	return mach_id;
-}
-
-void reboot_device(uint32_t reboot_reason)
-{
-	/* TODO: Not implemented yet. */
-	ASSERT(0);
-}
-
-uint32_t check_reboot_mode(void)
-{
-	uint32_t restart_reason = 0;
-
-	/* Read reboot reason and scrub it */
-	restart_reason = readl(RESTART_REASON_ADDR);
-	writel(0x00, RESTART_REASON_ADDR);
-
-	return restart_reason;
-}
-
-void target_serialno(unsigned char *buf)
-{
-	uint32_t serialno;
-	if(target_is_emmc_boot())
-	{
-		serialno =  mmc_get_psn();
-		sprintf(buf,"%x",serialno);
-	}
-}
-
-/* Do any target specific intialization needed before entering fastboot mode */
-void target_fastboot_init(void)
-{
-	/* Set the BOOT_DONE flag in PM8921 */
-	pm8921_boot_done();
-}
-
-/* GSBI to be used for UART */
-uint8_t target_uart_gsbi(void)
-{
-	return uart_gsbi_id;
-}
-
-/* Returns type of baseband. APQ for APPs only proc. */
-unsigned target_baseband()
-{
-	return BASEBAND_APQ;
-}
diff --git a/target/apq8064/keypad.c b/target/apq8064/keypad.c
deleted file mode 100644
index 2fec00f..0000000
--- a/target/apq8064/keypad.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2011, 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 <string.h>
-#include <dev/keys.h>
-#include <dev/ssbi.h>
-#include <dev/gpio_keypad.h>
-
-#define NUM_OF_ROWS 1
-#define NUM_OF_COLS 5
-
-#define BITS_IN_ELEMENT(x) (sizeof(x)[0] * 8)
-
-static unsigned char qwerty_keys_old[NUM_OF_ROWS];
-static unsigned char qwerty_keys_new[NUM_OF_ROWS];
-
-#define KEYMAP_INDEX(row, col) (row)* BITS_IN_ELEMENT(qwerty_keys_new) + (col)
-
-unsigned int qwerty_keymap[] = {
-    [KEYMAP_INDEX(0, 0)] = KEY_VOLUMEUP,
-    [KEYMAP_INDEX(0, 1)] = KEY_VOLUMEDOWN,
-};
-
-
-struct qwerty_keypad_info qwerty_keypad = {
-	.keymap         = qwerty_keymap,
-	.old_keys       = qwerty_keys_old,
-	.rec_keys       = qwerty_keys_new,
-	.rows           = NUM_OF_ROWS,
-	.columns        = NUM_OF_COLS,
-	.num_of_reads   = NUM_OF_ROWS,
-	.rd_func        = &pa1_ssbi2_read_bytes,
-	.wr_func        = &pa1_ssbi2_write_bytes,
-	.settle_time    = 5  /* msec */,
-	.poll_time      = 20 /* msec */,
-};
-
-void keypad_init(void)
-{
-	memset(qwerty_keys_old, 0, sizeof(qwerty_keys_old));
-	memset(qwerty_keys_new, 0, sizeof(qwerty_keys_new));
-
-	ssbi_keypad_init(&qwerty_keypad);
-}
diff --git a/target/apq8064/rules.mk b/target/apq8064/rules.mk
deleted file mode 100644
index 72dc708..0000000
--- a/target/apq8064/rules.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-LOCAL_DIR := $(GET_LOCAL_DIR)
-
-INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared
-
-PLATFORM := apq8064
-
-MEMBASE := 0x88F00000 # SDRAM
-MEMSIZE := 0x00100000 # 1MB
-
-SCRATCH_ADDR := 0x90000000
-SCRATCH_SIZE := 128 #size in MB
-
-KEYS_USE_GPIO_KEYPAD := 1
-
-MODULES += \
-	dev/keys \
-	dev/ssbi \
-	dev/pmic/pm8921 \
-	lib/ptable
-
-DEFINES += \
-	MEMSIZE=$(MEMSIZE) \
-	MEMBASE=$(MEMBASE) \
-	SCRATCH_ADDR=$(SCRATCH_ADDR) \
-	SCRATCH_SIZE=$(SCRATCH_SIZE)
-
-OBJS += \
-	$(LOCAL_DIR)/init.o \
-	$(LOCAL_DIR)/atags.o \
-	$(LOCAL_DIR)/keypad.o
diff --git a/target/apq8064/tools/makefile b/target/apq8064/tools/makefile
deleted file mode 100644
index 7da7c6d..0000000
--- a/target/apq8064/tools/makefile
+++ /dev/null
@@ -1,44 +0,0 @@
-#Makefile to generate appsboot.mbn
-
-ifeq ($(BOOTLOADER_OUT),.)
-APPSBOOTHEADER_DIR  := $(BUILDDIR)
-else
-APPSBOOTHEADER_DIR  := $(BOOTLOADER_OUT)/../../
-endif
-
-SRC_DIR  := target/$(TARGET)/tools
-COMPILER := gcc
-
-ifeq ($(EMMC_BOOT), 1)
-  APPSBOOTHDR_FILES := EMMCBOOT.MBN
-else
-  ifeq ($(BUILD_NANDWRITE), 1)
-    APPSBOOTHDR_FILES :=
-  else
-    APPSBOOTHDR_FILES := appsboot.mbn
-  endif
-endif
-
-APPSBOOTHEADER: $(APPSBOOTHDR_FILES)
-
-
-appsboot.mbn: appsboothd.mbn $(OUTBIN)
-	cp $(OUTBIN) $(APPSBOOTHEADER_DIR)/appsboot.raw
-	cat $(APPSBOOTHEADER_DIR)/appsboothd.mbn $(OUTBIN) > $(APPSBOOTHEADER_DIR)/appsboot.mbn
-	rm -f $(APPSBOOTHEADER_DIR)/appsboothd.mbn
-
-appsboothd.mbn: mkheader $(OUTBIN)
-	$(SRC_DIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/appsboothd.mbn
-
-EMMCBOOT.MBN: emmc_appsboothd.mbn $(OUTBIN)
-	cp $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboot.raw
-	cat $(APPSBOOTHEADER_DIR)/emmc_appsboothd.mbn $(OUTBIN) > $(APPSBOOTHEADER_DIR)/EMMCBOOT.MBN
-	cat $(APPSBOOTHEADER_DIR)/emmc_appsboothd.mbn $(OUTBIN) > $(APPSBOOTHEADER_DIR)/emmc_appsboot.mbn
-	rm -f $(APPSBOOTHEADER_DIR)/emmc_appsboothd.mbn
-
-emmc_appsboothd.mbn: mkheader $(OUTBIN)
-	$(SRC_DIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboothd.mbn
-
-mkheader: $(SRC_DIR)/mkheader.c
-	${COMPILER} -DMEMBASE=$(MEMBASE) $(SRC_DIR)/mkheader.c -o $(SRC_DIR)/mkheader
-	cp $(SRC_DIR)/mkheader $(APPSBOOTHEADER_DIR)/mkheader
diff --git a/target/apq8064/tools/mkheader.c b/target/apq8064/tools/mkheader.c
deleted file mode 100644
index cd11810..0000000
--- a/target/apq8064/tools/mkheader.c
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * Copyright (c) 2007, Google Inc.
- * All rights reserved.
- *
- * Copyright (c) 2009-2011, 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 Google, Inc. 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 AND FITNESS
- * FOR A PARTICULAR PURPOSE 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 <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-
-#include <sys/stat.h>
-
-int print_usage(){
-	fprintf(stderr,"usage: mkheader <bin> <hdr> <none|unified-boot>\n");
-	fprintf(stderr,"       mkheader <bin> <hdr> <unsecure-boot>"
-		       " <outbin>\n");
-	fprintf(stderr,"       mkheader <bin> <hdr> <secure-boot> <outbin>"
-		       " <maxsize>\n");
-	fprintf(stderr,"       mkheader <bin> <hdr> <secure-boot> <outbin>"
-		       " <maxsize> <certchain> <files...>\n\n");
-	fprintf(stderr,"bin:               Input raw appsbl binary\n");
-	fprintf(stderr,"hdr:               Output of appsbl header location\n");
-	fprintf(stderr,"outbin:            Output of the signed or unsigned"
-		       " apps boot location\n");
-	fprintf(stderr,"maxsize:           Maximum size for certificate"
-		       " chain\n");
-	fprintf(stderr,"certchain:         Output of the certchain location\n");
-	fprintf(stderr,"files:             Input format <bin signature>"
-		       " <certifcate file(s) for certificate chain>...\n");
-	fprintf(stderr,"certificate chain: Files will be concatenated in order"
-		       " to create the certificate chain\n\n");
-	return -1;
-}
-
-int cat(FILE * in, FILE * out, unsigned size, unsigned buff_size){
-	unsigned bytes_left = size;
-	char buf[buff_size];
-	int ret = 0;
-
-	while(bytes_left){
-		fread(buf, sizeof(char), buff_size, in);
-		if(!feof(in)){
-			bytes_left -= fwrite(buf, sizeof(char), buff_size, out);
-		}
-		else
-			bytes_left = 0;
-	}
-	ret = ferror(in) | ferror(out);
-	if(ret)
-		fprintf(stderr, "ERROR: Occured during file concatenation\n");
-	return ret;
-}
-
-int main(int argc, char *argv[])
-{
-	struct stat s;
-	unsigned size, base;
-	int unified_boot = 0;
-	unsigned unified_boot_magic[20];
-	unsigned non_unified_boot_magic[10];
-	unsigned magic_len = 0;
-	unsigned *magic;
-	unsigned cert_chain_size = 0;
-	unsigned signature_size = 0;
-	int secure_boot = 0;
-	int fd;
-
-	if(argc < 3) {
-		return print_usage();
-	}
-
-	if(argc == 4) {
-		if(!strcmp("unified-boot",argv[3])) {
-			unified_boot = 1;
-		}
-		else if(!strcmp("secure-boot",argv[3])){
-			fprintf(stderr,
-				"ERROR: Missing arguments: [outbin maxsize] |"
-				" [outbin, maxsize, certchain,"
-				" signature + certifcate(s)]\n");
-			return print_usage();
-		}
-		else if(!strcmp("unsecure-boot",argv[3])){
-			fprintf(stderr,"ERROR: Missing arguments:"
-				       " outbin directory\n");
-			return print_usage();
-		}
-	}
-
-	if(argc > 4) {
-		if(!strcmp("secure-boot",argv[3])) {
-			if(argc < 9 && argc != 6){
-				fprintf(stderr,
-					"ERROR: Missing argument(s):"
-					" [outbin maxsize] | [outbin, maxsize,"
-					" certchain,"
-					" signature + certifcate(s)]\n");
-				return print_usage();
-			}
-			secure_boot = 1;
-			signature_size = 256; //Support SHA 256
-			cert_chain_size = atoi(argv[5]);
-		}
-	}
-
-	if(stat(argv[1], &s)) {
-		perror("cannot stat binary");
-		return -1;
-	}
-
-	if(unified_boot) {
-		magic = unified_boot_magic;
-		magic_len = sizeof(unified_boot_magic);
-	}
-	else {
-		magic = non_unified_boot_magic;
-		magic_len = sizeof(non_unified_boot_magic);
-	}
-
-	size = s.st_size;
-#if MEMBASE
-	base = MEMBASE;
-#else
-	base = 0;
-#endif
-
-	printf("Image Destination Pointer: 0x%x\n", base);
-
-	magic[0] = 0x00000005; /* appsbl */
-	magic[1] = 0x00000003; //Flash_partition_version /* nand */
-	magic[2] = 0x00000000; //image source pointer
-	magic[3] = base;       //image destination pointer
-	magic[4] = size + cert_chain_size + signature_size; //image size
-	magic[5] = size;       //code size
-	magic[6] = base + size;
-	magic[7] = signature_size;
-	magic[8] = size + base + signature_size;
-	magic[9] = cert_chain_size;
-
-	if(unified_boot == 1)
-	{
-		magic[10] = 0x33836685;	/* cookie magic number */
-		magic[11] = 0x00000001;	/* cookie version */
-		magic[12] = 0x00000002;	/* file formats */
-		magic[13] = 0x00000000;
-		magic[14] = 0x00000000;	/* not setting size for boot.img */
-		magic[15] = 0x00000000;
-		magic[16] = 0x00000000;
-		magic[17] = 0x00000000;
-		magic[18] = 0x00000000;
-		magic[19] = 0x00000000;
-	}
-
-	fd = open(argv[2], O_WRONLY | O_CREAT | O_TRUNC, 0644);
-	if(fd < 0) {
-		perror("cannot open header for writing");
-		return -1;
-	}
-	if(write(fd, magic, magic_len) != magic_len) {
-		perror("cannot write header");
-		close(fd);
-		unlink(argv[2]);
-		return -1;
-	}
-	close(fd);
-
-	if(secure_boot && argc > 6){
-		FILE * input_file;
-		FILE * output_file;
-		unsigned buff_size = 1;
-		char buf[buff_size];
-		unsigned bytes_left;
-		unsigned current_cert_chain_size = 0;
-		int padding_size = 0;
-		int i;
-
-		if((output_file = fopen(argv[6], "wb"))==NULL){
-			perror("ERROR: Occured during fopen");
-			return -1;
-		}
-		printf("Certificate Chain Output File: %s\n", argv[6]);
-
-		for(i = 8; i < argc; i++){
-			if((input_file = fopen(argv[i], "rb"))==NULL){
-				perror("ERROR: Occured during fopen");
-				return -1;
-			}
-			stat(argv[i], &s);
-			bytes_left = s.st_size;
-			current_cert_chain_size += bytes_left;
-			if(cat(input_file, output_file, bytes_left, buff_size))
-				return -1;
-			fclose(input_file);
-		}
-
-		//Pad certifcate chain to the max expected size from input
-		memset(buf, 0xFF, sizeof(buf));
-		padding_size = cert_chain_size - current_cert_chain_size;
-
-		if(padding_size <0){
-			fprintf(stderr, "ERROR: Input certificate chain"
-					" (Size=%d) is larger than the maximum"
-					" specified (Size=%d)\n",
-				current_cert_chain_size, cert_chain_size);
-			return -1;
-		}
-
-		bytes_left = (padding_size > 0) ? padding_size : 0;
-		while(bytes_left){
-			if(!ferror(output_file))
-				bytes_left -= fwrite(buf,
-						     sizeof(buf),
-						     buff_size,
-						     output_file);
-			else{
-				fprintf(stderr, "ERROR: Occured during"
-						" certifcate chain padding\n");
-				return -1;
-			}
-		}
-		fclose(output_file);
-
-		/* Concat and combine to signed image.
-		 * Format [HDR][RAW APPSBOOT][PADDED CERT CHAIN]
-		 */
-		if((output_file = fopen(argv[4], "wb"))==NULL){
-			perror("ERROR: Occured during fopen");
-			return -1;
-		}
-		printf("Image Output File: %s\n", argv[4]);
-
-		//Header
-		if((input_file = fopen(argv[2], "rb"))==NULL){
-			perror("ERROR: Occured during fopen");
-			return -1;
-		}
-		stat(argv[2], &s);
-		if(cat(input_file, output_file, s.st_size, buff_size))
-			return -1;
-		fclose(input_file);
-
-		//Raw Appsbl
-		if((input_file = fopen(argv[1], "rb"))==NULL){
-			perror("ERROR: Occured during fopen");
-			return -1;
-		}
-		stat(argv[1], &s);
-		if(cat(input_file, output_file, s.st_size, buff_size))
-			return -1;
-		fclose(input_file);
-
-		//Signature
-		if((input_file = fopen(argv[7], "rb"))==NULL){
-			perror("ERROR: Occured during fopen");
-			return -1;
-		}
-		stat(argv[7], &s);
-		if(cat(input_file, output_file, s.st_size, buff_size))
-			return -1;
-		fclose(input_file);
-
-		//Certifcate Chain
-		if((input_file = fopen(argv[6], "rb"))==NULL){
-			perror("ERROR: Occured during fopen");
-			return -1;
-		}
-		if(cat(input_file, output_file,
-		       (current_cert_chain_size + padding_size), buff_size))
-			return -1;
-		fclose(input_file);
-
-		fclose(output_file);
-
-	}
-	else if(argc == 5 || argc == 6){
-		FILE * input_file;
-		FILE * output_file;
-		unsigned buff_size = 1;
-		char buf[buff_size];
-
-		/* Concat and combine to unsigned image.
-		 * Format [HDR][RAW APPSBOOT]
-		 */
-		if((output_file = fopen(argv[4], "wb"))==NULL){
-			perror("ERROR: Occured during fopen");
-			return -1;
-		}
-		printf("Image Output File: %s\n", argv[4]);
-
-		//Header
-		if((input_file = fopen(argv[2], "rb"))==NULL){
-			perror("ERROR: Occured during fopen");
-			return -1;
-		}
-		stat(argv[2], &s);
-		if(cat(input_file, output_file, s.st_size, buff_size))
-			return -1;
-		fclose(input_file);
-
-		//Raw Appsbl
-		if((input_file = fopen(argv[1], "rb"))==NULL){
-			perror("ERROR: Occured during fopen");
-			return -1;
-		}
-		stat(argv[1], &s);
-		if(cat(input_file, output_file, s.st_size, buff_size))
-			return -1;
-		fclose(input_file);
-		fclose(output_file);
-	}
-
-	printf("Done execution\n");
-
-	return 0;
-}
diff --git a/target/init.c b/target/init.c
index 3da8d89..4119eb7 100644
--- a/target/init.c
+++ b/target/init.c
@@ -80,7 +80,7 @@
 
 __WEAK void target_serialno(unsigned char *buf)
 {
-	sprintf((char *) buf, "%s",TARGET(BOARD));
+	snprintf((char *) buf, 13, "%s",TARGET(BOARD));
 }
 
 __WEAK void target_fastboot_init()
diff --git a/target/mdm9615/atags.c b/target/mdm9615/atags.c
index 18e75cf..f9b636f 100644
--- a/target/mdm9615/atags.c
+++ b/target/mdm9615/atags.c
@@ -36,7 +36,6 @@
 #define SIZE_15M    (15 * SIZE_1M)
 #define SIZE_23M    (23 * SIZE_1M)
 #define SIZE_88M    (11 * SIZE_8M)
-#define SIZE_128M   (128 * SIZE_1M)
 
 unsigned* target_atag_mem(unsigned* ptr)
 {
@@ -74,7 +73,12 @@
 	return ptr;
 }
 
+void *target_get_scratch_address(void)
+{
+	return((void *)SCRATCH_ADDR);
+}
+
 unsigned target_get_max_flash_size(void)
 {
-	return (SIZE_128M);
+	return (SIZE_23M);
 }
diff --git a/target/mdm9615/init.c b/target/mdm9615/init.c
index 3788bc3..ed569bc 100644
--- a/target/mdm9615/init.c
+++ b/target/mdm9615/init.c
@@ -215,4 +215,14 @@
 			name_size = strlen(ptable_ptn_names[name_index]);
 		}
 	}
+
+	/* Update the end to be actual end for grow partition */
+	ptn_index--;
+	for (;ptentry_ptr[ptn_index].length != end; ptn_index++){};
+
+	/* If SMEM ptable is updated already then don't manually update this */
+	if (ptentry_ptr[ptn_index].start != end)
+		ptentry_ptr[ptn_index].length =
+			((struct flash_info*)flash_get_info())->num_blocks -
+			ptentry_ptr[ptn_index].start;
 }
diff --git a/target/mdm9615/rules.mk b/target/mdm9615/rules.mk
index b2839ee..960894a 100644
--- a/target/mdm9615/rules.mk
+++ b/target/mdm9615/rules.mk
@@ -8,7 +8,7 @@
 MEMSIZE := 0x00100000 # 1MB
 
 BASE_ADDR        := 0x40800000
-SCRATCH_ADDR     := BASE_ADDR+0x04000000
+SCRATCH_ADDR     := BASE_ADDR+0x05000000
 
 DEFINES += NO_KEYPAD_DRIVER=1
 
diff --git a/target/msm7627a/init.c b/target/msm7627a/init.c
index b5b7185..4078823 100644
--- a/target/msm7627a/init.c
+++ b/target/msm7627a/init.c
@@ -45,6 +45,8 @@
 #define MSM7X27A_SURF	3352
 #define MSM7X27A_RUMI3	3353
 #define MSM7X27A_QRD1	3756
+#define MSM7X25A_SURF	3772
+#define MSM7X25A_FFA	3771
 
 #define LINUX_MACHTYPE  MSM7X27A_SURF
 
@@ -275,16 +277,32 @@
 		switch(id)
 		{
 			case 0x1:
-				hw_platform = MSM7X27A_SURF;
+				/* Set the machine type based on msm ID */
+				if (target_msm_id == MSM7225A || target_msm_id == MSM7625A || \
+					target_msm_id == ESM7225A || (target_msm_id >= MSM7225AA \
+					&& target_msm_id <= ESM7225AA))
+					hw_platform = MSM7X25A_SURF;
+				else
+					hw_platform = MSM7X27A_SURF;
 				break;
 			case 0x2:
-				hw_platform = MSM7X27A_FFA;
+				if (target_msm_id == MSM7225A || target_msm_id == MSM7625A || \
+					target_msm_id == ESM7225A || (target_msm_id >= MSM7225AA \
+					&& target_msm_id <= ESM7225AA))
+					hw_platform = MSM7X25A_FFA;
+				else
+					hw_platform = MSM7X27A_FFA;
 				break;
 			case 0xB:
 				hw_platform = MSM7X27A_QRD1;
 				break;
 			default:
-				hw_platform = MSM7X27A_SURF;
+				if (target_msm_id == MSM7225A || target_msm_id == MSM7625A || \
+					target_msm_id == ESM7225A || (target_msm_id >= MSM7225AA \
+					&& target_msm_id <= ESM7225AA))
+					hw_platform = MSM7X25A_SURF;
+				else
+					hw_platform = MSM7X27A_SURF;
 		};
 
 		if ((target_msm_id < MSM7225A) || (target_msm_id > ESM7227A))
diff --git a/target/msm7627a/keypad.c b/target/msm7627a/keypad.c
index 15aef13..4d9fde9 100644
--- a/target/msm7627a/keypad.c
+++ b/target/msm7627a/keypad.c
@@ -34,6 +34,8 @@
 #include <dev/ssbi.h>
 #include <dev/gpio_keypad.h>
 
+#define LINUX_MACHTYPE_7x27A_QRD 3756
+
 #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
 
 /* don't turn this on without updating the ffa support */
@@ -42,7 +44,11 @@
 static unsigned int halibut_row_gpios[] = {31, 32, 33, 34, 35};
 static unsigned int halibut_col_gpios[] = {36, 37, 38, 39, 40};
 
+static unsigned int halibut_row_gpios_qrd[] = {31, 32};
+static unsigned int halibut_col_gpios_qrd[] = {36, 37};
+
 #define KEYMAP_INDEX(row, col) ((row)*ARRAY_SIZE(halibut_col_gpios) + (col))
+#define KEYMAP_INDEX_QRD(row, col) ((row)*ARRAY_SIZE(halibut_col_gpios_qrd) + (col))
 
 static const unsigned short halibut_keymap[ARRAY_SIZE(halibut_col_gpios) * ARRAY_SIZE(halibut_row_gpios)] = {
 	[KEYMAP_INDEX(0, 0)] = KEY_7,
@@ -76,7 +82,12 @@
 	[KEYMAP_INDEX(4, 4)] = KEY_VOLUMEDOWN,
 };
 
-static struct gpio_keypad_info halibut_keypad_info = {
+static const unsigned short halibut_keymap_qrd[ARRAY_SIZE(halibut_col_gpios_qrd) * ARRAY_SIZE(halibut_row_gpios_qrd)] = {
+	[KEYMAP_INDEX_QRD(0, 0)] = KEY_VOLUMEUP,
+	[KEYMAP_INDEX_QRD(0, 1)] = KEY_VOLUMEDOWN,
+};
+
+static struct gpio_keypad_info halibut_keypad_info_surf = {
 	.keymap		= halibut_keymap,
 	.output_gpios	= halibut_row_gpios,
 	.input_gpios	= halibut_col_gpios,
@@ -87,7 +98,23 @@
 	.flags		= GPIOKPF_DRIVE_INACTIVE,
 };
 
+static struct gpio_keypad_info halibut_keypad_info_qrd = {
+	.keymap 	= halibut_keymap_qrd,
+	.output_gpios	= halibut_row_gpios_qrd,
+	.input_gpios	= halibut_col_gpios_qrd,
+	.noutputs	= ARRAY_SIZE(halibut_row_gpios_qrd),
+	.ninputs	= ARRAY_SIZE(halibut_col_gpios_qrd),
+	.settle_time	= 5 /* msec */,
+	.poll_time	= 20 /* msec */,
+	.flags		= GPIOKPF_DRIVE_INACTIVE,
+};
 void keypad_init(void)
 {
-	gpio_keypad_init(&halibut_keypad_info);
+	unsigned int mach_id;
+	mach_id = board_machtype();
+
+	if (mach_id == LINUX_MACHTYPE_7x27A_QRD)
+		gpio_keypad_init(&halibut_keypad_info_qrd);
+	else
+		gpio_keypad_init(&halibut_keypad_info_surf);
 }
diff --git a/target/msm7627a/panel.c b/target/msm7627a/panel.c
index 30295c0..b7f6854 100644
--- a/target/msm7627a/panel.c
+++ b/target/msm7627a/panel.c
@@ -34,53 +34,6 @@
 #include <platform/clock.h>
 #include <target/display.h>
 
-int mipi_dsi_phy_init(struct mipi_dsi_panel_config *pinfo){
-    struct mipi_dsi_phy_ctrl *pd;
-    uint32_t i, off = 0;
-
-    writel(0x00000001, DSI_PHY_SW_RESET);
-    mdelay(50);
-    writel(0x00000000, DSI_PHY_SW_RESET);
-
-    pd = (pinfo->dsi_phy_config);
-
-    off = 0x02cc;    /* regulator ctrl 0 */
-    for (i = 0; i < 4; i++) {
-            writel(pd->strength[i], MIPI_DSI_BASE + off);
-        off += 4;
-    }
-
-    off = 0x0260;   /* phy timig ctrl 0 */
-    for (i = 0; i < 11; i++) {
-            writel(pd->timing[i], MIPI_DSI_BASE + off);
-        off += 4;
-    }
-        writel(0x202f, DSI_CLKOUT_TIMING_CTRL);
-
-    off = 0x0290;    /* ctrl 0 */
-    for (i = 0; i < 4; i++) {
-            writel(pd->ctrl[i], MIPI_DSI_BASE + off);
-        off += 4;
-    }
-
-    off = 0x02a0;    /* strength 0 */
-    for (i = 0; i < 4; i++) {
-            writel(pd->strength[i], MIPI_DSI_BASE + off);
-        off += 4;
-    }
-
-    /* calibration ctrl */
-    writel(0x67, MIPI_DSI_BASE + 0x100);
-
-    /* pll ctrl 0 */
-    writel(pd->pll[0], MIPI_DSI_BASE + 0x200);
-    writel((pd->pll[0] | 0x01), MIPI_DSI_BASE + 0x200);
-
-    /* lane swap ctrl */
-    writel(0x1, MIPI_DSI_BASE + 0xac);
-    return 0;
-}
-
 void config_renesas_dsi_video_mode(void)
 {
 
diff --git a/target/msm7630_surf/init.c b/target/msm7630_surf/init.c
index 42673e0..09f77c9 100644
--- a/target/msm7630_surf/init.c
+++ b/target/msm7630_surf/init.c
@@ -378,7 +378,7 @@
 {
 	unsigned int serialno;
 	serialno =  mmc_get_psn();
-	sprintf(buf,"%x",serialno);
+	snprintf(buf, 13, "%x", serialno);
 }
 
 int emmc_recovery_init(void)
diff --git a/target/msm8660_surf/init.c b/target/msm8660_surf/init.c
index 46aa665..07e6130 100755
--- a/target/msm8660_surf/init.c
+++ b/target/msm8660_surf/init.c
@@ -410,7 +410,7 @@
 	if(target_is_emmc_boot())
 	{
 		serialno =  mmc_get_psn();
-		sprintf((char *) buf, "%x", serialno);
+		snprintf((char *) buf, 13, "%x", serialno);
 	}
 }
 
diff --git a/target/msm8960/init.c b/target/msm8960/init.c
index ba1f5c4..32f974b 100644
--- a/target/msm8960/init.c
+++ b/target/msm8960/init.c
@@ -43,7 +43,9 @@
 #include <gsbi.h>
 #include <target.h>
 #include <platform.h>
+#include <baseband.h>
 
+/* 8960 */
 #define LINUX_MACHTYPE_8960_SIM     3230
 #define LINUX_MACHTYPE_8960_RUMI3   3231
 #define LINUX_MACHTYPE_8960_CDP     3396
@@ -51,19 +53,38 @@
 #define LINUX_MACHTYPE_8960_FLUID   3398
 #define LINUX_MACHTYPE_8960_APQ     3399
 #define LINUX_MACHTYPE_8960_LIQUID  3535
+
+/* 8930 */
 #define LINUX_MACHTYPE_8930_CDP     3727
 #define LINUX_MACHTYPE_8930_MTP     3728
 #define LINUX_MACHTYPE_8930_FLUID   3729
 
+/* 8064 */
+#define LINUX_MACHTYPE_8064_SIM     3572
+#define LINUX_MACHTYPE_8064_RUMI3   3679
+
 extern void dmb(void);
 extern void keypad_init(void);
 extern void panel_backlight_on(void);
 
 static unsigned mmc_sdc_base[] = { MSM_SDC1_BASE, MSM_SDC2_BASE, MSM_SDC3_BASE, MSM_SDC4_BASE};
 
+static uint32_t platform_id;
+static uint32_t target_id;
+
 static pm8921_dev_t pmic;
 
-static const uint8_t uart_gsbi_id  = GSBI_ID_5;
+static void     target_detect(void);
+static uint8_t  get_uart_gsbi(void);
+
+void target_early_init(void)
+{
+	target_detect();
+
+#if WITH_DEBUG_UART
+	uart_init(get_uart_gsbi());
+#endif
+}
 
 void shutdown_device(void)
 {
@@ -81,6 +102,7 @@
 {
 	unsigned base_addr;
 	unsigned char slot;
+
 	dprintf(INFO, "target_init()\n");
 
 	/* Initialize PMIC driver */
@@ -88,16 +110,20 @@
 	pmic.write = (pm8921_write_func) &pa1_ssbi2_write_bytes;
 
 	pm8921_init(&pmic);
+
 	/* Keypad init */
 	keys_init();
 	keypad_init();
 
 	/* Display splash screen if enabled */
 #if DISPLAY_SPLASH_SCREEN
-	panel_backlight_on();
-	display_init();
-	dprintf(SPEW, "Diplay initialized\n");
-	display_image_on_screen();
+	if((platform_id == MSM8960) || (platform_id == MSM8930))
+	{
+		panel_backlight_on();
+		display_init();
+		dprintf(SPEW, "Diplay initialized\n");
+		display_image_on_screen();
+	}
 #endif
 
 	/* Trying Slot 1 first */
@@ -118,12 +144,17 @@
 
 unsigned board_machtype(void)
 {
+	return target_id;
+}
+
+
+void target_detect(void)
+{
 	struct smem_board_info_v6 board_info_v6;
 	unsigned int board_info_len = 0;
 	unsigned smem_status = 0;
 	unsigned format = 0;
 	unsigned id = HW_PLATFORM_UNKNOWN;
-	unsigned mach_id;
 
 
 	smem_status = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION,
@@ -143,46 +174,93 @@
 		}
 	}
 
+	platform_id = board_info_v6.board_info_v3.msm_id;
+
 	/* Detect the board we are running on */
-	if (board_info_v6.board_info_v3.msm_id == MSM8960)
+	if (platform_id == MSM8960)
 	{
 		switch(id)
 		{
 			case HW_PLATFORM_SURF:
-				mach_id = LINUX_MACHTYPE_8960_CDP;
+				target_id = LINUX_MACHTYPE_8960_CDP;
 				break;
 			case HW_PLATFORM_MTP:
-				mach_id = LINUX_MACHTYPE_8960_MTP;
+				target_id = LINUX_MACHTYPE_8960_MTP;
 				break;
 			case HW_PLATFORM_FLUID:
-				mach_id = LINUX_MACHTYPE_8960_FLUID;
+				target_id = LINUX_MACHTYPE_8960_FLUID;
 				break;
 			case HW_PLATFORM_LIQUID:
-				mach_id = LINUX_MACHTYPE_8960_LIQUID;
+				target_id = LINUX_MACHTYPE_8960_LIQUID;
 				break;
 			default:
-				mach_id = LINUX_MACHTYPE_8960_CDP;
+				target_id = LINUX_MACHTYPE_8960_CDP;
 		}
 	}
-	else if (board_info_v6.board_info_v3.msm_id == MSM8930)
+	else if (platform_id == MSM8930)
 	{
 		switch(id)
 		{
 			case HW_PLATFORM_SURF:
-				mach_id = LINUX_MACHTYPE_8930_CDP;
+				target_id = LINUX_MACHTYPE_8930_CDP;
 				break;
 			case HW_PLATFORM_MTP:
-				mach_id = LINUX_MACHTYPE_8930_MTP;
+				target_id = LINUX_MACHTYPE_8930_MTP;
 				break;
 			case HW_PLATFORM_FLUID:
-				mach_id = LINUX_MACHTYPE_8930_FLUID;
+				target_id = LINUX_MACHTYPE_8930_FLUID;
 				break;
 			default:
-				mach_id = LINUX_MACHTYPE_8930_CDP;
+				target_id = LINUX_MACHTYPE_8930_CDP;
 		}
 	}
+	else if (platform_id == APQ8064)
+	{
+		switch(id)
+		{
+			case HW_PLATFORM_SURF:
+				target_id = LINUX_MACHTYPE_8064_SIM;
+				break;
+			default:
+				target_id = LINUX_MACHTYPE_8064_RUMI3;
+		}
+	}
+	else
+	{
+		dprintf(CRITICAL, "platform_id (%d) is not identified.\n", platform_id);
+		ASSERT(0);
+	}
+}
 
-	return mach_id;
+unsigned target_baseband()
+{
+	struct smem_board_info_v6 board_info_v6;
+	unsigned int board_info_len = 0;
+	unsigned smem_status = 0;
+	unsigned format = 0;
+	unsigned baseband = BASEBAND_MSM;
+
+	smem_status = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION,
+					&format, sizeof(format), 0);
+	if(!smem_status)
+	{
+		if (format >= 6)
+		{
+			board_info_len = sizeof(board_info_v6);
+
+			smem_status = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
+							&board_info_v6, board_info_len);
+			if(!smem_status)
+			{
+				/* Check for LTE fused target.  Default to MSM */
+				if (board_info_v6.platform_subtype == HW_PLATFORM_SUBTYPE_MDM)
+					baseband = BASEBAND_MDM;
+				else
+					baseband = BASEBAND_MSM;
+			}
+		}
+	}
+	return baseband;
 }
 
 void reboot_device(unsigned reboot_reason)
@@ -213,7 +291,7 @@
 	if(target_is_emmc_boot())
 	{
 		serialno =  mmc_get_psn();
-		sprintf((char *) buf,"%x",serialno);
+		snprintf((char *) buf, 13, "%x", serialno);
 	}
 }
 
@@ -228,7 +306,35 @@
 	pm8921_boot_done();
 }
 
-uint8_t target_uart_gsbi(void)
+uint8_t get_uart_gsbi(void)
 {
-	return uart_gsbi_id;
+	switch(target_id)
+	{
+		case LINUX_MACHTYPE_8960_SIM:
+		case LINUX_MACHTYPE_8960_RUMI3:
+		case LINUX_MACHTYPE_8960_CDP:
+		case LINUX_MACHTYPE_8960_MTP:
+		case LINUX_MACHTYPE_8960_FLUID:
+		case LINUX_MACHTYPE_8960_APQ:
+		case LINUX_MACHTYPE_8960_LIQUID:
+
+			return GSBI_ID_5;
+
+		case LINUX_MACHTYPE_8930_CDP:
+		case LINUX_MACHTYPE_8930_MTP:
+		case LINUX_MACHTYPE_8930_FLUID:
+
+			return GSBI_ID_5;
+
+		case LINUX_MACHTYPE_8064_SIM:
+		case LINUX_MACHTYPE_8064_RUMI3:
+
+			return GSBI_ID_3;
+
+		default:
+			dprintf(CRITICAL, "uart gsbi not defined for target: %d\n",
+					target_id);
+
+			ASSERT(0);
+	}
 }