Exemplo n.º 1
0
static void init_lcd_te_control(void)
{
	const LCM_DBI_PARAMS *dbi = &(lcm_params->dbi);

	/* The board may not connect to LCM in META test mode,
	   force disalbe TE to avoid blocked in LCD controller
	 */
	/* but for uboot, the boot mode selection is done after lcd init, so we have to disable te always in uboot. */
	LCD_CHECK_RET(LCD_TE_Enable(FALSE));
	if (!DISP_IsLcmFound())
		return;

	if (LCM_DBI_TE_MODE_DISABLED == dbi->te_mode) {
		LCD_CHECK_RET(LCD_TE_Enable(FALSE));
		return;
	}

	if (LCM_DBI_TE_MODE_VSYNC_ONLY == dbi->te_mode) {
		LCD_CHECK_RET(LCD_TE_SetMode(LCD_TE_MODE_VSYNC_ONLY));
	} else if (LCM_DBI_TE_MODE_VSYNC_OR_HSYNC == dbi->te_mode) {
		LCD_CHECK_RET(LCD_TE_SetMode(LCD_TE_MODE_VSYNC_OR_HSYNC));
		LCD_CHECK_RET(LCD_TE_ConfigVHSyncMode(dbi->te_hs_delay_cnt,
						      dbi->te_vs_width_cnt,
						      (LCD_TE_VS_WIDTH_CNT_DIV) dbi->te_vs_width_cnt_div));
	} else
		ASSERT(0);

	LCD_CHECK_RET(LCD_TE_SetEdgePolarity(dbi->te_edge_polarity));
	LCD_CHECK_RET(LCD_TE_Enable(TRUE));
}
Exemplo n.º 2
0
static void init_lcd_te_control(void)
{
    const LCM_DBI_PARAMS *dbi = &(lcm_params->dbi);

    LCD_CHECK_RET(LCD_TE_Enable(FALSE));
    if(!DISP_IsLcmFound())
        return;
#ifdef BUILD_UBOOT
    {
        extern BOOTMODE g_boot_mode;
        printf("boot_mode = %d\n",g_boot_mode);
        if(g_boot_mode == META_BOOT)
            return;
    }
#endif
    if (LCM_DBI_TE_MODE_DISABLED == dbi->te_mode) {
        LCD_CHECK_RET(LCD_TE_Enable(FALSE));
        return;
    }

    if (LCM_DBI_TE_MODE_VSYNC_ONLY == dbi->te_mode) {
        LCD_CHECK_RET(LCD_TE_SetMode(LCD_TE_MODE_VSYNC_ONLY));
    } else if (LCM_DBI_TE_MODE_VSYNC_OR_HSYNC == dbi->te_mode) {
        LCD_CHECK_RET(LCD_TE_SetMode(LCD_TE_MODE_VSYNC_OR_HSYNC));
        LCD_CHECK_RET(LCD_TE_ConfigVHSyncMode(dbi->te_hs_delay_cnt,
                                              dbi->te_vs_width_cnt,
                                              (LCD_TE_VS_WIDTH_CNT_DIV)dbi->te_vs_width_cnt_div));
    } else ASSERT(0);

    LCD_CHECK_RET(LCD_TE_SetEdgePolarity(dbi->te_edge_polarity));
    LCD_CHECK_RET(LCD_TE_Enable(TRUE));
}
Exemplo n.º 3
0
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
}
Exemplo n.º 4
0
int do_nand_boot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
	DECLARE_GLOBAL_DATA_PTR;
	int ret;
	bd_t *bd = gd->bd;
	ulong addr, data, len, initrd_start, initrd_end;
    void (*theKernel)(int zero, int arch, uint params);
    int strlen;


#ifdef CONFIG_CMDLINE_TAG
    char *commandline = getenv ("bootargs");
#endif

#ifdef CFG_UBOOT_PROFILING
      extern unsigned int boot_time;
      unsigned int time_do_nand_boot= get_timer(0);
      unsigned int time_rootfs;
      unsigned int time_load_bootimg;
      unsigned int ubt;
#endif


