/*============================================================================*/ static bool usb_connect(u32 tmo) { ulong start_time = get_timer(0); bool result = FALSE; u32 i = 1; mt_usb_disconnect_internal(); mt_usb_connect_internal(); #if CFG_USBIF_COMPLIANCE /* USB compliance test: 100mA charging current when USB is unconfigured. */ platform_set_chrg_cur(70); #endif print("%s Enumeration(Start)\n", MOD); do { /* kick wdt to avoid cpu reset during usb driver installation if not present */ platform_wdt_all_kick(); service_interrupts(); if (usbdl_configured()) { #if CFG_USBIF_COMPLIANCE /* USB compliance test: 500mA charging current when USB is configured but * we set the charging current to 450mA since 500mA doesn't support in the * platform. */ platform_set_chrg_cur(450); #endif result = TRUE; break; } if (tmo) { /* enable timeout mechanism */ if (get_timer(start_time) > tmo) break; #if !CFG_FPGA_PLATFORM /* cable plugged-out and power key detection each 1 second */ if (get_timer(start_time) > i * 1000) { if (!usb_accessory_in() && !mt_detect_powerkey()) pl_power_off(); /* check bypass power key from the 2nd second */ if (i > 1 && mt_detect_powerkey()) { print("%s Enumeration(Skip): powerkey pressed\n", MOD); break; } i++; } #endif } } while(1); print("%s Enumeration(End): %s %dms \n", MOD, result == TRUE ? "OK" : "TMO", get_timer(start_time)); return result; }
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; }
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; }