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

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);
}

View File

@@ -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

View File

@@ -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

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;
}

View File

@@ -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);
}
}

View File

@@ -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

View File

@@ -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();
}
}

View File

@@ -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

View File

@@ -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;
}