#if defined (CONFIG_SETUP_MEMORY_TAGS) || \
    defined (CONFIG_CMDLINE_TAG) || \
    defined (CONFIG_INITRD_TAG) || \
    defined (CONFIG_SERIAL_TAG) || \
    defined (CONFIG_REVISION_TAG) || \
    defined (CONFIG_LCD) || \
    defined (CONFIG_VFD)
	setup_start_tag (bd);
#ifdef CONFIG_SERIAL_TAG
	setup_serial_tag (&params);
#endif
#ifdef CONFIG_REVISION_TAG
	setup_revision_tag (&params);
#endif
#ifdef CONFIG_SETUP_MEMORY_TAGS
	if(g_boot_mode == FACTORY_BOOT)
	{
	  setup_memory_tags_factory(bd);
	}
	else
	{
	setup_memory_tags (bd);
	}  
#endif

//#ifdef CONFIG_CMDLINE_TAG
	//****************
	//* according to current boot mode to set boot tag and related boot args
	//*
	switch(g_boot_mode)
	{
		//********************************************************************
		//* NORMAL BOOT
		//********************************************************************		
		case NORMAL_BOOT:
#if defined(CFG_NAND_BOOT)
      strlen += sprintf(commandline, "%s%s%x%s%x", 
                commandline, NAND_MANF_CMDLINE, nand_flash_man_code, NAND_DEV_CMDLINE, nand_flash_dev_id);
#endif

	  setup_boot_tag(NORMAL_BOOT);

      ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
      if (ret < 0) {
			 	msg_header_error("Android Boot Image");
      }
      
#ifdef CFG_UBOOT_PROFILING
      time_load_bootimg= get_timer(0);
#endif      
      ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
#ifdef CFG_UBOOT_PROFILING
        printf("[PROFILE] ------- load boot.img takes %d ms -------- \n", get_timer(time_load_bootimg));
#endif

      if (ret < 0) {
	  		msg_img_error("Android Boot Image");
      }          
			break;

		//********************************************************************
		//* META
		//********************************************************************		
		case META_BOOT:
		#ifdef CFG_META_MODE
			printf("[META] - Old bootargs : %s\n",commandline);		
			commandline=strcat(commandline,META_BOOTARGS);
			printf("[META] - New bootargs : %s\n",commandline);	
			setup_boot_tag(META_BOOT);
		#endif
      ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
      if (ret < 0) {
			  msg_header_error("Android Boot Image");
      }
      ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
      if (ret < 0) {
		    msg_img_error("Android Boot Image");
      }            
			break;						

      //********************************************************************
      //* ADVANCED META MODE
	  //********************************************************************
	  case ADVMETA_BOOT:
        printf("[META] - Old bootargs : %s\n",commandline);
        commandline=strcat(commandline, ADV_META_BOOTARGS);
        printf("[META] - New bootargs : %s\n",commandline);	
        setup_boot_tag(ADVMETA_BOOT);
        ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
        if (ret < 0) {
			  msg_header_error("Android Boot Image");
        }
        ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
        if (ret < 0) {
		  msg_img_error("Android Boot Image");
        }
      break;
      
		//********************************************************************
		//* ANDROID RECOVERY
		//********************************************************************		
		case RECOVERY_BOOT:
			#ifdef CFG_RECOVERY_MODE
				setup_boot_tag(RECOVERY_BOOT);
			#endif	
        ret = mboot_android_load_recoveryimg_hdr(PART_RECOVERY, CFG_BOOTIMG_LOAD_ADDR);            
        if (ret < 0) {
			  	msg_header_error("Android Recovery Image");
        }   
        ret = mboot_android_load_recoveryimg(PART_RECOVERY, CFG_BOOTIMG_LOAD_ADDR);            
        if (ret < 0) {
			  	msg_img_error("Android Recovery Image");
        }
			break;

		//********************************************************************
		//* FACTORY
		//********************************************************************
		case FACTORY_BOOT:
      #if defined(CFG_NAND_BOOT)
      strlen += sprintf(commandline, "%s%s%x%s%x", 
                commandline, NAND_MANF_CMDLINE, nand_flash_man_code, NAND_DEV_CMDLINE, nand_flash_dev_id);
      #endif
      
			#ifdef CFG_FACTORY_MODE
				setup_boot_tag(FACTORY_BOOT);
			#endif

      //*************
      //* parse recovery image header
      //* 
      ret = mboot_android_load_factoryimg_hdr(CFG_FACTORY_NAME, CFG_BOOTIMG_LOAD_ADDR);
            
      if (ret < 0) {
				printf("factory image doesn't exist in SD card\n");	
			  // load boot image from nand
	      ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
	      if (ret < 0) {
				  msg_header_error("Android Boot Image");
	      }            
	      ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
        if (ret < 0) {
					msg_img_error("Android Boot Image");
	      }          
      }            
      else
      {	
	    // load the factory image
	      ret = mboot_android_load_factoryimg(CFG_FACTORY_NAME, CFG_BOOTIMG_LOAD_ADDR);            
    	  if (ret < 0) {
				  msg_img_error("Android Factory Image");
        }
      }
			break;			
		//********************************************************************
		//* ATE_FACTORY_BOOT
		//********************************************************************
		case ATE_FACTORY_BOOT:
      #if defined(CFG_NAND_BOOT)
      strlen += sprintf(commandline, "%s%s%x%s%x", 
                commandline, NAND_MANF_CMDLINE, nand_flash_man_code, NAND_DEV_CMDLINE, nand_flash_dev_id);
      #endif
      
			#ifdef CFG_FACTORY_MODE
				setup_boot_tag(ATE_FACTORY_BOOT);
			#endif

      //*************
      //* parse recovery image header
      //* 
      ret = mboot_android_load_factoryimg_hdr(CFG_FACTORY_NAME, CFG_BOOTIMG_LOAD_ADDR);
            
      if (ret < 0) {
				printf("factory image doesn't exist in SD card\n");	
			  // load boot image from nand
	      ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
	      if (ret < 0) {
				  msg_header_error("Android Boot Image");
	      }            
	      ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
        if (ret < 0) {
					msg_img_error("Android Boot Image");
	      }          
      }            
      else
      {	
	    // load the factory image
	      ret = mboot_android_load_factoryimg(CFG_FACTORY_NAME, CFG_BOOTIMG_LOAD_ADDR);            
    	  if (ret < 0) {
				  msg_img_error("Android Factory Image");
        }
      }
			break;		
		//********************************************************************
		//* SW BOOT
		//********************************************************************		
		case SW_REBOOT:
			setup_boot_tag(SW_REBOOT);
      ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);          
      if (ret < 0) {
			  msg_header_error("Android Boot Image");
      }
      ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
      if (ret < 0) {
			  msg_img_error("Android Boot Image");
      }       
			break;        
		//********************************************************************
		//* ALARM BOOT
		//********************************************************************		
		case ALARM_BOOT:
