// check the boot mode : (1) meta mode or (2) recovery mode ... void boot_mode_select(void) { #ifdef CFG_META_MODE if (meta_detection()) { return; } #endif #ifdef CFG_FACTORY_MODE if (factory_detection()) { return; } #endif #ifdef CFG_RECOVERY_MODE if(recovery_detection()) { //************************************** //* CHECK IMAGE //************************************** if(DRV_Reg32(0x40002300)==0xE92D4800) { printf(" > do recovery_check\n"); //jump(0x40002300); } else { printf(" > bypass recovery_check\n"); } return; } #endif }
// check the boot mode : (1) meta mode or (2) recovery mode ... void boot_mode_select(void) { //Ivan ulong begin; if (meta_detection()) { return; } #if defined (HAVE_LK_TEXT_MENU) if(Check_RTC_PDN1_bit13()) { printf("[FASTBOOT] reboot to boot loader\n"); g_boot_mode = FASTBOOT; Set_Clr_RTC_PDN1_bit13(false); return; } //Ivan #ifdef MENU_BOOT_ENABLE boot_mode_dkey_check(); if (g_boot_mode == MENU_BOOT) { /* clean console screen */ video_clean_screen(); // mt65xx_disp_fill_rect(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT, 0x0); video_set_cursor(2,0); video_printf("Recovery Mode: Volume Up\r\n"); video_set_cursor(4,0); video_printf("Factory Mode: Volume Down\r\n"); // mt65xx_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT); mt65xx_backlight_on(); video_set_cursor(49,0); while (mt65XX_get_key() != 0xFFFF); printf(" > Key release!!!\n"); mdelay(500); //Ivan added mtk_wdt_restart(); begin = get_timer(0); while (g_boot_mode == MENU_BOOT) { if (factory_detection()) { video_clean_screen(); return; } if(boot_menu_detection())//recovery, fastboot, normal boot. { video_clean_screen(); return; } //Ivan add 20s time limit if (get_timer(begin) < 20000) mtk_wdt_restart(); } // video_clean_screen(); // mt65xx_disp_fill_rect(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT, 0x0); // mt65xx_disp_update(0, 0, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT); // video_set_cursor(49,0); // mt65xx_disp_wait_idle(); } if(Check_RTC_Recovery_Mode()) { g_boot_mode = RECOVERY_BOOT; } recovery_check_command_trigger(); #else //MENU_BOOT_ENABLE if (factory_detection()) { return; } if(boot_menu_detection())//recovery, fastboot, normal boot. { return; } recovery_detection(); #endif //MENU_BOOT_ENABLE #else //HAVE_LK_TEXT_MENU #ifdef MTK_FASTBOOT_SUPPORT if(fastboot_trigger()) { return; } #endif //MTK_FASTBOOT_SUPPORT if (factory_detection()) { return; } if(recovery_detection()) { //************************************** //* CHECK IMAGE //************************************** if(DRV_Reg32(0x40002300)==0xE92D4800) { printf(" > do recovery_check\n"); //jump(0x40002300); } else { printf(" > bypass recovery_check\n"); } return; } #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 }
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 }
void dummy_ap_entry(void) { unsigned int is_meta_mode = 0; int md_check_tbl[] = {1<<MD1_IMG, 1<<MD2_IMG}; int i=0; int get_val; volatile unsigned int count; volatile unsigned int count1; // Disable AP WDT *(volatile unsigned int *)(0x10007000) = 0x22000000; *(volatile unsigned int *)(0x10000500) = 0x22000000; printf("Welcome to use dummy AP!\n"); get_val = get_input(); apply_env_setting(get_val); // 0, Parse header info printf("Parsing image info!\n"); //parse_img_header(img_header_array); //<<<------ parse_img_header((unsigned int*)g_boot_arg->part_info, (unsigned int)g_boot_arg->part_num); printf("Begin to configure MD run env!\n"); for(i=0; i<MAX_MD_NUM; i++) { if(img_load_flag & md_check_tbl[i]) { printf("MD%d Enabled\n", i+1); // 1, Setup special GPIO request (RF/SIM/UART ... etc) //printf("Step 1: Configure special GPIO request!\n"); //md_gpio_config(i); // 2, Configure EMI remapping setting printf("Step 2: Configure EMI remapping...\n"); md_emi_remapping(i); // 3, Power up MD MTCMOS //printf("Step 3: Power up MD!\n"); //md_power_up_mtcmos(i); // 4, Configure DAP for ICE to connect to MD printf("Step 4: Configure DAP for ICE to connect to MD!\n"); md_jtag_config(i); // 5, Check boot Mode is_meta_mode = meta_detection(); printf("Step 5: Notify MD enter %s mode!\n", is_meta_mode ? "META" : "NORMAL"); // 6, MD register setting printf("Step 6: MD Common setting!\n"); md_common_setting(i); // 7, Boot up MD printf("Step 7: MD%d boot up with meta(%d)!\n", i+1, is_meta_mode); md_boot_up(i, is_meta_mode); printf("\nmd%d boot up done!!\n", i + 1); } } printf("All dummy AP config done, enter while(1), Yeah!!\n"); //Swtich MD to UART1 and Close AP log to aurt1 mt_set_gpio_mode(GPIO108,3); mt_set_gpio_mode(GPIO109,3); mt_set_gpio_mode(GPIO110,0); mt_set_gpio_mode(GPIO111,0); #if 0 md_wdt_init(); count = 1; while(count--) { count1 = 0x80000000; while(count1--); } printf("Write MD WDT SWRST\n"); *((volatile unsigned int *)0x2005001C) = 0x1209; count = 1; while(count--) { count1 = 0x08000000; while(count1--); } printf("Read back STA:%x!!\n", *((volatile unsigned int*)0x2005000C)); #endif while(1); }