Esempio n. 1
0
BOOL boot_menu_key_trigger(void)
{
#if 1
	//wait
    ulong begin = get_timer(0);
    dprintf(CRITICAL,"\n%s Check  boot menu\n",MODULE_NAME);
    dprintf(CRITICAL,"%s Wait 50ms for special keys\n",MODULE_NAME);

    //let some case of recovery mode pass.
    if(unshield_recovery_detection())
    {
        return TRUE;
    }

    while(get_timer(begin)<50)
    {
		if(mtk_detect_key(MT65XX_BOOT_MENU_KEY))
		{
                           mtk_wdt_disable();
                           boot_mode_menu_select();
                           mtk_wdt_init();
                           return TRUE;
		}
    }
#endif
     return FALSE;
}
Esempio n. 2
0
BOOL boot_menu_key_trigger(void)
{
#if 1
	//wait
    ulong begin = get_timer(0);
    printf("\n%s Check  boot menu\n",MODULE_NAME);
    printf("%s Wait 50ms for special keys\n",MODULE_NAME);

    //let some case of recovery mode pass.
    if(unshield_recovery_detection())
    {
        return TRUE;
    }

    while(get_timer(begin)<50)
    {

	    //lingjinming modify for p210 you ni sen 2014 09 19
		#if defined(P201_UNISON_KEYPAD)
        if(pmic_detect_homekey())  
		#else
		
		if(mtk_detect_key(MT65XX_BOOT_MENU_KEY))
		#endif
		
		{
                           mtk_wdt_disable();
                           boot_mode_menu_select();
                           mtk_wdt_init();
                           return TRUE;
		}
    }
#endif
     return FALSE;
}
Esempio n. 3
0
static void bldr_wait_forever(void)
{
    /* prevent wdt timeout and clear usbdl flag */
    mtk_wdt_disable();
    platform_safe_mode(0, 0);
    print("bldr_wait_forever\n");
    while(1);
}
Esempio n. 4
0
void factory_cpus_idle_test(void)
{
    int cpu = 0;
    int i = 0;
    unsigned char name[10] = {'\0'};
    struct task_struct *thread[nr_cpu_ids];
#ifdef CONFIG_SMP
    int ret = 0;
#endif

    spin_lock(&factory_lock);
    cpu = smp_processor_id();
    spin_unlock(&factory_lock);
    dcm_info("[%s]: it's cpu%d, num_online_cpus=%d\n", __func__, cpu, num_online_cpus());

#ifdef CONFIG_SMP
    mutex_lock(&ftm_cpu_prepare);
    disable_hotplug_policy(true, nr_cpu_ids);
    for (i = 1; i < nr_cpu_ids; i++) {
        ret = cpu_up(i);
        dcm_info("[%s]cpu_up(cpu%d) return %d, cpu1_killed=%u\n", __func__, i, ret, cpu1_killed);
    }
    mutex_unlock(&ftm_cpu_prepare);
#endif

    mtk_wdt_disable(); // disable watch dog

    // turn off backlight
#if defined(CONFIG_MTK_LEDS)
    mt65xx_leds_brightness_set(MT65XX_LED_TYPE_LCD, 0);
#endif

    for (i = nr_cpu_ids-1; i >= 0; i--) {
        cpuid[i] = i;
        init_completion(&each_thread_done[i]);
        sprintf(name, "idle-%d", i);
        thread[i] = kthread_create(cpu_enter_wfi[i], &cpuid[i], name);
        if (IS_ERR(thread[i])) {
            int ret = PTR_ERR(thread[i]);
            thread[i] = NULL;
            dcm_info("[%s]: kthread_create %s fail(%d)\n", __func__, name, ret);
            return;
        }
        dcm_info("[%s]: kthread_create %s done\n", __func__, name);
        kthread_bind(thread[i], i);
        dcm_info("[%s]: kthread_bind %s done\n", __func__, name);
        wake_up_process(thread[i]);
        dcm_info("[%s]: wake_up_process %s done\n", __func__, name);
        wait_for_completion(&each_thread_done[i]);
    }
    dcm_info("[%s]: cpu%d starts to complete_all all_threads_done\n", __func__, cpu);
    complete_all(&all_threads_done);
}
void platform_init(void)
{
    dprintf(INFO, "platform_init()\n");

#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;
    time_platform_init = get_timer(0);
    time_nand_emmc = get_timer(0);
#endif

#ifdef MTK_EMMC_SUPPORT
    mmc_legacy_init(1);
#else
    nand_init();
    nand_driver_test();
#endif

#ifdef LK_PROFILING
    printf("[PROFILE] ------- NAND/EMMC init takes %d ms -------- \n", get_timer(time_nand_emmc));
    time_load_logo = get_timer(0);
#endif
    mboot_common_load_logo((unsigned long)mt_get_logo_db_addr(), "logo");
    dprintf(INFO, "Show BLACK_PICTURE\n");
    mt_disp_fill_rect(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT, 0x0);
    mt_disp_power(TRUE);
//<2012/11/14-Yuting Shih-[BU2SC00137502]Add for LOGO display.
#if 1
    mt_disp_show_boot_logo();
#else
    mt_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT);
    mt_disp_power(1);           //power on display related modules
