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; }
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; }
/***************************************** * Routine: board_init * Description: Early hardware init. *****************************************/ int board_init (void) { /*Warning: DO NOT use "printf" before serial initialize*/ #ifdef CFG_UBOOT_PROFILING unsigned int time_disp_init; unsigned int time_led_init; unsigned int time_pmic6329_init; unsigned int time_gpio_init; unsigned int time_wdt_init; unsigned int time_serial_init; #endif mtk_serial_init(); mtk_wdt_init(); // Modify mtk_wdt.h can select dummy function. mt6577_pinmux_init(); gd->bd->bi_arch_number = MACH_TYPE_MT6577; /* board id for linux */ gd->bd->bi_boot_params = CFG_BOOTARGS_ADDR; /* address of boot parameters */ gd->fb_base = memory_size() - mt65xx_disp_get_vram_size(); #ifdef CFG_UBOOT_PROFILING time_led_init = get_timer(0); #endif leds_init(); isink0_init(); //turn on isink0, HW connection must be floating or pull low #ifdef CFG_UBOOT_PROFILING printf("[PROFILE] ------- led init takes %d ms -------- \n", get_timer(time_led_init)); #endif #ifdef CFG_LCD #ifdef CFG_UBOOT_PROFILING time_disp_init = get_timer(0); #endif mt65xx_disp_init((void*)gd->fb_base); UBOOT_TRACER; #ifdef CFG_UBOOT_PROFILING printf("[PROFILE] ------- disp init takes %d ms -------- \n", get_timer(time_disp_init)); #endif #endif #ifdef CFG_UBOOT_PROFILING time_pmic6329_init = get_timer(0); #endif pmic6329_init(); #ifdef CFG_UBOOT_PROFILING printf("[PROFILE] ------- pmic6329_init takes %d ms -------- \n", get_timer(time_pmic6329_init)); #endif printf("[CHIP]: %x-%x\n", get_chip_eco_ver(), get_chip_ver()); return 0; }
void cmd_continue(const char *arg, void *data, unsigned sz) { g_boot_mode = NORMAL_BOOT; fastboot_okay(""); udc_stop(); mtk_wdt_init(); //re-open wdt /*Will not return*/ boot_linux_from_storage(); }
void bootblock_soc_init(void) { mt_pll_init(); /* init pmic wrap SPI interface and pmic */ mt6391_init(); /* post init pll */ mt_pll_post_init(); mt8173_mmu_init(); /* init watch dog, will disable AP watch dog */ mtk_wdt_init(); }
void cmd_continue(const char *arg, void *data, unsigned sz) { g_boot_mode = NORMAL_BOOT; if(has_set_p2u) { set_p2u(has_set_p2u); fastboot_info("phone will continue boot up after 5s..."); fastboot_okay(""); mdelay(5000); } else { fastboot_okay(""); } udc_stop(); mtk_wdt_init(); //re-open wdt /*Will not return*/ boot_linux_from_storage(); }
void platform_early_init(void) { #ifdef LK_PROFILING unsigned int time_led_init; unsigned int time_pmic6329_init; unsigned int time_i2c_init; unsigned int time_disp_init; unsigned int time_platform_early_init; time_platform_early_init = get_timer(0); #endif /* initialize the uart */ uart_init_early(); /* initialize the frame buffet information */ g_fb_size = mt_disp_get_vram_size(); g_fb_base = memory_size() - g_fb_size; dprintf(INFO, "FB base = 0x%x, FB size = %d\n", g_fb_base, g_fb_size); platform_init_interrupts(); platform_early_init_timer(); mt_gpio_set_default(); #ifdef LK_PROFILING time_i2c_init = get_timer(0); #endif // i2c_v1_init(); #ifdef LK_PROFILING printf("[PROFILE] ------- i2c init takes %d ms -------- \n", get_timer(time_i2c_init)); #endif mtk_wdt_init(); #ifdef LK_PROFILING time_led_init = get_timer(0); #endif leds_init(); #ifdef LK_PROFILING printf("[PROFILE] ------- led init takes %d ms -------- \n", get_timer(time_led_init)); #endif isink0_init(); //turn on PMIC6329 isink0 #ifdef LK_PROFILING time_disp_init = get_timer(0); #endif mt_disp_init((void *)g_fb_base); #ifdef LK_PROFILING printf("[PROFILE] ------- disp init takes %d ms -------- \n", get_timer(time_disp_init)); #endif #ifdef CONFIG_CFB_CONSOLE drv_video_init(); #endif #ifdef LK_PROFILING time_pmic6329_init = get_timer(0); #endif pmic6329_init(); //<2013/01/03-samhuang, improve KPI-0092 to add VIB before show logo. lk_vibr_enable(); //>2013/01/03-samhuang #ifdef LK_PROFILING printf("[PROFILE] ------- pmic6329_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 }
void cmd_boot(const char *arg, void *data, unsigned sz) { unsigned kernel_actual; unsigned ramdisk_actual; static struct boot_img_hdr hdr; char *ptr = ((char*) data); unsigned page_size = 0; unsigned page_mask = 0; int strlen = 0; if (sz < sizeof(hdr)) { fastboot_fail("invalid bootimage header"); return; } memcpy(&hdr, data, sizeof(hdr)); printf("\n============================================================\n"); hdr.magic[7] = '\0'; printf("[%s] Android Boot IMG Hdr - Magic : %s\n",MODULE_NAME,hdr.magic); printf("[%s] Android Boot IMG Hdr - Kernel Size : 0x%x\n",MODULE_NAME,hdr.kernel_size); printf("[%s] Android Boot IMG Hdr - Rootfs Size : 0x%x\n",MODULE_NAME,hdr.ramdisk_size); printf("[%s] Android Boot IMG Hdr - Page Size : 0x%x\n",MODULE_NAME,hdr.page_size); printf("============================================================\n"); /* ensure commandline is terminated */ hdr.cmdline[BOOT_ARGS_SIZE-1] = 0; if(hdr.page_size) { page_size = hdr.page_size; page_mask = page_size - 1; //page_mask = 2*1024 ; /*FIXME*/ } else { printf("[FASTBOOT] Please specify the storage page-size in the boot header!\n"); fastboot_fail("Please specify the storage page-size in the boot header!\n"); return; } kernel_actual = ROUND_TO_PAGE(hdr.kernel_size, page_mask); ramdisk_actual = ROUND_TO_PAGE(hdr.ramdisk_size, page_mask); /* sz should have atleast raw boot image */ if (page_size + kernel_actual + ramdisk_actual > sz) { fastboot_fail("incomplete bootimage"); return; } memmove((void*) hdr.kernel_addr, (ptr + MKIMG_HEADER_SZ + BIMG_HEADER_SZ), hdr.kernel_size); memmove((void*) hdr.ramdisk_addr, (ptr + MKIMG_HEADER_SZ + BIMG_HEADER_SZ + kernel_actual), hdr.ramdisk_size); strlen += sprintf((const char*) hdr.cmdline, "%s lcm=%1d-%s", hdr.cmdline, DISP_IsLcmFound(), mt_disp_get_lcm_id()); strlen += sprintf((const char*) hdr.cmdline, "%s fps=%1d", hdr.cmdline, mt_disp_get_lcd_time()); fastboot_okay(""); udc_stop(); mtk_wdt_init(); //re-open wdt g_boot_mode = NORMAL_BOOT; boot_linux((void*) hdr.kernel_addr, (void*) hdr.tags_addr, (const char*) hdr.cmdline, board_machtype(), (void*) hdr.ramdisk_addr, hdr.ramdisk_size); #if 0 unsigned kernel_actual; unsigned ramdisk_actual; struct boot_img_hdr boot_hdr; unsigned int k_pg_cnt = 0; unsigned int r_pg_cnt = 0; unsigned int b_pg_cnt = 0; unsigned int size_b = 0; unsigned int pg_sz = 2*1024 ; int strlen = 0; /*copy hdr data from download_base*/ memcpy(&boot_hdr, data, sizeof(boot_hdr)); /* ensure commandline is terminated */ boot_hdr.cmdline[BOOT_ARGS_SIZE-1] = 0; printf("\n============================================================\n"); boot_hdr.magic[7] = '\0'; printf("[%s] Android Boot IMG Hdr - Magic : %s\n",MODULE_NAME,boot_hdr.magic); printf("[%s] Android Boot IMG Hdr - Kernel Size : 0x%x\n",MODULE_NAME,boot_hdr.kernel_size); printf("[%s] Android Boot IMG Hdr - Rootfs Size : 0x%x\n",MODULE_NAME,boot_hdr.ramdisk_size); printf("[%s] Android Boot IMG Hdr - Page Size : 0x%x\n",MODULE_NAME,boot_hdr.page_size); printf("============================================================\n"); //*************** //* check partition magic //* if (strncmp(boot_hdr.magic,BOOT_MAGIC, sizeof(BOOT_MAGIC))!=0) { printf("[%s] boot image header magic error\n", MODULE_NAME); return -1; } g_kmem_off = (unsigned int)target_get_scratch_address(); g_kmem_off = g_kmem_off + MKIMG_HEADER_SZ + BIMG_HEADER_SZ; if(boot_hdr.kernel_size % pg_sz == 0) { k_pg_cnt = boot_hdr.kernel_size / pg_sz; } else { k_pg_cnt = (boot_hdr.kernel_size / pg_sz) + 1; } if(boot_hdr.ramdisk_size % pg_sz == 0) { r_pg_cnt = boot_hdr.ramdisk_size / pg_sz; } else { r_pg_cnt = (boot_hdr.ramdisk_size / pg_sz) + 1; } printf(" > page count of kernel image = %d\n",k_pg_cnt); g_rmem_off = g_kmem_off + k_pg_cnt * pg_sz; printf(" > kernel mem offset = 0x%x\n",g_kmem_off); printf(" > rootfs mem offset = 0x%x\n",g_rmem_off); //*************** //* specify boot image size //* g_bimg_sz = (k_pg_cnt + r_pg_cnt + 2)* pg_sz; printf(" > boot image size = 0x%x\n",g_bimg_sz); memmove((void*)CFG_BOOTIMG_LOAD_ADDR , g_kmem_off, boot_hdr.kernel_size); memmove((void*)CFG_RAMDISK_LOAD_ADDR , g_rmem_off, boot_hdr.ramdisk_size); //custom_port_in_kernel(g_boot_mode, commanline); //strlen += sprintf(commanline, "%s lcm=%1d-%s", commanline, DISP_IsLcmFound(), mt_disp_get_lcm_id()); //strlen += sprintf(commanline, "%s fps=%1d", commanline, mt_disp_get_lcd_time()); fastboot_okay(""); udc_stop(); mtk_wdt_init(); boot_linux((void *)CFG_BOOTIMG_LOAD_ADDR, (unsigned *)CFG_BOOTARGS_ADDR, (const char*) boot_hdr.cmdline, board_machtype(), (void *)CFG_RAMDISK_LOAD_ADDR, boot_hdr.ramdisk_size); #endif }
//#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 }
void platform_early_init(void) { #ifdef LK_PROFILING unsigned int time_led_init; unsigned int time_pmic6329_init; unsigned int time_i2c_init; unsigned int time_disp_init; unsigned int time_platform_early_init; time_platform_early_init = get_timer(0); #endif /* initialize the frame buffet information */ 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); platform_init_interrupts(); platform_early_init_timer(); mt_gpio_set_default(); /* initialize the uart */ uart_init_early(); #ifdef LK_PROFILING time_i2c_init = get_timer(0); #endif mt_i2c_init(); #ifdef LK_PROFILING printf("[PROFILE] ------- i2c init takes %d ms -------- \n", get_timer(time_i2c_init)); #endif mtk_wdt_init(); #ifdef LK_PROFILING time_led_init = get_timer(0); #endif #ifndef MACH_FPAG 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 #ifdef LK_PROFILING time_disp_init = get_timer(0); #endif mt_disp_init((void *)g_fb_base); #ifdef LK_PROFILING printf("[PROFILE] ------- disp init takes %d ms -------- \n", get_timer(time_disp_init)); #endif #ifdef CONFIG_CFB_CONSOLE drv_video_init(); #endif #ifdef MACH_FPGA pwrap_init_lk(); pwrap_init_for_early_porting(); #endif #ifdef LK_PROFILING time_pmic6329_init = get_timer(0); #endif pmic6320_init(); #ifdef LK_PROFILING printf("[PROFILE] ------- pmic6329_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 }
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 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 }
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 }