void platform_exit(void) { msm_i2c_remove(); msm_prepare_clocks(); msm_gpio_deinit(); platform_deinit_timer(); arch_disable_cache(UCACHE); arch_disable_mmu(); platform_deinit_interrupts(); }
void bootlinux_direct(void *kernel, unsigned machtype, unsigned *tags) { void (*entry)(unsigned,unsigned,unsigned*) = kernel; enter_critical_section(); /* do any platform specific cleanup before kernel entry */ platform_uninit(); arch_disable_cache(UCACHE); arch_disable_mmu(); entry(0, machtype, tags); }
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 }
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 }
void boot_linux(void *kernel, unsigned *tags, const char *cmdline, unsigned machtype, void *ramdisk, unsigned ramdisk_size) { unsigned *ptr = tags; unsigned pcount = 0; void (*entry)(unsigned,unsigned,unsigned*) = kernel; struct ptable *ptable; int cmdline_len = 0; int have_cmdline = 0; int pause_at_bootup = 0; /* CORE */ *ptr++ = 2; *ptr++ = 0x54410001; if (ramdisk_size) { *ptr++ = 4; *ptr++ = 0x54420005; *ptr++ = (unsigned)ramdisk; *ptr++ = ramdisk_size; } ptr = target_atag_mem(ptr); if (!target_is_emmc_boot()) { /* Skip NAND partition ATAGS for eMMC boot */ if ((ptable = flash_get_ptable()) && (ptable->count != 0)) { int i; for(i=0; i < ptable->count; i++) { struct ptentry *ptn; ptn = ptable_get(ptable, i); if (ptn->type == TYPE_APPS_PARTITION) pcount++; } *ptr++ = 2 + (pcount * (sizeof(struct atag_ptbl_entry) / sizeof(unsigned))); *ptr++ = 0x4d534d70; for (i = 0; i < ptable->count; ++i) ptentry_to_tag(&ptr, ptable_get(ptable, i)); } } if (cmdline && cmdline[0]) { cmdline_len = strlen(cmdline); have_cmdline = 1; } if (target_is_emmc_boot()) { cmdline_len += strlen(emmc_cmdline); } if (target_pause_for_battery_charge()) { pause_at_bootup = 1; cmdline_len += strlen(battchg_pause); } if (cmdline_len > 0) { const char *src; char *dst; unsigned n; /* include terminating 0 and round up to a word multiple */ n = (cmdline_len + 4) & (~3); *ptr++ = (n / 4) + 2; *ptr++ = 0x54410009; dst = (char *)ptr; if (have_cmdline) { src = cmdline; while ((*dst++ = *src++)); } if (target_is_emmc_boot()) { src = emmc_cmdline; if (have_cmdline) --dst; have_cmdline = 1; while ((*dst++ = *src++)); } if (pause_at_bootup) { src = battchg_pause; if (have_cmdline) --dst; while ((*dst++ = *src++)); } ptr += (n / 4); } /* END */ *ptr++ = 0; *ptr++ = 0; dprintf(INFO, "booting linux @ %p, ramdisk @ %p (%d)\n", kernel, ramdisk, ramdisk_size); if (cmdline) dprintf(INFO, "cmdline: %s\n", cmdline); enter_critical_section(); platform_uninit_timer(); arch_disable_cache(UCACHE); arch_disable_mmu(); #if DISPLAY_SPLASH_SCREEN display_shutdown(); #endif entry(0, machtype, tags); }