BOOL sec_util_brom_download_recovery_check(void)
{
#ifdef KPD_DL_KEY2    	
    if (mtk_detect_key (KPD_DL_KEY2) && FALSE==bUsbHandshakeSuccess 
        && is_BR_cmd_disabled())
    {
        SMSG("[%s] Start checking (1500 ms)\n", MOD);
        mdelay(1500);

        if(false == mtk_detect_key (KPD_DL_KEY2))
        {        
            SMSG("[%s] Key is not detected, wait for 1500ms \n", MOD);
            mdelay(1500);
            if(mtk_detect_key (KPD_DL_KEY2))            
        {        
            SMSG("[%s] Key is detected\n", MOD);
            return sec_util_force_brom_download_recovery();
        }
        else
        {
            SMSG("[%s] Key is not detected\n", MOD);
            return FALSE;
        }
    }
        else
        {
            SMSG("[%s] Key is detected\n", MOD);
            return FALSE;
        }
    }
#endif
    return FALSE;
}
Beispiel #2
0
/******************************************************************************
 * meta_detection
 * 
 * DESCRIPTION:
 *   Detect META mode is on or off
 *
******************************************************************************/
BOOL mt6577_detect_meta_keys (void)
{
   if(mtk_detect_key(MT65XX_FACTORY_KEY) && mtk_detect_key(MT65XX_RECOVERY_KEY))
  {
        printf("Meta keys are pressed\n");
        return TRUE;
  }
  return FALSE;
}
Beispiel #3
0
int fastboot_oem_lock(const char *arg, void *data, unsigned sz)
{
    int ret = B_OK;
    char msg[128] = {0};
    int inFactory = 0;
    int requireConfirmation = 0;

    ret = sec_is_in_factory(&inFactory);
    if (ret)
        return ret;

    requireConfirmation = inFactory ? 0 : 1;

    lock_warranty();

    while(1)
    {
        if(mtk_detect_key(MT65XX_MENU_SELECT_KEY) || !requireConfirmation) //VOL_UP
        {
            fastboot_info("Start lock flow\n");
            //Invoke security check after confiming "yes" by user
            ret = fastboot_oem_lock_chk();
            if(ret != B_OK)
            {
                sprintf(msg, "\nlock failed - Err:0x%x \n", ret);
                video_printf("lock failed...return to fastboot in 3s\n");
                mdelay(3000);
                fastboot_boot_menu();
                fastboot_fail(msg);
            }
            else
            {
                video_printf("lock Pass...return to fastboot in 3s\n");
                mdelay(3000);
                fastboot_boot_menu();
                fastboot_okay("");
            }
            break;
        }
        else if(mtk_detect_key(MT65XX_MENU_OK_KEY))//VOL_DOWN
        {
            video_printf("return to fastboot in 3s\n");
            mdelay(3000);
            fastboot_boot_menu();
            fastboot_okay("");
            break;
        }
        else
        {
            //If we press other keys, discard it.
        }
    }
    return ret;
}
Beispiel #4
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;
}
BOOL recovery_check_key_trigger(void)
{
    //wait
    ulong begin = get_timer(0);

    //if it equal to menu key, skip the key check.
    if(MT65XX_RECOVERY_KEY == MT65XX_BOOT_MENU_KEY)
    {
      return false;
    }
    
	printf("\n%s Check recovery boot\n",MODULE_NAME);
	printf("%s Wait 50ms for special keys\n",MODULE_NAME);

	if(mtk_detect_pmic_just_rst())
	{
	  return false;
	}
	
#ifdef MT65XX_RECOVERY_KEY
    while(get_timer(begin)<50)
    {
    	if(mtk_detect_key(MT65XX_RECOVERY_KEY))
    	{
    		printf("%s Detect cal key\n",MODULE_NAME);
    		printf("%s Enable recovery mode\n",MODULE_NAME);
    		g_boot_mode = RECOVERY_BOOT;
    		//video_printf("%s : detect recovery mode !\n",MODULE_NAME);
    		return TRUE;
    	}
    }
#endif

    return FALSE;
}
Beispiel #6
0
BOOL recovery_check_key_trigger(void)
{
    //wait
    ulong begin = get_timer(0);
   dprintf(INFO, "\n%s Check recovery boot\n",MODULE_NAME);
   dprintf(INFO, "%s Wait 50ms for special keys\n",MODULE_NAME);

    if(mtk_detect_pmic_just_rst())
    {
        return false;
    }

#ifdef MT65XX_RECOVERY_KEY
    while(get_timer(begin)<50)
    {
        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 TRUE;
        }
    }