#if defined(CFG_NAND_BOOT)
      strlen += sprintf(commandline, "%s%s%x%s%x", 
                commandline, NAND_MANF_CMDLINE, nand_flash_man_code, NAND_DEV_CMDLINE, nand_flash_dev_id);
#endif

	  setup_boot_tag(ALARM_BOOT);

      ret = mboot_android_load_bootimg_hdr(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
      if (ret < 0) {
			 	msg_header_error("Android Boot Image");
      }
      
#ifdef CFG_UBOOT_PROFILING
      time_load_bootimg= get_timer(0);
#endif      
      ret = mboot_android_load_bootimg(PART_BOOTIMG, CFG_BOOTIMG_LOAD_ADDR);            
#ifdef CFG_UBOOT_PROFILING
        printf("[PROFILE] ------- load boot.img takes %d ms -------- \n", get_timer(time_load_bootimg));
#endif

      if (ret < 0) {
	  		msg_img_error("Android Boot Image");
      }          
			break;	    
	}

//*************
//* relocate rootfs (ignore rootfs header)
//*
#ifdef CFG_UBOOT_PROFILING
    time_rootfs = get_timer(0);
#endif
    //if(g_boot_mode == RECOVERY_BOOT)
    //{
      memcpy((char *)CFG_RAMDISK_LOAD_ADDR, (char *)(g_rmem_off), g_rimg_sz);
    //}
    g_rmem_off = CFG_RAMDISK_LOAD_ADDR;
