Example #1
0
void platform_init(void)
{
#ifdef LK_PROFILING
    unsigned int time_nand_emmc;
    unsigned int time_load_logo;
    unsigned int time_bat_init;
    unsigned int time_backlight;
    unsigned int time_show_logo;
    unsigned int time_boot_mode;
    unsigned int time_sw_env;
    unsigned int time_platform_init;
    unsigned int time_env;
    unsigned int time_disp_init;
    unsigned int time_security_init;
    unsigned int time_RTC_boot_Check;

    time_platform_init = get_timer(0);
    time_nand_emmc = get_timer(0);
#endif

    dprintf(INFO, "platform_init()\n");

#ifdef DUMMY_AP
	dummy_ap_entry();
#endif

#ifdef MTK_EMMC_SUPPORT
    mmc_legacy_init(1);
#else
#ifndef MACH_FPGA
    nand_init();
    nand_driver_test();

#endif
#endif

#ifdef MTK_KERNEL_POWER_OFF_CHARGING
	if((g_boot_arg->boot_reason == BR_USB) && (upmu_is_chr_det() == KAL_FALSE))
	{
		printf("[%s] Unplugged Charger/Usb between Pre-loader and Uboot in Kernel Charging Mode, Power Off \n", __func__);
		mt6575_power_off();
	}
#endif

#ifdef LK_PROFILING
    printf("[PROFILE] ------- NAND/EMMC init takes %d ms -------- \n", get_timer(time_nand_emmc));
    time_env = get_timer(0);
#endif
	env_init();
	print_env();
#ifdef LK_PROFILING
	dprintf(INFO,"[PROFILE] ------- ENV init takes %d ms -------- \n", (int)get_timer(time_env));
#endif

#ifdef LK_PROFILING
		time_disp_init = get_timer(0);
#endif

	//FIXME: Disable for MT6582 FPGA Ealry Porting
 #ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
    if(lcm_params->type==LCM_TYPE_DSI && lcm_params->dsi.mode ==CMD_MODE)
	 mt_disp_init((void *)g_fb_base);
 #endif
#ifdef LK_PROFILING
	 dprintf(INFO,"[PROFILE] ------- disp init takes %d ms -------- \n", (int)get_timer(time_disp_init));
#endif


#ifdef LK_PROFILING
                time_load_logo = get_timer(0);
#endif

#ifdef CONFIG_CFB_CONSOLE
		//FIXME: Disable for MT6582 FPGA Ealry Porting
    #ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
		drv_video_init();
    #endif
#endif

    //#endif
    #ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
    mboot_common_load_logo((unsigned long)mt_get_logo_db_addr(), "logo");
    dprintf(INFO, "Show BLACK_PICTURE\n");
    #endif

    //FIXME: Disable for MT6582 FPGA Ealry Porting
    #ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
#ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
    if(!is_low_battery(0))
    {
#endif
    mt_disp_fill_rect(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT, 0x0);
    mt_disp_power(TRUE);
    mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
    mt_disp_wait_idle();
    mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
    mt_disp_wait_idle();
    mt_disp_power(1);           //power on display related modules
#ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
    }
#endif
    #endif

#ifdef LK_PROFILING
    printf("[PROFILE] ------- load_logo takes %d ms -------- \n", get_timer(time_load_logo));
    time_backlight = get_timer(0);
#endif

    /*for kpd pmic mode setting*/
    set_kpd_pmic_mode();

    //FIXME: Disable for MT6582 FPGA Ealry Porting
    //#ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
#ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
    if(!is_low_battery(0))
    {
#endif
		/*some lcm panel need more time to start show picture*/	
		msleep(50);
    	mt65xx_backlight_on();
#ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
    }
#endif
    //#endif

#ifdef LK_PROFILING
    printf("[PROFILE] ------- backlight takes %d ms -------- \n", get_timer(time_backlight));
    time_boot_mode = get_timer(0);
#endif

    boot_mode_select();

#ifdef LK_PROFILING
    printf("[PROFILE] ------- boot mode select takes %d ms -------- \n", get_timer(time_boot_mode));
#endif


#ifdef MTK_SECURITY_SW_SUPPORT
    #ifdef LK_PROFILING
        time_security_init = get_timer(0);
    #endif
    /* initialize security library */
#ifdef MTK_EMMC_SUPPORT
    sec_func_init(1);
#else
    sec_func_init(0);
#endif
    #ifdef LK_PROFILING
    dprintf(INFO,"[PROFILE] ------- Security init takes %d ms -------- \n", (int)get_timer(time_security_init));
    #endif
#endif


    /*Show download logo & message on screen */
    if (g_boot_arg->boot_mode == DOWNLOAD_BOOT)
    {
	printf("[LK] boot mode is DOWNLOAD_BOOT\n");

#ifdef MTK_SECURITY_SW_SUPPORT
	/* verify da before jumping to da*/
	if (sec_usbdl_enabled()) {
	    u8  *da_addr = (u8 *)g_boot_arg->da_info.addr;
	    u32 da_len   = g_boot_arg->da_info.len;
	    u32 sig_len  = g_boot_arg->da_info.sig_len;
	    u8  *sig_addr = (unsigned char *)da_addr + (da_len - sig_len);

	    if (da_len == 0 || sig_len == 0) {
		printf("[LK] da argument is invalid\n");
		printf("da_addr = 0x%x\n", da_addr);
		printf("da_len  = 0x%x\n", da_len);
		printf("sig_len = 0x%x\n", sig_len);
	    }

	    if (sec_usbdl_verify_da(da_addr, (da_len - sig_len), sig_addr, sig_len)) {
		/* da verify fail */
                video_printf(" => Not authenticated tool, download stop...\n");
		while(1); /* fix me, should not be infinite loop in lk */
	    }
	}
	else
#endif
	{
	    printf(" DA verification disabled...\n");
	}
        mt_disp_show_boot_logo();
        video_printf(" => Downloading...\n");
        mt65xx_backlight_on();
        mtk_wdt_disable();//Disable wdt before jump to DA
        platform_uninit();
#ifdef HAVE_CACHE_PL310
        l2_disable();
#endif

#ifdef ENABLE_L2_SHARING
        config_shared_SRAM_size();
#endif
        arch_disable_cache(UCACHE);
        arch_disable_mmu();
        jump_da(g_boot_arg->da_info.addr, g_boot_arg->da_info.arg1, g_boot_arg->da_info.arg2);
    }

#ifdef LK_PROFILING
    time_bat_init = get_timer(0);
#endif

    mt65xx_bat_init();

#ifdef LK_PROFILING
    printf("[PROFILE] ------- battery init takes %d ms -------- \n", get_timer(time_bat_init));
#endif

#ifndef CFG_POWER_CHARGING
    #ifdef LK_PROFILING
    time_RTC_boot_Check = get_timer(0);
    #endif
    /* NOTE: if define CFG_POWER_CHARGING, will rtc_boot_check() in mt65xx_bat_init() */
    rtc_boot_check(false);
    #ifdef LK_PROFILING
    dprintf(INFO,"[PROFILE] ------- RTC boot check Init  takes %d ms -------- \n", (int)get_timer(time_RTC_boot_Check));
    #endif
#endif

#ifdef LK_PROFILING
    time_show_logo = get_timer(0);
#endif

#ifdef MTK_KERNEL_POWER_OFF_CHARGING
	if(kernel_charging_boot() == 1)
	{
#ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
		CHARGER_TYPE CHR_Type_num = CHARGER_UNKNOWN;
		charging_get_charger_type(&CHR_Type_num);
		if ((g_boot_mode != LOW_POWER_OFF_CHARGING_BOOT) ||
		((CHR_Type_num != STANDARD_HOST) && (CHR_Type_num != NONSTANDARD_CHARGER)))
		{
			dprintf(INFO, "[PROFILE] ------- g_boot_mode = %d -------- \n", g_boot_mode);
#endif
		mt_disp_power(TRUE);
		mt_disp_show_low_battery();
		mt_disp_wait_idle();
		mt65xx_leds_brightness_set(6, 110);
#ifdef MTK_BATLOWV_NO_PANEL_ON_EARLY
		}
#endif
	}
	else if(g_boot_mode != KERNEL_POWER_OFF_CHARGING_BOOT && g_boot_mode != LOW_POWER_OFF_CHARGING_BOOT)
	{
#ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
		if (g_boot_mode != ALARM_BOOT && (g_boot_mode != FASTBOOT))
		{
			mt_disp_show_boot_logo();
		}
#endif
	}
#else
#ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
	if (g_boot_mode != ALARM_BOOT && (g_boot_mode != FASTBOOT))
	{
		mt_disp_show_boot_logo();
	}
#endif
#endif

#ifdef LK_PROFILING
    printf("[PROFILE] ------- show logo takes %d ms -------- \n", get_timer(time_show_logo));
    time_sw_env= get_timer(0);
#endif

    //sw_env();

#ifdef LK_PROFILING
    printf("[PROFILE] ------- sw_env takes %d ms -------- \n", get_timer(time_sw_env));
    printf("[PROFILE] ------- platform_init takes %d ms -------- \n", get_timer(time_platform_init));
#endif
}
Example #2
0
void platform_init(void)
{
    u32 ret, tmp;
    boot_reason_t reason;
	
    /* init watch dog, will enable AP watch dog */
    mtk_wdt_init();
    /*init kpd PMIC mode support*/
    set_kpd_pmic_mode();


#if CFG_MDWDT_DISABLE 
    /* no need to disable MD WDT, the code here is for backup reason */

    /* disable MD0 watch dog. */
    DRV_WriteReg32(0x20050000, 0x2200); 

    /* disable MD1 watch dog. */
    DRV_WriteReg32(0x30050020, 0x2200); 
#endif

//ALPS00427972, implement the analog register formula
    //Set the calibration after power on
    //Add here for eFuse, chip version checking -> analog register calibration
    mt_usb_calibraion();
//ALPS00427972, implement the analog register formula

    /* make usb11 phy enter savecurrent mode */
    mt_usb11_phy_savecurrent();

#if 1 /* FIXME */
    g_boot_reason = reason = platform_boot_status();

    if (reason == BR_RTC || reason == BR_POWER_KEY || reason == BR_USB || reason == BR_WDT || reason == BR_WDT_BY_PASS_PWK)
        rtc_bbpu_power_on();
#else

    g_boot_reason = BR_POWER_KEY;

#endif

    enable_PMIC_kpd_clock();
#if CFG_EMERGENCY_DL_SUPPORT
    /* check if to enter emergency download mode */
    if (mtk_detect_dl_keys()) {
        platform_emergency_download(CFG_EMERGENCY_DL_TIMEOUT_MS);
    }
#endif

    /* init memory */
    mt_mem_init();

#ifdef MTK_MT8193_SUPPORT   
	mt8193_init();
#endif

    /* init device storeage */
    ret = boot_device_init();
    print("%s Init Boot Device: %s(%d)\n", MOD, ret ? "FAIL" : "OK", ret);

#if CFG_REBOOT_TEST
    mtk_wdt_sw_reset();
    while(1);
#endif

}
Example #3
0
void platform_init(void)
{

    /* init timer */
    //mtk_timer_init();
#ifdef LK_PROFILING
    unsigned int time_nand_emmc;
    unsigned int time_load_logo;
    unsigned int time_bat_init;
    unsigned int time_backlight;
    unsigned int time_show_logo;
    unsigned int time_boot_mode;
    unsigned int time_sw_env;
    unsigned int time_platform_init;
    unsigned int time_env;
    time_platform_init = get_timer(0);
    time_nand_emmc = get_timer(0);
#endif
    dprintf(INFO, "platform_init()\n");

#ifdef MTK_MT8193_SUPPORT
	mt8193_init();
#endif

#ifdef MTK_EMMC_SUPPORT
    mmc_legacy_init(1);
#else
    nand_init();
    nand_driver_test();
#endif
#ifdef MTK_KERNEL_POWER_OFF_CHARGING
	if((g_boot_arg->boot_reason == BR_USB) && (upmu_is_chr_det() == KAL_FALSE))
	{
		printf("[%s] Unplugged Charger/Usb between Pre-loader and Uboot in Kernel Charging Mode, Power Off \n", __func__);
		mt6575_power_off();
	}
#endif

#ifdef LK_PROFILING
    printf("[PROFILE] ------- NAND/EMMC init takes %d ms -------- \n", get_timer(time_nand_emmc));
    time_env = get_timer(0);
#endif
	env_init();
	print_env();
#ifdef LK_PROFILING
	printf("[PROFILE] ------- ENV init takes %d ms -------- \n", get_timer(time_env));
	time_load_logo = get_timer(0);
#endif
    mboot_common_load_logo((unsigned long)mt_get_logo_db_addr(), "logo");
#if ((!defined(MTK_NCP1851_SUPPORT)) && (!defined(MTK_BQ24196_SUPPORT)))    
    mt_disp_power(TRUE);           //power on display related modules
#endif    
    dprintf(INFO, "Show BLACK_PICTURE\n");
    mt_disp_fill_rect(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT, 0x0);
    mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
    mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
#ifdef LK_PROFILING
    printf("[PROFILE] ------- load_logo takes %d ms -------- \n", get_timer(time_load_logo));
    time_backlight = get_timer(0);
#endif

    /*for kpd pmic mode setting*/
    set_kpd_pmic_mode();
#if ((!defined(MTK_NCP1851_SUPPORT)) && (!defined(MTK_BQ24196_SUPPORT)))
    //mt65xx_backlight_on();
#endif    
#ifdef LK_PROFILING
    printf("[PROFILE] ------- backlight takes %d ms -------- \n", get_timer(time_backlight));
    time_boot_mode = get_timer(0);
#endif    
    enable_PMIC_kpd_clock();
    boot_mode_select();   
	
#ifdef LK_PROFILING
    printf("[PROFILE] ------- boot mode select takes %d ms -------- \n", get_timer(time_boot_mode));
#endif

    /* initialize security library */
#ifdef MTK_EMMC_SUPPORT
    sec_func_init(1);
#else
    sec_func_init(0);
#endif

    /*Show download logo & message on screen */
    if (g_boot_arg->boot_mode == DOWNLOAD_BOOT)
    {
	printf("[LK] boot mode is DOWNLOAD_BOOT\n");
	/* verify da before jumping to da*/
	if (sec_usbdl_enabled()) {
	    u8  *da_addr = g_boot_arg->da_info.addr;
	    u32 da_sig_len = DRV_Reg32(SRAMROM_BASE + 0x54);
	    u32 da_len   = da_sig_len >> 10;
	    u32 sig_len  = da_sig_len & 0x3ff;
	    u8  *sig_addr = (unsigned char *)da_addr + (da_len - sig_len);

	    if (da_len == 0 || sig_len == 0) {
		printf("[LK] da argument is invalid\n");
		printf("da_addr = 0x%x\n", da_addr);
		printf("da_len  = 0x%x\n", da_len);
		printf("sig_len = 0x%x\n", sig_len);
	    }

	    if (sec_usbdl_verify_da(da_addr, (da_len - sig_len), sig_addr, sig_len)) {
		/* da verify fail */    
                video_printf(" => Not authenticated tool, download stop...\n");
		DRV_WriteReg32(SRAMROM_BASE + 0x54, 0x0);
		while(1); /* fix me, should not be infinite loop in lk */
	    }
	}
	else {
void platform_init(void)
{
    u32 ret, tmp;
    boot_reason_t reason;
    #ifdef PL_PROFILING
    u32 profiling_time;
    profiling_time = 0;
    #endif


#if !defined(CFG_MEM_PRESERVED_MODE)
    #ifdef PL_PROFILING
    profiling_time = get_timer(0);
    #endif
    /* init watch dog, will enable AP watch dog */
    mtk_wdt_init();

    #ifdef PL_PROFILING
    printf("#T#wdt_init=%d\n", get_timer(profiling_time));
    profiling_time = get_timer(0);  //for next
    #endif
    /*init kpd PMIC mode support*/
    set_kpd_pmic_mode();

    #ifdef PL_PROFILING
    printf("#T#kpd_pmic=%d\n", get_timer(profiling_time));
    #endif
#else
    //Memory Preserved mode, disable WDT
    DRV_WriteReg32(0x10007000, 0x22000000);
#endif

#if CFG_MDWDT_DISABLE
    /* no need to disable MD WDT, the code here is for backup reason */
    /* disable MD0 watch dog. */
    DRV_WriteReg32(0x20050000, 0x2200);
#endif

#if !defined(CFG_MEM_PRESERVED_MODE)
    #ifdef PL_PROFILING
    profiling_time = get_timer(0);
    #endif
//ALPS00427972, implement the analog register formula
    //Set the calibration after power on
    //Add here for eFuse, chip version checking -> analog register calibration
    mt_usb_calibraion();
//ALPS00427972, implement the analog register formula

    /* make usb11 phy enter savecurrent mode */
    // USB11, USB host need it, 72 with host ip, but not list in feature list,
    // USB20, USB target for target,
    // access with UM (throught CPU) will mett all '?', means protect
    // access with PM (BUS, not CPU) will mett all '0', means clock or Power is gating
    //mt_usb11_phy_savecurrent();

    #ifdef PL_PROFILING
    printf("#T#usb calib=%d\n", get_timer(profiling_time));
    profiling_time = get_timer(0);  //for next
    #endif

    g_boot_reason = reason = platform_boot_status();
    if (reason == BR_RTC || reason == BR_POWER_KEY || reason == BR_USB || reason == BR_WDT || reason == BR_WDT_BY_PASS_PWK
#ifdef RTC_2SEC_REBOOT_ENABLE
        || reason == BR_2SEC_REBOOT
#endif //#ifdef RTC_2SEC_REBOOT_ENABLE
        )
        rtc_bbpu_power_on();

    #ifdef PL_PROFILING
    printf("#T#BR&bbpu on=%d\n", get_timer(profiling_time));
    profiling_time = get_timer(0);  //for next
    #endif
    enable_PMIC_kpd_clock();

    #ifdef PL_PROFILING
    printf("#T#enable PMIC kpd clk=%d\n", get_timer(profiling_time));
    #endif
#else
    rtc_bbpu_power_on();
#endif

#if !defined(CFG_MEM_PRESERVED_MODE)
#if CFG_EMERGENCY_DL_SUPPORT
    #ifdef PL_PROFILING
    profiling_time = get_timer(0);
    #endif
    /* check if to enter emergency download mode */
    if (mtk_detect_dl_keys()) {
        platform_emergency_download(CFG_EMERGENCY_DL_TIMEOUT_MS);
    }

    #ifdef PL_PROFILING
    printf("#T#chk_emgdwl=%d\n", get_timer(profiling_time));
    #endif
#endif

    #ifdef PL_PROFILING
    profiling_time = get_timer(0);
    #endif
    /* init memory */
    mt_mem_init();

    #ifdef PL_PROFILING
    printf("#T#mem_init&tst=%d\n", get_timer(profiling_time));
    #endif
#endif

#ifdef MTK_MT8193_SUPPORT
	mt8193_init();
#endif

    #ifdef PL_PROFILING
    profiling_time = get_timer(0);
    #endif
    /* init device storeage */
    ret = boot_device_init();
    print("%s Init Boot Device: %s(%d)\n", MOD, ret ? "FAIL" : "OK", ret);

    #ifdef PL_PROFILING
    printf("#T#bootdev_init=%d\n", get_timer(profiling_time));
    #endif
#if CFG_REBOOT_TEST
    mtk_wdt_sw_reset();
    while(1);
#endif

}