M7350v1_en_gpl

This commit is contained in:
T
2024-09-09 08:52:07 +00:00
commit f9cc65cfda
65988 changed files with 26357421 additions and 0 deletions
@@ -0,0 +1,23 @@
[cpu]
core = arm926ejs
# the rom file is loaded at address 0x0
[rom]
file = lk.bin
[system]
display = yes
console = yes
network = no
block = yes
[network]
device = /dev/tap0
[block]
file = ../blk.bin
[display]
width = 800
height = 600
depth = 32
@@ -0,0 +1,11 @@
# mostly null target configuration for the arm emulator, since there's only one real
# implementation.
LOCAL_DIR := $(GET_LOCAL_DIR)
PLATFORM := armemu
$(BUILDDIR)/armemu.conf: $(LOCAL_DIR)/armemu.conf
cp $< $@
EXTRA_BUILDDEPS += $(BUILDDIR)/armemu.conf
GENERATED += $(BUILDDIR)/armemu.conf
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef __TARGET_DEBUGCONFIG_H
#define __TARGET_DEBUGCONFIG_H
#define DEBUG_UART 2
#endif
@@ -0,0 +1,15 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += \
-I$(LOCAL_DIR)/include
PLATFORM := omap3
MODULES += \
dev/pmic/twl4030
MEMSIZE := 0x08000000 # 128MB
DEFINES += \
SDRAM_SIZE=$(MEMSIZE)
+124
View File
@@ -0,0 +1,124 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <err.h>
#include <debug.h>
#include <target.h>
#include <compiler.h>
#define EXPAND(NAME) #NAME
#define TARGET(NAME) EXPAND(NAME)
/*
* default implementations of these routines, if the target code
* chooses not to implement.
*/
__WEAK void target_early_init(void)
{
}
__WEAK void target_init(void)
{
}
__WEAK void *target_get_scratch_address(void)
{
return (void *)(SCRATCH_ADDR);
}
__WEAK unsigned target_get_max_flash_size(void)
{
return (120 * 1024 * 1024);
}
__WEAK int target_is_emmc_boot(void)
{
#if _EMMC_BOOT
return 1;
#else
return 0;
#endif
}
__WEAK unsigned check_reboot_mode(void)
{
return 0;
}
__WEAK void reboot_device(unsigned reboot_reason)
{
}
__WEAK int set_download_mode(void)
{
return -1;
}
__WEAK unsigned target_pause_for_battery_charge(void)
{
return 0;
}
__WEAK unsigned target_baseband()
{
return 0;
}
__WEAK void target_serialno(unsigned char *buf)
{
snprintf((char *) buf, 13, "%s",TARGET(BOARD));
}
__WEAK void target_fastboot_init()
{
}
__WEAK int emmc_recovery_init(void)
{
return 0;
}
__WEAK bool target_use_signed_kernel(void)
{
#if _SIGNED_KERNEL
return 1;
#else
return 0;
#endif
}
/* Default target does not support continuous splash screen feature. */
__WEAK int target_cont_splash_screen()
{
return 0;
}
/* Default target specific initialization before using USB */
__WEAK void target_usb_init(void)
{
}
/* Default target specific usb shutdown */
__WEAK void target_usb_stop(void)
{
}
+102
View File
@@ -0,0 +1,102 @@
/* Copyright (c) 2009-2011, The Linux Foundation. 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 The Linux Foundation 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 <smem.h>
#include <stdint.h>
#include <lib/ptable.h>
#define SIZE_1M (1024 * 1024)
#define SIZE_8M (8 * SIZE_1M)
#define SIZE_15M (15 * SIZE_1M)
#define SIZE_17M (17 * SIZE_1M)
#define SIZE_23M (23 * SIZE_1M)
#define SIZE_88M (11 * SIZE_8M)
unsigned *target_atag_mem(unsigned *ptr)
{
struct smem_ram_ptable ram_ptable;
uint8_t i = 0;
struct ptable *nand_ptable;
struct ptentry *dsp3_ptn;
unsigned int size;
if (smem_ram_ptable_init(&ram_ptable)) {
for (i = 0; i < ram_ptable.len; i++) {
if (ram_ptable.parts[i].category == SDRAM &&
ram_ptable.parts[i].type == SYS_MEMORY &&
ram_ptable.parts[i].start == 0x40000000) {
ASSERT(ram_ptable.parts[i].size >= SIZE_15M);
*ptr++ = 4;
*ptr++ = 0x54410002;
*ptr++ = SIZE_15M;
*ptr++ = ram_ptable.parts[i].start + SIZE_8M;
*ptr++ = 4;
*ptr++ = 0x54410002;
*ptr++ = SIZE_23M;
*ptr++ = ram_ptable.parts[i].start + SIZE_88M;
nand_ptable = flash_get_ptable();
dsp3_ptn = ptable_find(nand_ptable, "dsp3");
/* Check for DSP3 partition and its size */
if(dsp3_ptn != NULL){
size = dsp3_ptn->start;
size += dsp3_ptn->length;
if(size != dsp3_ptn->start)
continue;
}
/*Add additional atag to pass DSP3 memory to kernel*/
*ptr++ = 4;
*ptr++ = 0x54410002;
*ptr++ = SIZE_17M;
*ptr++ = ram_ptable.parts[i].start + SIZE_88M + SIZE_23M;
}
}
} else {
dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n");
ASSERT(0);
}
return ptr;
}
void *target_get_scratch_address(void)
{
return ((void *)SCRATCH_ADDR);
}
unsigned target_get_max_flash_size(void)
{
return (SIZE_23M);
}
@@ -0,0 +1,387 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
*
* Copyright (c) 2009-2013, The Linux Foundation. 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 <lib/ptable.h>
#include <dev/flash.h>
#include <dev/pm8921.h>
#include <dev/ssbi.h>
#include <string.h>
#include <smem.h>
#include <gsbi.h>
#include <platform/iomap.h>
#include <platform.h>
#define MDM9X15_CDP 3675
#define MDM9X15_MTP 3681
#define LINUX_MACHTYPE MDM9X15_CDP
#define RECOVERY_MODE 0x77665502
#define FOTA_COOKIE 0x64645343
#define FOTA_PARTITION 5
#define DSP3_PARTITION 5
static struct ptable flash_ptable;
unsigned hw_platform = 0;
unsigned target_msm_id = 0;
/* Partition names for fastboot flash */
static char *apps_ptn_names[] = { "aboot", "boot", "cache", "misc", "recovery", "fota",
"recoveryfs", "system", "userdata" };
/* Partitions should be in this order */
static char *ptable_ptn_names[] = { "APPSBL", "APPS", "CACHE", "MISC", "RECOVERY",
"FOTA", "RECOVERYFS", "SYSTEM", "USERDATA" };
static unsigned ptn_name_count = 9;
/* Apps partition flags to detect the presence of FOTA partitions.
* Initially, assume that the FOTA partitions are absent.
*/
static unsigned int apps_ptn_flag[] = {1, 1, 0, 0, 0, 0, 0, 1, 1};
/* Modem partition flags to detect the presence of DSP3 partitions.
* Initially, assume that the DSP3 partition is absent.
* The order of modem partiotions -
* "mibib", "sbl2", "rpm", "efs2", "dsp1", "dsp3", "dsp2"
*/
static unsigned int modem_ptn_flag[] = {1, 1, 1, 1, 1, 0, 1};
static unsigned modem_ptn_count = 7;
static const uint8_t uart_gsbi_id = GSBI_ID_4;
static pm8921_dev_t pmic;
void smem_ptable_init(void);
extern void reboot(unsigned reboot_reason);
void update_ptable_apps_partitions(void);
void update_ptable_modem_partitions(void);
void update_ptable_reorder(void);
extern int fake_key_get_state(void);
void target_init(void)
{
struct flash_info *flash_info;
dprintf(INFO, "target_init()\n");
/* Initialize PMIC driver */
pmic.read = (pm8921_read_func) & pa1_ssbi2_read_bytes;
pmic.write = (pm8921_write_func) & pa1_ssbi2_write_bytes;
pm8921_init(&pmic);
ptable_init(&flash_ptable);
smem_ptable_init();
flash_init();
flash_info = flash_get_info();
ASSERT(flash_info);
smem_add_modem_partitions(&flash_ptable);
/* Update the naming for apps partitions and type */
update_ptable_apps_partitions();
/* Update modem partitions to lower case for fastboot */
update_ptable_modem_partitions();
ptable_dump(&flash_ptable);
/* Reorder the partition table */
update_ptable_reorder();
flash_set_ptable( &flash_ptable);
}
static int read_from_flash(struct ptentry* ptn, int offset, int size, void *dest)
{
void *buffer = NULL;
unsigned page_size = flash_page_size();
unsigned page_mask = page_size - 1;
int read_size = (size + page_mask) & (~page_mask);
buffer = malloc(read_size);
if(!buffer){
dprintf(CRITICAL, "ERROR : Malloc failed for read_from_flash \n");
return -1;
}
if(flash_read(ptn, offset, buffer, read_size)){
dprintf(CRITICAL, "ERROR : Flash read failed \n");
return -1;
}
memcpy(dest, buffer, size);
free(buffer);
return 0;
}
static unsigned int get_fota_cookie(void)
{
struct ptentry *ptn;
struct ptable *ptable;
unsigned int cookie = 0;
ptable = flash_get_ptable();
if (ptable == NULL) {
dprintf(CRITICAL, "ERROR: Partition table not found\n");
return 0;
}
ptn = ptable_find(ptable, "fota");
if (ptn == NULL) {
dprintf(CRITICAL, "ERROR: No fota partition found\n");
return 0;
}
if(read_from_flash(ptn, 0, sizeof(unsigned int), &cookie) == -1){
dprintf(CRITICAL,"ERROR: failed to read fota cookie from flash");
return 0;
}
return cookie;
}
unsigned check_reboot_mode(void)
{
unsigned restart_reason = 0;
unsigned int cookie = 0;
/* Read reboot reason and scrub it */
restart_reason = readl(RESTART_REASON_ADDR);
writel(0x00, RESTART_REASON_ADDR);
/* SMEM value is not relied upon on power shutdown.
* Check either of SMEM or FOTA update cookie is set.
* Check fota cookie only when fota partition is available on target
*/
if (apps_ptn_flag[FOTA_PARTITION] == 1) {
cookie = get_fota_cookie();
if (cookie == FOTA_COOKIE)
return RECOVERY_MODE;
}
return restart_reason;
}
void board_info(void)
{
struct smem_board_info_v4 board_info_v4;
struct smem_board_info_v7 board_info_v7;
unsigned int board_info_len = 0;
unsigned smem_status;
unsigned format = 0;
unsigned id = 0;
if (hw_platform && target_msm_id)
return;
hw_platform = MDM9X15_CDP;
target_msm_id = MDM9600;
smem_status = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION,
&format, sizeof(format), 0);
if (!smem_status) {
if (format == 4) {
board_info_len = sizeof(board_info_v4);
smem_status =
smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
&board_info_v4,
board_info_len);
if (!smem_status) {
id = board_info_v4.board_info_v3.hw_platform;
target_msm_id =
board_info_v4.board_info_v3.msm_id;
}
} else if (format == 7) {
board_info_len = sizeof(board_info_v7);
smem_status =
smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
&board_info_v7,
board_info_len);
if (!smem_status) {
id = board_info_v7.board_info_v3.hw_platform;
target_msm_id =
board_info_v7.board_info_v3.msm_id;
}
} else
ASSERT(0);
}
return;
}
unsigned board_machtype(void)
{
board_info();
return hw_platform;
}
void reboot_device(unsigned reboot_reason)
{
/* Write reboot reason */
writel(reboot_reason, RESTART_REASON_ADDR);
/* Actually reset the chip */
pm8921_config_reset_pwr_off(1);
writel(0, MSM_PSHOLD_CTL_SU);
mdelay(10000);
dprintf(CRITICAL, "Rebooting failed\n");
return;
}
uint8_t target_uart_gsbi(void)
{
return uart_gsbi_id;
}
/*
* Return 1 to trigger to fastboot
*/
int fastboot_trigger(void)
{
int ret;
ret = fake_key_get_state();
/* Want to trigger when dip switch is on */
return (ret);
}
void update_ptable_modem_partitions(void)
{
uint32_t ptn_index, i = 0;
uint32_t name_size;
struct ptentry *ptentry_ptr = flash_ptable.parts;
struct ptentry *dsp3_ptn;
dsp3_ptn = ptable_find(&flash_ptable, "DSP3");
/* Check for DSP3 partition and its size */
if (dsp3_ptn != NULL)
if (dsp3_ptn->length > 0)
modem_ptn_flag[DSP3_PARTITION] = 1;
for (ptn_index = 0; ptn_index < modem_ptn_count; ptn_index++)
{
if (!modem_ptn_flag[ptn_index])
continue;
name_size = strlen(ptentry_ptr[ptn_index].name);
for (i = 0; i < name_size; i++)
{
ptentry_ptr[ptn_index].name[i] =
tolower(ptentry_ptr[ptn_index].name[i]);
}
ptentry_ptr[ptn_index].type = TYPE_APPS_PARTITION;
}
}
void update_ptable_apps_partitions(void)
{
uint32_t ptn_index, name_index = 0;
uint32_t end = 0xffffffff;
uint32_t name_size = strlen(ptable_ptn_names[name_index]);
struct ptentry *ptentry_ptr = flash_ptable.parts;
struct ptentry *fota_ptn;
unsigned int size;
fota_ptn = ptable_find(&flash_ptable, "FOTA");
/* Check for FOTA partitions and their size */
if (fota_ptn != NULL) {
if (fota_ptn->length > 0) {
/* FOTA partitions are present */
apps_ptn_flag[2] = 1;
apps_ptn_flag[3] = 1;
apps_ptn_flag[4] = 1;
apps_ptn_flag[5] = 1;
apps_ptn_flag[6] = 1;
}
}
for (ptn_index = 0; ptentry_ptr[ptn_index].start != end; ptn_index++) {
if (!(strncmp(ptentry_ptr[ptn_index].name,
ptable_ptn_names[name_index], name_size))) {
name_size = strlen(apps_ptn_names[name_index]);
name_size++; /* For null termination */
/* Update the partition names to something familiar */
if (name_size <= MAX_PTENTRY_NAME)
strncpy(ptentry_ptr[ptn_index].name,
apps_ptn_names[name_index], name_size);
/* Aboot uses modem page layout, leave aboot ptn */
if (name_index != 0)
ptentry_ptr[ptn_index].type =
TYPE_APPS_PARTITION;
/* Check for valid partitions
* according to the apps_ptn_flag
*/
do {
/* Don't go out of bounds */
name_index++;
if (name_index >= ptn_name_count)
goto ptn_name_update_done;
name_size =
strlen(ptable_ptn_names[name_index]);
} while (!apps_ptn_flag[name_index]);
}
}
ptn_name_update_done:
/* 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;
}
void update_ptable_reorder(void)
{
int boot_index;
struct ptentry boot_ptn;
boot_index = ptable_get_index(&flash_ptable, "boot");
if(boot_index == -1) {
dprintf (CRITICAL, "ERROR: Boot Partition not found. \n");
return;
}
boot_ptn = flash_ptable.parts[boot_index] ;
flash_ptable.parts[boot_index] = flash_ptable.parts[0];
flash_ptable.parts[0] = boot_ptn;
}
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2011, The Linux Foundation. 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 The Linux Foundation 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 <platform/gpio.h>
#include <platform/iomap.h>
/* GPIO that controls the Dip Switch
* for FASTBOOT.
*/
#define DIP_SWITCH_GPIO 49
/*
* Fake keypad for 9x15
* Returns 0 if dip switch is off, 1 if on
*/
int fake_key_get_state(void)
{
int ret;
/* GPIO 49 connects to Boot Config5 */
gpio_tlmm_config(DIP_SWITCH_GPIO, 0, GPIO_OUTPUT, GPIO_PULL_DOWN,
GPIO_2MA, GPIO_ENABLE);
ret = readl(GPIO_IN_OUT_ADDR(DIP_SWITCH_GPIO));
return ret;
}
@@ -0,0 +1,33 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared
PLATFORM := mdm9x15
MEMBASE := 0x41700000
MEMSIZE := 0x00100000 # 1MB
BASE_ADDR := 0x40800000
SCRATCH_ADDR := BASE_ADDR+0x05000000
DEFINES += NO_KEYPAD_DRIVER=1
MODULES += \
dev/keys \
dev/ssbi \
dev/pmic/pm8921 \
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)
OBJS += \
$(LOCAL_DIR)/init.o \
$(LOCAL_DIR)/atags.o \
$(LOCAL_DIR)/keypad.o
@@ -0,0 +1,43 @@
#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
@@ -0,0 +1,344 @@
/*
* Copyright (c) 2007, Google Inc.
* All rights reserved.
*
* Copyright (c) 2009-2011, The Linux Foundation. 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;
}
@@ -0,0 +1,38 @@
/* Copyright (c) 2012, The Linux Foundation. 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 The Linux Foundation 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_BOARD_H
#define __TARGET_BOARD_H
#define LINUX_MACHTYPE_9625_CDP 0
#define LINUX_MACHTYPE_9625_MTP 0
#endif
@@ -0,0 +1,224 @@
/* Copyright (c) 2012-2013, The Linux Foundation. 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 The Linux Foundation 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 <debug.h>
#include <board.h>
#include <platform.h>
#include <target.h>
#include <smem.h>
#include <baseband.h>
#include <lib/ptable.h>
#include <qpic_nand.h>
#include <ctype.h>
#include <string.h>
#include <pm8x41.h>
#include <reg.h>
#include <platform/timer.h>
extern void smem_ptable_init(void);
extern void smem_add_modem_partitions(struct ptable *flash_ptable);
static struct ptable flash_ptable;
/* PMIC config data */
#define PMIC_ARB_CHANNEL_NUM 0
#define PMIC_ARB_OWNER_ID 0
/* NANDc BAM pipe numbers */
#define DATA_CONSUMER_PIPE 0
#define DATA_PRODUCER_PIPE 1
#define CMD_PIPE 2
/* NANDc BAM pipe groups */
#define DATA_PRODUCER_PIPE_GRP 0
#define DATA_CONSUMER_PIPE_GRP 0
#define CMD_PIPE_GRP 1
/* NANDc EE */
#define QPIC_NAND_EE 0
/* NANDc max desc length. */
#define QPIC_NAND_MAX_DESC_LEN 0x7FFF
#define LAST_NAND_PTN_LEN_PATTERN 0xFFFFFFFF
struct qpic_nand_init_config config;
void update_ptable_names(void)
{
uint32_t ptn_index;
struct ptentry *ptentry_ptr = flash_ptable.parts;
struct ptentry *boot_ptn;
unsigned i;
uint32_t len;
/* Change all names to lower case. */
for (ptn_index = 0; ptn_index != (uint32_t)flash_ptable.count; ptn_index++)
{
len = strlen(ptentry_ptr[ptn_index].name);
for (i = 0; i < len; i++)
{
if (isupper(ptentry_ptr[ptn_index].name[i]))
{
ptentry_ptr[ptn_index].name[i] = tolower(ptentry_ptr[ptn_index].name[i]);
}
}
/* SBL fills in the last partition length as 0xFFFFFFFF.
* Update the length field based on the number of blocks on the flash.
*/
if ((uint32_t)(ptentry_ptr[ptn_index].length) == LAST_NAND_PTN_LEN_PATTERN)
{
ptentry_ptr[ptn_index].length = flash_num_blocks() - ptentry_ptr[ptn_index].start;
}
}
/* Rename apps ptn to boot. */
boot_ptn = ptable_find(&flash_ptable, "apps");
strcpy(boot_ptn->name, "boot");
/* Rename appsbl ptn to aboot. */
boot_ptn = ptable_find(&flash_ptable, "appsbl");
strcpy(boot_ptn->name, "aboot");
}
void target_early_init(void)
{
#if WITH_DEBUG_UART
uart_dm_init(3, 0, MSM_UART2_BASE);
#endif
}
/* init */
void target_init(void)
{
dprintf(INFO, "target_init()\n");
spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID);
config.pipes.read_pipe = DATA_PRODUCER_PIPE;
config.pipes.write_pipe = DATA_CONSUMER_PIPE;
config.pipes.cmd_pipe = CMD_PIPE;
config.pipes.read_pipe_grp = DATA_PRODUCER_PIPE_GRP;
config.pipes.write_pipe_grp = DATA_CONSUMER_PIPE_GRP;
config.pipes.cmd_pipe_grp = CMD_PIPE_GRP;
config.bam_base = MSM_NAND_BAM_BASE;
config.nand_base = MSM_NAND_BASE;
config.ee = QPIC_NAND_EE;
config.max_desc_len = QPIC_NAND_MAX_DESC_LEN;
qpic_nand_init(&config);
ptable_init(&flash_ptable);
smem_ptable_init();
smem_add_modem_partitions(&flash_ptable);
update_ptable_names();
flash_set_ptable(&flash_ptable);
}
/* reboot */
void reboot_device(unsigned reboot_reason)
{
uint32_t version = board_soc_version();
/* Write the reboot reason */
if(version >= 0x20000)
writel(reboot_reason, RESTART_REASON_ADDR_V2);
else
writel(reboot_reason, RESTART_REASON_ADDR);
/* Configure PMIC for warm reset */
/* PM 8019 v1 aligns with PM8941 v2.
* This call should be based on the pmic version
* when PM8019 v2 is available.
*/
pm8x41_v2_reset_configure(PON_PSHOLD_WARM_RESET);
/* Drop PS_HOLD for MSM */
writel(0x00, MPM2_MPM_PS_HOLD);
mdelay(5000);
dprintf(CRITICAL, "Rebooting failed\n");
return;
}
/* Identify the current target */
void target_detect(struct board_data *board)
{
/* Not used. set to unknown */
board->target = LINUX_MACHTYPE_UNKNOWN;
}
unsigned board_machtype(void)
{
return board_target_id();
}
/* Identify the baseband being used */
void target_baseband_detect(struct board_data *board)
{
/* Check for baseband variants. Default to MSM */
if (board->platform_subtype == HW_PLATFORM_SUBTYPE_UNKNOWN)
{
board->baseband = BASEBAND_MSM;
}
else
{
dprintf(CRITICAL, "Could not identify baseband id (%d)\n",
board->platform_subtype);
ASSERT(0);
}
}
unsigned check_reboot_mode(void)
{
unsigned restart_reason = 0;
uint32_t version = board_soc_version();
/* Read reboot reason and scrub it */
if(version >= 0x20000) {
restart_reason = readl(RESTART_REASON_ADDR_V2);
writel(0x00, RESTART_REASON_ADDR_V2);
}
else {
restart_reason = readl(RESTART_REASON_ADDR);
writel(0x00, RESTART_REASON_ADDR);
}
return restart_reason;
}
@@ -0,0 +1,64 @@
/* Copyright (c) 2012, The Linux Foundation. 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 The Linux Foundation 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 <platform/gpio.h>
#include <platform/iomap.h>
/* GPIO that controls the button
* for FASTBOOT.
*/
#define FASTBOOT_KEY_GPIO_ID 58
/*
* Returns fastboot button state.
* Returns 0 if button is not pressed, 1 when pressed.
*/
int get_fastboot_key_state(void)
{
int ret;
gpio_tlmm_config(FASTBOOT_KEY_GPIO_ID, 0, GPIO_INPUT, GPIO_PULL_DOWN, GPIO_2MA, GPIO_ENABLE);
ret = gpio_get_state(FASTBOOT_KEY_GPIO_ID);
return ret;
}
/*
* Return 1 to trigger to fastboot
*/
int fastboot_trigger(void)
{
int ret;
ret = get_fastboot_key_state();
return (ret);
}
@@ -0,0 +1,109 @@
/* Copyright (c) 2012-2013, The Linux Foundation. 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 The Linux Foundation 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 <malloc.h>
#include <smem.h>
#include <stdint.h>
#include <libfdt.h>
#include <platform.h>
#include <platform/iomap.h>
#include <dev_tree.h>
#define SIZE_1M (1024 * 1024)
static struct smem_ram_ptable ram_ptable;
struct smem_ram_ptable* target_smem_ram_ptable_init()
{
/* Make sure RAM partition table is initialized */
ASSERT(smem_ram_ptable_init(&ram_ptable));
return &ram_ptable;
}
/* Funtion to add the ram partition entries into device tree.
* The function assumes that all the entire fixed memory regions should
* be listed in the first bank of the passed in ddr regions.
*/
uint32_t target_dev_tree_mem(void *fdt, uint32_t memory_node_offset)
{
unsigned int i;
int ret;
for (i = 0; i < ram_ptable.len; i++)
{
if ((ram_ptable.parts[i].category == SDRAM) &&
(ram_ptable.parts[i].type == SYS_MEMORY))
{
if (ram_ptable.parts[i].start == 0)
{
/* Pass along all other usable memory regions to Linux */
/* Any memory not accessible by the kernel which is below the
* kernel start address must *not* be given to the kernel.
*/
ret = dev_tree_add_mem_info(fdt,
memory_node_offset,
ram_ptable.parts[i].start + 3*SIZE_1M,
ram_ptable.parts[i].size - 3*SIZE_1M);
}
else
{
/* Pass along all other usable memory regions to Linux */
ret = dev_tree_add_mem_info(fdt,
memory_node_offset,
ram_ptable.parts[i].start,
ram_ptable.parts[i].size);
}
if (ret)
{
dprintf(CRITICAL, "Failed to add memory bank addresses to device tree\n");
goto target_dev_tree_mem_err;
}
}
}
target_dev_tree_mem_err:
return ret;
}
void *target_get_scratch_address(void)
{
return ((void *) VA((addr_t)SCRATCH_REGION1));
}
unsigned target_get_max_flash_size(void)
{
return (SCRATCH_REGION1_SIZE + SCRATCH_REGION2_SIZE);
}
@@ -0,0 +1,36 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared
PLATFORM := mdm9x25
MEMBASE := 0x07E00000
MEMSIZE := 0x00100000 # 1MB
SCRATCH_ADDR := 0x00300000
SCRATCH_REGION1 := 0x00300000
SCRATCH_REGION1_SIZE := 0x01000000 #16 MB
SCRATCH_REGION2 := 0x06800000
SCRATCH_REGION2_SIZE := 0x01600000 #22 MB
DEFINES += NO_KEYPAD_DRIVER=1
DEFINES += PERIPH_BLK_BLSP=1
MODULES += \
dev/keys \
lib/ptable \
dev/pmic/pm8x41 \
lib/libfdt
DEFINES += \
MEMBASE=$(MEMBASE) \
SCRATCH_ADDR=$(SCRATCH_ADDR) \
SCRATCH_REGION1=$(SCRATCH_REGION1) \
SCRATCH_REGION2=$(SCRATCH_REGION2) \
MEMSIZE=$(MEMSIZE) \
SCRATCH_REGION1_SIZE=$(SCRATCH_REGION1_SIZE) \
SCRATCH_REGION2_SIZE=$(SCRATCH_REGION2_SIZE) \
OBJS += \
$(LOCAL_DIR)/init.o \
$(LOCAL_DIR)/meminfo.o \
$(LOCAL_DIR)/keypad.o
@@ -0,0 +1,43 @@
#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
@@ -0,0 +1,344 @@
/*
* Copyright (c) 2007, Google Inc.
* All rights reserved.
*
* Copyright (c) 2012, The Linux Foundation. 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;
}
@@ -0,0 +1,89 @@
/* Copyright (c) 2009-2010, The Linux Foundation. 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 The Linux Foundation 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 <smem.h>
#define SIZE_1M 0x00100000
unsigned round_to_mb(unsigned size)
{
unsigned size_in_mb = 0;
size_in_mb = size >> 20;
size_in_mb = size_in_mb << 20;
return size_in_mb;
}
unsigned* target_atag_mem(unsigned* ptr)
{
struct smem_ram_ptable ram_ptable;
unsigned i = 0;
unsigned size_in_mb = 0;
if (smem_ram_ptable_init(&ram_ptable))
{
for (i = 0; i < ram_ptable.len; i++)
{
/* Round down to align to Mega byte size */
size_in_mb = round_to_mb(ram_ptable.parts[i].size);
if ((ram_ptable.parts[i].attr == READWRITE)
&& (ram_ptable.parts[i].domain == APPS_DOMAIN)
&& (ram_ptable.parts[i].start != 0x0)
&& (!(size_in_mb <= SIZE_1M)))
{
/* ATAG_MEM */
*ptr++ = 4;
*ptr++ = 0x54410002;
/* RAM parition for Emmc boot are reported correctly by modem
* Use the size passed from modem directly after rounding down
* to MB as kernel expects a megabyte aligned size.
*/
if (target_is_emmc_boot()) {
*ptr++ = size_in_mb;
}
else
*ptr++ = ram_ptable.parts[i].size;
*ptr++ = ram_ptable.parts[i].start;
}
}
}
else
{
dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n");
ASSERT(0);
}
return ptr;
}
unsigned target_get_max_flash_size(void)
{
return (180 * 1024 * 1024);
}
@@ -0,0 +1,47 @@
/* Copyright (c) 2010, The Linux Foundation. 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 The Linux Foundation 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_MSM7627_SURF_DISPLAY_H
#define _TARGET_MSM7627_SURF_DISPLAY_H
#define TARGET_XRES 800
#define TARGET_YRES 480
#define LCDC_FB_WIDTH 800
#define LCDC_FB_HEIGHT 480
#define LCDC_HSYNC_PULSE_WIDTH_DCLK 60
#define LCDC_HSYNC_BACK_PORCH_DCLK 81
#define LCDC_HSYNC_FRONT_PORCH_DCLK 81
#define LCDC_HSYNC_SKEW_DCLK 0
#define LCDC_VSYNC_PULSE_WIDTH_LINES 2
#define LCDC_VSYNC_BACK_PORCH_LINES 20
#define LCDC_VSYNC_FRONT_PORCH_LINES 27
#endif
@@ -0,0 +1,298 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009-2011, The Linux Foundation. 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 <dev/keys.h>
#include <lib/ptable.h>
#include <dev/flash.h>
#include <smem.h>
#include <mmc.h>
#include <platform/iomap.h>
#include <platform.h>
#define LINUX_MACHTYPE_7x27_SURF 2705
#define LINUX_MACHTYPE_7x27_FFA 2706
#define VARIABLE_LENGTH 0x10101010
#define DIFF_START_ADDR 0xF0F0F0F0
#define NUM_PAGES_PER_BLOCK 0x40
static struct ptable flash_ptable;
static unsigned mmc_sdc_base[] = { MSM_SDC1_BASE, MSM_SDC2_BASE, MSM_SDC3_BASE, MSM_SDC4_BASE};
static int hw_platform_type = -1;
/* for these partitions, start will be offset by either what we get from
* smem, or from the above offset if smem is not useful. Also, we should
* probably have smem_ptable code populate our flash_ptable.
*
* When smem provides us with a full partition table, we can get rid of
* this altogether.
*
*/
static struct ptentry board_part_list[] = {
{
.start = 0,
.length = 5 /* In MB */,
.name = "boot",
},
{
.start = DIFF_START_ADDR,
.length = 180 /* In MB */,
.name = "system",
},
{
.start = DIFF_START_ADDR,
.length = 4 /* In MB */,
.name = "cache",
},
{
.start = DIFF_START_ADDR,
.length = 4 /* In MB */,
.name = "misc",
},
{
.start = DIFF_START_ADDR,
.length = VARIABLE_LENGTH,
.name = "userdata",
},
{
.start = DIFF_START_ADDR,
.length = 2 /* In MB */,
.name = "persist",
},
{
.start = DIFF_START_ADDR,
.length = 5 /* In MB */,
.name = "recovery",
},
};
static int num_parts = sizeof(board_part_list)/sizeof(struct ptentry);
void smem_ptable_init(void);
unsigned smem_get_apps_flash_start(void);
void keypad_init(void);
int target_is_emmc_boot(void);
void target_init(void)
{
unsigned offset;
struct flash_info *flash_info;
unsigned total_num_of_blocks;
unsigned next_ptr_start_adr = 0;
unsigned blocks_per_1MB = 8; /* Default value of 2k page size on 256MB flash drive*/
unsigned char slot;
unsigned int base_addr;
int i;
dprintf(INFO, "target_init()\n");
/* Display splash screen if enabled */
#if DISPLAY_SPLASH_SCREEN
display_init();
dprintf(SPEW, "Diplay initialized\n");
display_image_on_screen();
#endif
#if (!ENABLE_NANDWRITE)
keys_init();
keypad_init();
#endif
if (target_is_emmc_boot())
{
/* Must wait for modem-up before we can intialize MMC.
*/
while (readl(MSM_SHARED_BASE + 0x14) != 1);
/* Trying SDC3 first */
slot = 3;
base_addr = mmc_sdc_base[slot - 1];
if(mmc_boot_main(slot, base_addr))
{
/* Trying SDC1 next */
slot = 1;
base_addr = mmc_sdc_base[slot - 1];
if(mmc_boot_main(slot, base_addr))
{
dprintf(CRITICAL, "mmc init failed!");
ASSERT(0);
}
}
return;
}
ptable_init(&flash_ptable);
smem_ptable_init();
flash_init();
flash_info = flash_get_info();
ASSERT(flash_info);
offset = smem_get_apps_flash_start();
if (offset == 0xffffffff)
while(1);
total_num_of_blocks = flash_info->num_blocks;
blocks_per_1MB = (1 << 20) / (flash_info->block_size);
for (i = 0; i < num_parts; i++) {
struct ptentry *ptn = &board_part_list[i];
unsigned len = ((ptn->length) * blocks_per_1MB);
if(ptn->start != 0)
ASSERT(ptn->start == DIFF_START_ADDR);
ptn->start = next_ptr_start_adr;
if(ptn->length == VARIABLE_LENGTH)
{
unsigned length_for_prt = 0;
unsigned j;
for (j = i+1; j < num_parts; j++)
{
struct ptentry *temp_ptn = &board_part_list[j];
ASSERT(temp_ptn->length != VARIABLE_LENGTH);
length_for_prt += ((temp_ptn->length) * blocks_per_1MB);
}
len = total_num_of_blocks - (offset + ptn->start + length_for_prt);
ASSERT(len >= 0);
}
next_ptr_start_adr = ptn->start + len;
ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
len, ptn->flags, TYPE_APPS_PARTITION, PERM_WRITEABLE);
}
smem_add_modem_partitions(&flash_ptable);
ptable_dump(&flash_ptable);
flash_set_ptable(&flash_ptable);
}
unsigned board_machtype(void)
{
struct smem_board_info_v2 board_info_v2;
unsigned int board_info_len = 0;
enum platform platform_type = 0;
unsigned smem_status;
unsigned format = 0;
if(hw_platform_type != -1)
return hw_platform_type;
smem_status = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION,
&format, sizeof(format), 0);
if(!smem_status)
{
if(format == 2)
{
board_info_len = sizeof(board_info_v2);
smem_status = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
&board_info_v2, board_info_len);
if(!smem_status)
{
char *build_type = (char *)(board_info_v2.build_id)+ 12;
switch (*build_type)
{
case 'F':
hw_platform_type = LINUX_MACHTYPE_7x27_FFA; break;
case 'S':
hw_platform_type = LINUX_MACHTYPE_7x27_SURF; break;
default:
hw_platform_type = LINUX_MACHTYPE_7x27_SURF; break;
}
}
}
} else {
hw_platform_type = LINUX_MACHTYPE_7x27_SURF;
}
return hw_platform_type;
}
void reboot_device(unsigned reboot_reason)
{
reboot(reboot_reason);
}
unsigned check_reboot_mode(void)
{
unsigned mode[2] = {0, 0};
unsigned int mode_len = sizeof(mode);
unsigned smem_status;
smem_status = smem_read_alloc_entry(SMEM_APPS_BOOT_MODE,
&mode, mode_len );
if(smem_status)
{
dprintf(CRITICAL, "ERROR: unable to read shared memory for reboot mode\n");
return 0;
}
return mode[0];
}
static unsigned target_check_power_on_reason(void)
{
unsigned power_on_status = 0;
unsigned int status_len = sizeof(power_on_status);
unsigned smem_status;
smem_status = smem_read_alloc_entry(SMEM_POWER_ON_STATUS_INFO,
&power_on_status, status_len);
if (smem_status)
{
dprintf(CRITICAL, "ERROR: unable to read shared memory for power on reason\n");
}
return power_on_status;
}
#if _EMMC_BOOT
void target_serialno(unsigned char *buf)
{
unsigned int serialno;
serialno = mmc_get_psn();
sprintf(buf,"%x",serialno);
}
int emmc_recovery_init(void)
{
int rc;
rc = _emmc_recovery_init();
return rc;
}
#endif
@@ -0,0 +1,172 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009, The Linux Foundation. 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 <dev/keys.h>
#include <dev/ssbi.h>
#include <dev/gpio_keypad.h>
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
/* don't turn this on without updating the ffa support */
#define SCAN_FUNCTION_KEYS 0
#define LINUX_MACHTYPE_7x27_SURF 2705
static unsigned int halibut_row_gpios[] = {
31, 32, 33, 34, 35, 41
#if SCAN_FUNCTION_KEYS
, 42
#endif
};
static unsigned int halibut_col_gpios[] = { 36, 37, 38, 39, 40 };
#define KEYMAP_INDEX(row, col) ((row)*ARRAY_SIZE(halibut_col_gpios) + (col))
static const unsigned short halibut_keymap_surf[ARRAY_SIZE(halibut_col_gpios) * ARRAY_SIZE(halibut_row_gpios)] = {
[KEYMAP_INDEX(0, 0)] = KEY_5,
[KEYMAP_INDEX(0, 1)] = KEY_9,
[KEYMAP_INDEX(0, 2)] = KEY_SOFT1,
[KEYMAP_INDEX(0, 3)] = KEY_6,
[KEYMAP_INDEX(0, 4)] = KEY_LEFT,
[KEYMAP_INDEX(1, 0)] = KEY_0,
[KEYMAP_INDEX(1, 1)] = KEY_RIGHT,
[KEYMAP_INDEX(1, 2)] = KEY_1,
[KEYMAP_INDEX(1, 3)] = KEY_SHARP,
[KEYMAP_INDEX(1, 4)] = KEY_SEND,
[KEYMAP_INDEX(2, 0)] = KEY_VOLUMEUP,
[KEYMAP_INDEX(2, 1)] = KEY_HOME, /* FA */
[KEYMAP_INDEX(2, 2)] = KEY_F8, /* QCHT */
[KEYMAP_INDEX(2, 3)] = KEY_F6, /* R+ */
[KEYMAP_INDEX(2, 4)] = KEY_F7, /* R- */
[KEYMAP_INDEX(3, 0)] = KEY_UP,
[KEYMAP_INDEX(3, 1)] = KEY_CLEAR,
[KEYMAP_INDEX(3, 2)] = KEY_4,
[KEYMAP_INDEX(3, 3)] = KEY_MUTE, /* SPKR */
[KEYMAP_INDEX(3, 4)] = KEY_2,
[KEYMAP_INDEX(4, 0)] = KEY_SOFT2, /* SOFT2 */
[KEYMAP_INDEX(4, 1)] = KEY_CENTER, /* KEY_CENTER */
[KEYMAP_INDEX(4, 2)] = KEY_DOWN,
[KEYMAP_INDEX(4, 3)] = KEY_BACK, /* FB */
[KEYMAP_INDEX(4, 4)] = KEY_8,
[KEYMAP_INDEX(5, 0)] = KEY_VOLUMEDOWN,
[KEYMAP_INDEX(5, 1)] = KEY_STAR, /* KEY_STAR */
[KEYMAP_INDEX(5, 2)] = KEY_MAIL, /* MESG */
[KEYMAP_INDEX(5, 3)] = KEY_3,
[KEYMAP_INDEX(5, 4)] = KEY_7,
#if SCAN_FUNCTION_KEYS
[KEYMAP_INDEX(6, 0)] = KEY_F5,
[KEYMAP_INDEX(6, 1)] = KEY_F4,
[KEYMAP_INDEX(6, 2)] = KEY_F3,
[KEYMAP_INDEX(6, 3)] = KEY_F2,
[KEYMAP_INDEX(6, 4)] = KEY_F1
#endif
};
static const unsigned short halibut_keymap_ffa[ARRAY_SIZE(halibut_col_gpios) * ARRAY_SIZE(halibut_row_gpios)] = {
[KEYMAP_INDEX(0, 2)] = KEY_1,
[KEYMAP_INDEX(0, 3)] = KEY_SEND,
[KEYMAP_INDEX(0, 4)] = KEY_LEFT,
[KEYMAP_INDEX(1, 0)] = KEY_3,
[KEYMAP_INDEX(1, 1)] = KEY_RIGHT,
[KEYMAP_INDEX(1, 2)] = KEY_VOLUMEUP,
[KEYMAP_INDEX(1, 4)] = KEY_6,
[KEYMAP_INDEX(2, 0)] = KEY_HOME, /* A */
[KEYMAP_INDEX(2, 1)] = KEY_BACK, /* B */
[KEYMAP_INDEX(2, 2)] = KEY_0,
[KEYMAP_INDEX(2, 3)] = KEY_SHARP,
[KEYMAP_INDEX(2, 4)] = KEY_9,
[KEYMAP_INDEX(3, 0)] = KEY_UP,
[KEYMAP_INDEX(3, 1)] = KEY_CENTER,
[KEYMAP_INDEX(3, 2)] = KEY_4,
[KEYMAP_INDEX(3, 4)] = KEY_2,
[KEYMAP_INDEX(4, 0)] = KEY_VOLUMEDOWN,
[KEYMAP_INDEX(4, 1)] = KEY_SOUND,
[KEYMAP_INDEX(4, 2)] = KEY_DOWN,
[KEYMAP_INDEX(4, 3)] = KEY_8,
[KEYMAP_INDEX(4, 4)] = KEY_5,
[KEYMAP_INDEX(5, 1)] = KEY_STAR,
[KEYMAP_INDEX(5, 2)] = KEY_SOFT2,
[KEYMAP_INDEX(5, 3)] = KEY_MENU,
[KEYMAP_INDEX(5, 4)] = KEY_7,
#if SCAN_FUNCTION_KEYS
[KEYMAP_INDEX(6, 0)] = KEY_F5,
[KEYMAP_INDEX(6, 1)] = KEY_F4,
[KEYMAP_INDEX(6, 2)] = KEY_F3,
[KEYMAP_INDEX(6, 3)] = KEY_F2,
[KEYMAP_INDEX(6, 4)] = KEY_F1
#endif
};
static struct gpio_keypad_info halibut_keypad_info_surf = {
.keymap = halibut_keymap_surf,
.output_gpios = halibut_row_gpios,
.input_gpios = halibut_col_gpios,
.noutputs = ARRAY_SIZE(halibut_row_gpios),
.ninputs = ARRAY_SIZE(halibut_col_gpios),
.settle_time = 5 /* msec */,
.poll_time = 20 /* msec */,
.flags = GPIOKPF_DRIVE_INACTIVE,
};
static struct gpio_keypad_info halibut_keypad_info_ffa = {
.keymap = halibut_keymap_ffa,
.output_gpios = halibut_row_gpios,
.input_gpios = halibut_col_gpios,
.noutputs = ARRAY_SIZE(halibut_row_gpios),
.ninputs = ARRAY_SIZE(halibut_col_gpios),
.settle_time = 5 /* msec */,
.poll_time = 20 /* msec */,
.flags = GPIOKPF_DRIVE_INACTIVE,
};
void keypad_init(void)
{
unsigned int mach_id;
mach_id = board_machtype();
if (mach_id == LINUX_MACHTYPE_7x27_SURF)
gpio_keypad_init(&halibut_keypad_info_surf);
else
gpio_keypad_init(&halibut_keypad_info_ffa);
}
@@ -0,0 +1,44 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared
PLATFORM := msm7k
MEMBASE := 0x00000000 # SMI
MEMSIZE := 0x00100000 # 1MB
BASE_ADDR := 0x00200000
TAGS_ADDR := BASE_ADDR+0x00000100
KERNEL_ADDR := BASE_ADDR+0x00008000
RAMDISK_ADDR := BASE_ADDR+0x01000000
SCRATCH_ADDR := BASE_ADDR+0xA00000
LCDC_FB_ADDR := 0x0D300000
KEYS_USE_GPIO_KEYPAD := 1
DEFINES += DISPLAY_TYPE_MDDI=0
DEFINES += DISPLAY_TYPE_LCDC=1
DEFINES += DISPLAY_SPLASH_SCREEN=1
DEFINES += MDDI_MULTI_WRITE=1
MODULES += \
dev/keys \
dev/ssbi \
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) \
LCDC_FB_ADDR=$(LCDC_FB_ADDR)
OBJS += \
$(LOCAL_DIR)/init.o \
$(LOCAL_DIR)/keypad.o \
$(LOCAL_DIR)/atags.o
@@ -0,0 +1,41 @@
#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 emmc_appsboothd.mbn
else
ifeq ($(BUILD_NANDWRITE), 1)
APPSBOOTHDR_FILES :=
else
APPSBOOTHDR_FILES := appsboot.mbn appsboothd.mbn
endif
endif
APPSBOOTHEADER: $(APPSBOOTHDR_FILES)
appsboot.mbn: $(OUTBIN)
cp $(OUTBIN) $(APPSBOOTHEADER_DIR)/appsboot.raw
cp -f $(OUTBIN) $(APPSBOOTHEADER_DIR)/appsboot.mbn
appsboothd.mbn: mkheader $(OUTBIN)
$(BUILDDIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/appsboothd.mbn
EMMCBOOT.MBN: $(OUTBIN)
cp $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboot.raw
cp -f $(OUTBIN) $(APPSBOOTHEADER_DIR)/EMMCBOOT.MBN
cp -f $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboot.mbn
emmc_appsboothd.mbn: mkheader $(OUTBIN)
$(BUILDDIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboothd.mbn unified-boot
mkheader: $(SRC_DIR)/mkheader.c
@mkdir -p $(BUILDDIR)
${COMPILER} -DMEMBASE=$(MEMBASE) $(SRC_DIR)/mkheader.c -o $(BUILDDIR)/mkheader
@@ -0,0 +1,297 @@
/*
* Copyright (c) 2007, Google Inc.
* All rights reserved.
*
* Copyright (c) 2009-2011, The Linux Foundation. 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;
base = 0;
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;
}
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;
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;
}
//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;
}
//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);
}
return 0;
}
@@ -0,0 +1,74 @@
/* Copyright (c) 2009-2011, The Linux Foundation. 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 The Linux Foundation 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 <smem.h>
#define SIZE_1M 0x00100000
#define ROUND_TO_MB(x) ((x >> 20) << 20)
unsigned *target_atag_mem(unsigned *ptr)
{
struct smem_ram_ptable ram_ptable;
unsigned i = 0;
if (smem_ram_ptable_init(&ram_ptable)) {
for (i = 0; i < ram_ptable.len; i++) {
if ((ram_ptable.parts[i].attr == READWRITE)
&& (ram_ptable.parts[i].domain == APPS_DOMAIN)
&& (ram_ptable.parts[i].start != 0x0)
&&
(!(ROUND_TO_MB(ram_ptable.parts[i].size) <=
SIZE_1M))) {
/* ATAG_MEM */
*ptr++ = 4;
*ptr++ = 0x54410002;
/* RAM parition are reported correctly by NON-HLOS
Use the size passed directly */
if (target_is_emmc_boot())
*ptr++ =
ROUND_TO_MB(ram_ptable.parts[i].
size);
else
*ptr++ = ram_ptable.parts[i].size;
*ptr++ = ram_ptable.parts[i].start;
}
}
} else {
dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n");
ASSERT(0);
}
return ptr;
}
unsigned target_get_max_flash_size(void)
{
return (253 * 1024 * 1024);
}
@@ -0,0 +1,47 @@
/* Copyright (c) 2012, The Linux Foundation. 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 The Linux Foundation 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.
*
*/
#define MSM7X27A_FFA 3351
#define MSM7X27A_SURF 3352
#define MSM7X27A_RUMI3 3353
#define MSM7X27A_QRD1 3756
#define MSM7X25A_SURF 3772
#define MSM7X25A_FFA 3771
#define MSM7X27A_EVB 3934
#define MSM7X27A_QRD3 4005
#define MSM8X25_RUMI3 3871
#define MSM8X25_SURF 4037
#define MSM8X25_EVB 4042
#define MSM8X25_QRD7 4095
#define MSM8X25_FFA 4166
#define MSM8X25_EVT 4193
#define MSM8X25Q_SKUD 4393
#define LINUX_MACHTYPE MSM7X27A_SURF
@@ -0,0 +1,81 @@
/* Copyright (c) 2010-2011, The Linux Foundation. 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 The Linux Foundation 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_MSM7627_SURF_DISPLAY_H
#define _TARGET_MSM7627_SURF_DISPLAY_H
#define TARGET_XRES 800
#define TARGET_YRES 480
#define LCDC_FB_WIDTH 800
#define LCDC_FB_HEIGHT 480
#define LCDC_HSYNC_PULSE_WIDTH_DCLK 60
#define LCDC_HSYNC_BACK_PORCH_DCLK 81
#define LCDC_HSYNC_FRONT_PORCH_DCLK 81
#define LCDC_HSYNC_SKEW_DCLK 0
#define LCDC_VSYNC_PULSE_WIDTH_LINES 2
#define LCDC_VSYNC_BACK_PORCH_LINES 20
#define LCDC_VSYNC_FRONT_PORCH_LINES 27
/* RENESAS MIPI panel */
#define REN_MIPI_FB_WIDTH 480
#define REN_MIPI_FB_HEIGHT 864
#define MIPI_HSYNC_PULSE_WIDTH 8
#define MIPI_HSYNC_BACK_PORCH_DCLK 100
#define MIPI_HSYNC_FRONT_PORCH_DCLK 100
#define MIPI_VSYNC_PULSE_WIDTH 1
#define MIPI_VSYNC_BACK_PORCH_LINES 20
#define MIPI_VSYNC_FRONT_PORCH_LINES 20
/* RENESAS MIPI HVGA panel */
#define REN_MIPI_FB_WIDTH_HVGA 480
#define REN_MIPI_FB_HEIGHT_HVGA 320
#define MIPI_HSYNC_PULSE_WIDTH_HVGA 5
#define MIPI_HSYNC_BACK_PORCH_DCLK_HVGA 21
#define MIPI_HSYNC_FRONT_PORCH_DCLK_HVGA 15
#define MIPI_VSYNC_PULSE_WIDTH_HVGA 50
#define MIPI_VSYNC_BACK_PORCH_LINES_HVGA 50
#define MIPI_VSYNC_FRONT_PORCH_LINES_HVGA 101
/* NT35510 MIPI WVGA panel */
#define NT35510_MIPI_FB_WIDTH 480
#define NT35510_MIPI_FB_HEIGHT 800
#define MIPI_FB_ADDR 0x2C800000
#define LCDC_FB_ADDR 0x2C800000
extern int mipi_dsi_phy_init(struct mipi_dsi_panel_config *);
extern void config_renesas_dsi_video_mode(void);
int target_cont_splash_screen(void);
#endif
@@ -0,0 +1,733 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009-2013, The Linux Foundation. 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 <dev/keys.h>
#include <dev/ssbi.h>
#include <lib/ptable.h>
#include <dev/flash.h>
#include <smem.h>
#include <mmc.h>
#include <platform/iomap.h>
#include <target/board.h>
#include <platform.h>
#include <crypto_hash.h>
#define VARIABLE_LENGTH 0x10101010
#define DIFF_START_ADDR 0xF0F0F0F0
#define NUM_PAGES_PER_BLOCK 0x40
#define RECOVERY_MODE 0x77665502
#define FOTA_COOKIE 0x64645343
unsigned int fota_cookie[1];
static struct ptable flash_ptable;
unsigned hw_platform = 0;
unsigned target_msm_id = 0;
unsigned msm_version = 0;
/* Setting this variable to different values defines the
* behavior of CE engine:
* platform_ce_type = CRYPTO_ENGINE_TYPE_NONE : No CE engine
* platform_ce_type = CRYPTO_ENGINE_TYPE_SW : Software CE engine
* platform_ce_type = CRYPTO_ENGINE_TYPE_HW : Hardware CE engine
* Behavior is determined in the target code.
*/
static crypto_engine_type platform_ce_type = CRYPTO_ENGINE_TYPE_SW;
int machine_is_evb();
/* for these partitions, start will be offset by either what we get from
* smem, or from the above offset if smem is not useful. Also, we should
* probably have smem_ptable code populate our flash_ptable.
*
* When smem provides us with a full partition table, we can get rid of
* this altogether.
*
*/
static struct ptentry board_part_list_default[] = {
{
.start = 0,
.length = 10 /* In MB */ ,
.name = "boot",
},
{
.start = DIFF_START_ADDR,
.length = 253 /* In MB */ ,
.name = "system",
},
{
.start = DIFF_START_ADDR,
.length = 80 /* In MB */ ,
.name = "cache",
},
{
.start = DIFF_START_ADDR,
.length = 4 /* In MB */ ,
.name = "misc",
},
{
.start = DIFF_START_ADDR,
.length = VARIABLE_LENGTH,
.name = "userdata",
},
{
.start = DIFF_START_ADDR,
.length = 4 /* In MB */ ,
.name = "persist",
},
{
.start = DIFF_START_ADDR,
.length = 10 /* In MB */ ,
.name = "recovery",
},
};
/*
* SKU3 & SKU PVT devices use the same micron NAND device with different density,
* due to this SKU3 partition creation fails as the number of blocks calculated
* from flash density is wrong, To avoid this use a different partition table &
* move the variable length partition to the end, this way kernel will truncate
* the variable length partition & we need not add target checks in the shared
* nand driver code.
*/
static struct ptentry board_part_list_sku3[] = {
{
.start = 0,
.length = 10 /* In MB */ ,
.name = "boot",
},
{
.start = DIFF_START_ADDR,
.length = 253 /* In MB */ ,
.name = "system",
},
{
.start = DIFF_START_ADDR,
.length = 80 /* In MB */ ,
.name = "cache",
},
{
.start = DIFF_START_ADDR,
.length = 4 /* In MB */ ,
.name = "misc",
},
{
.start = DIFF_START_ADDR,
.length = 4 /* In MB */ ,
.name = "persist",
},
{
.start = DIFF_START_ADDR,
.length = 10 /* In MB */ ,
.name = "recovery",
},
{
.start = DIFF_START_ADDR,
.length = VARIABLE_LENGTH,
.name = "userdata",
},
};
static int num_parts = sizeof(board_part_list_default) / sizeof(struct ptentry);
void smem_ptable_init(void);
unsigned smem_get_apps_flash_start(void);
void keypad_init(void);
int target_is_emmc_boot(void);
void target_init(void)
{
unsigned offset;
struct flash_info *flash_info;
struct ptentry *board_part_list;
unsigned total_num_of_blocks;
unsigned next_ptr_start_adr = 0;
unsigned blocks_per_1MB = 8; /* Default value of 2k page size on 256MB flash drive */
int i;
dprintf(INFO, "target_init()\n");
#if (!ENABLE_NANDWRITE)
keys_init();
keypad_init();
#endif
/* Display splash screen if enabled */
#if DISPLAY_SPLASH_SCREEN
display_init();
dprintf(SPEW, "Diplay initialized\n");
#endif
if (target_is_emmc_boot()) {
/* Must wait for modem-up before we can intialize MMC.
*/
while (readl(MSM_SHARED_BASE + 0x14) != 1) ;
if (mmc_boot_main(MMC_SLOT, MSM_SDC3_BASE)) {
dprintf(CRITICAL, "mmc init failed!");
ASSERT(0);
}
return;
}
ptable_init(&flash_ptable);
smem_ptable_init();
flash_init();
flash_info = flash_get_info();
ASSERT(flash_info);
offset = smem_get_apps_flash_start();
if (offset == 0xffffffff)
while (1) ;
total_num_of_blocks = flash_info->num_blocks;
blocks_per_1MB = (1 << 20) / (flash_info->block_size);
if (target_is_sku3())
board_part_list = board_part_list_sku3;
else
board_part_list = board_part_list_default;
for (i = 0; i < num_parts; i++) {
struct ptentry *ptn = &board_part_list[i];
unsigned len = ((ptn->length) * blocks_per_1MB);
if (ptn->start != 0)
ASSERT(ptn->start == DIFF_START_ADDR);
ptn->start = next_ptr_start_adr;
if (ptn->length == VARIABLE_LENGTH) {
unsigned length_for_prt = 0;
unsigned j;
for (j = i + 1; j < num_parts; j++) {
struct ptentry *temp_ptn = &board_part_list[j];
ASSERT(temp_ptn->length != VARIABLE_LENGTH);
length_for_prt +=
((temp_ptn->length) * blocks_per_1MB);
}
len =
(total_num_of_blocks - 1) - (offset + ptn->start +
length_for_prt);
ASSERT(len >= 0);
}
next_ptr_start_adr = ptn->start + len;
ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
len, ptn->flags, TYPE_APPS_PARTITION,
PERM_WRITEABLE);
}
smem_add_modem_partitions(&flash_ptable);
ptable_dump(&flash_ptable);
flash_set_ptable(&flash_ptable);
}
void board_info(void)
{
struct smem_board_info_v4 board_info_v4;
unsigned int board_info_len = 0;
unsigned smem_status;
unsigned format = 0;
unsigned id = 0;
if (hw_platform && target_msm_id)
return;
hw_platform = MSM7X27A_SURF;
target_msm_id = MSM7225A;
smem_status = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION,
&format, sizeof(format), 0);
if (!smem_status) {
if (format == 4) {
board_info_len = sizeof(board_info_v4);
smem_status =
smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
&board_info_v4,
board_info_len);
if (!smem_status) {
id = board_info_v4.board_info_v3.hw_platform;
target_msm_id =
board_info_v4.board_info_v3.msm_id;
msm_version =
board_info_v4.board_info_v3.msm_version;
}
}
/* Detect SURF v/s FFA v/s QRD */
if (target_msm_id >= MSM8225 && target_msm_id <= MSM8625
|| (target_msm_id == MSM8125A)
|| (target_msm_id == MSM8125)) {
switch (id) {
case 0x1:
hw_platform = MSM8X25_SURF;
break;
case 0x2:
hw_platform = MSM8X25_FFA;
break;
case 0x10:
hw_platform = MSM8X25_EVT;
break;
case 0x11:
hw_platform = MSM8X25Q_SKUD;
break;
case 0xC:
hw_platform = MSM8X25_EVB;
break;
case 0xF:
hw_platform = MSM8X25_QRD7;
break;
default:
hw_platform = MSM8X25_SURF;
}
} else {
switch (id) {
case 0x1:
/* Set the machine type based on msm ID */
if (msm_is_7x25a(target_msm_id))
hw_platform = MSM7X25A_SURF;
else
hw_platform = MSM7X27A_SURF;
break;
case 0x2:
if (msm_is_7x25a(target_msm_id))
hw_platform = MSM7X25A_FFA;
else
hw_platform = MSM7X27A_FFA;
break;
case 0xB:
if(target_is_emmc_boot())
hw_platform = MSM7X27A_QRD1;
else
hw_platform = MSM7X27A_QRD3;
break;
case 0xC:
hw_platform = MSM7X27A_EVB;
break;
case 0xF:
hw_platform = MSM7X27A_QRD3;
break;
default:
if (msm_is_7x25a(target_msm_id))
hw_platform = MSM7X25A_SURF;
else
hw_platform = MSM7X27A_SURF;
};
}
/* Set msm ID for target variants based on values read from smem */
switch (target_msm_id) {
case MSM7225A:
case MSM7625A:
case ESM7225A:
case MSM7225AA:
case MSM7625AA:
case ESM7225AA:
case MSM7225AB:
case MSM7625AB:
case ESM7225AB:
case MSM7125A:
target_msm_id = MSM7625A;
break;
case MSM8225:
case MSM8625:
case MSM8125A:
case MSM8125:
target_msm_id = MSM8625;
break;
default:
target_msm_id = MSM7627A;
}
}
return;
}
unsigned board_machtype(void)
{
board_info();
return hw_platform;
}
unsigned board_msm_id(void)
{
board_info();
return target_msm_id;
}
unsigned board_msm_version(void)
{
board_info();
msm_version = (msm_version & 0xffff0000) >> 16;
return msm_version;
}
crypto_engine_type board_ce_type(void)
{
return platform_ce_type;
}
void reboot_device(unsigned reboot_reason)
{
reboot(reboot_reason);
}
static int read_from_flash(struct ptentry* ptn, int offset, int size, void *dest)
{
void *buffer = NULL;
unsigned page_size = flash_page_size();
unsigned page_mask = page_size - 1;
int read_size = (size + page_mask) & (~page_mask);
buffer = malloc(read_size);
if(!buffer){
dprintf(CRITICAL, "ERROR : Malloc failed for read_from_flash \n");
return -1;
}
if(flash_read(ptn, offset, buffer, read_size)){
dprintf(CRITICAL, "ERROR : Flash read failed \n");
return -1;
}
memcpy(dest, buffer, size);
free(buffer);
return 0;
}
static unsigned int get_fota_cookie_mtd(void)
{
struct ptentry *ptn;
struct ptable *ptable;
unsigned int cookie = 0;
ptable = flash_get_ptable();
if (ptable == NULL) {
dprintf(CRITICAL, "ERROR: Partition table not found\n");
return 0;
}
ptn = ptable_find(ptable, "FOTA");
if (ptn == NULL) {
dprintf(CRITICAL, "ERROR: No FOTA partition found\n");
return 0;
}
if (read_from_flash(ptn, 0, sizeof(unsigned int), &cookie) == -1) {
dprintf(CRITICAL, "ERROR: failed to read fota cookie from flash\n");
return 0;
}
return cookie;
}
static int read_from_mmc(struct ptentry* ptn, int size, void *dest)
{
void *buffer = NULL;
unsigned sector_mask = 511;
int read_size = (size + sector_mask) & (~sector_mask);
buffer = malloc(read_size);
if(!buffer){
dprintf(CRITICAL, "ERROR : Malloc failed for read_from_flash \n");
return -1;
}
if(mmc_read(ptn, buffer, read_size)) {
dprintf(CRITICAL, "ERROR : Flash read failed \n");
return -1;
}
memcpy(dest, buffer, size);
free(buffer);
return 0;
}
static int get_fota_cookie_mmc(void)
{
unsigned long long ptn = 0;
int index = -1;
unsigned int cookie = 0;
index = partition_get_index("FOTA");
ptn = partition_get_offset(index);
if(ptn == 0) {
dprintf(CRITICAL,"ERROR: FOTA partition not found\n");
return 0;
}
if(read_from_mmc(ptn, sizeof(unsigned int), &cookie)) {
dprintf(CRITICAL, "ERROR: Cannot read cookie info\n");
return 0;
}
return cookie;
}
unsigned check_reboot_mode(void)
{
unsigned mode[2] = { 0, 0 };
unsigned int mode_len = sizeof(mode);
unsigned smem_status;
unsigned int cookie = 0;
smem_status = smem_read_alloc_entry(SMEM_APPS_BOOT_MODE,
&mode, mode_len);
/*
* SMEM value is relied upon on power shutdown. Check either of SMEM
* or FOTA update cookie is set
*/
if (target_is_emmc_boot())
cookie = get_fota_cookie_mmc();
else
cookie = get_fota_cookie_mtd();
if ((mode[0] == RECOVERY_MODE) || (cookie == FOTA_COOKIE))
return RECOVERY_MODE;
if (smem_status) {
dprintf(CRITICAL,
"ERROR: unable to read shared memory for reboot mode\n");
return 0;
}
return mode[0];
}
static unsigned target_check_power_on_reason(void)
{
unsigned power_on_status = 0;
unsigned int status_len = sizeof(power_on_status);
unsigned smem_status;
smem_status = smem_read_alloc_entry(SMEM_POWER_ON_STATUS_INFO,
&power_on_status, status_len);
if (smem_status) {
dprintf(CRITICAL,
"ERROR: unable to read shared memory for power on reason\n");
}
return power_on_status;
}
unsigned target_pause_for_battery_charge(void)
{
if (target_check_power_on_reason() == PWR_ON_EVENT_WALL_CHG)
return 1;
return 0;
}
void target_battery_charging_enable(unsigned enable, unsigned disconnect)
{
}
#if _EMMC_BOOT
void target_serialno(unsigned char *buf)
{
unsigned int serialno;
serialno = mmc_get_psn();
sprintf(buf, "%x", serialno);
}
int emmc_recovery_init(void)
{
int rc;
rc = _emmc_recovery_init();
return rc;
}
#endif
int machine_is_evb()
{
int ret = 0;
unsigned mach_type = board_machtype();
switch(mach_type) {
case MSM7X27A_EVB:
case MSM8X25_EVB:
case MSM8X25_EVT:
ret = 1;
break;
default:
ret = 0;
}
return ret;
}
int machine_is_qrd()
{
int ret = 0;
unsigned mach_type = board_machtype();
switch(mach_type) {
case MSM7X27A_QRD1:
case MSM7X27A_QRD3:
case MSM8X25_QRD7:
ret = 1;
break;
default:
ret = 0;
}
return ret;
}
int machine_is_skud()
{
int ret = 0;
unsigned mach_type = board_machtype();
switch(mach_type) {
case MSM8X25Q_SKUD:
ret = 1;
break;
default:
ret = 0;
}
return ret;
}
int machine_is_8x25()
{
int ret = 0;
unsigned mach_type = board_machtype();
switch(mach_type) {
case MSM8X25_SURF:
case MSM8X25_FFA:
case MSM8X25_EVB:
case MSM8X25_EVT:
case MSM8X25_QRD7:
case MSM8X25Q_SKUD:
ret = 1;
break;
default:
ret = 0;
}
return ret;
}
int msm_is_7x25a(int msm_id)
{
int ret = 0;
switch (msm_id) {
case MSM7225A:
case MSM7625A:
case ESM7225A:
case MSM7225AA:
case MSM7625AA:
case ESM7225AA:
case MSM7225AB:
case MSM7625AB:
case ESM7225AB:
case MSM7125A:
ret = 1;
break;
default:
ret = 0;
};
return ret;
}
static void target_ulpi_init(void)
{
unsigned int reg;
ulpi_read(0x31);
dprintf(INFO, " Value of ulpi read 0x31 is %08x\n", reg);
/* todo : the write back value should be calculated according to
* reg &= 0xF3 but sometimes the value that is read initially
* doesnt look right
*/
ulpi_write(0x4A, 0x31);
reg = ulpi_read(0x31);
dprintf(INFO, " Value of ulpi read 0x31 after write is %08x\n", reg);
reg = ulpi_read(0x32);
dprintf(INFO, " Value of ulpi read 0x32 is %08x\n", reg);
ulpi_write(0x30, 0x32);
reg = ulpi_read(0x32);
dprintf(INFO, " Value of ulpi read 0x32 after write is %08x\n", reg);
reg = ulpi_read(0x36);
dprintf(INFO, " Value of ulpi read 0x36 is %08x\n", reg);
ulpi_write(reg | 0x2, 0x36);
reg = ulpi_read(0x36);
dprintf(INFO, " Value of ulpi read 0x36 after write is %08x\n", reg);
}
void target_usb_init(void)
{
target_ulpi_init();
}
int target_cont_splash_screen()
{
int ret = 0;
unsigned mach_type = 0;
mach_type = board_machtype();
switch(mach_type) {
case MSM8X25_EVB:
case MSM8X25_EVT:
case MSM8X25_QRD7:
ret = 1;
break;
default:
ret = 0;
};
return ret;
}
int target_is_sku3()
{
int ret = 0;
unsigned mach_type = 0;
mach_type = board_machtype();
switch(mach_type) {
case MSM7X27A_QRD3:
ret = 1;
break;
default:
ret = 0;
};
return ret;
}
/* Function to set the capabilities for the host */
void target_mmc_caps(struct mmc_host *host)
{
host->caps.ddr_mode = 0;
host->caps.hs200_mode = 0;
host->caps.bus_width = MMC_BOOT_BUS_WIDTH_4_BIT;
host->caps.hs_clk_rate = MMC_CLK_50MHZ;
}
@@ -0,0 +1,160 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009-2012, The Linux Foundation. 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 <dev/keys.h>
#include <dev/ssbi.h>
#include <dev/gpio_keypad.h>
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
/* don't turn this on without updating the ffa support */
#define SCAN_FUNCTION_KEYS 0
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 };
static unsigned int halibut_row_gpios_skud[] = { 31, 32 };
static unsigned int halibut_col_gpios_skud[] = { 37 };
static unsigned int halibut_row_gpios_evb[] = { 31 };
static unsigned int halibut_col_gpios_evb[] = { 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))
#define KEYMAP_INDEX_EVB(row, col) ((row)*ARRAY_SIZE(halibut_col_gpios_evb) + (col))
static const unsigned short halibut_keymap[ARRAY_SIZE(halibut_col_gpios) *
ARRAY_SIZE(halibut_row_gpios)] = {
[KEYMAP_INDEX(0, 0)] = KEY_7,
[KEYMAP_INDEX(0, 1)] = KEY_DOWN,
[KEYMAP_INDEX(0, 2)] = KEY_UP,
[KEYMAP_INDEX(0, 3)] = KEY_RIGHT,
[KEYMAP_INDEX(0, 4)] = KEY_CENTER,
[KEYMAP_INDEX(1, 0)] = KEY_LEFT,
[KEYMAP_INDEX(1, 1)] = KEY_SEND,
[KEYMAP_INDEX(1, 2)] = KEY_1,
[KEYMAP_INDEX(1, 3)] = KEY_4,
[KEYMAP_INDEX(1, 4)] = KEY_CLEAR,
[KEYMAP_INDEX(2, 0)] = KEY_6,
[KEYMAP_INDEX(2, 1)] = KEY_5,
[KEYMAP_INDEX(2, 2)] = KEY_8,
[KEYMAP_INDEX(2, 3)] = KEY_3,
[KEYMAP_INDEX(2, 4)] = KEY_STAR,
[KEYMAP_INDEX(3, 0)] = KEY_9,
[KEYMAP_INDEX(3, 1)] = KEY_SOFT1,
[KEYMAP_INDEX(3, 2)] = KEY_0,
[KEYMAP_INDEX(3, 3)] = KEY_2,
[KEYMAP_INDEX(3, 4)] = KEY_SOFT2,
[KEYMAP_INDEX(4, 0)] = KEY_MENU, /*R- */
[KEYMAP_INDEX(4, 1)] = KEY_HOME, /*L+ */
[KEYMAP_INDEX(4, 2)] = KEY_BACK, /*L- */
[KEYMAP_INDEX(4, 3)] = KEY_VOLUMEUP,
[KEYMAP_INDEX(4, 4)] = KEY_VOLUMEDOWN,
};
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 const unsigned short halibut_keymap_evb[ARRAY_SIZE(halibut_col_gpios_evb)
*
ARRAY_SIZE
(halibut_row_gpios_evb)] = {
[KEYMAP_INDEX_EVB(0, 0)] = KEY_VOLUMEUP,
[KEYMAP_INDEX_EVB(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,
.noutputs = ARRAY_SIZE(halibut_row_gpios),
.ninputs = ARRAY_SIZE(halibut_col_gpios),
.settle_time = 5 /* msec */ ,
.poll_time = 20 /* msec */ ,
.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,
};
static struct gpio_keypad_info halibut_keypad_info_skud = {
.keymap = halibut_keymap_qrd,
.output_gpios = halibut_row_gpios_skud,
.input_gpios = halibut_col_gpios_skud,
.noutputs = ARRAY_SIZE(halibut_row_gpios_skud),
.ninputs = ARRAY_SIZE(halibut_col_gpios_skud),
.settle_time = 5 /* msec */ ,
.poll_time = 20 /* msec */ ,
.flags = GPIOKPF_DRIVE_INACTIVE,
};
static struct gpio_keypad_info halibut_keypad_info_evb = {
.keymap = halibut_keymap_evb,
.output_gpios = halibut_row_gpios_evb,
.input_gpios = halibut_col_gpios_evb,
.noutputs = ARRAY_SIZE(halibut_row_gpios_evb),
.ninputs = ARRAY_SIZE(halibut_col_gpios_evb),
.settle_time = 5 /* msec */ ,
.poll_time = 20 /* msec */ ,
.flags = GPIOKPF_DRIVE_INACTIVE,
};
void keypad_init(void)
{
if (machine_is_qrd())
gpio_keypad_init(&halibut_keypad_info_qrd);
else if (machine_is_skud())
gpio_keypad_init(&halibut_keypad_info_skud);
else if (machine_is_evb())
gpio_keypad_init(&halibut_keypad_info_evb);
else
gpio_keypad_init(&halibut_keypad_info_surf);
}
@@ -0,0 +1,48 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared
PLATFORM := msm7x27a
MEMBASE := 0x00000000 # SMI
MEMSIZE := 0x00100000 # 1MB
BASE_ADDR := 0x00200000
TAGS_ADDR := BASE_ADDR+0x00000100
KERNEL_ADDR := BASE_ADDR+0x00008000
RAMDISK_ADDR := BASE_ADDR+0x01000000
SCRATCH_ADDR := BASE_ADDR+0x000A0000
KEYS_USE_GPIO_KEYPAD := 1
DEFINES += DISPLAY_TYPE_MDDI=0
DEFINES += DISPLAY_TYPE_LCDC=0
DEFINES += DISPLAY_SPLASH_SCREEN=1
DEFINES += DISPLAY_TYPE_MIPI=1
DEFINES += DISPLAY_MIPI_PANEL_RENESAS=1
DEFINES += USE_PCOM_SECBOOT=1
DEFINES += TARGET_USES_GIC_VIC=1
DEFINES += MIPI_VIDEO_MODE=0
MODULES += \
dev/keys \
dev/ssbi \
lib/ptable \
dev/panel/msm
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)
OBJS += \
$(LOCAL_DIR)/init.o \
$(LOCAL_DIR)/keypad.o \
$(LOCAL_DIR)/atags.o \
$(LOCAL_DIR)/target_display.o
@@ -0,0 +1,163 @@
/* Copyright (c) 2012, The Linux Foundation. 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 The Linux Foundation, 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 <debug.h>
#include <msm_panel.h>
#include <target/display.h>
#include <target/board.h>
#include <dev/lcdc.h>
static struct msm_fb_panel_data panel;
static uint8_t display_enabled;
extern int msm_display_init(struct msm_fb_panel_data *pdata);
extern int msm_display_off();
extern int mipi_renesas_panel_dsi_config(int);
extern int mipi_nt35510_panel_dsi_config(int);
extern int lcdc_truly_panel_on(int);
static int msm7627a_mdp_clock_init(int enable)
{
int ret = 0;
unsigned rate = 0;
rate = panel.panel_info.clk_rate;
if (enable)
mdp_clock_init(rate);
else
mdp_clock_disable();
return ret;
}
static int msm7627a_lcdc_clock_init(int enable)
{
int ret = 0;
unsigned rate = panel.panel_info.clk_rate;
if (enable) {
mdp_clock_init(rate);
lcdc_clock_init(rate);
} else {
mdp_clock_disable();
lcdc_clock_disable();
}
return ret;
}
void display_init(void)
{
unsigned mach_type;
mach_type = board_machtype();
dprintf(SPEW, "display_init\n");
switch (mach_type) {
case MSM7X27A_SURF:
case MSM8X25_SURF:
case MSM7X27A_FFA:
#if MIPI_VIDEO_MODE
mipi_renesas_video_fwvga_init(&(panel.panel_info));
#else
mipi_renesas_cmd_fwvga_init(&(panel.panel_info));
#endif
panel.clk_func = msm7627a_mdp_clock_init;
panel.power_func = mipi_renesas_panel_dsi_config;
panel.fb.base = MIPI_FB_ADDR;
panel.fb.width = panel.panel_info.xres;
panel.fb.height = panel.panel_info.yres;
panel.fb.stride = panel.panel_info.xres;
panel.fb.bpp = panel.panel_info.bpp;
panel.fb.format = FB_FORMAT_RGB888;
panel.mdp_rev = MDP_REV_303;
break;
case MSM7X25A_SURF:
case MSM7X25A_FFA:
#if MIPI_VIDEO_MODE
mipi_renesas_video_hvga_init(&(panel.panel_info));
#else
mipi_renesas_cmd_hvga_init(&(panel.panel_info));
#endif
panel.clk_func = msm7627a_mdp_clock_init;
panel.power_func = mipi_renesas_panel_dsi_config;
panel.fb.base = MIPI_FB_ADDR;
panel.fb.width = panel.panel_info.xres;
panel.fb.height = panel.panel_info.yres;
panel.fb.stride = panel.panel_info.xres;
panel.fb.bpp = panel.panel_info.bpp;
panel.fb.format = FB_FORMAT_RGB888;
panel.mdp_rev = MDP_REV_303;
break;
case MSM7X27A_EVB:
case MSM8X25_EVB:
case MSM8X25_EVT:
#if MIPI_VIDEO_MODE
mipi_nt35510_video_wvga_init(&(panel.panel_info));
#else
mipi_nt35510_cmd_wvga_init(&(panel.panel_info));
#endif
panel.clk_func = msm7627a_mdp_clock_init;
panel.power_func = mipi_nt35510_panel_dsi_config;
panel.fb.base = MIPI_FB_ADDR;
panel.fb.width = panel.panel_info.xres;
panel.fb.height = panel.panel_info.yres;
panel.fb.stride = panel.panel_info.xres;
panel.fb.bpp = panel.panel_info.bpp;
panel.fb.format = FB_FORMAT_RGB888;
panel.mdp_rev = MDP_REV_303;
if (mach_type == MSM8X25_EVT)
panel.rotate = 1;
break;
case MSM8X25_QRD7:
lcdc_truly_hvga_init(&(panel.panel_info));
panel.clk_func = msm7627a_lcdc_clock_init;
panel.power_func = lcdc_truly_panel_on;
panel.fb.base = LCDC_FB_ADDR;
panel.fb.width = panel.panel_info.xres;
panel.fb.height = panel.panel_info.yres;
panel.fb.stride = panel.panel_info.xres;
panel.fb.bpp = panel.panel_info.bpp;
panel.fb.format = FB_FORMAT_RGB565;
panel.mdp_rev = MDP_REV_303;
break;
default:
return;
};
if (msm_display_init(&panel)) {
dprintf(CRITICAL, "Display init failed!\n");
return;
}
display_enabled = 1;
}
void display_shutdown(void)
{
dprintf(SPEW, "display_shutdown()\n");
if (display_enabled)
msm_display_off();
}
@@ -0,0 +1,41 @@
#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 emmc_appsboothd.mbn
else
ifeq ($(BUILD_NANDWRITE), 1)
APPSBOOTHDR_FILES :=
else
APPSBOOTHDR_FILES := appsboot.mbn appsboothd.mbn
endif
endif
APPSBOOTHEADER: $(APPSBOOTHDR_FILES)
appsboot.mbn: $(OUTBIN)
cp $(OUTBIN) $(APPSBOOTHEADER_DIR)/appsboot.raw
cp -f $(OUTBIN) $(APPSBOOTHEADER_DIR)/appsboot.mbn
appsboothd.mbn: mkheader $(OUTBIN)
$(BUILDDIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/appsboothd.mbn
EMMCBOOT.MBN: $(OUTBIN)
cp $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboot.raw
cp -f $(OUTBIN) $(APPSBOOTHEADER_DIR)/EMMCBOOT.MBN
cp -f $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboot.mbn
emmc_appsboothd.mbn: mkheader $(OUTBIN)
$(BUILDDIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboothd.mbn unified-boot
mkheader: $(SRC_DIR)/mkheader.c
@mkdir -p $(BUILDDIR)
${COMPILER} -DMEMBASE=$(MEMBASE) $(SRC_DIR)/mkheader.c -o $(BUILDDIR)/mkheader
@@ -0,0 +1,306 @@
/*
* Copyright (c) 2007, Google Inc.
* All rights reserved.
*
* Copyright (c) 2010-2011, The Linux Foundation. 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> <emmc>\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,
"emmc: This flag takes value 1 or 0, 1 - emmc 0 - nand\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 emmc = 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 != 7) {
fprintf(stderr,
"ERROR: Missing argument(s): [outbin maxsize] | [outbin, maxsize, certchain, signature + certifcate(s)]\n");
return print_usage();
}
if (argc == 7 && atoi(argv[6]) == 1) {
emmc = 1;
}
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 || emmc) {
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;
base = 0;
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 || emmc == 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 > 7) {
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;
}
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;
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 [RAW APPSBOOT][PADDED CERT CHAIN]
if ((output_file = fopen(argv[4], "wb")) == NULL) {
perror("ERROR: Occured during fopen");
return -1;
}
//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 == 7) {
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;
}
//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);
}
return 0;
}
@@ -0,0 +1,105 @@
/* Copyright (c) 2009, The Linux Foundation. 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 The Linux Foundation 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 <smem.h>
#define EBI1_ADDR_128M 0x08000000
#define SIZE_1M 0x00100000
static int scratch_addr = -1;
unsigned *target_atag_mem(unsigned *ptr)
{
struct smem_ram_ptable ram_ptable;
unsigned i = 0;
if (smem_ram_ptable_init(&ram_ptable)) {
for (i = 0; i < ram_ptable.len; i++) {
if ((ram_ptable.parts[i].attr == READWRITE)
&& (ram_ptable.parts[i].domain == APPS_DOMAIN)
&& (ram_ptable.parts[i].type == APPS_MEMORY)
&& (ram_ptable.parts[i].category != IMEM)) {
/* ATAG_MEM */
*ptr++ = 4;
*ptr++ = 0x54410002;
*ptr++ = ram_ptable.parts[i].size;
*ptr++ = ram_ptable.parts[i].start;
}
/* Check for modem bootloader memory that can be reclaimed */
if ((ram_ptable.parts[i].attr == READWRITE)
&& (ram_ptable.parts[i].domain == APPS_DOMAIN)
&& (ram_ptable.parts[i].type ==
BOOT_REGION_MEMORY1)) {
/* ATAG_MEM_OSBL */
*ptr++ = 4;
*ptr++ = 0x5441000C;
*ptr++ = ram_ptable.parts[i].size;
*ptr++ = ram_ptable.parts[i].start;
}
}
} else {
dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n");
ASSERT(0);
}
return ptr;
}
void *target_get_scratch_address(void)
{
struct smem_ram_ptable ram_ptable;
unsigned i = 0;
if (smem_ram_ptable_init(&ram_ptable)) {
for (i = 0; i < ram_ptable.len; i++) {
if ((ram_ptable.parts[i].attr == READWRITE)
&& (ram_ptable.parts[i].domain == APPS_DOMAIN)
&& (ram_ptable.parts[i].start != 0x0)) {
if (ram_ptable.parts[i].size >=
FASTBOOT_BUF_SIZE) {
scratch_addr =
ram_ptable.parts[i].start;
break;
}
}
}
} else {
dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n");
ASSERT(0);
}
return (void *)((scratch_addr == -1) ? EBI1_ADDR_128M : scratch_addr);
}
unsigned target_get_max_flash_size(void)
{
return (256 * 1024 * 1024);
}
@@ -0,0 +1,47 @@
/* Copyright (c) 2010, The Linux Foundation. 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 The Linux Foundation 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_MSM7630_SURF_DISPLAY_H
#define _TARGET_MSM7630_SURF_DISPLAY_H
#define TARGET_XRES 480
#define TARGET_YRES 800
#define LCDC_FB_WIDTH 480
#define LCDC_FB_HEIGHT 800
#define LCDC_HSYNC_PULSE_WIDTH_DCLK 8
#define LCDC_HSYNC_BACK_PORCH_DCLK 184
#define LCDC_HSYNC_FRONT_PORCH_DCLK 4
#define LCDC_HSYNC_SKEW_DCLK 0
#define LCDC_VSYNC_PULSE_WIDTH_LINES 1
#define LCDC_VSYNC_BACK_PORCH_LINES 2
#define LCDC_VSYNC_FRONT_PORCH_LINES 3
#endif
@@ -0,0 +1,446 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009-2011, The Linux Foundation. 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 <dev/keys.h>
#include <dev/gpio.h>
#include <dev/ssbi.h>
#include <lib/ptable.h>
#include <dev/flash.h>
#include <smem.h>
#include <reg.h>
#include <mmc.h>
#include <platform/iomap.h>
#include <platform/machtype.h>
#if TARGET_USES_RSPIN_LOCK
#include <platform/remote_spinlock.h>
#endif
#include <platform.h>
#include <crypto_hash.h>
#define MSM8255_ID 74
#define MSM8655_ID 75
#define APQ8055_ID 85
#define VARIABLE_LENGTH 0x10101010
#define DIFF_START_ADDR 0xF0F0F0F0
#define NUM_PAGES_PER_BLOCK 0x40
static unsigned mmc_sdc_base[] =
{ MSM_SDC1_BASE, MSM_SDC2_BASE, MSM_SDC3_BASE, MSM_SDC4_BASE };
static struct ptable flash_ptable;
static int hw_platform_type = -1;
/* Setting this variable to different values defines the
* behavior of CE engine:
* platform_ce_type = CRYPTO_ENGINE_TYPE_NONE : No CE engine
* platform_ce_type = CRYPTO_ENGINE_TYPE_SW : Software CE engine
* platform_ce_type = CRYPTO_ENGINE_TYPE_HW : Hardware CE engine
* Behavior is determined in the target code.
*/
static crypto_engine_type platform_ce_type = CRYPTO_ENGINE_TYPE_HW;
/* for these partitions, start will be offset by either what we get from
* smem, or from the above offset if smem is not useful. Also, we should
* probably have smem_ptable code populate our flash_ptable.
*
* When smem provides us with a full partition table, we can get rid of
* this altogether.
*
*/
static struct ptentry board_part_list[] = {
{
.start = 0,
.length = 10 /* In MB */ ,
.name = "boot",
},
{
.start = DIFF_START_ADDR,
.length = 256 /* In MB */ ,
.name = "system",
},
{
.start = DIFF_START_ADDR,
.length = 5 /* In MB */ ,
.name = "cache",
},
{
.start = DIFF_START_ADDR,
.length = 1 /* In MB */ ,
.name = "misc",
},
{
.start = DIFF_START_ADDR,
.length = 1 /* In MB */ ,
.name = "devinfo",
},
{
.start = DIFF_START_ADDR,
.length = VARIABLE_LENGTH,
.name = "userdata",
},
{
.start = DIFF_START_ADDR,
.length = 3 /* In MB */ ,
.name = "persist",
},
{
.start = DIFF_START_ADDR,
.length = 10 /* In MB */ ,
.name = "recovery",
},
};
static int num_parts = sizeof(board_part_list) / sizeof(struct ptentry);
void smem_ptable_init(void);
unsigned smem_get_apps_flash_start(void);
unsigned smem_read_alloc_entry_offset(smem_mem_type_t, void *, int, int);
void keypad_init(void);
static int emmc_boot = -1; /* set to uninitialized */
int target_is_emmc_boot(void);
static int platform_version = -1;
static int target_msm_id = -1;
static int interleaved_mode_enabled = -1;
void enable_interleave_mode(int);
int target_is_interleaved_mode(void)
{
struct smem_board_info_v4 board_info_v4;
unsigned int board_info_len = 0;
unsigned smem_status;
char *build_type;
unsigned format = 0;
if (interleaved_mode_enabled != -1) {
return interleaved_mode_enabled;
}
smem_status = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION,
&format, sizeof(format), 0);
if (!smem_status) {
if ((format == 3) || (format == 4)) {
if (format == 4)
board_info_len = sizeof(board_info_v4);
else
board_info_len =
sizeof(board_info_v4.board_info_v3);
smem_status =
smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
&board_info_v4,
board_info_len);
if (!smem_status) {
build_type =
(char *)(board_info_v4.
board_info_v3.build_id) + 9;
interleaved_mode_enabled = 0;
if (*build_type == 'C') {
interleaved_mode_enabled = 1;
}
}
}
}
return interleaved_mode_enabled;
}
void target_init(void)
{
unsigned offset;
struct flash_info *flash_info;
unsigned total_num_of_blocks;
unsigned next_ptr_start_adr = 0;
unsigned blocks_per_1MB = 8; /* Default value of 2k page size on 256MB flash drive */
unsigned base_addr;
unsigned char slot;
int i;
dprintf(INFO, "target_init()\n");
#if TARGET_USES_RSPIN_LOCK
if(remote_spinlock_init(&rlock))
dprintf(SPEW,"Failed to Initialize remote spin locks\n");
#endif
#if (!ENABLE_NANDWRITE)
keys_init();
keypad_init();
#endif
/* Display splash screen if enabled */
#if DISPLAY_SPLASH_SCREEN
display_init();
dprintf(SPEW, "Diplay initialized\n");
display_image_on_screen();
#endif
if (target_is_emmc_boot()) {
/* Must wait for modem-up before we can intialize MMC.
*/
while (readl(MSM_SHARED_BASE + 0x14) != 1) ;
/* Trying Slot 2 first */
slot = 2;
base_addr = mmc_sdc_base[slot - 1];
if (mmc_boot_main(slot, base_addr)) {
/* Trying Slot 4 next */
slot = 4;
base_addr = mmc_sdc_base[slot - 1];
if (mmc_boot_main(slot, base_addr)) {
dprintf(CRITICAL, "mmc init failed!");
ASSERT(0);
}
}
return;
}
ptable_init(&flash_ptable);
smem_ptable_init();
flash_init();
flash_info = flash_get_info();
ASSERT(flash_info);
enable_interleave_mode(target_is_interleaved_mode());
offset = smem_get_apps_flash_start();
if (offset == 0xffffffff)
while (1) ;
total_num_of_blocks = flash_info->num_blocks;
blocks_per_1MB = (1 << 20) / (flash_info->block_size);
for (i = 0; i < num_parts; i++) {
struct ptentry *ptn = &board_part_list[i];
unsigned len = ((ptn->length) * blocks_per_1MB);
if (ptn->start != 0)
ASSERT(ptn->start == DIFF_START_ADDR);
ptn->start = next_ptr_start_adr;
if (ptn->length == VARIABLE_LENGTH) {
unsigned length_for_prt = 0;
unsigned j;
for (j = i + 1; j < num_parts; j++) {
struct ptentry *temp_ptn = &board_part_list[j];
ASSERT(temp_ptn->length != VARIABLE_LENGTH);
length_for_prt +=
((temp_ptn->length) * blocks_per_1MB);
}
len =
total_num_of_blocks - (offset + ptn->start +
length_for_prt);
ASSERT(len >= 0);
}
next_ptr_start_adr = ptn->start + len;
if (target_is_interleaved_mode()) {
ptable_add(&flash_ptable, ptn->name,
offset + (ptn->start / 2), (len / 2),
ptn->flags, TYPE_APPS_PARTITION,
PERM_WRITEABLE);
} else {
ptable_add(&flash_ptable, ptn->name,
offset + ptn->start, len, ptn->flags,
TYPE_APPS_PARTITION, PERM_WRITEABLE);
}
}
smem_add_modem_partitions(&flash_ptable);
ptable_dump(&flash_ptable);
flash_set_ptable(&flash_ptable);
}
int target_platform_version(void)
{
return platform_version;
}
int target_is_msm8x55(void)
{
if ((target_msm_id == MSM8255_ID) ||
(target_msm_id == MSM8655_ID) || (target_msm_id == APQ8055_ID))
return 1;
else
return 0;
}
unsigned board_machtype(void)
{
struct smem_board_info_v4 board_info_v4;
unsigned int board_info_len = 0;
enum platform platform_type = 0;
unsigned smem_status;
unsigned format = 0;
if (hw_platform_type != -1)
return hw_platform_type;
smem_status = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION,
&format, sizeof(format), 0);
if (!smem_status) {
if ((format == 3) || (format == 4)) {
if (format == 4)
board_info_len = sizeof(board_info_v4);
else
board_info_len =
sizeof(board_info_v4.board_info_v3);
smem_status =
smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
&board_info_v4,
board_info_len);
if (!smem_status) {
if (format == 4)
platform_version =
board_info_v4.platform_version;
platform_type =
board_info_v4.board_info_v3.hw_platform;
target_msm_id =
board_info_v4.board_info_v3.msm_id;
switch (platform_type) {
case HW_PLATFORM_SURF:
hw_platform_type =
((target_is_msm8x55())?
LINUX_MACHTYPE_8x55_SURF :
LINUX_MACHTYPE_7x30_SURF);
break;
case HW_PLATFORM_FFA:
hw_platform_type =
((target_is_msm8x55())?
LINUX_MACHTYPE_8x55_FFA :
LINUX_MACHTYPE_7x30_FFA);
break;
case HW_PLATFORM_FLUID:
hw_platform_type =
LINUX_MACHTYPE_7x30_FLUID;
break;
case HW_PLATFORM_SVLTE:
hw_platform_type =
LINUX_MACHTYPE_8x55_SVLTE_FFA;
break;
default:
hw_platform_type =
((target_is_msm8x55())?
LINUX_MACHTYPE_8x55_SURF :
LINUX_MACHTYPE_7x30_SURF);
break;
}
return hw_platform_type;
}
}
}
hw_platform_type = LINUX_MACHTYPE_7x30_SURF;
return hw_platform_type;
}
void reboot_device(unsigned reboot_reason)
{
reboot(reboot_reason);
}
unsigned check_reboot_mode(void)
{
unsigned mode[2] = { 0, 0 };
unsigned int mode_len = sizeof(mode);
unsigned smem_status;
smem_status = smem_read_alloc_entry(SMEM_APPS_BOOT_MODE,
&mode, mode_len);
if (smem_status) {
dprintf(CRITICAL,
"ERROR: unable to read shared memory for reboot mode\n");
return 0;
}
return mode[0];
}
static unsigned target_check_power_on_reason(void)
{
unsigned power_on_status = 0;
unsigned int status_len = sizeof(power_on_status);
unsigned smem_status;
smem_status = smem_read_alloc_entry(SMEM_POWER_ON_STATUS_INFO,
&power_on_status, status_len);
if (smem_status) {
dprintf(CRITICAL,
"ERROR: unable to read shared memory for power on reason\n");
}
return power_on_status;
}
#if _EMMC_BOOT
void target_serialno(unsigned char *buf)
{
unsigned int serialno;
serialno = mmc_get_psn();
snprintf(buf, 13, "%x", serialno);
}
int emmc_recovery_init(void)
{
int rc;
rc = _emmc_recovery_init();
return rc;
}
#endif
crypto_engine_type board_ce_type(void)
{
return platform_ce_type;
}
int machine_is_ffa()
{
unsigned mach_type;
int ret = 0;
mach_type = board_machtype();
switch(mach_type) {
case LINUX_MACHTYPE_8x55_FFA:
case LINUX_MACHTYPE_7x30_FFA:
ret = 1;
break;
default:
ret = 0;
}
return ret;
}
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009-2010, The Linux Foundation. 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 <dev/keys.h>
#include <dev/ssbi.h>
#include <dev/gpio_keypad.h>
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
#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(4, 2)] = KEY_BACK, /* -L on SURF & FFA */
[KEYMAP_INDEX(3, 4)] = KEY_HOME, /* +R on SURF & FFA */
[KEYMAP_INDEX(1, 3)] = KEY_VOLUMEUP, /* '+' of left side switch on FLUID */
[KEYMAP_INDEX(1, 4)] = KEY_VOLUMEDOWN, /* '-' of left side switch on FLUID */
};
static struct qwerty_keypad_info qwerty_keypad = {
.keymap = qwerty_keymap,
.old_keys = qwerty_keys_old,
.rec_keys = qwerty_keys_new,
.rows = 5,
.columns = 5,
.num_of_reads = 6,
.rd_func = &i2c_ssbi_read_bytes,
.wr_func = &i2c_ssbi_write_bytes,
.settle_time = 5 /* msec */ ,
.poll_time = 20 /* msec */ ,
};
void keypad_init(void)
{
ssbi_keypad_init(&qwerty_keypad);
}
@@ -0,0 +1,48 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared -I$(LK_TOP_DIR)/platform/msm7x30
PLATFORM := msm7x30
MEMBASE := 0x00000000 # EBI
MEMSIZE := 0x00100000 # 1MB
BASE_ADDR := 0x00200000
TAGS_ADDR := BASE_ADDR+0x00000100
KERNEL_ADDR := BASE_ADDR+0x00008000
RAMDISK_ADDR := BASE_ADDR+0x01000000
SCRATCH_ADDR := 0x08008000
FASTBOOT_BUF_SIZE := 0x10000000
LCDC_FB_ADDR := 0x08008000
KEYS_USE_GPIO_KEYPAD := 1
DEFINES += DISPLAY_SPLASH_SCREEN=1
DEFINES += DISPLAY_TYPE_MDDI=0
DEFINES += DISPLAY_TYPE_LCDC=1
DEFINES += MMC_BOOT_ADM=0
DEFINES += TARGET_USES_RSPIN_LOCK=0
DEFINES += USE_PCOM_SECBOOT=1
MODULES += \
dev/keys \
dev/ssbi \
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) \
FASTBOOT_BUF_SIZE=$(FASTBOOT_BUF_SIZE) \
LCDC_FB_ADDR=$(LCDC_FB_ADDR)
OBJS += \
$(LOCAL_DIR)/init.o \
$(LOCAL_DIR)/atags.o \
$(LOCAL_DIR)/keypad.o
@@ -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)
$(BUILDDIR)/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)
$(BUILDDIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboothd.mbn
mkheader: $(SRC_DIR)/mkheader.c
@mkdir -p $(BUILDDIR)
${COMPILER} -DMEMBASE=$(MEMBASE) $(SRC_DIR)/mkheader.c -o $(BUILDDIR)/mkheader
@@ -0,0 +1,332 @@
/*
* Copyright (c) 2007, Google Inc.
* All rights reserved.
*
* Copyright (c) 2009-2010, The Linux Foundation. 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;
}
@@ -0,0 +1,364 @@
/* Copyright (c) 2012-2013, The Linux Foundation. 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 The Linux Foundation 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 <debug.h>
#include <platform/iomap.h>
#include <reg.h>
#include <target.h>
#include <platform.h>
#include <dload_util.h>
#include <uart_dm.h>
#include <mmc_sdhci.h>
#include <platform/gpio.h>
#include <spmi.h>
#include <board.h>
#include <smem.h>
#include <baseband.h>
#include <dev/keys.h>
#include <pm8x41.h>
#include <crypto5_wrapper.h>
#include <hsusb.h>
extern bool target_use_signed_kernel(void);
static void set_sdc_power_ctrl(void);
#define PMIC_ARB_CHANNEL_NUM 0
#define PMIC_ARB_OWNER_ID 0
#define CRYPTO_ENGINE_INSTANCE 1
#define CRYPTO_ENGINE_EE 1
#define CRYPTO_ENGINE_FIFO_SIZE 64
#define CRYPTO_ENGINE_READ_PIPE 3
#define CRYPTO_ENGINE_WRITE_PIPE 2
#define CRYPTO_ENGINE_CMD_ARRAY_SIZE 20
#define TLMM_VOL_UP_BTN_GPIO 106
static uint32_t mmc_sdhci_base[] =
{ MSM_SDC1_SDHCI_BASE, MSM_SDC2_SDHCI_BASE, MSM_SDC3_SDHCI_BASE };
struct mmc_device *dev;
void target_early_init(void)
{
#if WITH_DEBUG_UART
uart_dm_init(1, 0, BLSP1_UART2_BASE);
#endif
}
/* Return 1 if vol_up pressed */
static int target_volume_up()
{
uint8_t status = 0;
gpio_tlmm_config(TLMM_VOL_UP_BTN_GPIO, 0, GPIO_INPUT, GPIO_PULL_UP, GPIO_2MA, GPIO_ENABLE);
thread_sleep(10);
/* Get status of GPIO */
status = gpio_status(TLMM_VOL_UP_BTN_GPIO);
/* Active low signal. */
return !status;
}
/* Return 1 if vol_down pressed */
uint32_t target_volume_down()
{
/* Volume down button tied in with PMIC RESIN. */
return pm8x41_resin_status();
}
static void target_keystatus()
{
keys_init();
if(target_volume_down())
keys_post_event(KEY_VOLUMEDOWN, 1);
if(target_volume_up())
keys_post_event(KEY_VOLUMEUP, 1);
}
/* Set up params for h/w CRYPTO_ENGINE. */
void target_crypto_init_params()
{
struct crypto_init_params ce_params;
/* Set up base addresses and instance. */
ce_params.crypto_instance = CRYPTO_ENGINE_INSTANCE;
ce_params.crypto_base = MSM_CE1_BASE;
ce_params.bam_base = MSM_CE1_BAM_BASE;
/* Set up BAM config. */
ce_params.bam_ee = CRYPTO_ENGINE_EE;
ce_params.pipes.read_pipe = CRYPTO_ENGINE_READ_PIPE;
ce_params.pipes.write_pipe = CRYPTO_ENGINE_WRITE_PIPE;
/* Assign buffer sizes. */
ce_params.num_ce = CRYPTO_ENGINE_CMD_ARRAY_SIZE;
ce_params.read_fifo_size = CRYPTO_ENGINE_FIFO_SIZE;
ce_params.write_fifo_size = CRYPTO_ENGINE_FIFO_SIZE;
crypto_init_params(&ce_params);
}
void target_sdc_init()
{
struct mmc_config_data config;
/*
* Set drive strength & pull ctrl for emmc
*/
set_sdc_power_ctrl();
/* Enable sdhci mode */
sdhci_mode_enable(1);
config.bus_width = DATA_BUS_WIDTH_8BIT;
config.max_clk_rate = MMC_CLK_200MHZ;
/* Trying Slot 1*/
config.slot = 1;
config.base = mmc_sdhci_base[config.slot - 1];
if (!(dev = mmc_init(&config)))
{
/* Trying Slot 2 next */
config.slot = 2;
config.base = mmc_sdhci_base[config.slot - 1];
if (!(dev = mmc_init(&config))) {
dprintf(CRITICAL, "mmc init failed!");
ASSERT(0);
}
}
/*
* MMC initialization is complete, read the partition table info
*/
if (partition_read_table()) {
dprintf(CRITICAL, "Error reading the partition table info\n");
ASSERT(0);
}
}
void target_init(void)
{
dprintf(INFO, "target_init()\n");
spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID);
target_keystatus();
target_sdc_init();
if (target_use_signed_kernel())
target_crypto_init_params();
}
/* Do any target specific intialization needed before entering fastboot mode */
void target_fastboot_init(void)
{
/* Set the BOOT_DONE flag in PM8026 */
pm8x41_set_boot_done();
}
/* Detect the target type */
void target_detect(struct board_data *board)
{
board->target = LINUX_MACHTYPE_UNKNOWN;
}
/* Detect the modem type */
void target_baseband_detect(struct board_data *board)
{
uint32_t platform;
uint32_t platform_subtype;
platform = board->platform;
platform_subtype = board->platform_subtype;
/*
* Look for platform subtype if present, else
* check for platform type to decide on the
* baseband type
*/
switch(platform_subtype)
{
case HW_PLATFORM_SUBTYPE_UNKNOWN:
break;
default:
dprintf(CRITICAL, "Platform Subtype : %u is not supported\n", platform_subtype);
ASSERT(0);
};
switch(platform)
{
case MSM8826:
case MSM8626:
case MSM8226:
case MSM8926:
case MSM8126:
case MSM8326:
board->baseband = BASEBAND_MSM;
break;
case APQ8026:
board->baseband = BASEBAND_APQ;
break;
default:
dprintf(CRITICAL, "Platform type: %u is not supported\n", platform);
ASSERT(0);
};
}
void target_serialno(unsigned char *buf)
{
uint32_t serialno;
if (target_is_emmc_boot()) {
serialno = mmc_get_psn();
snprintf((char *)buf, 13, "%x", serialno);
}
}
unsigned 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 reboot_device(unsigned reboot_reason)
{
writel(reboot_reason, RESTART_REASON_ADDR);
/* Configure PMIC for warm reset */
pm8x41_reset_configure(PON_PSHOLD_WARM_RESET);
/* Drop PS_HOLD for MSM */
writel(0x00, MPM2_MPM_PS_HOLD);
mdelay(5000);
dprintf(CRITICAL, "Rebooting failed\n");
}
crypto_engine_type board_ce_type(void)
{
return CRYPTO_ENGINE_TYPE_HW;
}
unsigned board_machtype(void)
{
return 0;
}
void target_usb_stop(void)
{
/* Disable VBUS mimicing in the controller. */
ulpi_write(ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT, ULPI_MISC_A_CLEAR);
}
void target_usb_init(void)
{
uint32_t val;
/* Select and enable external configuration with USB PHY */
ulpi_write(ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT, ULPI_MISC_A_SET);
/* Enable sess_vld */
val = readl(USB_GENCONFIG_2) | GEN2_SESS_VLD_CTRL_EN;
writel(val, USB_GENCONFIG_2);
/* Enable external vbus configuration in the LINK */
val = readl(USB_USBCMD);
val |= SESS_VLD_CTRL;
writel(val, USB_USBCMD);
}
unsigned target_pause_for_battery_charge(void)
{
uint8_t pon_reason = pm8x41_get_pon_reason();
/* This function will always return 0 to facilitate
* automated testing/reboot with usb connected.
* uncomment if this feature is needed.
*/
/* if ((pon_reason == USB_CHG) || (pon_reason == DC_CHG))
* return 1;
*/
return 0;
}
unsigned target_baseband()
{
return board_baseband();
}
int emmc_recovery_init(void)
{
return _emmc_recovery_init();
}
int set_download_mode(void)
{
dload_util_write_cookie(FORCE_DLOAD_MODE_ADDR);
return 0;
}
static void set_sdc_power_ctrl()
{
/* Drive strength configs for sdc pins */
struct tlmm_cfgs sdc1_hdrv_cfg[] =
{
{ SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK },
{ SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK },
{ SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK },
};
/* Pull configs for sdc pins */
struct tlmm_cfgs sdc1_pull_cfg[] =
{
{ SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK },
{ SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK },
{ SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK },
};
/* Set the drive strength & pull control values */
tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg));
tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg));
}
struct mmc_device *target_mmc_device()
{
return dev;
}
@@ -0,0 +1,86 @@
/* Copyright (c) 2012-2013, The Linux Foundation. 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 The Linux Foundation 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 <malloc.h>
#include <smem.h>
#include <stdint.h>
#include <libfdt.h>
#include <platform/iomap.h>
#include <dev_tree.h>
/* Funtion to add the ram partition entries into device tree.
* The function assumes that all the entire fixed memory regions should
* be listed in the first bank of the passed in ddr regions.
*/
uint32_t target_dev_tree_mem(void *fdt, uint32_t memory_node_offset)
{
struct smem_ram_ptable ram_ptable;
uint32_t i;
int ret = 0;
/* Make sure RAM partition table is initialized */
ASSERT(smem_ram_ptable_init(&ram_ptable));
/* Calculating the size of the mem_info_ptr */
for (i = 0 ; i < ram_ptable.len; i++)
{
if((ram_ptable.parts[i].category == SDRAM) &&
(ram_ptable.parts[i].type == SYS_MEMORY))
{
/* Pass along all other usable memory regions to Linux */
ret = dev_tree_add_mem_info(fdt,
memory_node_offset,
ram_ptable.parts[i].start,
ram_ptable.parts[i].size);
if (ret)
{
dprintf(CRITICAL, "Failed to add secondary banks memory addresses\n");
goto target_dev_tree_mem_err;
}
}
}
target_dev_tree_mem_err:
return ret;
}
void *target_get_scratch_address(void)
{
return ((void *)SCRATCH_ADDR);
}
unsigned target_get_max_flash_size(void)
{
return (512 * 1024 * 1024);
}
@@ -0,0 +1,35 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared
PLATFORM := msm8226
MEMBASE := 0x0FF00000 # SDRAM
MEMSIZE := 0x00100000 # 1MB
BASE_ADDR := 0x00000
TAGS_ADDR := BASE_ADDR+0x00000100
KERNEL_ADDR := BASE_ADDR+0x00008000
RAMDISK_ADDR := BASE_ADDR+0x01000000
SCRATCH_ADDR := 0x10000000
MODULES += \
dev/keys \
lib/ptable \
dev/pmic/pm8x41 \
lib/libfdt
DEFINES += \
MEMSIZE=$(MEMSIZE) \
MEMBASE=$(MEMBASE) \
BASE_ADDR=$(BASE_ADDR) \
TAGS_ADDR=$(TAGS_ADDR) \
KERNEL_ADDR=$(KERNEL_ADDR) \
RAMDISK_ADDR=$(RAMDISK_ADDR) \
SCRATCH_ADDR=$(SCRATCH_ADDR)
OBJS += \
$(LOCAL_DIR)/init.o \
$(LOCAL_DIR)/meminfo.o
@@ -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)
$(BUILDDIR)/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)
$(BUILDDIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboothd.mbn
mkheader: $(SRC_DIR)/mkheader.c
@mkdir -p $(BUILDDIR)
${COMPILER} -DMEMBASE=$(MEMBASE) $(SRC_DIR)/mkheader.c -o $(BUILDDIR)/mkheader
@@ -0,0 +1,343 @@
/*
* Copyright (c) 2007, Google Inc.
* All rights reserved.
*
* Copyright (c) 2009-2011, The Linux Foundation. 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 The Linux Foundation 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 <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;
}
@@ -0,0 +1,270 @@
/* Copyright (c) 2013, The Linux Foundation. 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 The Linux Foundation 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 <debug.h>
#include <platform/iomap.h>
#include <reg.h>
#include <target.h>
#include <platform.h>
#include <uart_dm.h>
#include <mmc.h>
#include <platform/gpio.h>
#include <spmi.h>
#include <board.h>
#include <smem.h>
#include <baseband.h>
#include <dev/keys.h>
#include <pm8x41.h>
#include <hsusb.h>
#include <kernel/thread.h>
#define PMIC_ARB_CHANNEL_NUM 0
#define PMIC_ARB_OWNER_ID 0
#define TLMM_VOL_UP_BTN_GPIO 72
static uint32_t mmc_sdc_base[] =
{ MSM_SDC1_BASE, MSM_SDC2_BASE };
void target_early_init(void)
{
#if WITH_DEBUG_UART
uart_dm_init(2, 0, BLSP1_UART1_BASE);
#endif
}
/* Return 1 if vol_up pressed */
static int target_volume_up()
{
uint8_t status = 0;
gpio_tlmm_config(TLMM_VOL_UP_BTN_GPIO, 0, GPIO_INPUT, GPIO_PULL_UP, GPIO_2MA, GPIO_ENABLE);
/* Wait for the configuration to complete.*/
thread_sleep(1);
/* Get status of GPIO */
status = gpio_status(TLMM_VOL_UP_BTN_GPIO);
/* Active low signal. */
return !status;
}
/* Return 1 if vol_down pressed */
uint32_t target_volume_down()
{
/* Volume down button tied in with PMIC RESIN. */
return pm8x41_resin_status();
}
static void target_keystatus()
{
keys_init();
if(target_volume_down())
keys_post_event(KEY_VOLUMEDOWN, 1);
if(target_volume_up())
keys_post_event(KEY_VOLUMEUP, 1);
}
void target_init(void)
{
uint32_t base_addr;
uint8_t slot;
dprintf(INFO, "target_init()\n");
spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID);
target_keystatus();
/* Trying Slot 1*/
slot = 1;
base_addr = mmc_sdc_base[slot - 1];
if (mmc_boot_main(slot, base_addr))
{
/* Trying Slot 2 next */
slot = 2;
base_addr = mmc_sdc_base[slot - 1];
if (mmc_boot_main(slot, base_addr))
{
dprintf(CRITICAL, "mmc init failed!");
ASSERT(0);
}
}
}
/* Do any target specific intialization needed before entering fastboot mode */
void target_fastboot_init(void)
{
/* Set the BOOT_DONE flag in PM8110 */
pm8x41_set_boot_done();
}
/* Detect the target type */
void target_detect(struct board_data *board)
{
board->target = LINUX_MACHTYPE_UNKNOWN;
}
/* Detect the modem type */
void target_baseband_detect(struct board_data *board)
{
uint32_t platform;
uint32_t platform_subtype;
platform = board->platform;
platform_subtype = board->platform_subtype;
/*
* Look for platform subtype if present, else
* check for platform type to decide on the
* baseband type
*/
switch(platform_subtype)
{
case HW_PLATFORM_SUBTYPE_UNKNOWN:
break;
default:
dprintf(CRITICAL, "Platform Subtype : %u is not supported\n", platform_subtype);
ASSERT(0);
};
switch(platform)
{
case MSM8610:
case MSM8110:
case MSM8210:
case MSM8810:
case MSM8612:
case MSM8212:
case MSM8812:
board->baseband = BASEBAND_MSM;
break;
default:
dprintf(CRITICAL, "Platform type: %u is not supported\n", platform);
ASSERT(0);
};
}
unsigned target_baseband()
{
return board_baseband();
}
void target_serialno(unsigned char *buf)
{
uint32_t serialno;
if (target_is_emmc_boot()) {
serialno = mmc_get_psn();
snprintf((char *)buf, 13, "%x", serialno);
}
}
unsigned 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 reboot_device(unsigned reboot_reason)
{
writel(reboot_reason, RESTART_REASON_ADDR);
/* Configure PMIC for warm reset */
pm8x41_reset_configure(PON_PSHOLD_WARM_RESET);
/* Drop PS_HOLD for MSM */
writel(0x00, MPM2_MPM_PS_HOLD);
mdelay(5000);
dprintf(CRITICAL, "Rebooting failed\n");
}
unsigned target_pause_for_battery_charge(void)
{
uint8_t pon_reason = pm8x41_get_pon_reason();
/* This function will always return 0 to facilitate
* automated testing/reboot with usb connected.
* uncomment if this feature is needed.
*/
/* if ((pon_reason == USB_CHG) || (pon_reason == DC_CHG))
* return 1;
*/
return 0;
}
void target_usb_stop(void)
{
/* Disable VBUS mimicing in the controller. */
ulpi_write(ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT, ULPI_MISC_A_CLEAR);
}
void target_usb_init(void)
{
uint32_t val;
/* Select and enable external configuration with USB PHY */
ulpi_write(ULPI_MISC_A_VBUSVLDEXTSEL | ULPI_MISC_A_VBUSVLDEXT, ULPI_MISC_A_SET);
/* Enable sess_vld */
val = readl(USB_GENCONFIG_2) | GEN2_SESS_VLD_CTRL_EN;
writel(val, USB_GENCONFIG_2);
/* Enable external vbus configuration in the LINK */
val = readl(USB_USBCMD);
val |= SESS_VLD_CTRL;
writel(val, USB_USBCMD);
}
unsigned board_machtype(void)
{
return 0;
}
/*
* Function to set the capabilities for the host
*/
void target_mmc_caps(struct mmc_host *host)
{
host->caps.ddr_mode = 0;
host->caps.hs200_mode = 0;
host->caps.bus_width = MMC_BOOT_BUS_WIDTH_8_BIT;
host->caps.hs_clk_rate = MMC_CLK_50MHZ;
}
@@ -0,0 +1,86 @@
/* Copyright (c) 2013, The Linux Foundation. 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 The Linux Foundation 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 <malloc.h>
#include <smem.h>
#include <stdint.h>
#include <libfdt.h>
#include <platform/iomap.h>
#include <dev_tree.h>
/* Funtion to add the ram partition entries into device tree.
* The function assumes that all the entire fixed memory regions should
* be listed in the first bank of the passed in ddr regions.
*/
uint32_t target_dev_tree_mem(void *fdt, uint32_t memory_node_offset)
{
struct smem_ram_ptable ram_ptable;
uint32_t i;
int ret = 0;
/* Make sure RAM partition table is initialized */
ASSERT(smem_ram_ptable_init(&ram_ptable));
/* Calculating the size of the mem_info_ptr */
for (i = 0 ; i < ram_ptable.len; i++)
{
if((ram_ptable.parts[i].category == SDRAM) &&
(ram_ptable.parts[i].type == SYS_MEMORY))
{
/* Pass along all other usable memory regions to Linux */
ret = dev_tree_add_mem_info(fdt,
memory_node_offset,
ram_ptable.parts[i].start,
ram_ptable.parts[i].size);
if (ret)
{
dprintf(CRITICAL, "Failed to add secondary banks memory addresses\n");
goto target_dev_tree_mem_err;
}
}
}
target_dev_tree_mem_err:
return ret;
}
void *target_get_scratch_address(void)
{
return ((void *)SCRATCH_ADDR);
}
unsigned target_get_max_flash_size(void)
{
return (288 * 1024 * 1024);
}
@@ -0,0 +1,35 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared
PLATFORM := msm8610
MEMBASE := 0x07A00000 # SDRAM
MEMSIZE := 0x00100000 # 1MB
BASE_ADDR := 0x00000
TAGS_ADDR := BASE_ADDR+0x00000100
KERNEL_ADDR := BASE_ADDR+0x00008000
RAMDISK_ADDR := BASE_ADDR+0x01000000
SCRATCH_ADDR := 0x0E000000
MODULES += \
dev/keys \
lib/ptable \
dev/pmic/pm8x41 \
lib/libfdt
DEFINES += \
MEMSIZE=$(MEMSIZE) \
MEMBASE=$(MEMBASE) \
BASE_ADDR=$(BASE_ADDR) \
TAGS_ADDR=$(TAGS_ADDR) \
KERNEL_ADDR=$(KERNEL_ADDR) \
RAMDISK_ADDR=$(RAMDISK_ADDR) \
SCRATCH_ADDR=$(SCRATCH_ADDR)
OBJS += \
$(LOCAL_DIR)/init.o \
$(LOCAL_DIR)/meminfo.o
@@ -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)
$(BUILDDIR)/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)
$(BUILDDIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboothd.mbn
mkheader: $(SRC_DIR)/mkheader.c
@mkdir -p $(BUILDDIR)
${COMPILER} -DMEMBASE=$(MEMBASE) $(SRC_DIR)/mkheader.c -o $(BUILDDIR)/mkheader
@@ -0,0 +1,343 @@
/*
* Copyright (c) 2007, Google Inc.
* All rights reserved.
*
* Copyright (c) 2009-2011, The Linux Foundation. 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 The Linux Foundation 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 <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;
}
@@ -0,0 +1,97 @@
/* Copyright (c) 2009-2010, The Linux Foundation. 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 The Linux Foundation 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 <smem.h>
#define SIZE_44M 0x02C00000 // 44M
#define EBI1_ADDR_1026M 0x40200000
#define SIZE_128M 0x08000000 // 128M
#define EBI1_ADDR_1152M 0x48000000
#define SIZE_256M 0x10000000 // 256M
#define EBI1_ADDR_1280M 0x50000000
#define SIZE_768M 0x30000000 // 256M + 512M
#define SIZE_1792M 0x70000000 // 256M + 512M + 1G
#define EBI1_CS1_ADDR_BASE 0x00A40024
unsigned *target_atag_mem(unsigned *ptr)
{
unsigned value = 0;
/* ATAG_MEM */
*ptr++ = 4;
*ptr++ = 0x54410002;
*ptr++ = SIZE_44M;
*ptr++ = EBI1_ADDR_1026M;
*ptr++ = 4;
*ptr++ = 0x54410002;
*ptr++ = SIZE_128M;
*ptr++ = EBI1_ADDR_1152M;
value = readl(EBI1_CS1_ADDR_BASE);
value = (value >> 8) & 0xFF;
if (value == 0x50) {
/* For 512MB RAM */
*ptr++ = 4;
*ptr++ = 0x54410002;
*ptr++ = SIZE_256M;
*ptr++ = EBI1_ADDR_1280M;
} else if (value == 0x60) {
/* For 1GB RAM */
*ptr++ = 4;
*ptr++ = 0x54410002;
*ptr++ = SIZE_768M;
*ptr++ = EBI1_ADDR_1280M;
} else if (value == 0x80) {
/* For 2GB RAM */
*ptr++ = 4;
*ptr++ = 0x54410002;
//*ptr++ = SIZE_1792M;
*ptr++ = SIZE_768M;
*ptr++ = EBI1_ADDR_1280M;
}
return ptr;
}
void *target_get_scratch_address(void)
{
return ((void *)SCRATCH_ADDR);
}
unsigned target_get_max_flash_size(void)
{
return (384 * 1024 * 1024);
}
@@ -0,0 +1,71 @@
/* Copyright (c) 2010, The Linux Foundation. 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 The Linux Foundation 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_QSD8660_SURF_DISPLAY_H
#define _TARGET_QSD8660_SURF_DISPLAY_H
#define MIPI_FB_ADDR 0x43E00000
#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
/* HDMI Panel Macros for 1080p */
#define DTV_FB_HEIGHT 1080
#define DTV_FB_WIDTH 1920
#define DTV_FORMAT_RGB565 0
#define DTV_BPP 16
#endif
@@ -0,0 +1,552 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009-2012, The Linux Foundation. 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 <dev/keys.h>
#include <dev/ssbi.h>
#include <dev/gpio.h>
#include <lib/ptable.h>
#include <dev/flash.h>
#include <smem.h>
#include <mmc.h>
#include <platform/timer.h>
#include <platform/iomap.h>
#include <platform/gpio.h>
#include <baseband.h>
#include <reg.h>
#include <platform.h>
#include <gsbi.h>
#include <platform/scm-io.h>
#include <platform/machtype.h>
#include <crypto_hash.h>
static const uint8_t uart_gsbi_id = GSBI_ID_12;
/* Setting this variable to different values defines the
* behavior of CE engine:
* platform_ce_type = CRYPTO_ENGINE_TYPE_NONE : No CE engine
* platform_ce_type = CRYPTO_ENGINE_TYPE_SW : Software CE engine
* platform_ce_type = CRYPTO_ENGINE_TYPE_HW : Hardware CE engine
* Behavior is determined in the target code.
*/
static crypto_engine_type platform_ce_type = CRYPTO_ENGINE_TYPE_SW;
void keypad_init(void);
extern void dmb(void);
int target_is_emmc_boot(void);
void debug_led_write(char);
char debug_led_read();
uint32_t platform_id_read(void);
void setup_fpga(void);
int pm8901_reset_pwr_off(int reset);
int pm8058_reset_pwr_off(int reset);
int pm8058_rtc0_alarm_irq_disable(void);
static void target_shutdown_for_rtc_alarm(void);
void target_init(void)
{
target_shutdown_for_rtc_alarm();
dprintf(INFO, "target_init()\n");
setup_fpga();
/* Setting Debug LEDs ON */
debug_led_write(0xFF);
#if (!ENABLE_NANDWRITE)
keys_init();
keypad_init();
#endif
/* Display splash screen if enabled */
#if DISPLAY_SPLASH_SCREEN
display_init();
dprintf(SPEW, "Diplay initialized\n");
display_image_on_screen();
#endif
if (mmc_boot_main(MMC_SLOT, MSM_SDC1_BASE)) {
dprintf(CRITICAL, "mmc init failed!");
ASSERT(0);
}
}
unsigned board_machtype(void)
{
struct smem_board_info_v5 board_info_v5;
struct smem_board_info_v6 board_info_v6;
unsigned int board_info_len = 0;
unsigned smem_status = 0;
unsigned format = 0;
unsigned id = 0;
unsigned hw_platform = 0;
unsigned fused_chip = 0;
unsigned platform_subtype = 0;
static unsigned mach_id = 0xFFFFFFFF;
if (mach_id != 0xFFFFFFFF)
return mach_id;
/* Detect external msm if this is a "fusion" */
smem_status = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION,
&format, sizeof(format), 0);
if (!smem_status) {
if (format == 5) {
board_info_len = sizeof(board_info_v5);
smem_status =
smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
&board_info_v5,
board_info_len);
if (!smem_status) {
fused_chip = board_info_v5.fused_chip;
id = board_info_v5.board_info_v3.hw_platform;
}
} else 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) {
fused_chip = board_info_v6.fused_chip;
id = board_info_v6.board_info_v3.hw_platform;
platform_subtype =
board_info_v6.platform_subtype;
}
}
}
/* Detect SURF v/s FFA v/s Fluid */
switch (id) {
case 0x1:
hw_platform = HW_PLATFORM_SURF;
break;
case 0x2:
hw_platform = HW_PLATFORM_FFA;
break;
case 0x3:
hw_platform = HW_PLATFORM_FLUID;
break;
case 0x6:
hw_platform = HW_PLATFORM_QT;
break;
case 0xA:
hw_platform = HW_PLATFORM_DRAGON;
break;
default:
/* Writing to Debug LED register and reading back to auto detect
SURF and FFA. If we read back, it is SURF */
debug_led_write(0xA5);
if ((debug_led_read() & 0xFF) == 0xA5) {
debug_led_write(0);
hw_platform = HW_PLATFORM_SURF;
} else
hw_platform = HW_PLATFORM_FFA;
};
/* Use platform_subtype or fused_chip information to determine machine id */
if (format >= 6) {
switch (platform_subtype) {
case HW_PLATFORM_SUBTYPE_CSFB:
case HW_PLATFORM_SUBTYPE_SVLTE2A:
if (hw_platform == HW_PLATFORM_SURF)
mach_id = LINUX_MACHTYPE_8660_CHARM_SURF;
else if (hw_platform == HW_PLATFORM_FFA)
mach_id = LINUX_MACHTYPE_8660_CHARM_FFA;
break;
default:
if (hw_platform == HW_PLATFORM_SURF)
mach_id = LINUX_MACHTYPE_8660_SURF;
else if (hw_platform == HW_PLATFORM_FFA)
mach_id = LINUX_MACHTYPE_8660_FFA;
else if (hw_platform == HW_PLATFORM_FLUID)
mach_id = LINUX_MACHTYPE_8660_FLUID;
else if (hw_platform == HW_PLATFORM_QT)
mach_id = LINUX_MACHTYPE_8660_QT;
else if (hw_platform == HW_PLATFORM_DRAGON)
mach_id = LINUX_MACHTYPE_8x60_DRAGON;
}
} else if (format == 5) {
switch (fused_chip) {
case UNKNOWN:
if (hw_platform == HW_PLATFORM_SURF)
mach_id = LINUX_MACHTYPE_8660_SURF;
else if (hw_platform == HW_PLATFORM_FFA)
mach_id = LINUX_MACHTYPE_8660_FFA;
else if (hw_platform == HW_PLATFORM_FLUID)
mach_id = LINUX_MACHTYPE_8660_FLUID;
else if (hw_platform == HW_PLATFORM_QT)
mach_id = LINUX_MACHTYPE_8660_QT;
else if (hw_platform == HW_PLATFORM_DRAGON)
mach_id = LINUX_MACHTYPE_8x60_DRAGON;
break;
case MDM9200:
case MDM9600:
if (hw_platform == HW_PLATFORM_SURF)
mach_id = LINUX_MACHTYPE_8660_CHARM_SURF;
else if (hw_platform == HW_PLATFORM_FFA)
mach_id = LINUX_MACHTYPE_8660_CHARM_FFA;
break;
default:
mach_id = LINUX_MACHTYPE_8660_FFA;
}
}
return mach_id;
}
void shutdown_device()
{
gpio_config_pshold();
pm8058_reset_pwr_off(0);
pm8901_reset_pwr_off(0);
writel(0, MSM_PSHOLD_CTL_SU);
mdelay(10000);
dprintf(CRITICAL, "Shutdown failed\n");
}
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 */
secure_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 = (void *)0x2A05F65C;
/* 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)
{
}
void setup_fpga()
{
writel(0x147, GPIO_CFG133_ADDR);
writel(0x144, GPIO_CFG135_ADDR);
writel(0x144, GPIO_CFG136_ADDR);
writel(0x144, GPIO_CFG137_ADDR);
writel(0x144, GPIO_CFG138_ADDR);
writel(0x144, GPIO_CFG139_ADDR);
writel(0x144, GPIO_CFG140_ADDR);
writel(0x144, GPIO_CFG141_ADDR);
writel(0x144, GPIO_CFG142_ADDR);
writel(0x144, GPIO_CFG143_ADDR);
writel(0x144, GPIO_CFG144_ADDR);
writel(0x144, GPIO_CFG145_ADDR);
writel(0x144, GPIO_CFG146_ADDR);
writel(0x144, GPIO_CFG147_ADDR);
writel(0x144, GPIO_CFG148_ADDR);
writel(0x144, GPIO_CFG149_ADDR);
writel(0x144, GPIO_CFG150_ADDR);
writel(0x147, GPIO_CFG151_ADDR);
writel(0x147, GPIO_CFG152_ADDR);
writel(0x147, GPIO_CFG153_ADDR);
writel(0x3, GPIO_CFG154_ADDR);
writel(0x147, GPIO_CFG155_ADDR);
writel(0x147, GPIO_CFG156_ADDR);
writel(0x147, GPIO_CFG157_ADDR);
writel(0x3, GPIO_CFG158_ADDR);
writel(0x00000B31, EBI2_CHIP_SELECT_CFG0);
writel(0xA3030020, EBI2_XMEM_CS3_CFG1);
}
void debug_led_write(char val)
{
writeb(val, SURF_DEBUG_LED_ADDR);
}
char debug_led_read()
{
return readb(SURF_DEBUG_LED_ADDR);
}
unsigned target_baseband()
{
struct smem_board_info_v5 board_info_v5;
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 == 5) {
board_info_len = sizeof(board_info_v5);
smem_status =
smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
&board_info_v5,
board_info_len);
if (!smem_status) {
/* Check for LTE fused targets or APQ. Default to MSM */
if (board_info_v5.fused_chip == MDM9200)
baseband = BASEBAND_CSFB;
else if (board_info_v5.fused_chip == MDM9600)
baseband = BASEBAND_SVLTE2A;
else if (board_info_v5.board_info_v3.msm_id ==
APQ8060)
baseband = BASEBAND_APQ;
else
baseband = BASEBAND_MSM;
}
} else 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 targets or APQ. Default to MSM */
if (board_info_v6.platform_subtype ==
HW_PLATFORM_SUBTYPE_CSFB)
baseband = BASEBAND_CSFB;
else if (board_info_v6.platform_subtype ==
HW_PLATFORM_SUBTYPE_SVLTE2A)
baseband = BASEBAND_SVLTE2A;
else if (board_info_v6.board_info_v3.msm_id ==
APQ8060)
baseband = BASEBAND_APQ;
else
baseband = BASEBAND_MSM;
}
}
}
return baseband;
}
crypto_engine_type board_ce_type(void)
{
struct smem_board_info_v5 board_info_v5;
struct smem_board_info_v6 board_info_v6;
unsigned int board_info_len = 0;
unsigned smem_status = 0;
unsigned format = 0;
smem_status = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION,
&format, sizeof(format), 0);
if (!smem_status) {
if (format == 5) {
board_info_len = sizeof(board_info_v5);
smem_status = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
&board_info_v5,
board_info_len);
if (!smem_status) {
if ((board_info_v5.board_info_v3.msm_id == APQ8060) ||
(board_info_v5.board_info_v3.msm_id == MSM8660) ||
(board_info_v5.board_info_v3.msm_id == MSM8260))
platform_ce_type = CRYPTO_ENGINE_TYPE_HW;
}
} else 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) {
if ((board_info_v6.board_info_v3.msm_id == APQ8060) ||
(board_info_v6.board_info_v3.msm_id == MSM8660) ||
(board_info_v6.board_info_v3.msm_id == MSM8260))
platform_ce_type = CRYPTO_ENGINE_TYPE_HW;
}
}
}
return platform_ce_type;
}
static unsigned target_check_power_on_reason(void)
{
unsigned power_on_status = 0;
unsigned int status_len = sizeof(power_on_status);
unsigned smem_status;
smem_status = smem_read_alloc_entry(SMEM_POWER_ON_STATUS_INFO,
&power_on_status, status_len);
if (smem_status) {
dprintf(CRITICAL,
"ERROR: unable to read shared memory for power on reason\n");
}
dprintf(INFO, "Power on reason %u\n", power_on_status);
return power_on_status;
}
static void target_shutdown_for_rtc_alarm(void)
{
if (target_check_power_on_reason() == PWR_ON_EVENT_RTC_ALARM) {
dprintf(CRITICAL,
"Power on due to RTC alarm. Going to shutdown!!\n");
pm8058_rtc0_alarm_irq_disable();
shutdown_device();
}
}
unsigned target_pause_for_battery_charge(void)
{
if (target_check_power_on_reason() == PWR_ON_EVENT_WALL_CHG)
return 1;
return 0;
}
void target_serialno(unsigned char *buf)
{
unsigned int serialno;
if (target_is_emmc_boot()) {
serialno = mmc_get_psn();
snprintf((char *)buf, 13, "%x", serialno);
}
}
void hsusb_gpio_init(void)
{
uint32_t func;
uint32_t pull;
uint32_t dir;
uint32_t enable;
uint32_t drv;
/* GPIO 131 and 132 need to be configured for connecting to USB HS PHY */
func = 0;
enable = 1;
pull = GPIO_NO_PULL;
dir = 2;
drv = GPIO_2MA;
gpio_tlmm_config(131, func, dir, pull, drv, enable);
gpio_set(131, dir);
func = 0;
enable = 1;
pull = GPIO_NO_PULL;
dir = 1;
drv = GPIO_2MA;
gpio_tlmm_config(132, func, dir, pull, drv, enable);
gpio_set(132, dir);
return;
}
#define USB_CLK 0x00902910
#define USB_PHY_CLK 0x00902E20
#define CLK_RESET_ASSERT 0x1
#define CLK_RESET_DEASSERT 0x0
#define CLK_RESET(x,y) writel((y), (x));
static int msm_otg_xceiv_reset()
{
CLK_RESET(USB_CLK, CLK_RESET_ASSERT);
CLK_RESET(USB_PHY_CLK, CLK_RESET_ASSERT);
mdelay(20);
CLK_RESET(USB_PHY_CLK, CLK_RESET_DEASSERT);
CLK_RESET(USB_CLK, CLK_RESET_DEASSERT);
mdelay(20);
return 0;
}
static void target_ulpi_init(void)
{
unsigned int reg;
reg = ulpi_read(0x32);
dprintf(INFO, " Value of ulpi read 0x32 is %08x\n", reg);
ulpi_write(0x30, 0x32);
reg = ulpi_read(0x32);
dprintf(INFO, " Value of ulpi read 0x32 after write is %08x\n", reg);
reg = ulpi_read(0x36);
dprintf(INFO, " Value of ulpi read 0x36 is %08x\n", reg);
ulpi_write(reg | 0x2, 0x36);
reg = ulpi_read(0x36);
dprintf(INFO, " Value of ulpi read 0x36 aafter write is %08x\n", reg);
}
/* Do target specific usb initialization */
void target_usb_init(void)
{
hsusb_gpio_init();
msm_otg_xceiv_reset();
target_ulpi_init();
}
void target_usb_stop(void)
{
int val;
/* Voting down PLL8 */
val = readl(0x009034C0);
val &= ~(1 << 8);
writel(val, 0x009034C0);
}
uint8_t target_uart_gsbi(void)
{
return uart_gsbi_id;
}
int emmc_recovery_init(void)
{
int rc;
rc = _emmc_recovery_init();
return rc;
}
@@ -0,0 +1,88 @@
/*
* Copyright (c) 2010-2011, The Linux Foundation. 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 The Linux Foundation 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/ssbi.h>
#include <dev/gpio_keypad.h>
#include <platform.h>
#define LINUX_MACHTYPE_8660_QT 3298
#define BITS_IN_ELEMENT(x) (sizeof(x)[0] * 8)
#define KEYMAP_INDEX(row, col) (row)* BITS_IN_ELEMENT(qwerty_keys_new) + (col)
static unsigned char qwerty_keys_old[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static unsigned char qwerty_keys_new[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static unsigned int qt_keymap[] = {
[KEYMAP_INDEX(0, 3)] = KEY_BACK, /* Volume down key */
[KEYMAP_INDEX(1, 3)] = KEY_HOME, /* Volume up key */
};
static struct qwerty_keypad_info qt_keypad = {
.keymap = qt_keymap,
.old_keys = qwerty_keys_old,
.rec_keys = qwerty_keys_new,
.rows = 3,
.columns = 1,
.num_of_reads = 3,
.rd_func = &pa1_ssbi2_read_bytes,
.wr_func = &pa1_ssbi2_write_bytes,
.settle_time = 32 /* msec */ ,
.poll_time = 10 /* msec */ ,
};
static unsigned int qwerty_keymap[] = {
[KEYMAP_INDEX(1, 3)] = KEY_BACK, /* Volume down key */
[KEYMAP_INDEX(0, 3)] = KEY_HOME, /* Volume up 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)
{
unsigned int mach_id;
mach_id = board_machtype();
if (mach_id == LINUX_MACHTYPE_8660_QT)
ssbi_keypad_init(&qt_keypad);
else
ssbi_keypad_init(&qwerty_keypad);
}
@@ -0,0 +1,45 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared
PLATFORM := msm8x60
MEMBASE := 0x40100000 # SMI
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 += MMC_BOOT_ADM=0
DEFINES += DISPLAY_TYPE_HDMI=0
DEFINES += ASYNC_RESET_CE=1
MODULES += \
dev/keys \
dev/ssbi \
lib/ptable
DEFINES += \
MEMSIZE=$(MEMSIZE) \
MEMBASE=$(MEMBASE) \
BASE_ADDR=$(BASE_ADDR) \
TAGS_ADDR=$(TAGS_ADDR) \
KERNEL_ADDR=$(KERNEL_ADDR) \
RAMDISK_ADDR=$(RAMDISK_ADDR) \
SCRATCH_ADDR=$(SCRATCH_ADDR)
OBJS += \
$(LOCAL_DIR)/init.o \
$(LOCAL_DIR)/atags.o \
$(LOCAL_DIR)/keypad.o
@@ -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)
$(BUILDDIR)/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)
$(BUILDDIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboothd.mbn
mkheader: $(SRC_DIR)/mkheader.c
@mkdir -p $(BUILDDIR)
${COMPILER} -DMEMBASE=$(MEMBASE) $(SRC_DIR)/mkheader.c -o $(BUILDDIR)/mkheader
@@ -0,0 +1,332 @@
/*
* Copyright (c) 2007, Google Inc.
* All rights reserved.
*
* Copyright (c) 2009-2010, The Linux Foundation. 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;
}
+250
View File
@@ -0,0 +1,250 @@
/* Copyright (c) 2009-2013, The Linux Foundation. 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 Linux Foundation 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 <smem.h>
#include <stdint.h>
#include "board.h"
#include "baseband.h"
#define SIZE_1M (1024 * 1024)
#define SIZE_2M (2 * SIZE_1M)
#define SIZE_256M (256 * SIZE_1M)
#define SIZE_512M (512 * SIZE_1M)
#define SIZE_768M (768 * SIZE_1M)
#define ATAG_MEM 0x54410002
#define PHYS_MEM_START_ADDR 0x80000000
typedef struct {
uint32_t size;
uint32_t start_addr;
}atag_mem_info;
atag_mem_info apq8064_standalone_first_256M[] = {
{ .size = (140 * SIZE_1M),
.start_addr = PHYS_MEM_START_ADDR + SIZE_2M
},
{ .size = (58 * SIZE_1M),
.start_addr = PHYS_MEM_START_ADDR + (0xA0 * SIZE_1M)
},
{ .size = (4 * SIZE_1M),
.start_addr = PHYS_MEM_START_ADDR + (0xEC * SIZE_1M)
},
{ .size = (7 * SIZE_1M),
.start_addr = PHYS_MEM_START_ADDR + (0xF7 * SIZE_1M)
}
};
atag_mem_info apq8064_fusion_first_256M[] = {
{ .size = (140 * SIZE_1M),
.start_addr = PHYS_MEM_START_ADDR + SIZE_2M
},
{ .size = (74 * SIZE_1M),
.start_addr = PHYS_MEM_START_ADDR + (0x90 * SIZE_1M)
},
{ .size = (7 * SIZE_1M),
.start_addr = PHYS_MEM_START_ADDR + (0xF7 * SIZE_1M)
},
{ .size = (4 * SIZE_1M),
.start_addr = PHYS_MEM_START_ADDR + (0xEC * SIZE_1M)
},
{ .size = SIZE_1M,
.start_addr = PHYS_MEM_START_ADDR + (0xFF * SIZE_1M)
}
};
atag_mem_info mpq8064_first_256M[] = {
{ .size = (140 * SIZE_1M),
.start_addr = PHYS_MEM_START_ADDR + SIZE_2M
},
{ .size = (74 * SIZE_1M),
.start_addr = PHYS_MEM_START_ADDR + (0x90 * SIZE_1M)
},
{ .size = (20 * SIZE_1M),
.start_addr = PHYS_MEM_START_ADDR + (0xEC * SIZE_1M)
}
};
atag_mem_info msm8960_default_first_256M[] = {
{ .size = (140 * SIZE_1M),
.start_addr = PHYS_MEM_START_ADDR + SIZE_2M
}
};
atag_mem_info msm8930_default_first_256M[] = {
{ .size = (140 * SIZE_1M),
.start_addr = PHYS_MEM_START_ADDR + SIZE_2M
},
{ .size = (4 * SIZE_1M),
.start_addr = PHYS_MEM_START_ADDR + (0xEC * SIZE_1M)
},
{ .size = (3 * SIZE_1M),
.start_addr = PHYS_MEM_START_ADDR + (0xF8 * SIZE_1M)
},
{ .size = (1 * SIZE_1M),
.start_addr = PHYS_MEM_START_ADDR + (0xFE * SIZE_1M)
}
};
unsigned *target_mem_atag_create(unsigned *ptr, uint32_t size, uint32_t addr)
{
*ptr++ = 4;
*ptr++ = ATAG_MEM;
*ptr++ = size;
*ptr++ = addr;
return ptr;
}
unsigned *target_atag(unsigned *ptr, atag_mem_info usable_mem_map[], unsigned num_regions)
{
unsigned i;
dprintf(SPEW, "Number of regions for HLOS in 1st 256MB = %u\n", num_regions);
for (i=0; i < num_regions; i++)
{
ptr = target_mem_atag_create(ptr,
usable_mem_map[i].size,
usable_mem_map[i].start_addr);
}
return ptr;
}
unsigned *target_first_256M_atag(unsigned *ptr)
{
unsigned int platform_id = board_platform_id();
unsigned int baseband = board_baseband();
switch (platform_id) {
case APQ8064:
case APQ8064AA:
case APQ8064AB:
if(baseband == BASEBAND_MDM)
{
/* Use 8064 Fusion 3 memory map */
ptr = target_atag(ptr,
apq8064_fusion_first_256M,
ARRAY_SIZE(apq8064_fusion_first_256M));
} else {
/* Use 8064 standalone memory map */
ptr = target_atag(ptr,
apq8064_standalone_first_256M,
ARRAY_SIZE(apq8064_standalone_first_256M));
}
break;
case MPQ8064:
ptr = target_atag(ptr, mpq8064_first_256M, ARRAY_SIZE(mpq8064_first_256M));
break;
case MSM8130:
case MSM8230:
case MSM8930:
case MSM8630:
case MSM8130AA:
case MSM8230AA:
case MSM8630AA:
case MSM8930AA:
case MSM8930AB:
case MSM8630AB:
case MSM8230AB:
case MSM8130AB:
case APQ8030AB:
case APQ8030:
case APQ8030AA:
ptr = target_atag(ptr, msm8930_default_first_256M,
ARRAY_SIZE(msm8930_default_first_256M));
break;
case MSM8960: /* fall through */
case MSM8960AB:
case APQ8060AB:
case MSM8260AB:
case MSM8660AB:
default:
ptr = target_atag(ptr,
msm8960_default_first_256M,
ARRAY_SIZE(msm8960_default_first_256M));
break;
}
return ptr;
}
unsigned *target_atag_mem(unsigned *ptr)
{
struct smem_ram_ptable ram_ptable;
uint8_t i = 0;
if (smem_ram_ptable_init(&ram_ptable))
{
for (i = 0; i < ram_ptable.len; i++)
{
if (ram_ptable.parts[i].category == SDRAM &&
(ram_ptable.parts[i].type == SYS_MEMORY) &&
(ram_ptable.parts[i].start == PHYS_MEM_START_ADDR))
{
ASSERT(ram_ptable.parts[i].size >= SIZE_256M);
ptr = target_first_256M_atag(ptr);
if (ram_ptable.parts[i].size > SIZE_256M)
{
ptr = target_mem_atag_create(ptr,
(ram_ptable.parts[i].size - SIZE_256M),
(ram_ptable.parts[i].start + SIZE_256M));
}
}
/* Pass along all other usable memory regions to Linux */
if (ram_ptable.parts[i].category == SDRAM &&
(ram_ptable.parts[i].type == SYS_MEMORY) &&
(ram_ptable.parts[i].start != PHYS_MEM_START_ADDR))
{
ptr = target_mem_atag_create(ptr,
ram_ptable.parts[i].size,
ram_ptable.parts[i].start);
}
}
} else {
dprintf(CRITICAL, "ERROR: Unable to read RAM partition\n");
ASSERT(0);
}
return ptr;
}
void *target_get_scratch_address(void)
{
return ((void *) SCRATCH_ADDR);
}
unsigned target_get_max_flash_size(void)
{
return (SIZE_768M);
}
@@ -0,0 +1,66 @@
/* Copyright (c) 2012-2013, The Linux Foundation. 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 Linux Foundation 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_BOARD_H
#define __TARGET_BOARD_H
/* 8960 */
#define LINUX_MACHTYPE_8960_SIM 3230
#define LINUX_MACHTYPE_8960_RUMI3 3231
#define LINUX_MACHTYPE_8960_CDP 3396
#define LINUX_MACHTYPE_8960_MTP 3397
#define LINUX_MACHTYPE_8960_FLUID 3398
#define LINUX_MACHTYPE_8960_APQ 3399
#define LINUX_MACHTYPE_8960_LIQUID 3535
/* 8627 */
#define LINUX_MACHTYPE_8627_CDP 3861
#define LINUX_MACHTYPE_8627_MTP 3862
/* 8930 */
#define LINUX_MACHTYPE_8930_CDP 3727
#define LINUX_MACHTYPE_8930_MTP 3728
#define LINUX_MACHTYPE_8930_FLUID 3729
#define LINUX_MACHTYPE_8930_EVT 4558
/* 8064 */
#define LINUX_MACHTYPE_8064_SIM 3572
#define LINUX_MACHTYPE_8064_RUMI3 3679
#define LINUX_MACHTYPE_8064_CDP 3948
#define LINUX_MACHTYPE_8064_MTP 3949
#define LINUX_MACHTYPE_8064_LIQUID 3951
#define LINUX_MACHTYPE_8064_MPQ_CDP 3993
#define LINUX_MACHTYPE_8064_MPQ_HRD 3994
#define LINUX_MACHTYPE_8064_MPQ_DTV 3995
#define LINUX_MACHTYPE_8064_EP 3996
#define LINUX_MACHTYPE_8064_MPQ_DMA 4511
#endif
@@ -0,0 +1,52 @@
/* Copyright (c) 2010-2011, The Linux Foundation. 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 The Linux Foundation 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 MIPI_FB_ADDR 0x89000000
/* Toshiba MDT61 Mipi Panel */
/* Unique to this panel, display width is 800, image is 600 */
#define TSH_MDT61_DISPLAY_WIDTH 800
#define TSH_MDT61_MIPI_FB_WIDTH (TSH_MDT61_DISPLAY_WIDTH - 200)
#define TSH_MDT61_MIPI_FB_HEIGHT 1024
#define MIPI_HSYNC_PULSE_WIDTH 8
#define MIPI_HSYNC_BACK_PORCH_DCLK 16
#define MIPI_HSYNC_FRONT_PORCH_DCLK 23
#define MIPI_VSYNC_PULSE_WIDTH 2
#define MIPI_VSYNC_BACK_PORCH_LINES 2
#define MIPI_VSYNC_FRONT_PORCH_LINES 7
extern int mipi_dsi_phy_init(struct mipi_dsi_panel_config *);
extern void mdp_setup_mdt61_video_dsi_config(void);
extern void config_mdt61_dsi_video_mode(void);
#endif
+525
View File
@@ -0,0 +1,525 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009-2013, The Linux Foundation. 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 <mmc.h>
#include <platform/timer.h>
#include <platform/gpio.h>
#include <reg.h>
#include <dev/keys.h>
#include <dev/pm8921.h>
#include <dev/ssbi.h>
#include <gsbi.h>
#include <target.h>
#include <platform.h>
#include <baseband.h>
#include <uart_dm.h>
#include <crypto_hash.h>
#include <board.h>
#include <target/board.h>
extern void dmb(void);
extern void msm8960_keypad_init(void);
extern void msm8930_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 pm8921_dev_t pmic;
/* Setting this variable to different values defines the
* behavior of CE engine:
* platform_ce_type = CRYPTO_ENGINE_TYPE_NONE : No CE engine
* platform_ce_type = CRYPTO_ENGINE_TYPE_SW : Software CE engine
* platform_ce_type = CRYPTO_ENGINE_TYPE_HW : Hardware CE engine
* Behavior is determined in the target code.
*/
static crypto_engine_type platform_ce_type = CRYPTO_ENGINE_TYPE_SW;
static void target_uart_init(void);
void target_early_init(void)
{
#if WITH_DEBUG_UART
target_uart_init();
#endif
}
void shutdown_device(void)
{
dprintf(CRITICAL, "Shutdown system.\n");
pm8921_config_reset_pwr_off(0);
/* Actually reset the chip */
writel(0, MSM_PSHOLD_CTL_SU);
mdelay(5000);
dprintf(CRITICAL, "Shutdown failed.\n");
}
void target_init(void)
{
unsigned base_addr;
unsigned char slot;
unsigned platform_id = board_platform_id();
dprintf(INFO, "target_init()\n");
/* Initialize PMIC driver */
pmic.read = (pm8921_read_func) & pa1_ssbi2_read_bytes;
pmic.write = (pm8921_write_func) & pa1_ssbi2_write_bytes;
pm8921_init(&pmic);
/* Keypad init */
keys_init();
switch(platform_id) {
case MSM8960:
case MSM8960AB:
case APQ8060AB:
case MSM8260AB:
case MSM8660AB:
msm8960_keypad_init();
break;
case MSM8130:
case MSM8230:
case MSM8630:
case MSM8930:
case MSM8130AA:
case MSM8230AA:
case MSM8630AA:
case MSM8930AA:
case MSM8930AB:
case MSM8630AB:
case MSM8230AB:
case MSM8130AB:
case APQ8030AB:
case APQ8030:
case APQ8030AA:
msm8930_keypad_init();
break;
case APQ8064:
case MPQ8064:
case APQ8064AA:
case APQ8064AB:
apq8064_keypad_init();
break;
default:
dprintf(CRITICAL,"Keyboard is not supported for platform: %d\n",platform_id);
};
/* Display splash screen if enabled */
#if DISPLAY_SPLASH_SCREEN
display_init();
dprintf(SPEW, "Diplay initialized\n");
#endif
if ((platform_id == MSM8960) || (platform_id == MSM8960AB) ||
(platform_id == APQ8060AB) || (platform_id == MSM8260AB) ||
(platform_id == MSM8660AB) || (platform_id == MSM8660A) ||
(platform_id == MSM8260A) || (platform_id == APQ8060A) ||
(platform_id == APQ8064) || (platform_id == APQ8064AA) ||
(platform_id == APQ8064AB))
/* Enable Hardware CE */
platform_ce_type = CRYPTO_ENGINE_TYPE_HW;
/* 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);
}
}
}
unsigned board_machtype(void)
{
return board_target_id();
}
crypto_engine_type board_ce_type(void)
{
return platform_ce_type;
}
unsigned target_baseband()
{
return board_baseband();
}
static unsigned target_check_power_on_reason(void)
{
unsigned power_on_status = 0;
unsigned int status_len = sizeof(power_on_status);
unsigned smem_status;
smem_status = smem_read_alloc_entry(SMEM_POWER_ON_STATUS_INFO,
&power_on_status, status_len);
if (smem_status) {
dprintf(CRITICAL,
"ERROR: unable to read shared memory for power on reason\n");
}
dprintf(INFO, "Power on reason %u\n", power_on_status);
return power_on_status;
}
void reboot_device(unsigned reboot_reason)
{
writel(reboot_reason, RESTART_REASON_ADDR);
/* Actually reset the chip */
pm8921_config_reset_pwr_off(1);
writel(0, MSM_PSHOLD_CTL_SU);
mdelay(10000);
dprintf(CRITICAL, "PSHOLD failed, trying watchdog reset\n");
writel(1, MSM_WDT0_RST);
writel(0, MSM_WDT0_EN);
writel(0x31F3, MSM_WDT0_BT);
writel(3, MSM_WDT0_EN);
dmb();
writel(3, MSM_TCSR_BASE + TCSR_WDOG_CFG);
mdelay(10000);
dprintf(CRITICAL, "Rebooting failed\n");
}
unsigned check_reboot_mode(void)
{
unsigned restart_reason = 0;
/* Read reboot reason and scrub it */
restart_reason = readl(RESTART_REASON_ADDR);
writel(0x00, RESTART_REASON_ADDR);
return restart_reason;
}
unsigned target_pause_for_battery_charge(void)
{
if (target_check_power_on_reason() == PWR_ON_EVENT_WALL_CHG)
return 1;
return 0;
}
void target_serialno(unsigned char *buf)
{
unsigned int serialno;
if (target_is_emmc_boot()) {
serialno = mmc_get_psn();
snprintf((char *)buf, 13, "%x", serialno);
}
}
void target_battery_charging_enable(unsigned enable, unsigned disconnect)
{
}
/* 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();
}
void target_uart_init(void)
{
unsigned target_id = board_machtype();
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:
if(board_baseband() == BASEBAND_SGLTE || board_baseband() == BASEBAND_SGLTE2)
{
uart_dm_init(8, 0x1A000000, 0x1A040000);;
}
else
{
uart_dm_init(5, 0x16400000, 0x16440000);
}
break;
case LINUX_MACHTYPE_8930_CDP:
case LINUX_MACHTYPE_8930_MTP:
case LINUX_MACHTYPE_8930_FLUID:
uart_dm_init(5, 0x16400000, 0x16440000);
break;
case LINUX_MACHTYPE_8064_SIM:
case LINUX_MACHTYPE_8064_RUMI3:
uart_dm_init(3, 0x16200000, 0x16240000);
break;
case LINUX_MACHTYPE_8064_CDP:
case LINUX_MACHTYPE_8064_MTP:
case LINUX_MACHTYPE_8064_LIQUID:
uart_dm_init(7, 0x16600000, 0x16640000);
break;
case LINUX_MACHTYPE_8064_EP:
uart_dm_init(2, 0x12480000, 0x12490000);
break;
case LINUX_MACHTYPE_8064_MPQ_CDP:
case LINUX_MACHTYPE_8064_MPQ_HRD:
case LINUX_MACHTYPE_8064_MPQ_DTV:
case LINUX_MACHTYPE_8064_MPQ_DMA:
uart_dm_init(5, 0x1A200000, 0x1A240000);
break;
case LINUX_MACHTYPE_8627_CDP:
case LINUX_MACHTYPE_8627_MTP:
uart_dm_init(5, 0x16400000, 0x16440000);
break;
default:
dprintf(CRITICAL, "uart gsbi not defined for target: %d\n",
target_id);
}
}
/* Detect the target type */
void target_detect(struct board_data *board)
{
uint32_t platform;
uint32_t platform_hw;
uint32_t target_id;
platform = board->platform;
platform_hw = board->platform_hw;
/* Detect the board we are running on */
if ((platform == MSM8960) || (platform == MSM8960AB) ||
(platform == APQ8060AB) || (platform == MSM8260AB) ||
(platform == MSM8660AB) ||(platform == MSM8660A) ||
(platform == MSM8260A) || (platform == APQ8060A)) {
switch (platform_hw) {
case HW_PLATFORM_SURF:
target_id = LINUX_MACHTYPE_8960_CDP;
break;
case HW_PLATFORM_MTP:
target_id = LINUX_MACHTYPE_8960_MTP;
break;
case HW_PLATFORM_FLUID:
target_id = LINUX_MACHTYPE_8960_FLUID;
break;
case HW_PLATFORM_LIQUID:
target_id = LINUX_MACHTYPE_8960_LIQUID;
break;
default:
target_id = LINUX_MACHTYPE_8960_CDP;
}
} else if ((platform == MSM8130) ||
(platform == MSM8130AA) || (platform == MSM8130AB) ||
(platform == MSM8230) || (platform == MSM8630) ||
(platform == MSM8930) || (platform == MSM8230AA) ||
(platform == MSM8630AA) || (platform == MSM8930AA) ||
(platform == MSM8930AB) || (platform == MSM8630AB) ||
(platform == MSM8230AB) || (platform == APQ8030AB) ||
(platform == APQ8030) || platform == APQ8030AA) {
switch (platform_hw) {
case HW_PLATFORM_SURF:
target_id = LINUX_MACHTYPE_8930_CDP;
break;
case HW_PLATFORM_MTP:
target_id = LINUX_MACHTYPE_8930_MTP;
break;
case HW_PLATFORM_FLUID:
target_id = LINUX_MACHTYPE_8930_FLUID;
break;
case HW_PLATFORM_QRD:
target_id = LINUX_MACHTYPE_8930_EVT;
break;
default:
target_id = LINUX_MACHTYPE_8930_CDP;
}
} else if ((platform == MSM8227) || (platform == MSM8627) ||
(platform == MSM8227AA) || (platform == MSM8627AA)) {
switch (platform_hw) {
case HW_PLATFORM_SURF:
target_id = LINUX_MACHTYPE_8627_CDP;
break;
case HW_PLATFORM_MTP:
target_id = LINUX_MACHTYPE_8627_MTP;
break;
default:
target_id = LINUX_MACHTYPE_8627_CDP;
}
} else if (platform == MPQ8064) {
switch (platform_hw) {
case HW_PLATFORM_SURF:
target_id = LINUX_MACHTYPE_8064_MPQ_CDP;
break;
case HW_PLATFORM_HRD:
target_id = LINUX_MACHTYPE_8064_MPQ_HRD;
break;
case HW_PLATFORM_DTV:
target_id = LINUX_MACHTYPE_8064_MPQ_DTV;
break;
case HW_PLATFORM_DMA:
target_id = LINUX_MACHTYPE_8064_MPQ_DMA;
break;
default:
target_id = LINUX_MACHTYPE_8064_MPQ_CDP;
}
} else if ((platform == APQ8064) || (platform == APQ8064AA)
|| (platform == APQ8064AB)) {
switch (platform_hw) {
case HW_PLATFORM_SURF:
target_id = LINUX_MACHTYPE_8064_CDP;
break;
case HW_PLATFORM_MTP:
target_id = LINUX_MACHTYPE_8064_MTP;
break;
case HW_PLATFORM_LIQUID:
target_id = LINUX_MACHTYPE_8064_LIQUID;
break;
case HW_PLATFORM_BTS:
target_id = LINUX_MACHTYPE_8064_EP;
break;
default:
target_id = LINUX_MACHTYPE_8064_CDP;
}
} else {
dprintf(CRITICAL, "platform (%d) is not identified.\n",
platform);
ASSERT(0);
}
board->target = target_id;
}
/* Detect the modem type */
void target_baseband_detect(struct board_data *board)
{
uint32_t baseband;
uint32_t platform;
uint32_t platform_subtype;
platform = board->platform;
platform_subtype = board->platform_subtype;
/* Check for baseband variants. Default to MSM */
if (platform_subtype == HW_PLATFORM_SUBTYPE_MDM)
baseband = BASEBAND_MDM;
else if (platform_subtype == HW_PLATFORM_SUBTYPE_SGLTE)
baseband = BASEBAND_SGLTE;
else if (platform_subtype == HW_PLATFORM_SUBTYPE_DSDA)
baseband = BASEBAND_DSDA;
else if (platform_subtype == HW_PLATFORM_SUBTYPE_DSDA2)
baseband = BASEBAND_DSDA2;
else if (platform_subtype == HW_PLATFORM_SUBTYPE_SGLTE2)
baseband = BASEBAND_SGLTE2;
else {
switch(platform) {
case APQ8060:
case APQ8064:
case APQ8064AA:
case APQ8064AB:
case APQ8030AB:
case MPQ8064:
case APQ8030:
case APQ8030AA:
baseband = BASEBAND_APQ;
break;
default:
baseband = BASEBAND_MSM;
};
}
board->baseband = baseband;
}
/* Returns 1 if target supports continuous splash screen. */
int target_cont_splash_screen()
{
switch(board_platform_id())
{
case MSM8960:
case MSM8960AB:
case APQ8060AB:
case MSM8260AB:
case MSM8660AB:
return 1;
default:
return 0;
}
}
void apq8064_ext_3p3V_enable()
{
/* Configure GPIO for output */
gpio_tlmm_config(77, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_ENABLE);
/* Output High */
gpio_set(77, 2);
}
/* Do target specific usb initialization */
void target_usb_init(void)
{
if(board_target_id() == LINUX_MACHTYPE_8064_LIQUID)
{
apq8064_ext_3p3V_enable();
}
}
/*
* Function to set the capabilities for the host
*/
void target_mmc_caps(struct mmc_host *host)
{
host->caps.ddr_mode = 1;
host->caps.hs200_mode = 1;
host->caps.bus_width = MMC_BOOT_BUS_WIDTH_8_BIT;
host->caps.hs_clk_rate = MMC_CLK_96MHZ;
}
@@ -0,0 +1,191 @@
/*
* Copyright (c) 2011-2012, The Linux Foundation. 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 The Linux Foundation 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 <debug.h>
#include <dev/keys.h>
#include <dev/ssbi.h>
#include <dev/gpio_keypad.h>
#include <dev/pm8921.h>
#include <platform/gpio.h>
#include <sys/types.h>
#include <board.h>
#include <smem.h>
#define BITS_IN_ELEMENT(x) (sizeof(x) * 8)
#define KEYMAP_INDEX(row, col) (row)* BITS_IN_ELEMENT(unsigned int) + (col)
unsigned int msm8960_qwerty_keymap[] = {
[KEYMAP_INDEX(0, 0)] = KEY_VOLUMEUP, /* Volume key on the device/CDP */
[KEYMAP_INDEX(0, 1)] = KEY_VOLUMEDOWN, /* Volume key on the device/CDP */
};
unsigned int msm8960_keys_gpiomap[] = {
[KEYMAP_INDEX(0, 0)] = PM_GPIO(1), /* Volume key on the device/CDP */
[KEYMAP_INDEX(0, 1)] = PM_GPIO(2), /* Volume key on the device/CDP */
};
struct qwerty_keypad_info msm8960_qwerty_keypad = {
.keymap = msm8960_qwerty_keymap,
.gpiomap = msm8960_keys_gpiomap,
.mapsize = ARRAY_SIZE(msm8960_qwerty_keymap),
.key_gpio_get = &pm8921_gpio_get,
.settle_time = 5 /* msec */ ,
.poll_time = 20 /* msec */ ,
};
unsigned int msm8930_qwerty_keymap[] = {
[KEYMAP_INDEX(0, 0)] = KEY_VOLUMEUP, /* Volume key on the device/CDP */
[KEYMAP_INDEX(0, 1)] = KEY_VOLUMEDOWN, /* Volume key on the device/CDP */
};
unsigned int msm8930_keys_pm8038_gpiomap[] = {
[KEYMAP_INDEX(0, 0)] = PM_GPIO(3), /* Volume key on the device/CDP */
[KEYMAP_INDEX(0, 1)] = PM_GPIO(8), /* Volume key on the device/CDP */
};
unsigned int msm8930_keys_pm8917_gpiomap[] = {
[KEYMAP_INDEX(0, 0)] = PM_GPIO(27), /* Volume key on the device/CDP */
[KEYMAP_INDEX(0, 1)] = PM_GPIO(28), /* Volume key on the device/CDP */
};
struct qwerty_keypad_info msm8930_pm8038_qwerty_keypad = {
.keymap = msm8930_qwerty_keymap,
.gpiomap = msm8930_keys_pm8038_gpiomap,
.mapsize = ARRAY_SIZE(msm8930_qwerty_keymap),
.key_gpio_get = &pm8921_gpio_get,
.settle_time = 5 /* msec */ ,
.poll_time = 20 /* msec */ ,
};
struct qwerty_keypad_info msm8930_pm8917_qwerty_keypad = {
.keymap = msm8930_qwerty_keymap,
.gpiomap = msm8930_keys_pm8917_gpiomap,
.mapsize = ARRAY_SIZE(msm8930_qwerty_keymap),
.key_gpio_get = &pm8921_gpio_get,
.settle_time = 5 /* msec */ ,
.poll_time = 20 /* msec */ ,
};
unsigned int apq8064_qwerty_keymap[] = {
[KEYMAP_INDEX(0, 0)] = KEY_VOLUMEUP, /* Volume key on the device/CDP */
[KEYMAP_INDEX(0, 1)] = KEY_VOLUMEDOWN, /* Volume key on the device/CDP */
};
unsigned int apq8064_pm8921_keys_gpiomap[] = {
[KEYMAP_INDEX(0, 0)] = PM_GPIO(35), /* Volume key on the device/CDP */
[KEYMAP_INDEX(0, 1)] = PM_GPIO(38), /* Volume key on the device/CDP */
};
unsigned int apq8064_pm8917_keys_gpiomap[] = {
[KEYMAP_INDEX(0, 0)] = PM_GPIO(35), /* Volume key on the device/CDP */
[KEYMAP_INDEX(0, 1)] = PM_GPIO(30), /* Volume key on the device/CDP */
};
struct qwerty_keypad_info apq8064_pm8921_qwerty_keypad = {
.keymap = apq8064_qwerty_keymap,
.gpiomap = apq8064_pm8921_keys_gpiomap,
.mapsize = ARRAY_SIZE(apq8064_qwerty_keymap),
.key_gpio_get = &pm8921_gpio_get,
.settle_time = 5 /* msec */ ,
.poll_time = 20 /* msec */ ,
};
struct qwerty_keypad_info apq8064_pm8917_qwerty_keypad = {
.keymap = apq8064_qwerty_keymap,
.gpiomap = apq8064_pm8917_keys_gpiomap,
.mapsize = ARRAY_SIZE(apq8064_qwerty_keymap),
.key_gpio_get = &pm8921_gpio_get,
.settle_time = 5 /* msec */ ,
.poll_time = 20 /* msec */ ,
};
void msm8960_keypad_init(void)
{
msm8960_keypad_gpio_init();
ssbi_gpio_keypad_init(&msm8960_qwerty_keypad);
}
void msm8930_keypad_init(void)
{
msm8930_keypad_gpio_init();
if (platform_pmic_type(PMIC_IS_PM8917))
{
ssbi_gpio_keypad_init(&msm8930_pm8917_qwerty_keypad);
}
else
{
ssbi_gpio_keypad_init(&msm8930_pm8038_qwerty_keypad);
}
}
void apq8064_keypad_init(void)
{
apq8064_keypad_gpio_init();
if (platform_pmic_type(PMIC_IS_PM8917))
ssbi_gpio_keypad_init(&apq8064_pm8917_qwerty_keypad);
else
ssbi_gpio_keypad_init(&apq8064_pm8921_qwerty_keypad);
}
/* Configure keypad_drv through pwm or DBUS inputs or manually */
int led_kp_set( int current,
enum kp_backlight_mode mode,
enum kp_backlight_flash_logic flash_logic)
{
int rc = pm8921_config_drv_keypad(current, flash_logic, mode);
if (rc)
{
dprintf(CRITICAL, "FAIL pm8921_config_drv_keypad(): rc=%d.\n", rc);
}
}
/* Configure gpio 26 through lpg2 */
void keypad_led_drv_on_pwm(void)
{
struct pm8921_gpio keypad_pwm = {
.direction = PM_GPIO_DIR_OUT,
.output_buffer = 0,
.output_value = 0,
.pull = PM_GPIO_PULL_NO,
.vin_sel = 2,
.out_strength = PM_GPIO_STRENGTH_HIGH,
.function = PM_GPIO_FUNC_2,
.inv_int_pol = 0,
};
int rc = pm8921_gpio_config(PM_GPIO(26), &keypad_pwm);
if (rc)
{
dprintf(CRITICAL, "FAIL pm8921_gpio_config(): rc=%d.\n", rc);
}
}
@@ -0,0 +1,47 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared
PLATFORM := msm8960
MEMBASE := 0x88F00000 # SDRAM
MEMSIZE := 0x00100000 # 1MB
BASE_ADDR := 0x80200000
TAGS_ADDR := BASE_ADDR+0x00000100
KERNEL_ADDR := BASE_ADDR+0x00008000
RAMDISK_ADDR := BASE_ADDR+0x01000000
SCRATCH_ADDR := 0x90000000
KEYS_USE_GPIO_KEYPAD := 1
DEFINES += DISPLAY_SPLASH_SCREEN=1
DEFINES += DISPLAY_TYPE_MIPI=1
DEFINES += DISPLAY_TYPE_HDMI=1
MODULES += \
dev/keys \
dev/pmic/pm8921 \
dev/ssbi \
lib/ptable \
dev/panel/msm \
DEFINES += \
MEMSIZE=$(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 \
$(LOCAL_DIR)/target_display.o
@@ -0,0 +1,354 @@
/* Copyright (c) 2012-2013, The Linux Foundation. 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 The Linux Foundation 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 <debug.h>
#include <msm_panel.h>
#include <dev/pm8921.h>
#include <board.h>
#include <mdp4.h>
#include <target/display.h>
#include <target/board.h>
static struct msm_fb_panel_data panel;
static uint8_t display_enable;
extern int msm_display_init(struct msm_fb_panel_data *pdata);
extern int msm_display_off();
static int apq8064_lvds_panel_power(int enable)
{
if (enable) {
/* Enable LVS7 */
pm8921_low_voltage_switch_enable(lvs_7);
/* Set and enabale LDO2 1.2V for VDDA_LVDS_PLL*/
pm8921_ldo_set_voltage(LDO_2, LDO_VOLTAGE_1_2V);
/* Enable Ext 3.3V - MSM GPIO 77*/
/* TODO: IS this really needed? This wasn't even implemented correctly.
* GPIO enable was not happening.
*/
apq8064_ext_3p3V_enable();
apq8064_display_gpio_init();
/* Configure PMM MPP 3*/
pm8921_mpp_set_digital_output(mpp_3);
}
return 0;
}
static int apq8064_lvds_clock(int enable)
{
if (enable)
mdp_clock_init();
return 0;
}
static int fusion3_mtp_panel_power(int enable)
{
if (enable) {
/* Enable LVS7 */
pm8921_low_voltage_switch_enable(7);
/* Set and enabale LDO2 1.2V for VDDA_MIPI_DSI0/1_PLL */
pm8921_ldo_set_voltage(LDO_2, LDO_VOLTAGE_1_2V);
/* Set and enabale LDO11 3.0V for LCD1_MIPI_AVDD */
pm8921_ldo_set_voltage(LDO_11, LDO_VOLTAGE_3_0V);
apq8064_display_gpio_init();
}
return 0;
}
static int fusion3_mtp_clock(int enable)
{
if (enable) {
mdp_clock_init();
mmss_clock_init();
} else if(!target_cont_splash_screen()) {
mmss_clock_disable();
}
return 0;
}
static void msm8960_backlight_on(void)
{
struct pm8921_gpio backlight_pwm = {
.direction = PM_GPIO_DIR_OUT,
.output_buffer = 0,
.output_value = 0,
.pull = PM_GPIO_PULL_NO,
.vin_sel = 2,
.out_strength = PM_GPIO_STRENGTH_HIGH,
.function = PM_GPIO_FUNC_1,
.inv_int_pol = 0,
};
int rc = pm8921_gpio_config(PM_GPIO(24), &backlight_pwm);
if (rc)
dprintf(CRITICAL, "FAIL pm8921_gpio_config(): rc=%d.\n", rc);
}
/* Pull DISP_RST_N high to get panel out of reset */
static void msm8960_mipi_panel_reset(void)
{
struct pm8921_gpio gpio43_param = {
.direction = PM_GPIO_DIR_OUT,
.output_buffer = 0,
.output_value = 1,
.pull = PM_GPIO_PULL_UP_30,
.vin_sel = 2,
.out_strength = PM_GPIO_STRENGTH_HIGH,
.function = PM_GPIO_FUNC_PAIRED,
.inv_int_pol = 0,
.disable_pin = 0,
};
pm8921_gpio_config(PM_GPIO(43), &gpio43_param);
}
static int msm8960_mipi_panel_clock(int enable)
{
if (enable) {
mdp_clock_init();
mmss_clock_init();
} else if(!target_cont_splash_screen()) {
mmss_clock_disable();
}
return 0;
}
static int mpq8064_hdmi_panel_clock(int enable)
{
if (enable)
mdp_clock_init();
hdmi_app_clk_init(enable);
return 0;
}
static int mpq8064_hdmi_panel_power(int enable)
{
if (enable)
hdmi_power_init();
return 0;
}
static int msm8960_liquid_mipi_panel_clock(int enable)
{
if (enable) {
mdp_clock_init();
liquid_mmss_clock_init(); /* 240 MHZ MIPI-DSI clk */
} else if(!target_cont_splash_screen()) {
mmss_clock_disable();
}
return 0;
}
static int msm8960_mipi_panel_power(int enable)
{
if (enable) {
msm8960_backlight_on();
/* Turn on LDO8 for lcd1 mipi vdd */
pm8921_ldo_set_voltage(LDO_8, LDO_VOLTAGE_3_0V);
/* Turn on LDO23 for lcd1 mipi vddio */
pm8921_ldo_set_voltage(LDO_23, LDO_VOLTAGE_1_8V);
/* Turn on LDO2 for vdda_mipi_dsi */
pm8921_ldo_set_voltage(LDO_2, LDO_VOLTAGE_1_2V);
msm8960_mipi_panel_reset();
}
return 0;
}
#define PM_GPIO_VIN_VPH 0 /* 3v ~ 4.4v */
#define PM_GPIO_VIN_BB 1 /* ~3.3v */
#define PM_GPIO_VIN_S4 2 /* 1.8v */
#define PM_GPIO_VIN_L15 3
static int msm8960_liquid_mipi_panel_power(int enable)
{
if (enable) {
static int gpio17, gpio21, gpio43 ;
int rc;
struct pm8921_gpio gpio_config = {
.direction = PM_GPIO_DIR_OUT,
.output_buffer = 0,
.output_value = 1,
.pull = PM_GPIO_PULL_NO,
.vin_sel = PM_GPIO_VIN_S4,
.out_strength = PM_GPIO_STRENGTH_HIGH,
.function = PM_GPIO_FUNC_NORMAL,
.inv_int_pol = 0,
.disable_pin = 0,
};
/* Note: PWM is controlled by PM-GPIO#24 */
gpio17 = PM_GPIO(17); /* ext_3p3v */
gpio21 = PM_GPIO(21); /* disp power enable_n , vin=VPH-PWR */
gpio43 = PM_GPIO(43); /* Displays Enable (rst_n) */
gpio_config.output_value = 1;
rc = pm8921_gpio_config(gpio17, &gpio_config);
mdelay(100);
gpio_config.output_value = 0;
/* disp disable (resx=0) */
rc = pm8921_gpio_config(gpio43, &gpio_config);
mdelay(100);
gpio_config.output_value = 0;
gpio_config.vin_sel = PM_GPIO_VIN_VPH; /* VPH_PWR */
/* disp power enable_n */
rc = pm8921_gpio_config(gpio21, &gpio_config);
mdelay(100);
gpio_config.output_value = 1;
gpio_config.vin_sel = PM_GPIO_VIN_S4;
/* disp enable */
rc = pm8921_gpio_config(gpio43, &gpio_config);
mdelay(100);
pm8921_low_voltage_switch_enable(lvs_4); /* S4 1.8 V */
/* Turn on LDO2 for vdda_mipi_dsi */
pm8921_ldo_set_voltage(LDO_2, LDO_VOLTAGE_1_2V);
msm8960_backlight_on();
}
return 0;
}
void display_init(void)
{
int target_id = board_target_id();
dprintf(INFO, "display_init(),target_id=%d.\n", target_id);
switch (target_id) {
case LINUX_MACHTYPE_8960_LIQUID:
mipi_chimei_video_wxga_init(&(panel.panel_info));
/*
* mipi_chimei_wxga panel not supported yet in LK.
* However, MIPI clocks and power should be set in LK.
*/
panel.clk_func = msm8960_liquid_mipi_panel_clock;
panel.power_func = msm8960_liquid_mipi_panel_power;
panel.fb.base = MIPI_FB_ADDR;
panel.fb.width = panel.panel_info.xres;
panel.fb.height = panel.panel_info.yres;
panel.fb.stride = panel.panel_info.xres;
panel.fb.bpp = panel.panel_info.bpp;
panel.fb.format = FB_FORMAT_RGB888;
panel.mdp_rev = MDP_REV_44;
break;
case LINUX_MACHTYPE_8064_CDP:
lvds_chimei_wxga_init(&(panel.panel_info));
panel.clk_func = apq8064_lvds_clock;
panel.power_func = apq8064_lvds_panel_power;
panel.fb.base = 0x80B00000;
panel.fb.width = panel.panel_info.xres;
panel.fb.height = panel.panel_info.yres;
panel.fb.stride = panel.panel_info.xres;
panel.fb.bpp = panel.panel_info.bpp;
panel.fb.format = FB_FORMAT_RGB888;
panel.mdp_rev = MDP_REV_44;
break;
case LINUX_MACHTYPE_8064_MTP:
mipi_toshiba_video_wsvga_init(&(panel.panel_info));
panel.clk_func = fusion3_mtp_clock;
panel.power_func = fusion3_mtp_panel_power;
panel.fb.base = 0x89000000;
panel.fb.width = panel.panel_info.xres;
panel.fb.height = panel.panel_info.yres;
panel.fb.stride = panel.panel_info.xres;
panel.fb.bpp = panel.panel_info.bpp;
panel.fb.format = FB_FORMAT_RGB888;
panel.mdp_rev = MDP_REV_44;
break;
case LINUX_MACHTYPE_8960_CDP:
case LINUX_MACHTYPE_8960_MTP:
case LINUX_MACHTYPE_8960_FLUID:
mipi_toshiba_video_wsvga_init(&(panel.panel_info));
panel.clk_func = msm8960_mipi_panel_clock;
panel.power_func = msm8960_mipi_panel_power;
panel.fb.base = 0x89000000;
panel.fb.width = panel.panel_info.xres;
panel.fb.height = panel.panel_info.yres;
panel.fb.stride = panel.panel_info.xres;
panel.fb.bpp = panel.panel_info.bpp;
panel.fb.format = FB_FORMAT_RGB888;
panel.mdp_rev = MDP_REV_42;
break;
case LINUX_MACHTYPE_8064_MPQ_CDP:
case LINUX_MACHTYPE_8064_MPQ_HRD:
case LINUX_MACHTYPE_8064_MPQ_DTV:
hdmi_msm_panel_init(&panel.panel_info);
panel.clk_func = mpq8064_hdmi_panel_clock;
panel.power_func = mpq8064_hdmi_panel_power;
panel.fb.base = 0x89000000;
panel.fb.width = panel.panel_info.xres;
panel.fb.height = panel.panel_info.yres;
panel.fb.stride = panel.panel_info.xres;
panel.fb.bpp = panel.panel_info.bpp;
panel.fb.format = FB_FORMAT_RGB565;
panel.mdp_rev = MDP_REV_44;
hdmi_set_fb_addr(panel.fb.base);
break;
default:
return;
};
if (msm_display_init(&panel)) {
dprintf(CRITICAL, "Display init failed!\n");
return;
}
display_enable = 1;
}
void display_shutdown(void)
{
if (display_enable) {
msm_display_off();
}
}
@@ -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)
$(BUILDDIR)/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)
$(BUILDDIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboothd.mbn
mkheader: $(SRC_DIR)/mkheader.c
@mkdir -p $(BUILDDIR)
${COMPILER} -DMEMBASE=$(MEMBASE) $(SRC_DIR)/mkheader.c -o $(BUILDDIR)/mkheader
@@ -0,0 +1,344 @@
/*
* Copyright (c) 2007, Google Inc.
* All rights reserved.
*
* Copyright (c) 2009-2011, The Linux Foundation. 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;
}
@@ -0,0 +1,45 @@
/* Copyright (c) 2012-2013, The Linux Foundation. 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 The Linux Foundation 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_COPPER_DISPLAY_H
#define _TARGET_COPPER_DISPLAY_H
#define MIPI_FB_ADDR 0x0D200000
#define MIPI_HSYNC_PULSE_WIDTH 12
#define MIPI_HSYNC_BACK_PORCH_DCLK 32
#define MIPI_HSYNC_FRONT_PORCH_DCLK 144
#define MIPI_VSYNC_PULSE_WIDTH 4
#define MIPI_VSYNC_BACK_PORCH_LINES 3
#define MIPI_VSYNC_FRONT_PORCH_LINES 9
extern int mdss_dsi_phy_init(struct mipi_dsi_panel_config *);
extern int mdss_dsi_uniphy_pll_config(void);
#endif
@@ -0,0 +1,610 @@
/* Copyright (c) 2012-2013, The Linux Foundation. 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 The Linux Foundation 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 <debug.h>
#include <platform/iomap.h>
#include <platform/gpio.h>
#include <reg.h>
#include <target.h>
#include <platform.h>
#include <dload_util.h>
#include <uart_dm.h>
#include <mmc.h>
#include <spmi.h>
#include <board.h>
#include <smem.h>
#include <baseband.h>
#include <dev/keys.h>
#include <pm8x41.h>
#include <crypto5_wrapper.h>
#include <hsusb.h>
#include <clock.h>
#include <partition_parser.h>
#include <scm.h>
#include <platform/clock.h>
#include <platform/gpio.h>
#include <stdlib.h>
extern bool target_use_signed_kernel(void);
static void set_sdc_power_ctrl();
static unsigned int target_id;
static uint32_t pmic_ver;
#if MMC_SDHCI_SUPPORT
struct mmc_device *dev;
#endif
#define PMIC_ARB_CHANNEL_NUM 0
#define PMIC_ARB_OWNER_ID 0
#define WDOG_DEBUG_DISABLE_BIT 17
#define CE_INSTANCE 2
#define CE_EE 1
#define CE_FIFO_SIZE 64
#define CE_READ_PIPE 3
#define CE_WRITE_PIPE 2
#define CE_ARRAY_SIZE 20
#ifdef SSD_ENABLE
#define SSD_CE_INSTANCE_1 1
#define SSD_PARTITION_SIZE 8192
#endif
#if MMC_SDHCI_SUPPORT
static uint32_t mmc_sdhci_base[] =
{ MSM_SDC1_SDHCI_BASE, MSM_SDC2_SDHCI_BASE, MSM_SDC3_SDHCI_BASE, MSM_SDC4_SDHCI_BASE };
#endif
static uint32_t mmc_sdc_base[] =
{ MSM_SDC1_BASE, MSM_SDC2_BASE, MSM_SDC3_BASE, MSM_SDC4_BASE };
void target_early_init(void)
{
#if WITH_DEBUG_UART
uart_dm_init(1, 0, BLSP1_UART1_BASE);
#endif
}
/* Return 1 if vol_up pressed */
static int target_volume_up()
{
uint8_t status = 0;
struct pm8x41_gpio gpio;
/* CDP vol_up seems to be always grounded. So gpio status is read as 0,
* whether key is pressed or not.
* Ignore volume_up key on CDP for now.
*/
if (board_hardware_id() == HW_PLATFORM_SURF)
return 0;
/* Configure the GPIO */
gpio.direction = PM_GPIO_DIR_IN;
gpio.function = 0;
gpio.pull = PM_GPIO_PULL_UP_30;
gpio.vin_sel = 2;
pm8x41_gpio_config(5, &gpio);
/* Get status of P_GPIO_5 */
pm8x41_gpio_get(5, &status);
return !status; /* active low */
}
/* Return 1 if vol_down pressed */
uint32_t target_volume_down()
{
/* Volume down button is tied in with RESIN on MSM8974. */
if (pmic_ver == PMIC_VERSION_V2)
return pm8x41_resin_bark_workaround_status();
else
return pm8x41_resin_status();
}
static void target_keystatus()
{
keys_init();
if(target_volume_down())
keys_post_event(KEY_VOLUMEDOWN, 1);
if(target_volume_up())
keys_post_event(KEY_VOLUMEUP, 1);
}
/* Set up params for h/w CE. */
void target_crypto_init_params()
{
struct crypto_init_params ce_params;
/* Set up base addresses and instance. */
ce_params.crypto_instance = CE_INSTANCE;
ce_params.crypto_base = MSM_CE2_BASE;
ce_params.bam_base = MSM_CE2_BAM_BASE;
/* Set up BAM config. */
ce_params.bam_ee = CE_EE;
ce_params.pipes.read_pipe = CE_READ_PIPE;
ce_params.pipes.write_pipe = CE_WRITE_PIPE;
/* Assign buffer sizes. */
ce_params.num_ce = CE_ARRAY_SIZE;
ce_params.read_fifo_size = CE_FIFO_SIZE;
ce_params.write_fifo_size = CE_FIFO_SIZE;
/* BAM is initialized by TZ for this platform.
* Do not do it again as the initialization address space
* is locked.
*/
ce_params.do_bam_init = 0;
crypto_init_params(&ce_params);
}
crypto_engine_type board_ce_type(void)
{
return CRYPTO_ENGINE_TYPE_HW;
}
#if MMC_SDHCI_SUPPORT
static target_mmc_sdhci_init()
{
struct mmc_config_data config;
uint32_t soc_ver = 0;
/* Enable sdhci mode */
sdhci_mode_enable(1);
soc_ver = board_soc_version();
/*
* 8974 v1 fluid devices, have a hardware bug
* which limits the bus width to 4 bit.
*/
switch(board_hardware_id())
{
case HW_PLATFORM_FLUID:
if (soc_ver >= BOARD_SOC_VERSION2)
config.bus_width = DATA_BUS_WIDTH_8BIT;
else
config.bus_width = DATA_BUS_WIDTH_4BIT;
break;
default:
config.bus_width = DATA_BUS_WIDTH_8BIT;
};
config.max_clk_rate = MMC_CLK_200MHZ;
/* Trying Slot 1*/
config.slot = 1;
config.base = mmc_sdhci_base[config.slot - 1];
if (!(dev = mmc_init(&config))) {
/* Trying Slot 2 next */
config.slot = 2;
config.base = mmc_sdhci_base[config.slot - 1];
if (!(dev = mmc_init(&config))) {
dprintf(CRITICAL, "mmc init failed!");
ASSERT(0);
}
}
}
struct mmc_device *target_mmc_device()
{
return dev;
}
#else
static target_mmc_mci_init()
{
uint32_t base_addr;
uint8_t slot;
/* Trying Slot 1 */
slot = 1;
base_addr = mmc_sdc_base[slot - 1];
if (mmc_boot_main(slot, base_addr))
{
/* Trying Slot 2 next */
slot = 2;
base_addr = mmc_sdc_base[slot - 1];
if (mmc_boot_main(slot, base_addr)) {
dprintf(CRITICAL, "mmc init failed!");
ASSERT(0);
}
}
}
/*
* Function to set the capabilities for the host
*/
void target_mmc_caps(struct mmc_host *host)
{
uint32_t soc_ver = 0;
soc_ver = board_soc_version();
/*
* 8974 v1 fluid devices, have a hardware bug
* which limits the bus width to 4 bit.
*/
switch(board_hardware_id())
{
case HW_PLATFORM_FLUID:
if (soc_ver >= BOARD_SOC_VERSION2)
host->caps.bus_width = MMC_BOOT_BUS_WIDTH_8_BIT;
else
host->caps.bus_width = MMC_BOOT_BUS_WIDTH_4_BIT;
break;
default:
host->caps.bus_width = MMC_BOOT_BUS_WIDTH_8_BIT;
};
host->caps.ddr_mode = 1;
host->caps.hs200_mode = 1;
host->caps.hs_clk_rate = MMC_CLK_96MHZ;
}
#endif
void target_init(void)
{
dprintf(INFO, "target_init()\n");
spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID);
/* Save PM8941 version info. */
pmic_ver = pm8x41_get_pmic_rev();
target_keystatus();
if (target_use_signed_kernel())
target_crypto_init_params();
/* Display splash screen if enabled */
#if DISPLAY_SPLASH_SCREEN
dprintf(INFO, "Display Init: Start\n");
display_init();
dprintf(INFO, "Display Init: Done\n");
#endif
/*
* Set drive strength & pull ctrl for
* emmc
*/
set_sdc_power_ctrl();
#if MMC_SDHCI_SUPPORT
target_mmc_sdhci_init();
#else
target_mmc_mci_init();
#endif
/*
* MMC initialization is complete, read the partition table info
*/
if (partition_read_table()) {
dprintf(CRITICAL, "Error reading the partition table info\n");
ASSERT(0);
}
}
unsigned board_machtype(void)
{
return target_id;
}
/* Do any target specific intialization needed before entering fastboot mode */
#ifdef SSD_ENABLE
static void ssd_load_keystore_from_emmc()
{
uint64_t ptn = 0;
int index = -1;
uint32_t size = SSD_PARTITION_SIZE;
int ret = -1;
uint32_t *buffer = (uint32_t *)memalign(CACHE_LINE,
ROUNDUP(SSD_PARTITION_SIZE, CACHE_LINE));
if (!buffer) {
dprintf(CRITICAL, "Error Allocating memory for SSD buffer\n");
ASSERT(0);
}
index = partition_get_index("ssd");
ptn = partition_get_offset(index);
if(ptn == 0){
dprintf(CRITICAL,"ERROR: ssd parition not found");
return;
}
if(mmc_read(ptn, buffer, size)){
dprintf(CRITICAL,"ERROR:Cannot read data\n");
return;
}
ret = scm_protect_keystore((uint32_t *)&buffer[0],size);
if(ret != 0)
dprintf(CRITICAL,"ERROR: scm_protect_keystore Failed");
free(buffer);
}
#endif
void target_fastboot_init(void)
{
/* Set the BOOT_DONE flag in PM8921 */
pm8x41_set_boot_done();
#ifdef SSD_ENABLE
clock_ce_enable(SSD_CE_INSTANCE_1);
ssd_load_keystore_from_emmc();
#endif
}
/* Detect the target type */
void target_detect(struct board_data *board)
{
board->target = LINUX_MACHTYPE_UNKNOWN;
}
/* Detect the modem type */
void target_baseband_detect(struct board_data *board)
{
uint32_t platform;
uint32_t platform_subtype;
platform = board->platform;
platform_subtype = board->platform_subtype;
/*
* Look for platform subtype if present, else
* check for platform type to decide on the
* baseband type
*/
switch(platform_subtype) {
case HW_PLATFORM_SUBTYPE_UNKNOWN:
break;
case HW_PLATFORM_SUBTYPE_MDM:
board->baseband = BASEBAND_MDM;
return;
default:
dprintf(CRITICAL, "Platform Subtype : %u is not supported\n",platform_subtype);
ASSERT(0);
};
switch(platform) {
case MSM8974:
case MSM8274:
case MSM8674:
board->baseband = BASEBAND_MSM;
break;
case APQ8074:
board->baseband = BASEBAND_APQ;
break;
default:
dprintf(CRITICAL, "Platform type: %u is not supported\n",platform);
ASSERT(0);
};
}
unsigned target_baseband()
{
return board_baseband();
}
void target_serialno(unsigned char *buf)
{
unsigned int serialno;
if (target_is_emmc_boot()) {
serialno = mmc_get_psn();
snprintf((char *)buf, 13, "%x", serialno);
}
}
unsigned check_reboot_mode(void)
{
uint32_t restart_reason = 0;
uint32_t soc_ver = 0;
uint32_t restart_reason_addr;
soc_ver = board_soc_version();
if (soc_ver >= BOARD_SOC_VERSION2)
restart_reason_addr = RESTART_REASON_ADDR_V2;
else
restart_reason_addr = RESTART_REASON_ADDR;
/* Read reboot reason and scrub it */
restart_reason = readl(restart_reason_addr);
writel(0x00, restart_reason_addr);
return restart_reason;
}
void reboot_device(unsigned reboot_reason)
{
uint32_t soc_ver = 0;
soc_ver = board_soc_version();
/* Write the reboot reason */
if (soc_ver >= BOARD_SOC_VERSION2)
writel(reboot_reason, RESTART_REASON_ADDR_V2);
else
writel(reboot_reason, RESTART_REASON_ADDR);
/* Configure PMIC for warm reset */
if (pmic_ver == PMIC_VERSION_V2)
pm8x41_v2_reset_configure(PON_PSHOLD_WARM_RESET);
else
pm8x41_reset_configure(PON_PSHOLD_WARM_RESET);
/* Disable Watchdog Debug.
* Required becuase of a H/W bug which causes the system to
* reset partially even for non watchdog resets.
*/
writel(readl(GCC_WDOG_DEBUG) & ~(1 << WDOG_DEBUG_DISABLE_BIT), GCC_WDOG_DEBUG);
dsb();
/* Wait until the write takes effect. */
while(readl(GCC_WDOG_DEBUG) & (1 << WDOG_DEBUG_DISABLE_BIT));
/* Drop PS_HOLD for MSM */
writel(0x00, MPM2_MPM_PS_HOLD);
mdelay(5000);
dprintf(CRITICAL, "Rebooting failed\n");
}
int set_download_mode(void)
{
dload_util_write_cookie(FORCE_DLOAD_MODE_ADDR_V2);
return 0;
}
/* Do target specific usb initialization */
void target_usb_init(void)
{
/* Enable secondary USB PHY on DragonBoard8074 */
if (board_hardware_id() == HW_PLATFORM_DRAGON) {
/* Route ChipIDea to use secondary USB HS port2 */
writel_relaxed(1, USB2_PHY_SEL);
/* Enable access to secondary PHY by clamping the low
* voltage interface between DVDD of the PHY and Vddcx
* (set bit16 (USB2_PHY_HS2_DIG_CLAMP_N_2) = 1) */
writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_SEC_CTRL)
| 0x00010000, USB_OTG_HS_PHY_SEC_CTRL);
/* Perform power-on-reset of the PHY.
* Delay values are arbitrary */
writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_CTRL)|1,
USB_OTG_HS_PHY_CTRL);
thread_sleep(10);
writel_relaxed(readl_relaxed(USB_OTG_HS_PHY_CTRL) & 0xFFFFFFFE,
USB_OTG_HS_PHY_CTRL);
thread_sleep(10);
/* Enable HSUSB PHY port for ULPI interface,
* then configure related parameters within the PHY */
writel_relaxed(((readl_relaxed(USB_PORTSC) & 0xC0000000)
| 0x8c000004), USB_PORTSC);
}
}
/* Returns 1 if target supports continuous splash screen. */
int target_cont_splash_screen()
{
switch(board_hardware_id())
{
case HW_PLATFORM_SURF:
case HW_PLATFORM_MTP:
case HW_PLATFORM_FLUID:
case HW_PLATFORM_DRAGON:
dprintf(SPEW, "Target_cont_splash=1\n");
return 1;
break;
default:
dprintf(SPEW, "Target_cont_splash=0\n");
return 0;
}
}
unsigned target_pause_for_battery_charge(void)
{
uint8_t pon_reason = pm8x41_get_pon_reason();
/* This function will always return 0 to facilitate
* automated testing/reboot with usb connected.
* uncomment if this feature is needed */
/* if ((pon_reason == USB_CHG) || (pon_reason == DC_CHG))
return 1;*/
return 0;
}
void target_usb_stop(void)
{
#ifdef SSD_ENABLE
clock_ce_disable(SSD_CE_INSTANCE_1);
#endif
}
void shutdown_device()
{
dprintf(CRITICAL, "Going down for shutdown.\n");
/* Configure PMIC for shutdown. */
if (pmic_ver == PMIC_VERSION_V2)
pm8x41_v2_reset_configure(PON_PSHOLD_SHUTDOWN);
else
pm8x41_reset_configure(PON_PSHOLD_SHUTDOWN);
/* Drop PS_HOLD for MSM */
writel(0x00, MPM2_MPM_PS_HOLD);
mdelay(5000);
dprintf(CRITICAL, "Shutdown failed\n");
}
static void set_sdc_power_ctrl()
{
/* Drive strength configs for sdc pins */
struct tlmm_cfgs sdc1_hdrv_cfg[] =
{
{ SDC1_CLK_HDRV_CTL_OFF, TLMM_CUR_VAL_16MA, TLMM_HDRV_MASK },
{ SDC1_CMD_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK },
{ SDC1_DATA_HDRV_CTL_OFF, TLMM_CUR_VAL_10MA, TLMM_HDRV_MASK },
};
/* Pull configs for sdc pins */
struct tlmm_cfgs sdc1_pull_cfg[] =
{
{ SDC1_CLK_PULL_CTL_OFF, TLMM_NO_PULL, TLMM_PULL_MASK },
{ SDC1_CMD_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK },
{ SDC1_DATA_PULL_CTL_OFF, TLMM_PULL_UP, TLMM_PULL_MASK },
};
/* Set the drive strength & pull control values */
tlmm_set_hdrive_ctrl(sdc1_hdrv_cfg, ARRAY_SIZE(sdc1_hdrv_cfg));
tlmm_set_pull_ctrl(sdc1_pull_cfg, ARRAY_SIZE(sdc1_pull_cfg));
}
int emmc_recovery_init(void)
{
return _emmc_recovery_init();
}
@@ -0,0 +1,89 @@
/* Copyright (c) 2012, The Linux Foundation. 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 The Linux Foundation 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.
*/
#if DEVICE_TREE /* If using device tree */
#include <reg.h>
#include <debug.h>
#include <malloc.h>
#include <smem.h>
#include <stdint.h>
#include <libfdt.h>
#include <platform/iomap.h>
#include <dev_tree.h>
/* Funtion to add the ram partition entries into device tree.
* The function assumes that all the entire fixed memory regions should
* be listed in the first bank of the passed in ddr regions.
*/
uint32_t target_dev_tree_mem(void *fdt, uint32_t memory_node_offset)
{
struct smem_ram_ptable ram_ptable;
unsigned int i;
int ret = 0;
/* Make sure RAM partition table is initialized */
ASSERT(smem_ram_ptable_init(&ram_ptable));
/* Calculating the size of the mem_info_ptr */
for (i = 0 ; i < ram_ptable.len; i++)
{
if((ram_ptable.parts[i].category == SDRAM) &&
(ram_ptable.parts[i].type == SYS_MEMORY))
{
/* Pass along all other usable memory regions to Linux */
ret = dev_tree_add_mem_info(fdt,
memory_node_offset,
ram_ptable.parts[i].start,
ram_ptable.parts[i].size);
if (ret)
{
dprintf(CRITICAL, "Failed to add secondary banks memory addresses\n");
goto target_dev_tree_mem_err;
}
}
}
target_dev_tree_mem_err:
return ret;
}
void *target_get_scratch_address(void)
{
return ((void *)SCRATCH_ADDR);
}
unsigned target_get_max_flash_size(void)
{
return (512 * 1024 * 1024);
}
#endif /* DEVICE_TREE */
@@ -0,0 +1,41 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared
PLATFORM := msm8974
MEMBASE := 0x0F900000 # SDRAM
MEMSIZE := 0x00100000 # 1MB
BASE_ADDR := 0x00000
TAGS_ADDR := BASE_ADDR+0x00000100
KERNEL_ADDR := BASE_ADDR+0x00008000
RAMDISK_ADDR := BASE_ADDR+0x01000000
SCRATCH_ADDR := 0x11000000
DEFINES += DISPLAY_SPLASH_SCREEN=1
DEFINES += DISPLAY_TYPE_MIPI=1
DEFINES += DISPLAY_TYPE_DSI6G=1
MODULES += \
dev/keys \
dev/pmic/pm8x41 \
dev/panel/msm \
lib/ptable \
lib/libfdt
DEFINES += \
MEMSIZE=$(MEMSIZE) \
MEMBASE=$(MEMBASE) \
BASE_ADDR=$(BASE_ADDR) \
TAGS_ADDR=$(TAGS_ADDR) \
KERNEL_ADDR=$(KERNEL_ADDR) \
RAMDISK_ADDR=$(RAMDISK_ADDR) \
SCRATCH_ADDR=$(SCRATCH_ADDR)
OBJS += \
$(LOCAL_DIR)/init.o \
$(LOCAL_DIR)/meminfo.o \
$(LOCAL_DIR)/target_display.o
@@ -0,0 +1,216 @@
/* Copyright (c) 2012-2013, The Linux Foundation. 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 The Linux Foundation 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 <smem.h>
#include <msm_panel.h>
#include <pm8x41.h>
#include <pm8x41_wled.h>
#include <board.h>
#include <mdp5.h>
#include <platform/gpio.h>
#include <platform/clock.h>
#include <target/display.h>
static struct msm_fb_panel_data panel;
static uint8_t display_enable;
extern int msm_display_init(struct msm_fb_panel_data *pdata);
extern int msm_display_off();
extern int mdss_dsi_uniphy_pll_config(void);
extern int mdss_sharp_dsi_uniphy_pll_config(void);
static int msm8974_backlight_on()
{
static struct pm8x41_wled_data wled_ctrl = {
.mod_scheme = 0xC3,
.led1_brightness = (0x0F << 8) | 0xEF,
.led2_brightness = (0x0F << 8) | 0xEF,
.led3_brightness = (0x0F << 8) | 0xEF,
.max_duty_cycle = 0x01,
};
pm8x41_wled_config(&wled_ctrl);
pm8x41_wled_sink_control(1);
pm8x41_wled_iled_sync_control(1);
pm8x41_wled_enable(1);
return 0;
}
static int msm8974_mdss_dsi_panel_clock(uint8_t enable)
{
if (enable) {
mdp_gdsc_ctrl(enable);
mdp_clock_init();
mdss_dsi_uniphy_pll_config();
mmss_clock_init(DSI0_PHY_PLL_OUT);
} else if(!target_cont_splash_screen()) {
// * Add here for continuous splash *
mmss_clock_disable();
mdp_clock_disable();
mdp_gdsc_ctrl(enable);
}
return 0;
}
static int msm8974_mdss_sharp_dsi_panel_clock(uint8_t enable)
{
if (enable) {
mdp_gdsc_ctrl(enable);
mdp_clock_init();
mdss_sharp_dsi_uniphy_pll_config();
mmss_clock_init(DSI0_PHY_PLL_OUT);
} else if (!target_cont_splash_screen()) {
/* Add here for continuous splash */
mmss_clock_disable();
mdp_clock_disable();
mdp_gdsc_ctrl(enable);
}
return 0;
}
/* Pull DISP_RST_N high to get panel out of reset */
static void msm8974_mdss_mipi_panel_reset(uint8_t enable)
{
struct pm8x41_gpio gpio19_param = {
.direction = PM_GPIO_DIR_OUT,
.output_buffer = PM_GPIO_OUT_CMOS,
.out_strength = PM_GPIO_OUT_DRIVE_MED,
};
pm8x41_gpio_config(19, &gpio19_param);
if (enable) {
gpio_tlmm_config(58, 0, GPIO_OUTPUT, GPIO_NO_PULL, GPIO_8MA, GPIO_DISABLE);
pm8x41_gpio_set(19, PM_GPIO_FUNC_HIGH);
mdelay(2);
pm8x41_gpio_set(19, PM_GPIO_FUNC_LOW);
mdelay(5);
pm8x41_gpio_set(19, PM_GPIO_FUNC_HIGH);
mdelay(2);
gpio_set(58, 2);
} else {
gpio19_param.out_strength = PM_GPIO_OUT_DRIVE_LOW;
pm8x41_gpio_config(19, &gpio19_param);
pm8x41_gpio_set(19, PM_GPIO_FUNC_LOW);
gpio_set(58, 2);
}
}
static int msm8974_mipi_panel_power(uint8_t enable)
{
if (enable) {
/* Enable backlight */
msm8974_backlight_on();
/* Turn on LDO8 for lcd1 mipi vdd */
dprintf(SPEW, " Setting LDO22\n");
pm8x41_ldo_set_voltage("LDO22", 3000000);
pm8x41_ldo_control("LDO22", enable);
dprintf(SPEW, " Setting LDO12\n");
/* Turn on LDO23 for lcd1 mipi vddio */
pm8x41_ldo_set_voltage("LDO12", 1800000);
pm8x41_ldo_control("LDO12", enable);
dprintf(SPEW, " Setting LDO2\n");
/* Turn on LDO2 for vdda_mipi_dsi */
pm8x41_ldo_set_voltage("LDO2", 1200000);
pm8x41_ldo_control("LDO2", enable);
dprintf(SPEW, " Panel Reset \n");
/* Panel Reset */
msm8974_mdss_mipi_panel_reset(enable);
dprintf(SPEW, " Panel Reset Done\n");
} else {
msm8974_mdss_mipi_panel_reset(enable);
pm8x41_wled_enable(enable);
pm8x41_ldo_control("LDO2", enable);
pm8x41_ldo_control("LDO22", enable);
}
return 0;
}
void display_init(void)
{
uint32_t hw_id = board_hardware_id();
uint32_t soc_ver = board_soc_version();
dprintf(INFO, "display_init(),target_id=%d.\n", hw_id);
switch (hw_id) {
case HW_PLATFORM_MTP:
case HW_PLATFORM_FLUID:
case HW_PLATFORM_SURF:
mipi_toshiba_video_720p_init(&(panel.panel_info));
panel.clk_func = msm8974_mdss_dsi_panel_clock;
panel.power_func = msm8974_mipi_panel_power;
panel.fb.base = MIPI_FB_ADDR;
panel.fb.width = panel.panel_info.xres;
panel.fb.height = panel.panel_info.yres;
panel.fb.stride = panel.panel_info.xres;
panel.fb.bpp = panel.panel_info.bpp;
panel.fb.format = FB_FORMAT_RGB888;
panel.mdp_rev = MDP_REV_50;
break;
case HW_PLATFORM_DRAGON:
mipi_sharp_video_qhd_init(&(panel.panel_info));
panel.clk_func = msm8974_mdss_sharp_dsi_panel_clock;
panel.power_func = msm8974_mipi_panel_power;
panel.fb.base = MIPI_FB_ADDR;
panel.fb.width = panel.panel_info.xres;
panel.fb.height = panel.panel_info.yres;
panel.fb.stride = panel.panel_info.xres;
panel.fb.bpp = panel.panel_info.bpp;
panel.fb.format = FB_FORMAT_RGB888;
panel.mdp_rev = MDP_REV_50;
break;
default:
return;
};
if (msm_display_init(&panel)) {
dprintf(CRITICAL, "Display init failed!\n");
return;
}
display_enable = 1;
}
void display_shutdown(void)
{
if (display_enable)
msm_display_off();
}
@@ -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)
$(BUILDDIR)/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)
$(BUILDDIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/emmc_appsboothd.mbn
mkheader: $(SRC_DIR)/mkheader.c
@mkdir -p $(BUILDDIR)
${COMPILER} -DMEMBASE=$(MEMBASE) $(SRC_DIR)/mkheader.c -o $(BUILDDIR)/mkheader
@@ -0,0 +1,344 @@
/*
* Copyright (c) 2007, Google Inc.
* All rights reserved.
*
* Copyright (c) 2009-2011, The Linux Foundation. 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;
}
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2008 Travis Geiselbrecht
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <err.h>
#include <debug.h>
#include <target.h>
#include <compiler.h>
#include <dev/net/smc91c96.h>
void target_init(void)
{
smc91c96_init();
}
@@ -0,0 +1,17 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
PLATFORM := omap5912
MODULES += \
dev/net/smc91c96
OBJS += \
$(LOCAL_DIR)/init.o
MEMSIZE := 0x02000000 # 32MB
DEFINES += \
SDRAM_SIZE=$(MEMSIZE) \
SMC91C96_BASE_ADDR=0x04800300 \
SMC91C96_IRQ=0
@@ -0,0 +1,5 @@
# mostly null target configuration for pc-x86
LOCAL_DIR := $(GET_LOCAL_DIR)
PLATFORM := pc
@@ -0,0 +1,7 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
PLATFORM := integrator
MEMBASE := 0x10000 # this is where qemu loads us
MEMSIZE := 0x08000000 # 128MB
@@ -0,0 +1,82 @@
/* Copyright (c) 2009, The Linux Foundation. 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 The Linux Foundation nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <reg.h>
#define EBI1_SIZE1 0x0E800000 //232MB for 256/512/1024MB RAM
#define EBI1_ADDR1 0x20000000
#define EBI1_SIZE2_512M 0x10000000 //256MB for 512MB RAM
#define EBI1_SIZE2_1G 0x30000000 //768MB for 1GB RAM
#define EBI1_ADDR2 0x30000000
static unsigned check_1gb_mem()
{
// check for 1GB
unsigned adr1 = 0x57000000;
unsigned adr2 = 0x5F000000;
unsigned value1 = 0x55555555;
unsigned value2 = 0xAAAAAAAA;
writel(value1, adr1);
writel(value2, adr2);
return ((value1 == readl(adr1)) && (value2 == readl(adr2)));
}
unsigned* target_atag_mem(unsigned* ptr)
{
unsigned size;
/* ATAG_MEM */
/* 1st segment */
*ptr++ = 4;
*ptr++ = 0x54410002;
*ptr++ = EBI1_SIZE1;
*ptr++ = EBI1_ADDR1;
/* 2nd segment */
#ifdef USE_512M_RAM
size = EBI1_SIZE2_512M;
#else
size = 0;
#endif
if (check_1gb_mem()) {
size = EBI1_SIZE2_1G;
}
if (size > 0) {
*ptr++ = 4;
*ptr++ = 0x54410002;
*ptr++ = size;
*ptr++ = EBI1_ADDR2;
}
return ptr;
}
@@ -0,0 +1,47 @@
/* Copyright (c) 2010, The Linux Foundation. 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 The Linux Foundation 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_QSD8250_FFA_DISPLAY_H
#define _TARGET_QSD8250_FFA_DISPLAY_H
#define TARGET_XRES 480
#define TARGET_YRES 800
#define LCDC_FB_WIDTH 800
#define LCDC_FB_HEIGHT 480
#define LCDC_HSYNC_PULSE_WIDTH_DCLK 60
#define LCDC_HSYNC_BACK_PORCH_DCLK 81
#define LCDC_HSYNC_FRONT_PORCH_DCLK 81
#define LCDC_HSYNC_SKEW_DCLK 0
#define LCDC_VSYNC_PULSE_WIDTH_LINES 2
#define LCDC_VSYNC_BACK_PORCH_LINES 20
#define LCDC_VSYNC_FRONT_PORCH_LINES 27
#endif
@@ -0,0 +1,182 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009-2010, The Linux Foundation. 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 <dev/keys.h>
#include <dev/gpio_keypad.h>
#include <lib/ptable.h>
#include <dev/flash.h>
#include <smem.h>
#define LINUX_MACHTYPE 2710
#define VARIABLE_LENGTH 0x10101010
#define DIFF_START_ADDR 0xF0F0F0F0
#define NUM_PAGES_PER_BLOCK 0x40
static struct ptable flash_ptable;
/* for these partitions, start will be offset by either what we get from
* smem, or from the above offset if smem is not useful. Also, we should
* probably have smem_ptable code populate our flash_ptable.
*
* When smem provides us with a full partition table, we can get rid of
* this altogether.
*
*/
static struct ptentry board_part_list[] = {
{
.start = 0,
.length = 5 /* In MB */,
.name = "boot",
},
{
.start = DIFF_START_ADDR,
.length = 100 /* In MB */,
.name = "system",
},
{
.start = DIFF_START_ADDR,
.length = 30 /* In MB */,
.name = "cache",
},
{
.start = DIFF_START_ADDR,
.length = 1 /* In MB */,
.name = "misc",
},
{
.start = DIFF_START_ADDR,
.length = VARIABLE_LENGTH,
.name = "userdata",
},
{
.start = DIFF_START_ADDR,
.length = 5 /* In MB */,
.name = "recovery",
},
};
static int num_parts = sizeof(board_part_list)/sizeof(struct ptentry);
void smem_ptable_init(void);
unsigned smem_get_apps_flash_start(void);
void keypad_init(void);
void target_init(void)
{
unsigned offset;
struct flash_info *flash_info;
unsigned total_num_of_blocks;
unsigned next_ptr_start_adr = 0;
unsigned blocks_per_1MB = 8; /* Default value of 2k page size on 256MB flash drive*/
int i;
dprintf(INFO, "target_init()\n");
#if (!ENABLE_NANDWRITE)
keys_init();
keypad_init();
#endif
ptable_init(&flash_ptable);
smem_ptable_init();
flash_init();
flash_info = flash_get_info();
ASSERT(flash_info);
offset = smem_get_apps_flash_start();
if (offset == 0xffffffff)
while(1);
total_num_of_blocks = flash_info->num_blocks;
blocks_per_1MB = (1 << 20) / (flash_info->block_size);
for (i = 0; i < num_parts; i++) {
struct ptentry *ptn = &board_part_list[i];
unsigned len = ((ptn->length) * blocks_per_1MB);
if(ptn->start != 0)
ASSERT(ptn->start == DIFF_START_ADDR);
ptn->start = next_ptr_start_adr;
if(ptn->length == VARIABLE_LENGTH)
{
unsigned length_for_prt = 0;
unsigned j;
for (j = i+1; j < num_parts; j++)
{
struct ptentry *temp_ptn = &board_part_list[j];
ASSERT(temp_ptn->length != VARIABLE_LENGTH);
length_for_prt += ((temp_ptn->length) * blocks_per_1MB);
}
len = (total_num_of_blocks - 1) - (offset + ptn->start + length_for_prt);
ASSERT(len >= 0);
}
next_ptr_start_adr = ptn->start + len;
ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
len, ptn->flags, TYPE_APPS_PARTITION, PERM_WRITEABLE);
}
smem_add_modem_partitions(&flash_ptable);
ptable_dump(&flash_ptable);
flash_set_ptable(&flash_ptable);
}
unsigned board_machtype(void)
{
return LINUX_MACHTYPE;
}
void reboot_device(unsigned reboot_reason)
{
reboot(reboot_reason);
}
unsigned check_reboot_mode(void)
{
unsigned mode[2] = {0, 0};
unsigned int mode_len = sizeof(mode);
unsigned smem_status;
smem_status = smem_read_alloc_entry(SMEM_APPS_BOOT_MODE,
&mode, mode_len );
if(smem_status)
{
dprintf(CRITICAL, "ERROR: unable to read shared memory for reboot mode\n");
return 0;
}
return mode[0];
}
@@ -0,0 +1,112 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009, The Linux Foundation. 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 <dev/keys.h>
#include <dev/gpio_keypad.h>
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
/* don't turn this on without updating the ffa support */
#define SCAN_FUNCTION_KEYS 0
static unsigned int halibut_row_gpios[] = {
31, 32, 33, 34, 35, 36
#if SCAN_FUNCTION_KEYS
, 42
#endif
};
static unsigned int halibut_col_gpios[] = { 38, 39, 40, 41, 42 };
#define KEYMAP_INDEX(row, col) ((row)*ARRAY_SIZE(halibut_col_gpios) + (col))
static const unsigned short halibut_keymap[ARRAY_SIZE(halibut_col_gpios) * ARRAY_SIZE(halibut_row_gpios)] = {
[KEYMAP_INDEX(0, 0)] = KEY_VOLUMEDOWN,
/*[KEYMAP_INDEX(0, 1)] = ,*/
[KEYMAP_INDEX(0, 2)] = KEY_DOWN,
[KEYMAP_INDEX(0, 3)] = KEY_8,
[KEYMAP_INDEX(0, 4)] = KEY_5,
[KEYMAP_INDEX(1, 0)] = KEY_UP,
[KEYMAP_INDEX(1, 1)] = KEY_CLEAR,
[KEYMAP_INDEX(1, 2)] = KEY_4,
/*[KEYMAP_INDEX(1, 3)] = ,*/
[KEYMAP_INDEX(1, 4)] = KEY_2,
[KEYMAP_INDEX(2, 0)] = KEY_HOME, /* A */
[KEYMAP_INDEX(2, 1)] = KEY_BACK, /* B */
[KEYMAP_INDEX(2, 2)] = KEY_0,
[KEYMAP_INDEX(2, 3)] = 228, /* KEY_SHARP */
[KEYMAP_INDEX(2, 4)] = KEY_9,
[KEYMAP_INDEX(3, 0)] = KEY_3,
[KEYMAP_INDEX(3, 1)] = KEY_RIGHT,
[KEYMAP_INDEX(3, 2)] = KEY_VOLUMEUP,
/*[KEYMAP_INDEX(3, 3)] = ,*/
[KEYMAP_INDEX(3, 4)] = KEY_6,
[KEYMAP_INDEX(4, 0)] = 232, /* OK */
[KEYMAP_INDEX(4, 1)] = KEY_SOUND,
[KEYMAP_INDEX(4, 2)] = KEY_1,
[KEYMAP_INDEX(4, 3)] = KEY_SEND,
[KEYMAP_INDEX(4, 4)] = KEY_LEFT,
/*[KEYMAP_INDEX(5, 0)] = ,*/
[KEYMAP_INDEX(5, 1)] = 227, /* KEY_STAR */
[KEYMAP_INDEX(5, 2)] = 230, /* (SOFT2)2 */
[KEYMAP_INDEX(5, 3)] = KEY_MENU, /* 1 */
[KEYMAP_INDEX(5, 4)] = KEY_7,
#if SCAN_FUNCTION_KEYS
[KEYMAP_INDEX(6, 0)] = KEY_F5,
[KEYMAP_INDEX(6, 1)] = KEY_F4,
[KEYMAP_INDEX(6, 2)] = KEY_F3,
[KEYMAP_INDEX(6, 3)] = KEY_F2,
[KEYMAP_INDEX(6, 4)] = KEY_F1
#endif
};
static struct gpio_keypad_info halibut_keypad_info = {
.keymap = halibut_keymap,
.output_gpios = halibut_row_gpios,
.input_gpios = halibut_col_gpios,
.noutputs = ARRAY_SIZE(halibut_row_gpios),
.ninputs = ARRAY_SIZE(halibut_col_gpios),
.settle_time = 5 /* msec */,
.poll_time = 20 /* msec */,
.flags = GPIOKPF_DRIVE_INACTIVE,
};
void keypad_init(void)
{
gpio_keypad_init(&halibut_keypad_info);
}
@@ -0,0 +1,37 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared
PLATFORM := qsd8k
MEMBASE := 0x00000000 # SMI
MEMSIZE := 0x00100000 # 1MB
BASE_ADDR := 0x20000000
TAGS_ADDR := BASE_ADDR+0x00000100
KERNEL_ADDR := BASE_ADDR+0x00008000
RAMDISK_ADDR := BASE_ADDR+0x01000000
SCRATCH_ADDR := BASE_ADDR+0x04000000
KEYS_USE_GPIO_KEYPAD := 1
DEFINES += DISPLAY_SPLASH_SCREEN=1
DEFINES += DISPLAY_TYPE_MDDI=1
MODULES += \
dev/keys \
lib/ptable
DEFINES += \
SDRAM_SIZE=$(MEMSIZE) \
BASE_ADDR=$(BASE_ADDR) \
TAGS_ADDR=$(TAGS_ADDR) \
KERNEL_ADDR=$(KERNEL_ADDR) \
RAMDISK_ADDR=$(RAMDISK_ADDR) \
SCRATCH_ADDR=$(SCRATCH_ADDR)
OBJS += \
$(LOCAL_DIR)/init.o \
$(LOCAL_DIR)/atags.o \
$(LOCAL_DIR)/keypad.o
@@ -0,0 +1,30 @@
#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 ($(BUILD_NANDWRITE), 1)
APPSBOOTHDR_FILES :=
else
APPSBOOTHDR_FILES := appsboot.mbn
endif
APPSBOOTHEADER: $(APPSBOOTHDR_FILES)
appsboot.mbn: appsboothd.mbn $(OUTBIN)
cat $(APPSBOOTHEADER_DIR)/appsboothd.mbn $(OUTBIN) > $(APPSBOOTHEADER_DIR)/appsboot.mbn
rm -rf $(APPSBOOTHEADER_DIR)/appsboothd.mbn
appsboothd.mbn: mkheader $(OUTBIN)
$(SRC_DIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/appsboothd.mbn
mkheader: $(SRC_DIR)/mkheader.c
${COMPILER} $(SRC_DIR)/mkheader.c -o $(SRC_DIR)/mkheader
@@ -0,0 +1,55 @@
/* Copyright 2007, Google Inc. */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
int main(int argc, char *argv[])
{
struct stat s;
unsigned size, base;
unsigned magic[10];
int fd;
if(argc != 3) {
fprintf(stderr,"usage: mkheader <bin> <hdr>\n");
return -1;
}
if(stat(argv[1], &s)) {
perror("cannot stat binary");
return -1;
}
size = s.st_size;
base = 0;
magic[0] = 0x00000005; /* appsbl */
magic[1] = 0x00000002; /* nand */
magic[2] = 0x00000000;
magic[3] = base;
magic[4] = size;
magic[5] = size;
magic[6] = size + base;
magic[7] = 0x00000000;
magic[8] = size + base;
magic[9] = 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, sizeof(magic)) != sizeof(magic)) {
perror("cannot write header");
close(fd);
unlink(argv[2]);
return -1;
}
close(fd);
return 0;
}
@@ -0,0 +1,82 @@
/* Copyright (c) 2009, The Linux Foundation. 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 The Linux Foundation nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <reg.h>
#define EBI1_SIZE1 0x0E800000 //232MB for 256/512/1024MB RAM
#define EBI1_ADDR1 0x20000000
#define EBI1_SIZE2_512M 0x10000000 //256MB for 512MB RAM
#define EBI1_SIZE2_1G 0x30000000 //768MB for 1GB RAM
#define EBI1_ADDR2 0x30000000
static unsigned check_1gb_mem()
{
// check for 1GB
unsigned adr1 = 0x57000000;
unsigned adr2 = 0x5F000000;
unsigned value1 = 0x55555555;
unsigned value2 = 0xAAAAAAAA;
writel(value1, adr1);
writel(value2, adr2);
return ((value1 == readl(adr1)) && (value2 == readl(adr2)));
}
unsigned* target_atag_mem(unsigned* ptr)
{
unsigned size;
/* ATAG_MEM */
/* 1st segment */
*ptr++ = 4;
*ptr++ = 0x54410002;
*ptr++ = EBI1_SIZE1;
*ptr++ = EBI1_ADDR1;
/* 2nd segment */
#ifdef USE_512M_RAM
size = EBI1_SIZE2_512M;
#else
size = 0;
#endif
if (check_1gb_mem()) {
size = EBI1_SIZE2_1G;
}
if (size > 0) {
*ptr++ = 4;
*ptr++ = 0x54410002;
*ptr++ = size;
*ptr++ = EBI1_ADDR2;
}
return ptr;
}
@@ -0,0 +1,47 @@
/* Copyright (c) 2010, The Linux Foundation. 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 The Linux Foundation 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_QSD8250_SURF_DISPLAY_H
#define _TARGET_QSD8250_SURF_DISPLAY_H
#define TARGET_XRES 800
#define TARGET_YRES 480
#define LCDC_FB_WIDTH 800
#define LCDC_FB_HEIGHT 480
#define LCDC_HSYNC_PULSE_WIDTH_DCLK 60
#define LCDC_HSYNC_BACK_PORCH_DCLK 81
#define LCDC_HSYNC_FRONT_PORCH_DCLK 81
#define LCDC_HSYNC_SKEW_DCLK 0
#define LCDC_VSYNC_PULSE_WIDTH_LINES 2
#define LCDC_VSYNC_BACK_PORCH_LINES 20
#define LCDC_VSYNC_FRONT_PORCH_LINES 27
#endif
@@ -0,0 +1,183 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009-2011, The Linux Foundation. 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 <dev/keys.h>
#include <dev/gpio_keypad.h>
#include <lib/ptable.h>
#include <dev/flash.h>
#include <smem.h>
#include <platform.h>
#define LINUX_MACHTYPE 2708
#define VARIABLE_LENGTH 0x10101010
#define DIFF_START_ADDR 0xF0F0F0F0
#define NUM_PAGES_PER_BLOCK 0x40
static struct ptable flash_ptable;
/* for these partitions, start will be offset by either what we get from
* smem, or from the above offset if smem is not useful. Also, we should
* probably have smem_ptable code populate our flash_ptable.
*
* When smem provides us with a full partition table, we can get rid of
* this altogether.
*
*/
static struct ptentry board_part_list[] = {
{
.start = 0,
.length = 5 /* In MB */,
.name = "boot",
},
{
.start = DIFF_START_ADDR,
.length = 100 /* In MB */,
.name = "system",
},
{
.start = DIFF_START_ADDR,
.length = 30 /* In MB */,
.name = "cache",
},
{
.start = DIFF_START_ADDR,
.length = 1 /* In MB */,
.name = "misc",
},
{
.start = DIFF_START_ADDR,
.length = VARIABLE_LENGTH,
.name = "userdata",
},
{
.start = DIFF_START_ADDR,
.length = 5 /* In MB */,
.name = "recovery",
},
};
static int num_parts = sizeof(board_part_list)/sizeof(struct ptentry);
void smem_ptable_init(void);
unsigned smem_get_apps_flash_start(void);
void keypad_init(void);
void target_init(void)
{
unsigned offset;
struct flash_info *flash_info;
unsigned total_num_of_blocks;
unsigned next_ptr_start_adr = 0;
unsigned blocks_per_1MB = 8; /* Default value of 2k page size on 256MB flash drive*/
int i;
dprintf(INFO, "target_init()\n");
#if (!ENABLE_NANDWRITE)
keys_init();
keypad_init();
#endif
ptable_init(&flash_ptable);
smem_ptable_init();
flash_init();
flash_info = flash_get_info();
ASSERT(flash_info);
offset = smem_get_apps_flash_start();
if (offset == 0xffffffff)
while(1);
total_num_of_blocks = flash_info->num_blocks;
blocks_per_1MB = (1 << 20) / (flash_info->block_size);
for (i = 0; i < num_parts; i++) {
struct ptentry *ptn = &board_part_list[i];
unsigned len = ((ptn->length) * blocks_per_1MB);
if(ptn->start != 0)
ASSERT(ptn->start == DIFF_START_ADDR);
ptn->start = next_ptr_start_adr;
if(ptn->length == VARIABLE_LENGTH)
{
unsigned length_for_prt = 0;
unsigned j;
for (j = i+1; j < num_parts; j++)
{
struct ptentry *temp_ptn = &board_part_list[j];
ASSERT(temp_ptn->length != VARIABLE_LENGTH);
length_for_prt += ((temp_ptn->length) * blocks_per_1MB);
}
len = (total_num_of_blocks - 1) - (offset + ptn->start + length_for_prt);
ASSERT(len >= 0);
}
next_ptr_start_adr = ptn->start + len;
ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
len, ptn->flags, TYPE_APPS_PARTITION, PERM_WRITEABLE);
}
smem_add_modem_partitions(&flash_ptable);
ptable_dump(&flash_ptable);
flash_set_ptable(&flash_ptable);
}
unsigned board_machtype(void)
{
return LINUX_MACHTYPE;
}
void reboot_device(unsigned reboot_reason)
{
reboot(reboot_reason);
}
unsigned check_reboot_mode(void)
{
unsigned mode[2] = {0, 0};
unsigned int mode_len = sizeof(mode);
unsigned smem_status;
smem_status = smem_read_alloc_entry(SMEM_APPS_BOOT_MODE,
&mode, mode_len );
if(smem_status)
{
dprintf(CRITICAL, "ERROR: unable to read shared memory for reboot mode\n");
return 0;
}
return mode[0];
}
@@ -0,0 +1,112 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009, The Linux Foundation. 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 <dev/keys.h>
#include <dev/gpio_keypad.h>
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
/* don't turn this on without updating the ffa support */
#define SCAN_FUNCTION_KEYS 0
static unsigned int halibut_row_gpios[] = {
31, 32, 33, 34, 35, 41
#if SCAN_FUNCTION_KEYS
, 42
#endif
};
static unsigned int halibut_col_gpios[] = { 36, 37, 38, 39, 40 };
#define KEYMAP_INDEX(row, col) ((row)*ARRAY_SIZE(halibut_col_gpios) + (col))
static const unsigned short halibut_keymap[ARRAY_SIZE(halibut_col_gpios) * ARRAY_SIZE(halibut_row_gpios)] = {
[KEYMAP_INDEX(0, 0)] = KEY_5,
[KEYMAP_INDEX(0, 1)] = KEY_9,
[KEYMAP_INDEX(0, 2)] = KEY_SOFT1,
[KEYMAP_INDEX(0, 3)] = KEY_6,
[KEYMAP_INDEX(0, 4)] = KEY_LEFT,
[KEYMAP_INDEX(1, 0)] = KEY_0,
[KEYMAP_INDEX(1, 1)] = KEY_RIGHT,
[KEYMAP_INDEX(1, 2)] = KEY_1,
[KEYMAP_INDEX(1, 3)] = KEY_SHARP,
[KEYMAP_INDEX(1, 4)] = KEY_SEND,
[KEYMAP_INDEX(2, 0)] = KEY_VOLUMEUP,
[KEYMAP_INDEX(2, 1)] = KEY_HOME, /* FA */
[KEYMAP_INDEX(2, 2)] = KEY_F8, /* QCHT */
[KEYMAP_INDEX(2, 3)] = KEY_F6, /* R+ */
[KEYMAP_INDEX(2, 4)] = KEY_F7, /* R- */
[KEYMAP_INDEX(3, 0)] = KEY_UP,
[KEYMAP_INDEX(3, 1)] = KEY_CLEAR,
[KEYMAP_INDEX(3, 2)] = KEY_4,
[KEYMAP_INDEX(3, 3)] = KEY_MUTE, /* SPKR */
[KEYMAP_INDEX(3, 4)] = KEY_2,
[KEYMAP_INDEX(4, 0)] = KEY_SOFT2, /* SOFT2 */
[KEYMAP_INDEX(4, 1)] = KEY_CENTER, /* KEY_CENTER */
[KEYMAP_INDEX(4, 2)] = KEY_DOWN,
[KEYMAP_INDEX(4, 3)] = KEY_BACK, /* FB */
[KEYMAP_INDEX(4, 4)] = KEY_8,
[KEYMAP_INDEX(5, 0)] = KEY_VOLUMEDOWN,
[KEYMAP_INDEX(5, 1)] = KEY_STAR, /* KEY_STAR */
[KEYMAP_INDEX(5, 2)] = KEY_MAIL, /* MESG */
[KEYMAP_INDEX(5, 3)] = KEY_3,
[KEYMAP_INDEX(5, 4)] = KEY_7,
#if SCAN_FUNCTION_KEYS
[KEYMAP_INDEX(6, 0)] = KEY_F5,
[KEYMAP_INDEX(6, 1)] = KEY_F4,
[KEYMAP_INDEX(6, 2)] = KEY_F3,
[KEYMAP_INDEX(6, 3)] = KEY_F2,
[KEYMAP_INDEX(6, 4)] = KEY_F1
#endif
};
static struct gpio_keypad_info halibut_keypad_info = {
.keymap = halibut_keymap,
.output_gpios = halibut_row_gpios,
.input_gpios = halibut_col_gpios,
.noutputs = ARRAY_SIZE(halibut_row_gpios),
.ninputs = ARRAY_SIZE(halibut_col_gpios),
.settle_time = 5 /* msec */,
.poll_time = 20 /* msec */,
.flags = GPIOKPF_DRIVE_INACTIVE,
};
void keypad_init(void)
{
gpio_keypad_init(&halibut_keypad_info);
}
@@ -0,0 +1,37 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared
PLATFORM := qsd8k
MEMBASE := 0x00000000 # SMI
MEMSIZE := 0x00100000 # 1MB
BASE_ADDR := 0x20000000
TAGS_ADDR := BASE_ADDR+0x00000100
KERNEL_ADDR := BASE_ADDR+0x00008000
RAMDISK_ADDR := BASE_ADDR+0x01000000
SCRATCH_ADDR := BASE_ADDR+0x04000000
KEYS_USE_GPIO_KEYPAD := 1
DEFINES += DISPLAY_SPLASH_SCREEN=1
DEFINES += DISPLAY_TYPE_LCDC=1
MODULES += \
dev/keys \
lib/ptable
DEFINES += \
SDRAM_SIZE=$(MEMSIZE) \
BASE_ADDR=$(BASE_ADDR) \
TAGS_ADDR=$(TAGS_ADDR) \
KERNEL_ADDR=$(KERNEL_ADDR) \
RAMDISK_ADDR=$(RAMDISK_ADDR) \
SCRATCH_ADDR=$(SCRATCH_ADDR)
OBJS += \
$(LOCAL_DIR)/init.o \
$(LOCAL_DIR)/atags.o \
$(LOCAL_DIR)/keypad.o
@@ -0,0 +1,30 @@
#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 ($(BUILD_NANDWRITE), 1)
APPSBOOTHDR_FILES :=
else
APPSBOOTHDR_FILES := appsboot.mbn
endif
APPSBOOTHEADER: $(APPSBOOTHDR_FILES)
appsboot.mbn: appsboothd.mbn $(OUTBIN)
cat $(APPSBOOTHEADER_DIR)/appsboothd.mbn $(OUTBIN) > $(APPSBOOTHEADER_DIR)/appsboot.mbn
rm -rf $(APPSBOOTHEADER_DIR)/appsboothd.mbn
appsboothd.mbn: mkheader $(OUTBIN)
$(SRC_DIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/appsboothd.mbn
mkheader: $(SRC_DIR)/mkheader.c
${COMPILER} $(SRC_DIR)/mkheader.c -o $(SRC_DIR)/mkheader
@@ -0,0 +1,55 @@
/* Copyright 2007, Google Inc. */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
int main(int argc, char *argv[])
{
struct stat s;
unsigned size, base;
unsigned magic[10];
int fd;
if(argc != 3) {
fprintf(stderr,"usage: mkheader <bin> <hdr>\n");
return -1;
}
if(stat(argv[1], &s)) {
perror("cannot stat binary");
return -1;
}
size = s.st_size;
base = 0;
magic[0] = 0x00000005; /* appsbl */
magic[1] = 0x00000002; /* nand */
magic[2] = 0x00000000;
magic[3] = base;
magic[4] = size;
magic[5] = size;
magic[6] = size + base;
magic[7] = 0x00000000;
magic[8] = size + base;
magic[9] = 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, sizeof(magic)) != sizeof(magic)) {
perror("cannot write header");
close(fd);
unlink(argv[2]);
return -1;
}
close(fd);
return 0;
}
@@ -0,0 +1,56 @@
/* Copyright (c) 2009-2010, The Linux Foundation. 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 The Linux Foundation nor
* the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include <reg.h>
#define EBI1_SIZE1 0x0E000000 //224M
#define EBI1_ADDR1 0x00000000
#define EBI1_SIZE2 0x30000000 //768M
#define EBI1_ADDR2 0x10000000
unsigned* target_atag_mem(unsigned* ptr)
{
unsigned size;
/* ATAG_MEM */
/* 1st segment */
*ptr++ = 4;
*ptr++ = 0x54410002;
*ptr++ = EBI1_SIZE1;
*ptr++ = EBI1_ADDR1;
/* 2nd segment */
*ptr++ = 4;
*ptr++ = 0x54410002;
*ptr++ = EBI1_SIZE2;
*ptr++ = EBI1_ADDR2;
return ptr;
}
@@ -0,0 +1,47 @@
/* Copyright (c) 2010, The Linux Foundation. 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 The Linux Foundation 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_QSD8650A_ST1X_DISPLAY_H
#define _TARGET_QSD8650A_ST1X_DISPLAY_H
#define TARGET_XRES 800
#define TARGET_YRES 480
#define LCDC_FB_WIDTH 800
#define LCDC_FB_HEIGHT 480
#define LCDC_HSYNC_PULSE_WIDTH_DCLK 60
#define LCDC_HSYNC_BACK_PORCH_DCLK 81
#define LCDC_HSYNC_FRONT_PORCH_DCLK 81
#define LCDC_HSYNC_SKEW_DCLK 0
#define LCDC_VSYNC_PULSE_WIDTH_LINES 2
#define LCDC_VSYNC_BACK_PORCH_LINES 20
#define LCDC_VSYNC_FRONT_PORCH_LINES 27
#endif
@@ -0,0 +1,201 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009-2011, The Linux Foundation. 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 <dev/keys.h>
#include <dev/gpio_keypad.h>
#include <lib/ptable.h>
#include <dev/flash.h>
#include <smem.h>
#include <platform.h>
#define LINUX_MACHTYPE 2627
#define VARIABLE_LENGTH 0x10101010
#define DIFF_START_ADDR 0xF0F0F0F0
#define NUM_PAGES_PER_BLOCK 0x40
static struct ptable flash_ptable;
/* for these partitions, start will be offset by either what we get from
* smem, or from the above offset if smem is not useful. Also, we should
* probably have smem_ptable code populate our flash_ptable.
*
* When smem provides us with a full partition table, we can get rid of
* this altogether.
*
*/
static struct ptentry board_part_list[] = {
{
.start = 0,
.length = 40 /* 5MB */,
.name = "boot",
},
{
.start = 40,
.length = 800 /* 100MB */,
.name = "system",
},
{
.start = 840,
.length = 240 /* 30MB */,
.name = "cache",
},
{
.start = 1080,
.length = 3 /* 384KB */,
.name = "misc",
},
{
.start = 1083,
.length = VARIABLE_LENGTH,
.name = "userdata",
},
{
.start = DIFF_START_ADDR,
.length = 40 /* 5MB */,
.name = "recovery",
},
};
static int num_parts = sizeof(board_part_list)/sizeof(struct ptentry);
void smem_ptable_init(void);
unsigned smem_get_apps_flash_start(void);
void usb_charger_change_state(void);
void usb_charger_reset(void);
void usb_stop_charging(unsigned);
void keypad_init(void);
void target_init(void)
{
unsigned offset;
struct flash_info *flash_info;
unsigned total_num_of_blocks;
bool start_addr_changed = false;
unsigned next_ptr_start_adr = 0;
int i;
dprintf(INFO, "target_init()\n");
#if (!ENABLE_NANDWRITE)
keys_init();
keypad_init();
#endif
ptable_init(&flash_ptable);
smem_ptable_init();
flash_init();
flash_info = flash_get_info();
ASSERT(flash_info);
offset = smem_get_apps_flash_start();
if (offset == 0xffffffff)
while(1);
total_num_of_blocks = flash_info->num_blocks;
for (i = 0; i < num_parts; i++) {
struct ptentry *ptn = &board_part_list[i];
unsigned len = ptn->length;
if(len == VARIABLE_LENGTH)
{
start_addr_changed = true;
unsigned length_for_prt = 0;
unsigned j;
for (j = i+1; j < num_parts; j++)
{
struct ptentry *temp_ptn = &board_part_list[j];
ASSERT(temp_ptn->length != VARIABLE_LENGTH);
length_for_prt += temp_ptn->length;
}
len = (total_num_of_blocks - 1) - (offset + ptn->start + length_for_prt);
ASSERT(len >= 0);
next_ptr_start_adr = ptn->start + len;
}
if((ptn->start == DIFF_START_ADDR) && (start_addr_changed))
{
ASSERT(next_ptr_start_adr);
ptn->start = next_ptr_start_adr;
next_ptr_start_adr = ptn->start + ptn->length;
}
ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
len, ptn->flags, TYPE_APPS_PARTITION, PERM_WRITEABLE);
}
smem_add_modem_partitions(&flash_ptable);
ptable_dump(&flash_ptable);
flash_set_ptable(&flash_ptable);
}
unsigned board_machtype(void)
{
return LINUX_MACHTYPE;
}
void reboot_device(unsigned reboot_reason)
{
reboot(reboot_reason);
}
unsigned check_reboot_mode(void)
{
unsigned mode[2] = {0, 0};
unsigned int mode_len = sizeof(mode);
unsigned smem_status;
smem_status = smem_read_alloc_entry(SMEM_APPS_BOOT_MODE,
&mode, mode_len );
if(smem_status)
{
dprintf(CRITICAL, "ERROR: unable to read shared memory for reboot mode\n");
return 0;
}
return mode[0];
}
void target_battery_charging_enable(unsigned enable, unsigned disconnect)
{
if(disconnect){
usb_charger_reset();
return;
}
else
usb_stop_charging(!enable);
for(;;)
{
thread_sleep(10);
usb_charger_change_state();
}
}
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
* Copyright (c) 2009, The Linux Foundation. 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 <dev/keys.h>
#include <dev/gpio_keypad.h>
void keypad_init(void)
{
}
@@ -0,0 +1,38 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared
PLATFORM := qsd8650a
MEMBASE := 0xE0000000 # SMI
MEMSIZE := 0x00100000 # 1MB
BASE_ADDR := 0x00000000
TAGS_ADDR := BASE_ADDR+0x00000100
KERNEL_ADDR := BASE_ADDR+0x00008000
RAMDISK_ADDR := BASE_ADDR+0x04000000
SCRATCH_ADDR := BASE_ADDR+0x00008000
KEYS_USE_GPIO_KEYPAD := 1
DEFINES += ENABLE_BATTERY_CHARGING=0
DEFINES += NO_KEYPAD_DRIVER=1
MODULES += \
dev/keys \
lib/ptable
DEFINES += \
MEMBASE=$(MEMBASE) \
SDRAM_SIZE=$(MEMSIZE) \
BASE_ADDR=$(BASE_ADDR) \
TAGS_ADDR=$(TAGS_ADDR) \
KERNEL_ADDR=$(KERNEL_ADDR) \
RAMDISK_ADDR=$(RAMDISK_ADDR) \
SCRATCH_ADDR=$(SCRATCH_ADDR)
OBJS += \
$(LOCAL_DIR)/init.o \
$(LOCAL_DIR)/atags.o \
$(LOCAL_DIR)/keypad.o
@@ -0,0 +1,30 @@
#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 ($(BUILD_NANDWRITE), 1)
APPSBOOTHDR_FILES :=
else
APPSBOOTHDR_FILES := appsboot.mbn
endif
APPSBOOTHEADER: $(APPSBOOTHDR_FILES)
appsboot.mbn: appsboothd.mbn $(OUTBIN)
cat $(APPSBOOTHEADER_DIR)/appsboothd.mbn $(OUTBIN) > $(APPSBOOTHEADER_DIR)/appsboot.mbn
rm -rf $(APPSBOOTHEADER_DIR)/appsboothd.mbn
appsboothd.mbn: mkheader $(OUTBIN)
$(SRC_DIR)/mkheader $(OUTBIN) $(APPSBOOTHEADER_DIR)/appsboothd.mbn
mkheader: $(SRC_DIR)/mkheader.c
${COMPILER} $(SRC_DIR)/mkheader.c -o $(SRC_DIR)/mkheader
@@ -0,0 +1,55 @@
/* Copyright 2007, Google Inc. */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
int main(int argc, char *argv[])
{
struct stat s;
unsigned size, base;
unsigned magic[10];
int fd;
if(argc != 3) {
fprintf(stderr,"usage: mkheader <bin> <hdr>\n");
return -1;
}
if(stat(argv[1], &s)) {
perror("cannot stat binary");
return -1;
}
size = s.st_size;
base = 0xE0000000;
magic[0] = 0x00000005; /* appsbl */
magic[1] = 0x00000002; /* nand */
magic[2] = 0x00000000;
magic[3] = base;
magic[4] = size;
magic[5] = size;
magic[6] = size + base;
magic[7] = 0x00000000;
magic[8] = size + base;
magic[9] = 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, sizeof(magic)) != sizeof(magic)) {
perror("cannot write header");
close(fd);
unlink(argv[2]);
return -1;
}
close(fd);
return 0;
}
+6
View File
@@ -0,0 +1,6 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
OBJS += \
$(LOCAL_DIR)/init.o \
$(LOCAL_DIR)/target_display.o

Some files were not shown because too many files have changed in this diff Show More