[msm8960]: Initial support for MSM8960.
What is working in this patch:
- Fastboot flash boot.img on to eMMC
- Fastboot boot
- Boot boot.img from eMMC
Not in this patch:
- Clock settings are not done in LK. Expects
startup scripts to setup the required
clocks.
Change-Id: I230bb92c6b214976a84a79a7f770f190e822f647
diff --git a/arch/arm/crt0.S b/arch/arm/crt0.S
index cb6e552..68dbc67 100644
--- a/arch/arm/crt0.S
+++ b/arch/arm/crt0.S
@@ -44,6 +44,7 @@
#endif
/* do some cpu setup */
#if ARM_WITH_CP15
+ /* Read SCTLR */
mrc p15, 0, r0, c1, c0, 0
/* XXX this is currently for arm926, revist with armv6 cores */
/* new thumb behavior, low exception vectors, i/d cache disable, mmu disabled */
@@ -51,6 +52,7 @@
bic r0, r0, #(1<<2 | 1<<0)
/* enable alignment faults */
orr r0, r0, #(1<<1)
+ /* Write SCTLR */
mcr p15, 0, r0, c1, c0, 0
#ifdef ENABLE_TRUSTZONE
/*nkazi: not needed ? Setting VBAR to location of new vector table : 0x80000 */
diff --git a/platform/msm8x60/include/platform/iomap.h b/platform/msm8x60/include/platform/iomap.h
index e7d23db..2714df6 100755
--- a/platform/msm8x60/include/platform/iomap.h
+++ b/platform/msm8x60/include/platform/iomap.h
@@ -36,21 +36,30 @@
#define MSM_UART3_BASE 0xA9C00000
#define MSM_VIC_BASE 0x02080000
-#define MSM_TMR_BASE 0x02000000
+
+#ifdef PLATFORM_MSM8960
+ #define MSM_TMR_BASE 0x0200A000
+ #define MSM_TCSR_BASE 0x1A400000
+ #define MSM_GIC_CPU_BASE 0x02002000
+ #define MSM_GIC_DIST_BASE 0x02000000
+#else
+ #define MSM_TMR_BASE 0x02000000
+ #define MSM_TCSR_BASE 0x16B00000
+ #define MSM_GIC_CPU_BASE 0x02081000
+ #define MSM_GIC_DIST_BASE 0x02080000
+#endif
+
#define MSM_GPT_BASE (MSM_TMR_BASE + 0x04)
#define MSM_CSR_BASE 0x02081000
#define MSM_GCC_BASE 0x02082000
#define MSM_ACC0_BASE 0x02041000
#define MSM_ACC1_BASE 0x02051000
-#define MSM_TCSR_BASE 0x16B00000
#define TCSR_WDOG_CFG 0x30
#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 MSM_GIC_CPU_BASE 0x02081000
-#define MSM_GIC_DIST_BASE 0x02080000
#define MSM_SDC1_BASE 0x12400000
diff --git a/platform/msm8x60/include/platform/irqs.h b/platform/msm8x60/include/platform/irqs.h
index 7fbf37e..66cea19 100755
--- a/platform/msm8x60/include/platform/irqs.h
+++ b/platform/msm8x60/include/platform/irqs.h
@@ -33,7 +33,12 @@
#define GIC_PPI_START 16
#define GIC_SPI_START 32
-#define INT_DEBUG_TIMER_EXP (GIC_PPI_START + 0)
+
+#ifdef PLATFORM_MSM8960
+ #define INT_DEBUG_TIMER_EXP (GIC_PPI_START + 1)
+#else
+ #define INT_DEBUG_TIMER_EXP (GIC_PPI_START + 0)
+#endif
#define USB1_HS_IRQ (GIC_SPI_START + 100)
#define USB1_HS_BAM_IRQ (GIC_SPI_START + 94)
diff --git a/platform/msm8x60/mmc_init.c b/platform/msm8x60/mmc_init.c
index d0a89ec..9a32924 100755
--- a/platform/msm8x60/mmc_init.c
+++ b/platform/msm8x60/mmc_init.c
@@ -89,6 +89,11 @@
void clock_set_enable (unsigned int mclk)
{
+
+#ifdef PLATFORM_MSM8960
+ return;
+#endif
+
if (mclk == MMC_CLK_400KHZ)
{
mmc_set_clk(0x0010005B, 0x0001000F);
diff --git a/platform/msm_shared/hsusb.c b/platform/msm_shared/hsusb.c
index bdd8e2e..64fdd70 100644
--- a/platform/msm_shared/hsusb.c
+++ b/platform/msm_shared/hsusb.c
@@ -510,6 +510,7 @@
static int msm_otg_xceiv_reset()
{
+#ifndef PLATFORM_MSM8960
CLK_RESET(USB_CLK, CLK_RESET_ASSERT);
CLK_RESET(USB_PHY_CLK, CLK_RESET_ASSERT);
mdelay(20);
@@ -517,6 +518,7 @@
CLK_RESET(USB_CLK, CLK_RESET_DEASSERT);
mdelay(20);
+#endif
/* select ULPI phy */
writel(0x81000000, USB_PORTSC);
return 0;
@@ -527,7 +529,9 @@
int udc_init(struct udc_device *dev)
{
+#ifndef PLATFORM_MSM8960
hsusb_clock_init();
+#endif
epts = memalign(4096, 4096);
@@ -737,8 +741,8 @@
/* create our device descriptor */
desc = udc_descriptor_alloc(TYPE_DEVICE, 0, 18);
data = desc->data;
- data[2] = 0x10; /* usb spec rev 2.10 */
- data[3] = 0x02;
+ data[2] = 0x00; /* usb spec minor rev */
+ data[3] = 0x02; /* usb spec major rev */
data[4] = 0x00; /* class */
data[5] = 0x00; /* subclass */
data[6] = 0x00; /* protocol */
@@ -767,11 +771,13 @@
udc_ifc_desc_fill(the_gadget, data + 9);
udc_descriptor_register(desc);
+ register_int_handler(INT_USB_HS, udc_interrupt, (void*) 0);
+ writel(STS_URI | STS_SLI | STS_UI | STS_PCI, USB_USBINTR);
+ unmask_interrupt(INT_USB_HS);
+
/* go to RUN mode (D+ pullup enable) */
writel(0x00080001, USB_USBCMD);
- register_int_handler(INT_USB_HS, udc_interrupt, (void*) 0);
- unmask_interrupt(INT_USB_HS);
- writel(STS_URI | STS_SLI | STS_UI | STS_PCI, USB_USBINTR);
+
return 0;
}
diff --git a/platform/msm_shared/include/uart_dm.h b/platform/msm_shared/include/uart_dm.h
index bf386c4..9f8ed7b 100644
--- a/platform/msm_shared/include/uart_dm.h
+++ b/platform/msm_shared/include/uart_dm.h
@@ -104,7 +104,11 @@
/* Using GSBI12 for UART */
-#define MSM_BOOT_GSBI_BASE 0x19C00000
+#ifdef PLATFORM_MSM8960
+ #define MSM_BOOT_GSBI_BASE 0x16100000
+#else
+ #define MSM_BOOT_GSBI_BASE 0x19C00000
+#endif
#define MSM_BOOT_GSBI_CTRL_REG MSM_BOOT_GSBI_BASE
diff --git a/platform/msm_shared/timer.c b/platform/msm_shared/timer.c
index 9f98ffa..34062ca 100644
--- a/platform/msm_shared/timer.c
+++ b/platform/msm_shared/timer.c
@@ -47,7 +47,8 @@
#define MSM_DGT_BASE (MSM_TMR_BASE + 0x24)
#define GPT_REG(off) (MSM_GPT_BASE + (off))
#define DGT_REG(off) (MSM_DGT_BASE + (off))
-#define SPSS_TIMER_STATUS (MSM_TMR_BASE + 0x88)
+#define SPSS_TIMER_STATUS (MSM_TMR_BASE + 0x88)
+#define SPSS_TIMER_STATUS_DGT_EN (1 << 0)
#define GPT_MATCH_VAL GPT_REG(0x0000)
#define GPT_COUNT_VAL GPT_REG(0x0004)
@@ -160,7 +161,7 @@
static void wait_for_timer_op(void)
{
#if PLATFORM_QSD8K || PLATFORM_MSM7X30 || PLATFORM_MSM8X60
- while(readl(SPSS_TIMER_STATUS)) ;
+ while( readl(SPSS_TIMER_STATUS) & SPSS_TIMER_STATUS_DGT_EN );
#endif
}
diff --git a/platform/msm_shared/uart_dm.c b/platform/msm_shared/uart_dm.c
index 9e06cd0..a16ee71 100644
--- a/platform/msm_shared/uart_dm.c
+++ b/platform/msm_shared/uart_dm.c
@@ -197,7 +197,9 @@
static unsigned int msm_boot_uart_dm_gsbi_init(void)
{
/* Configure the clock block */
+#ifndef PLATFORM_MSM8960
msm_boot_uart_dm_config_clock();
+#endif
/* Configure TLMM/GPIO to provide connectivity between GSBI
product ports and chip pads */
diff --git a/project/msm8960.mk b/project/msm8960.mk
new file mode 100644
index 0000000..54e4c51
--- /dev/null
+++ b/project/msm8960.mk
@@ -0,0 +1,11 @@
+# top level project rules for the msm8960_virtio project
+#
+LOCAL_DIR := $(GET_LOCAL_DIR)
+
+TARGET := msm8960
+
+MODULES += app/aboot
+
+#DEFINES += WITH_DEBUG_DCC=1
+DEFINES += WITH_DEBUG_UART=1
+#DEFINES += WITH_DEBUG_FBCON=1
diff --git a/target/msm8960/atags.c b/target/msm8960/atags.c
new file mode 100644
index 0000000..de5a92a
--- /dev/null
+++ b/target/msm8960/atags.c
@@ -0,0 +1,51 @@
+/* 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.
+ *
+ */
+
+/* Note: As of now, kernel crashes when RAM size is configured as 2GB.
+ * Configuring to 64MB for now.
+ */
+#define SIZE_64M 0x04000000
+#define EBI1_ADDR_1026M 0x40200000
+
+unsigned* target_atag_mem(unsigned* ptr)
+{
+ unsigned value = 0;
+
+ /* ATAG_MEM */
+ *ptr++ = 4;
+ *ptr++ = 0x54410002;
+ *ptr++ = SIZE_64M;
+ *ptr++ = EBI1_ADDR_1026M;
+
+ return ptr;
+}
+
+void *target_get_scratch_address(void)
+{
+ return((void *)SCRATCH_ADDR);
+}
diff --git a/target/msm8960/include/target/display.h b/target/msm8960/include/target/display.h
new file mode 100644
index 0000000..e28d60f
--- /dev/null
+++ b/target/msm8960/include/target/display.h
@@ -0,0 +1,63 @@
+/* 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 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 _TARGET_MSM8960_DISPLAY_H
+#define _TARGET_MSM8960_DISPLAY_H
+
+#define TARGET_XRES 1024
+#define TARGET_YRES 600
+
+#define LCDC_FB_WIDTH 1024
+#define LCDC_FB_HEIGHT 600
+
+#define LCDC_HSYNC_PULSE_WIDTH_DCLK 32
+#define LCDC_HSYNC_BACK_PORCH_DCLK 80
+#define LCDC_HSYNC_FRONT_PORCH_DCLK 48
+#define LCDC_HSYNC_SKEW_DCLK 0
+
+#define LCDC_VSYNC_PULSE_WIDTH_LINES 1
+#define LCDC_VSYNC_BACK_PORCH_LINES 4
+#define LCDC_VSYNC_FRONT_PORCH_LINES 3
+
+/* Toshiba MIPI panel */
+#define TSH_MIPI_FB_WIDTH 480
+#define TSH_MIPI_FB_HEIGHT 854
+
+/* NOVATEK MIPI panel */
+#define NOV_MIPI_FB_WIDTH 540
+#define NOV_MIPI_FB_HEIGHT 960
+
+#define MIPI_HSYNC_PULSE_WIDTH 50
+#define MIPI_HSYNC_BACK_PORCH_DCLK 500
+#define MIPI_HSYNC_FRONT_PORCH_DCLK 500
+
+#define MIPI_VSYNC_PULSE_WIDTH 5
+#define MIPI_VSYNC_BACK_PORCH_LINES 20
+#define MIPI_VSYNC_FRONT_PORCH_LINES 20
+
+#endif
diff --git a/target/msm8960/init.c b/target/msm8960/init.c
new file mode 100644
index 0000000..d6c32d1
--- /dev/null
+++ b/target/msm8960/init.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2009, 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 <debug.h>
+#include <lib/ptable.h>
+#include <smem.h>
+#include <platform/iomap.h>
+#include <reg.h>
+
+#define LINUX_MACHTYPE_8960_SIM 3230
+#define LINUX_MACHTYPE_8960_RUMI3 3231
+
+void target_init(void)
+{
+ dprintf(INFO, "target_init()\n");
+
+ if(mmc_boot_main(MMC_SLOT, MSM_SDC1_BASE))
+ {
+ dprintf(CRITICAL, "mmc init failed!");
+ ASSERT(0);
+ }
+}
+
+unsigned board_machtype(void)
+{
+/* TODO: Add a run time mechanism to detect if we are running on RUMI3.
+ * Until then, LINUX_MACHTYPE_RUMI3 can be defined as compile time
+ * option for RUMI3.
+ */
+
+#ifdef LINUX_MACHTYPE_RUMI3
+ return LINUX_MACHTYPE_8960_RUMI3;
+#else
+ return LINUX_MACHTYPE_8960_SIM;
+#endif
+}
+
+void reboot_device(unsigned reboot_reason)
+{
+ /* Reset WDG0 counter */
+ writel(1,MSM_WDT0_RST);
+ /* Disable WDG0 */
+ writel(0,MSM_WDT0_EN);
+ /* Set WDG0 bark time */
+ writel(0x31F3,MSM_WDT0_BT);
+ /* Enable WDG0 */
+ writel(3,MSM_WDT0_EN);
+ dmb();
+ /* Enable WDG output */
+ writel(3,MSM_TCSR_BASE + TCSR_WDOG_CFG);
+ mdelay(10000);
+ dprintf (CRITICAL, "Rebooting failed\n");
+ return;
+}
+
+unsigned check_reboot_mode(void)
+{
+ unsigned restart_reason = 0;
+ void *restart_reason_addr = 0x401FFFFC;
+
+ /* Read reboot reason and scrub it */
+ restart_reason = readl(restart_reason_addr);
+ writel(0x00, restart_reason_addr);
+
+ return restart_reason;
+}
+
+void target_battery_charging_enable(unsigned enable, unsigned disconnect)
+{
+}
diff --git a/target/msm8960/keypad.c b/target/msm8960/keypad.c
new file mode 100644
index 0000000..9b87c87
--- /dev/null
+++ b/target/msm8960/keypad.c
@@ -0,0 +1,60 @@
+/*
+ * 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 <dev/keys.h>
+#include <dev/gpio_keypad.h>
+
+#define BITS_IN_ELEMENT(x) (sizeof(x)[0] * 8)
+
+static unsigned char qwerty_keys_old[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char qwerty_keys_new[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+#define KEYMAP_INDEX(row, col) (row)* BITS_IN_ELEMENT(qwerty_keys_new) + (col)
+
+static unsigned int qwerty_keymap[] = {
+ [KEYMAP_INDEX(1, 3)] = KEY_BACK, /* Volume down key */
+};
+
+static struct qwerty_keypad_info qwerty_keypad = {
+ .keymap = qwerty_keymap,
+ .old_keys = qwerty_keys_old,
+ .rec_keys = qwerty_keys_new,
+ .rows = 6,
+ .columns = 5,
+ .num_of_reads = 6,
+ .rd_func = &pa1_ssbi2_read_bytes,
+ .wr_func = &pa1_ssbi2_write_bytes,
+ .settle_time = 5 /* msec */,
+ .poll_time = 20 /* msec */,
+};
+
+void keypad_init(void)
+{
+ ssbi_keypad_init(&qwerty_keypad);
+}
diff --git a/target/msm8960/rules.mk b/target/msm8960/rules.mk
new file mode 100644
index 0000000..0091d68
--- /dev/null
+++ b/target/msm8960/rules.mk
@@ -0,0 +1,47 @@
+LOCAL_DIR := $(GET_LOCAL_DIR)
+
+INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared
+
+PLATFORM := msm8x60
+
+MEMBASE := 0x40100000 # SDRAM
+MEMSIZE := 0x00100000 # 1MB
+
+BASE_ADDR := 0x40200000
+
+TAGS_ADDR := BASE_ADDR+0x00000100
+KERNEL_ADDR := BASE_ADDR+0x00008000
+RAMDISK_ADDR := BASE_ADDR+0x01000000
+SCRATCH_ADDR := 0x48000000
+
+KEYS_USE_GPIO_KEYPAD := 1
+
+#DEFINES += DISPLAY_SPLASH_SCREEN=1
+#DEFINES += DISPLAY_TYPE_LCDC=1
+#DEFINES += DISPLAY_TYPE_MIPI=0
+#DEFINES += DISPLAY_MIPI_PANEL_NOVATEK_BLUE=0
+#DEFINES += DISPLAY_MIPI_PANEL_TOSHIBA=0
+
+DEFINES += PLATFORM_MSM8960=1
+
+MODULES += \
+ dev/keys \
+ lib/ptable
+
+DEFINES += \
+ SDRAM_SIZE=$(MEMSIZE) \
+ MEMBASE=$(MEMBASE) \
+ BASE_ADDR=$(BASE_ADDR) \
+ TAGS_ADDR=$(TAGS_ADDR) \
+ KERNEL_ADDR=$(KERNEL_ADDR) \
+ RAMDISK_ADDR=$(RAMDISK_ADDR) \
+ SCRATCH_ADDR=$(SCRATCH_ADDR)
+
+ifeq ($(LINUX_MACHTYPE_RUMI3), 1)
+DEFINES += LINUX_MACHTYPE_RUMI3
+endif
+
+OBJS += \
+ $(LOCAL_DIR)/init.o \
+ $(LOCAL_DIR)/atags.o \
+ $(LOCAL_DIR)/keypad.o
diff --git a/target/msm8960/tools/makefile b/target/msm8960/tools/makefile
new file mode 100644
index 0000000..7da7c6d
--- /dev/null
+++ b/target/msm8960/tools/makefile
@@ -0,0 +1,44 @@
+#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/msm8960/tools/mkheader.c b/target/msm8960/tools/mkheader.c
new file mode 100644
index 0000000..cd11810
--- /dev/null
+++ b/target/msm8960/tools/mkheader.c
@@ -0,0 +1,344 @@
+/*
+ * 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;
+}