#endif
//>2012/11/14-Yuting Shih-[BU2SC00137502].
#ifdef LK_PROFILING
    printf("[PROFILE] ------- load_logo takes %d ms -------- \n", get_timer(time_load_logo));
    time_backlight = get_timer(0);
#endif

    mt65xx_backlight_on();
#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
    /*Show download logo & message on screen */
    if (g_boot_arg->boot_mode == DOWNLOAD_BOOT)
    {
        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
        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

    /* NOTE: if define CFG_POWER_CHARGING, will rtc_boot_check() in mt65xx_bat_init() */
#ifndef CFG_POWER_CHARGING
    rtc_boot_check(false);
#endif

#ifdef LK_PROFILING
    time_show_logo = get_timer(0);
#endif
    if ((g_boot_mode != ALARM_BOOT) && (g_boot_mode != FASTBOOT))
    {
     printf("show log disable\n");
     mt_disp_show_boot_logo();
     printf("show log end\n");
    }
#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));
#endif
#ifdef LK_PROFILING
    printf("[PROFILE] ------- platform_init takes %d ms -------- \n", get_timer(time_platform_init));
#endif

}
Esempio n. 6
0
int fastboot_init(void *base, unsigned size)
{
	thread_t *thr;

	dprintf(ALWAYS, "fastboot_init()\n");

	download_base = base;
	download_max = size;

	mtk_wdt_disable(); /*It will re-enable during continue boot*/

	fastboot_register("getvar:", cmd_getvar, FALSE);
	fastboot_publish("version", "0.5");
#ifndef USER_BUILD
	fastboot_register("boot", cmd_boot, FALSE);
#endif
	fastboot_register("signature", cmd_install_sig, FALSE);

#ifdef MTK_EMMC_SUPPORT
	fastboot_register("flash:", cmd_flash_emmc, TRUE);
	#ifndef USER_BUILD
	fastboot_register("erase:", cmd_erase_emmc, FALSE);
	#endif
#else
	fastboot_register("flash:", cmd_flash_nand, TRUE);
	#ifndef USER_BUILD
	fastboot_register("erase:", cmd_erase_nand, FALSE);
	#endif
#endif

	fastboot_register("continue", cmd_continue, FALSE);
	fastboot_register("reboot", cmd_reboot, FALSE);
	fastboot_register("reboot-bootloader", cmd_reboot_bootloader, FALSE);
	fastboot_publish("product", TARGET(BOARD));
	fastboot_publish("kernel", "lk");
	//fastboot_publish("serialno", sn_buf);

	register_parition_var();


	/*LXO: Download related command*/
	fastboot_register("download:", cmd_download, TRUE);

	/*LXO: END!Download related command*/

	fastboot_oem_register();

    fastboot_register("oem p2u", cmd_oem_p2u, FALSE);
    fastboot_register("oem reboot-recovery",cmd_oem_reboot2recovery, FALSE);
	event_init(&usb_online, 0, EVENT_FLAG_AUTOUNSIGNAL);
	event_init(&txn_done, 0, EVENT_FLAG_AUTOUNSIGNAL);

	in = udc_endpoint_alloc(UDC_TYPE_BULK_IN, 512);
	if (!in)
		goto fail_alloc_in;
	out = udc_endpoint_alloc(UDC_TYPE_BULK_OUT, 512);
	if (!out)
		goto fail_alloc_out;

	fastboot_endpoints[0] = in;
	fastboot_endpoints[1] = out;

	req = udc_request_alloc();
	if (!req)
		goto fail_alloc_req;

	if (udc_register_gadget(&fastboot_gadget))
		goto fail_udc_register;

	thr = thread_create("fastboot", fastboot_handler, 0, DEFAULT_PRIORITY, 4096);
	if (!thr)
	{
		goto fail_alloc_in;
	}
	thread_resume(thr);
	return 0;

fail_udc_register:
	udc_request_free(req);
fail_alloc_req:
	udc_endpoint_free(out);
fail_alloc_out:
	udc_endpoint_free(in);
fail_alloc_in:
	return -1;
}
Esempio n. 7
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
}
Esempio n. 8
0
//#define PMIC_WRAP_PORTING //only for lk early porting
void platform_early_init(void)
{
#ifdef LK_PROFILING
    unsigned int time_led_init;
    unsigned int time_pmic6329_init;
    unsigned int time_platform_early_init;
    unsigned int time_repair_sram;
    unsigned int time_display_early_init;
    unsigned int time_wdt_early_init;
    time_platform_early_init = get_timer(0);
#endif
    /* initialize the uart */
    uart_init_early();
    platform_init_interrupts();
    platform_early_init_timer();
    mt_gpio_set_default();

    #ifdef REPAIR_SRAM_ENABLE_LK_FOR_82_BRINGUP
    #ifdef LK_PROFILING
    time_repair_sram = get_timer(0);
    #endif
    int repair_ret;
    repair_ret = repair_sram();
    if(repair_ret != 0)
    {
        printf("Sram repair failed %d\n", repair_ret);
        while(1);
    }
    #ifdef LK_PROFILING
    dprintf(INFO,"[PROFILE] ------- Repair SRAM takes %d ms -------- \n",(int) get_timer(time_repair_sram));
    #endif
    #endif
    //i2c_v1_init();
    #ifdef LK_PROFILING
    time_wdt_early_init = get_timer(0);
    #endif
    mtk_wdt_init();
    #ifdef LK_PROFILING
    dprintf(INFO,"[PROFILE] ------- WDT Init  takes %d ms -------- \n", (int)get_timer(time_wdt_early_init));
    #endif
// WDT will be triggered when uncompressing linux image on FPGA
#ifdef MACH_FPGA
    mtk_wdt_disable();
#endif
#ifdef MTK_MT8193_SUPPORT
	mt8193_init();
#endif
/* initialize the frame buffet information */
//FIXME: Disable for MT6582 FPGA Ealry Porting
#ifndef DISABLE_DISPLAY_IN_LK_FOR_82_BRINGUP
    #ifdef LK_PROFILING
    time_display_early_init = get_timer(0);
    #endif
    g_fb_size = mt_disp_get_vram_size();
    g_fb_base = memory_size() - g_fb_size + DRAM_PHY_ADDR;
    dprintf(INFO, "FB base = 0x%x, FB size = %d\n", g_fb_base, g_fb_size);
    #ifdef LK_PROFILING
    dprintf(INFO,"[PROFILE] ------- Display eraly init takes %d ms -------- \n", (int)get_timer(time_display_early_init));
    #endif
#endif


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

#ifndef MACH_FPGA
    leds_init();
#endif

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

    isink0_init();              //turn on PMIC6329 isink0


    //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 PMIC_WRAP_PORTING
    pwrap_init_lk();
    pwrap_init_for_early_porting();
#endif

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

    pmic_init();

#ifdef LK_PROFILING
    printf("[PROFILE] ------- pmic_init takes %d ms -------- \n", get_timer(time_pmic6329_init));
    printf("[PROFILE] ------- platform_early_init takes %d ms -------- \n", get_timer(time_platform_early_init));
#endif
}
Esempio n. 9
0
void factory_cpu0_idle_test(void)
{
    int cpu = 0;
#ifdef CONFIG_SMP
    int i = 0;
    int ret = 0;
    int cpu_pwrdn_flag[nr_cpu_ids];
#endif

    spin_lock(&factory_lock);
    cpu = smp_processor_id();
    spin_unlock(&factory_lock);

    printk("[%s]it's cpu%d\n", __func__, cpu);

#ifdef CONFIG_SMP
    mutex_lock(&ftm_cpu_prepare);
    disable_hotplug_policy(true, nr_cpu_ids);
    memset(cpu_pwrdn_flag, 0, nr_cpu_ids * sizeof(int));
    for (i = 1; i < nr_cpu_ids; i++) {
        if (cpu_online(i)) {
            cpu_pwrdn_flag[i] = 1;
            ret = cpu_down(i);
            dcm_info("[%s]cpu_down(cpu%d) return %d, cpu1_killed=%u\n", __func__, i, ret, cpu1_killed);
        } else {
            dcm_info("[%s]no need to power down cpu%d\n", __func__, i);
        }
    }
    mutex_unlock(&ftm_cpu_prepare);
#endif

#ifdef CONFIG_LOCAL_WDT
    mpcore_wk_wdt_stop();
#endif
    mtk_wdt_disable(); // disable watch dog
    
    //this should be set by low power requirement.
#ifdef IDLE_LOW_POWER_TEST
    enable_low_power_settings();
#endif
    local_irq_disable();
    go_to_idle();
    local_irq_enable();
#ifdef IDLE_LOW_POWER_TEST
    disable_low_power_settings();
#endif

#ifdef CONFIG_SMP
    mutex_lock(&ftm_cpu_prepare);
    for (i = 1; i < nr_cpu_ids; i++) {
        if (cpu_pwrdn_flag[i] == 1) {
            ret = cpu_up(i);
            dcm_info("[%s]cpu_up(cpu%d) return %d, cpu1_killed=%u\n", __func__, i, ret, cpu1_killed);
        } else {
            dcm_info("[%s]no need to power up cpu%d\n", __func__, i);
        }
    }
    disable_hotplug_policy(false, nr_cpu_ids);
    mutex_unlock(&ftm_cpu_prepare);
#endif
}
Esempio n. 10
0
void boot_mode_select(void)
{

    int factory_forbidden = 0;
  //  int forbid_mode;
/*We put conditions here to filer some cases that can not do key detection*/
    extern int kedump_mini(void) __attribute__((weak));
    if (kedump_mini) {
      if (kedump_mini())
	return;
    }
    if (meta_detection())
    {
      return;
    }
    if (aee_kdump_detection())
    {
	return;
    }
#if defined (HAVE_LK_TEXT_MENU)
/*Check RTC to know if system want to reboot to Fastboot*/
    if(Check_RTC_PDN1_bit13())
    {
     dprintf(CRITICAL, "[FASTBOOT] reboot to boot loader\n");
      g_boot_mode = FASTBOOT;
      Set_Clr_RTC_PDN1_bit13(false);
          return;
    }
    /*If forbidden mode is factory, cacel the factory key detection*/
    if(g_boot_arg->sec_limit.magic_num == 0x4C4C4C4C)
    {
        if(g_boot_arg->sec_limit.forbid_mode == F_FACTORY_MODE)
        {
            //Forbid to enter factory mode
           dprintf(CRITICAL, "%s Forbidden\n",MODULE_NAME);
            factory_forbidden=1;
        }
    }
  //  forbid_mode = g_boot_arg->boot_mode &= 0x000000FF;
    /*If boot reason is power key + volumn down, then
     disable factory mode dectection*/
    if(mtk_detect_pmic_just_rst())
    {
          factory_forbidden=1;
    }
    /*Check RTC to know if system want to reboot to Recovery*/
    if(Check_RTC_Recovery_Mode())
    {
          g_boot_mode = RECOVERY_BOOT;
          return;
    }
    /*If MISC Write has not completed  in recovery mode
     before system reboot, go to recovery mode to
    finish remain tasks*/
    if(unshield_recovery_detection())
    {
        return;
    }
    ulong begin = get_timer(0);

/*we put key dectection here to detect key which is pressed*/
   dprintf(INFO, "eng build\n");
#ifdef MT65XX_FACTORY_KEY
   dprintf(CRITICAL, "MT65XX_FACTORY_KEY 0x%x\n",MT65XX_FACTORY_KEY);
#endif
#ifdef MT65XX_BOOT_MENU_KEY
   dprintf(CRITICAL, "MT65XX_BOOT_MENU_KEY 0x%x\n",MT65XX_BOOT_MENU_KEY);
#endif
#ifdef MT65XX_RECOVERY_KEY
   dprintf(CRITICAL, "MT65XX_RECOVERY_KEY 0x%x\n",MT65XX_RECOVERY_KEY);
#endif
    while(get_timer(begin)<50)
    {


        if(!factory_forbidden){
                   if(mtk_detect_key(MT65XX_FACTORY_KEY))
                   {
                         dprintf(CRITICAL, "%s Detect key\n",MODULE_NAME);
                         dprintf(CRITICAL, "%s Enable factory mode\n",MODULE_NAME);
                          g_boot_mode = FACTORY_BOOT;
                          //video_printf("%s : detect factory mode !\n",MODULE_NAME);
                          return;
                   }
        }
#if MT65XX_BOOT_MENU_KEY
        if(mtk_detect_key(MT65XX_BOOT_MENU_KEY))
         {
                          dprintf(CRITICAL, "\n%s Check  boot menu\n",MODULE_NAME);
                          dprintf(CRITICAL, "%s Wait 50ms for special keys\n",MODULE_NAME);
                          mtk_wdt_disable();
                          /*************************/
                          mt65xx_backlight_on();
                          /*************************/
                           boot_mode_menu_select();
                           mtk_wdt_init();
                           return;
         }
#endif
#ifdef MT65XX_RECOVERY_KEY
            if(mtk_detect_key(MT65XX_RECOVERY_KEY))
           {
               dprintf(CRITICAL, "%s Detect cal key\n",MODULE_NAME);
               dprintf(CRITICAL, "%s Enable recovery mode\n",MODULE_NAME);
                g_boot_mode = RECOVERY_BOOT;
                //video_printf("%s : detect recovery mode !\n",MODULE_NAME);
                return;
            }
#endif
    }
#else

/*We put conditions here to filer some cases that can not do key detection*/

/*Check RTC to know if system want to reboot to Fastboot*/
#ifdef MTK_FASTBOOT_SUPPORT
  if(Check_RTC_PDN1_bit13())
  {
    dprintf(INFO,"[FASTBOOT] reboot to boot loader\n");
    g_boot_mode = FASTBOOT;
    Set_Clr_RTC_PDN1_bit13(false);
         return TRUE;
  }
#endif

   /*If forbidden mode is factory, cacel the factory key detection*/
    if(g_boot_arg->sec_limit.magic_num == 0x4C4C4C4C)
    {
        if(g_boot_arg->sec_limit.forbid_mode == F_FACTORY_MODE)
        {
            //Forbid to enter factory mode
           dprintf(INFO, "%s Forbidden\n",MODULE_NAME);
            factory_forbidden=1;
        }
    }
//    forbid_mode = g_boot_arg->boot_mode &= 0x000000FF;
    /*If boot reason is power key + volumn down, then
     disable factory mode dectection*/
    if(mtk_detect_pmic_just_rst())
    {
          factory_forbidden=1;
    }
    /*Check RTC to know if system want to reboot to Recovery*/
    if(Check_RTC_Recovery_Mode())
    {
          g_boot_mode = RECOVERY_BOOT;
          return TRUE;
    }
    /*If MISC Write has not completed  in recovery mode
     and interrupted by system reboot, go to recovery mode to
    finish remain tasks*/
    if(unshield_recovery_detection())
    {
        return TRUE;
    }
    ulong begin = get_timer(0);
/*we put key dectection here to detect key which is pressed*/
while(get_timer(begin)<50){
#ifdef MTK_FASTBOOT_SUPPORT
    if(mtk_detect_key(MT_CAMERA_KEY))
    {
          dprintf(INFO,"[FASTBOOT]Key Detect\n");
          g_boot_mode = FASTBOOT;
          return TRUE;
    }
#endif
    if(!factory_forbidden){
                if(mtk_detect_key(MT65XX_FACTORY_KEY))
                {
                      dprintf(INFO, "%s Detect key\n",MODULE_NAME);
                      dprintf(INFO, "%s Enable factory mode\n",MODULE_NAME);
                       g_boot_mode = FACTORY_BOOT;
                       //video_printf("%s : detect factory mode !\n",MODULE_NAME);
                       return TRUE;
                }
     }
#ifdef MT65XX_RECOVERY_KEY
        if(mtk_detect_key(MT65XX_RECOVERY_KEY))
        {
            dprintf(INFO, "%s Detect cal key\n",MODULE_NAME);
            dprintf(INFO, "%s Enable recovery mode\n",MODULE_NAME);
             g_boot_mode = RECOVERY_BOOT;
             //video_printf("%s : detect recovery mode !\n",MODULE_NAME);
             return TRUE;
         }
#endif
}

#endif

#ifdef MTK_KERNEL_POWER_OFF_CHARGING
	if(kernel_power_off_charging_detection())
	{
		printf(" < Kernel Power Off Charging Detection Ok> \n");
		return;
	}
	else
	{
		printf("< Kernel Enter Normal Boot > \n");
	}
#endif
}