#ifdef CFG_UBOOT_PROFILING
    printf("[PROFILE] ------- reloate rootfs takes %d ms -------- \n", get_timer(time_rootfs));
#endif
    
          strlen += sprintf(commandline, "%s%s%s",
                                      commandline, 
                                      " uboot_ver=" UBOOT_VERSION_CLI,
                                      " uboot_build_ver=" BUILD_VERSION_CLI
                                      );
#ifdef CFG_UBOOT_PROFILING
        ubt = ((unsigned int)get_timer(boot_time)) + 810;
        strlen += sprintf(commandline, "%s%s%d", commandline, ".ubt.", ubt);
#endif    
	
    custom_port_in_kernel(g_boot_mode, commandline);
	strlen += sprintf(commandline, "%s lcm=%1d-%s", commandline, DISP_IsLcmFound(), mt65xx_disp_get_lcm_id());
    setup_commandline_tag (bd, commandline);
  
//#endif //CONFIG_CMDLINE_TAG

//*************
//* dump some starting instruction for debug
//* 
//printf(" theKernel (0x%x)\n",g_kmem_off);
//printf(" theKernel (0x%x) = 0x%x\n",g_kmem_off,DRV_Reg32(g_kmem_off));
//printf(" theKernel (0x%x) = 0x%x\n",g_kmem_off+0x4,DRV_Reg32(g_kmem_off+0x4));
//printf(" theKernel (0x%x) = 0x%x\n",g_kmem_off+0x8,DRV_Reg32(g_kmem_off+0x8));  



//*************
//* dump some starting instruction for debug
//* 
//printf("\n rootfs (0x%x)\n",g_rmem_off);
//printf(" rootfs (0x%x) = 0x%x\n",g_rmem_off,DRV_Reg32(g_rmem_off));
//printf(" rootfs (0x%x) = 0x%x\n",g_rmem_off+0x4,DRV_Reg32(g_rmem_off+0x4));
//printf(" rootfs (0x%x) = 0x%x\n",g_rmem_off+0x8,DRV_Reg32(g_rmem_off+0x8)); 


//*************
//* specify the kernel jumping address
//* 
  theKernel = (void (*)(int, int, uint)) (g_kmem_off);
//printf("\n > kernel mem offset (not include header) = 0x%x\n",theKernel);


//*************
//* specify the rootfs starting address
//* 
  initrd_start = g_rmem_off;
  initrd_end = initrd_start + g_rimg_sz;  
//printf(" > rootfs mem offset (not include header) = 0x%x\n\n",initrd_start);


#ifdef CONFIG_INITRD_TAG
	if (initrd_start && initrd_end)
	  setup_initrd_tag (bd, initrd_start, initrd_end);
#endif
#if CONFIG_VIDEOLFB_TAG
	setup_videolfb_tag ((gd_t *) gd);
#endif
	setup_end_tag (bd);
#endif


#ifdef CFG_UBOOT_PROFILING
  printf("[PROFILE] ------- do_nand_boot takes %d ms -------- \n", get_timer(time_do_nand_boot));
  printf("[MBOOT] ------- UBoot boot kernel takes %d ms -------- \n", get_timer(boot_time));
#endif

  printf("NAND BOOT\n");
#ifdef CONFIG_LCD
  video_printf("NAND BOOT\n");
  video_printf("Boot Linux Kernel\n");   	
#endif

	//*****************
	//* to centralize deinit process, moving 
	//* "Uboot_power_saving" to "cleanup_before_linux"
	//*
	cleanup_before_linux();

	printf(" > kernel mem offset (not include header) = 0x%x\n",theKernel);


	//*****************
	//* jump to kernel
	//*
	theKernel (0, bd->bi_arch_number, bd->bi_boot_params);
	return 0;
}