#endif

    return FALSE;
}
Beispiel #7
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;
}
static boot_reason_t platform_boot_status(void)
{
#if defined (MTK_KERNEL_POWER_OFF_CHARGING)
	ulong begin = get_timer(0);
	do  {
		if (rtc_boot_check()) {
			print("%s RTC boot!\n", MOD);
			return BR_RTC;
		}
		if(!kpoc_flag)
			break;
	} while (get_timer(begin) < 1000 && kpoc_flag);
#else
    if (rtc_boot_check()) {
        print("%s RTC boot!\n", MOD);
        return BR_RTC;
    }

#endif
    if (mtk_wdt_boot_check() == WDT_NORMAL_REBOOT) {
        print("%s WDT normal boot!\n", MOD);
        return BR_WDT;
    } else if (mtk_wdt_boot_check() == WDT_BY_PASS_PWK_REBOOT){
        print("%s WDT reboot bypass power key!\n", MOD);
        return BR_WDT_BY_PASS_PWK;
    }
#if !CFG_FPGA_PLATFORM
    /* check power key */
    if (mtk_detect_key(8)) {
        print("%s Power key boot!\n", MOD);
        rtc_mark_bypass_pwrkey();
        return BR_POWER_KEY;
    }
#endif

#ifndef CFG_EVB_PLATFORM
    if (usb_accessory_in()) {
        print("%s USB/charger boot!\n", MOD);
        return BR_USB;
    }
#ifdef RTC_2SEC_REBOOT_ENABLE
    //need to unlock rtc PROT
    //check after rtc_boot_check() initial finish.
    if (rtc_2sec_reboot_check()) {
        print("%s 2sec reboot!\n", MOD);
        return BR_2SEC_REBOOT;
    }
#endif //#ifdef RTC_2SEC_REBOOT_ENABLE

    print("%s Unknown boot!\n", MOD);
    pl_power_off();
    /* should nerver be reached */
#endif

    print("%s Power key boot!\n", MOD);

    return BR_POWER_KEY;
}
Beispiel #9
0
BOOL fastboot_trigger(void)
{
  ulong begin = get_timer(0);
  dprintf(INFO,"\n Check FASTBOOT\n");

/*Check Fastboot RTC bit*/
#if 1
  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

  dprintf(INFO,"Wait 50ms for special keys\n");
  
  while(get_timer(begin)<50)
  {    

//                               
	#if defined (FASTBOOT_USERDEBUG) /* jjm_l10 */
    if(mtk_detect_key(LGE_QMEMO_KEY))
	#else
    if(mtk_detect_key(MT_CAMERA_KEY))
	#endif
//                               
    { 
   	  dprintf(INFO,"[FASTBOOT]Key Detect\n");
   	  g_boot_mode = FASTBOOT;
   	  return TRUE;
    }
  }
        
  return FALSE;	
}
BOOL meta_check_key_trigger(void)
{
    //wait
    ulong begin = get_timer(0);
    printf("\nMETA Check meta boot\n");
    printf("%META Wait 50ms for special keys\n");
         
    while(get_timer(begin)<50)
    {    
        if(mtk_detect_key(MT65XX_META_KEY))
        {        
            printf("META Enable meta mode\n");              
            return TRUE;
        }
    }    
    return FALSE;                 
}
Beispiel #11
0
bool platform_com_wait_forever_check(void)
{
#ifdef USBDL_DETECT_VIA_KEY
    /* check download key */
    if (TRUE == mtk_detect_key(COM_WAIT_KEY)) {
        print("%s COM handshake timeout force disable: Key\n", MOD);
        return TRUE;
    }
#endif

#ifdef USBDL_DETECT_VIA_AT_COMMAND
    /* check WDT_NONRST_REG */
    if (MTK_WDT_NONRST_DL == (INREG32(MTK_WDT_NONRST_REG) & MTK_WDT_NONRST_DL)) {
	print("%s COM handshake timeout force disable: AT Cmd\n", MOD);	
	CLRREG32(MTK_WDT_NONRST_REG, MTK_WDT_NONRST_DL);
	return TRUE;
    }
#endif

    return FALSE;
}
bool platform_com_wait_forever_check(void)
{
#ifdef USBDL_DETECT_VIA_KEY
    /* check download key */
    if (TRUE == mtk_detect_key(COM_WAIT_KEY)) {
        print("%s COM handshake timeout force disable: Key\n", MOD);
        return TRUE;
    }
#endif

#ifdef USBDL_DETECT_VIA_AT_COMMAND
    /* check SRAMROM_USBDL_TO_DIS */
    if (USBDL_TO_DIS == (INREG32(SRAMROM_USBDL_TO_DIS) & USBDL_TO_DIS)) {
	print("%s COM handshake timeout force disable: AT Cmd\n", MOD);
	CLRREG32(SRAMROM_USBDL_TO_DIS, USBDL_TO_DIS);
	return TRUE;
    }
#endif

    return FALSE;
}
Beispiel #13
0
void boot_mode_menu_select()
{
          int select = 0;  // 0=recovery mode, 1=fastboot.  2=normal boot 3=normal boot + ftrace.4=slub debug off
          const char* title_msg = "Select Boot Mode:\n[VOLUME_UP to select.  VOLUME_DOWN is OK.]\n\n";
          video_clean_screen();
          video_set_cursor(video_get_rows()/2, 0);
          video_printf(title_msg);
          video_printf("[Recovery    Mode]         <<==\n");
#ifdef MTK_FASTBOOT_SUPPORT
          video_printf("[Fastboot    Mode]             \n");
#endif
          video_printf("[Normal      Boot]             \n");
#ifndef USER_BUILD
          video_printf("[Normal      Boot +ftrace]    \n");
          video_printf("[Normal      slub debug off]     \n");
#endif
          while(1)
          {
             if(mtk_detect_key(MT65XX_MENU_SELECT_KEY))//VOL_UP
             {
                    g_boot_menu = true;
                    switch(select) {

                        case 0:
#ifdef MTK_FASTBOOT_SUPPORT
                            select = 1;

                            video_set_cursor(video_get_rows()/2, 0);
                            video_printf(title_msg);
                            video_printf("[Recovery    Mode]             \n");
                            video_printf("[Fastboot    Mode]         <<==\n");
                            video_printf("[Normal      Boot]             \n");
#ifndef USER_BUILD
                            video_printf("[Normal      Boot +ftrace]     \n");
                            video_printf("[Normal      slub debug off]     \n");
#endif
                        break;
#endif
                        case 1:
                            select = 2;

                            video_set_cursor(video_get_rows()/2, 0);
                            video_printf(title_msg);
                            video_printf("[Recovery    Mode]             \n");
#ifdef MTK_FASTBOOT_SUPPORT
                            video_printf("[Fastboot    Mode]             \n");
#endif
                            video_printf("[Normal      Boot]         <<==\n");
#ifndef USER_BUILD
                            video_printf("[Normal      Boot +ftrace]     \n");
                            video_printf("[Normal      slub debug off]     \n");
#endif
                        break;

                        case 2:
#ifdef USER_BUILD
                            select = 0;
#else
                            select = 3;
#endif
    
                            video_set_cursor(video_get_rows()/2, 0);
                            video_printf(title_msg);
#ifdef USER_BUILD
                            video_printf("[Recovery    Mode]         <<==\n");
#ifdef MTK_FASTBOOT_SUPPORT
                            video_printf("[Fastboot    Mode]             \n");
#endif
                            video_printf("[Normal      Boot]             \n");
#else
                            video_printf("[Recovery    Mode]             \n");
#ifdef MTK_FASTBOOT_SUPPORT
                            video_printf("[Fastboot    Mode]             \n");
#endif
                            video_printf("[Normal      Boot]             \n");
                            video_printf("[Normal      Boot +ftrace] <<==\n");
                            video_printf("[Normal      slub debug off]     \n");
#endif
                        break;

#ifndef USER_BUILD
                        case 3:
                            select = 4;
                            video_set_cursor(video_get_rows()/2, 0);
                            video_printf(title_msg);
                            video_printf("[Recovery    Mode]             \n");
#ifdef MTK_FASTBOOT_SUPPORT
                            video_printf("[Fastboot    Mode]             \n");
#endif
                            video_printf("[Normal      Boot]             \n");
                            video_printf("[Normal      Boot +ftrace]     \n");
                            video_printf("[Normal      slub debug off] <<==\n");
                            
                        break;
#endif


#ifndef USER_BUILD
                        case 4:
                            select = 0;
                            video_set_cursor(video_get_rows()/2, 0);
                            video_printf(title_msg);
                            video_printf("[Recovery    Mode]         <<==\n");
#ifdef MTK_FASTBOOT_SUPPORT
                            video_printf("[Fastboot    Mode]             \n");
#endif
                            video_printf("[Normal      Boot]             \n");
                            video_printf("[Normal      Boot +ftrace]     \n");
                            video_printf("[Normal      slub debug off]     \n");                            
                        break;
#endif

                        default: 
                        break;
                    }
                    dprintf(CRITICAL,  "[VOL_UP]Key Detect, current select:%d\n", select);
                    mdelay(300);
             }
             else if(mtk_detect_key(MT65XX_MENU_OK_KEY))//VOL_DOWN,
             {
                 //use for OK
                 break;
             }
             else
             {
                //pass
             }
          }
          if(select == 0)
          {
               g_boot_mode = RECOVERY_BOOT;
          }
          else if(select == 1)
          {
                g_boot_mode = FASTBOOT;
          }
          else if(select == 2)
          {
                g_boot_mode = NORMAL_BOOT;
          }
          else if(select == 3)
          {
                sprintf(g_CMDLINE, "%s trace_buf_size=11m boot_time_ftrace", g_CMDLINE);
                g_boot_mode = NORMAL_BOOT;
          }
          else if (select == 4)
          {
                sprintf(g_CMDLINE, "%s slub_debug=-", g_CMDLINE);
                g_boot_mode = NORMAL_BOOT;
          }
          else{
                //pass
          }
          video_printf("\n");
          return;
}
Beispiel #14
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
}
Beispiel #15
0
static boot_reason_t platform_boot_status(void)
{  
#if defined (MTK_KERNEL_POWER_OFF_CHARGING)
    ulong begin = get_timer(0);
    do  {
        if (rtc_boot_check()) {
            print("%s RTC boot!\n", MOD);
            return BR_RTC;
        }
        if(!kpoc_flag)
            break;
    } while (get_timer(begin) < 1000 && kpoc_flag);
#else
    if (rtc_boot_check()) {
        print("%s RTC boot!\n", MOD);
        return BR_RTC;
    }

#endif
    if (mtk_wdt_boot_check() == WDT_NORMAL_REBOOT) {
        print("%s WDT normal boot!\n", MOD);
        return BR_WDT;
    } else if (mtk_wdt_boot_check() == WDT_BY_PASS_PWK_REBOOT){
        print("%s WDT reboot bypass power key!\n", MOD);
        return BR_WDT_BY_PASS_PWK;
    }
#if !CFG_FPGA_PLATFORM
#ifdef  LENOVO_BOOT_TIME_DELAY
	/* check power key */
	int iLoop=0;
	int iCheck_num=3;
	int iInterval=250;
	int iRet=0;
	
	for(iLoop=0; iLoop < iCheck_num; iLoop++ )
	{
		iRet = mtk_detect_key(8);
		if(false == iRet )
			break;
		mdelay(iInterval);
	}
	
	if (iRet) 
	{
		print("%s Power key boot!\n", MOD);
		rtc_mark_bypass_pwrkey();
		return BR_POWER_KEY;
	}
	
#else

    /* check power key */
    if (mtk_detect_key(8)) {
        print("%s Power key boot!\n", MOD);
        rtc_mark_bypass_pwrkey();
        return BR_POWER_KEY;
    }
	
#endif

#endif

#ifndef EVB_PLATFORM
    if (usb_accessory_in()) {
        print("%s USB/charger boot!\n", MOD);
        return BR_USB;
    }

    print("%s Unknown boot!\n", MOD);
    pl_power_off();
    /* should nerver be reached */
#endif

    print("%s Power key boot!\n", MOD);

    return BR_POWER_KEY;
}
Beispiel #16
0
void boot_mode_menu_select()
{
	int select = 0;  // 0=recovery mode, 1=fastboot.  2=normal boot 3=normal boot + ftrace.4=slub debug off
	const char* title_msg = "Select Boot Mode:\n[VOLUME_UP to select.  VOLUME_DOWN is OK.]\n\n";
	mt65xx_backlight_on();
	video_clean_screen();
	video_set_cursor(video_get_rows()/2, 0);
	video_printf(title_msg);
	video_printf("[Recovery    Mode]         <<==\n");
#ifdef MTK_FASTBOOT_SUPPORT
	video_printf("[Fastboot    Mode]             \n");
#endif
	video_printf("[Normal      Boot]             \n");
#if !defined(USER_BUILD) || defined(MTK_BUILD_ROOT)
	video_printf("[Normal      Boot +ftrace]    \n");
	video_printf("[Normal      slub debug off]     \n");
#endif
	while (1) {
		if (mtk_detect_key(MT65XX_MENU_SELECT_KEY)) { //VOL_UP
			g_boot_menu = true;
			switch (select) {

				case 0:
#ifdef MTK_FASTBOOT_SUPPORT
					select = 1;

					video_set_cursor(video_get_rows()/2, 0);
					video_printf(title_msg);
					video_printf("[Recovery    Mode]             \n");
					video_printf("[Fastboot    Mode]         <<==\n");
					video_printf("[Normal      Boot]             \n");
#if !defined(USER_BUILD) || defined(MTK_BUILD_ROOT)
					video_printf("[Normal      Boot +ftrace]     \n");
					video_printf("[Normal      slub debug off]     \n");
#endif
					break;
#endif
				case 1:
					select = 2;

					video_set_cursor(video_get_rows()/2, 0);
					video_printf(title_msg);
					video_printf("[Recovery    Mode]             \n");
#ifdef MTK_FASTBOOT_SUPPORT
					video_printf("[Fastboot    Mode]             \n");
#endif
					video_printf("[Normal      Boot]         <<==\n");
#if !defined(USER_BUILD) || defined(MTK_BUILD_ROOT)
					video_printf("[Normal      Boot +ftrace]     \n");
					video_printf("[Normal      slub debug off]     \n");
#endif
					break;

				case 2:
#if defined(USER_BUILD) && !defined(MTK_BUILD_ROOT)
					select = 0;
#else
					select = 3;
#endif

					video_set_cursor(video_get_rows()/2, 0);
					video_printf(title_msg);
#if defined(USER_BUILD) && !defined(MTK_BUILD_ROOT)
					video_printf("[Recovery    Mode]         <<==\n");
#ifdef MTK_FASTBOOT_SUPPORT
					video_printf("[Fastboot    Mode]             \n");
#endif
					video_printf("[Normal      Boot]             \n");
#else
					video_printf("[Recovery    Mode]             \n");
#ifdef MTK_FASTBOOT_SUPPORT
					video_printf("[Fastboot    Mode]             \n");
#endif
					video_printf("[Normal      Boot]             \n");
					video_printf("[Normal      Boot +ftrace] <<==\n");
					video_printf("[Normal      slub debug off]     \n");
#endif
					break;

#if !defined(USER_BUILD) || defined(MTK_BUILD_ROOT)
				case 3:
					select = 4;
					video_set_cursor(video_get_rows()/2, 0);
					video_printf(title_msg);
					video_printf("[Recovery    Mode]             \n");
#ifdef MTK_FASTBOOT_SUPPORT
					video_printf("[Fastboot    Mode]             \n");
#endif
					video_printf("[Normal      Boot]             \n");
					video_printf("[Normal      Boot +ftrace]     \n");
					video_printf("[Normal      slub debug off] <<==\n");

					break;
#endif


#if !defined(USER_BUILD) || defined(MTK_BUILD_ROOT)
				case 4:
					select = 0;
					video_set_cursor(video_get_rows()/2, 0);
					video_printf(title_msg);
					video_printf("[Recovery    Mode]         <<==\n");
#ifdef MTK_FASTBOOT_SUPPORT
					video_printf("[Fastboot    Mode]             \n");
#endif
					video_printf("[Normal      Boot]             \n");
					video_printf("[Normal      Boot +ftrace]     \n");
					video_printf("[Normal      slub debug off]     \n");
					break;
#endif

				default:
					break;
			}
			dprintf(0,  "[VOL_UP]Key Detect, current select:%d\n", select);
			mdelay(300);
		} else if (mtk_detect_key(MT65XX_MENU_OK_KEY)) { //VOL_DOWN,
			//use for OK
			break;
		} else {
			//pass
		}
	}
	if (select == 0) {
		g_boot_mode = RECOVERY_BOOT;
	} else if (select == 1) {
		g_boot_mode = FASTBOOT;
	} else if (select == 2) {
		g_boot_mode = NORMAL_BOOT;
	} else if (select == 3) {
                cmdline_append("boot_trace");
		g_boot_mode = NORMAL_BOOT;
	} else if (select == 4) {
		cmdline_append("slub_debug=-");
		g_boot_mode = NORMAL_BOOT;
	} else {
		//pass
	}

	video_set_cursor(video_get_rows()/2 +8, 0);
	return;
}