Mtk android LCD开机启动过程

 /bootable/bootloader/uboot/arch/arm/lib/board.c

  void start_armboot (void)
{
      
     …...........省略部分函数
//功能函数初始化 即函数队列 LCD驱动相关挂载调用
   for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr)

    {
  
             if ((*init_fnc_ptr)() != 0) {
                     hang ();

             }
     }
  
 …...........省略部分函数
// Some driver refresh RAM data to LCM after sleeping out.
// LCM must sleep out before backlight on. Or Users may see the mess data in LCM in a instance.
mt65xx_disp_power(1);
//上电
        if(g_boot_mode != ALARM_BOOT)
       {
mt65xx_disp_show_boot_logo();
  //显示的log图片
        }
          …...........省略部分函数
}


init_fnc_t *init_sequence[] = {
        cpu_init,               /* basic cpu dependent setup */
        dram_init,              /* configure available RAM banks */ /*  change the original init order */
         board_init,             /* basic board dependent setup */
        interrupt_init,         /* set up exceptions */
        env_init,               /* initialize environment */
        init_baudrate,          /* initialze baudrate settings */
        serial_init,            /* serial communications setup */
        console_init_f,         /* stage 1 init of console */
        display_banner,         /* say that we are here */
#if defined(CONFIG_DISPLAY_CPUINFO)
        print_cpuinfo,          /* display cpu info (and speed) */
#endif
#if defined(CONFIG_DISPLAY_BOARDINFO)
        checkboard,             /* display board info */
#endif
        display_dram_config,
        NULL,
};

/mediatek/platform/mt6575/uboot/mt6577_board.c
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_ARCH_ID; /* 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 mt65xx_disp_init(void *lcdbase)

{

UINT32 boot_mode_addr = 0;
    fb_size = ALIGN_TO(CFG_DISPLAY_WIDTH, 32) * ALIGN_TO(CFG_DISPLAY_HEIGHT, 32) * CFG_DISPLAY_BPP / 8;

boot_mode_addr = (void *)((UINT32)lcdbase + fb_size);

    logo_db_addr = (void *)((UINT32)lcdbase - 4 * 1024 * 1024);

//    fb_addr      = (void *)((UINT32)lcdbase + fb_size);

fb_addr  =   lcdbase;
    ///for debug prupose
    disp_log_enable(1);
    dbi_log_enable(1);
    DISP_CHECK_RET( DISP_Init((UINT32)lcdbase, (UINT32)lcdbase, FALSE));
 
memset((void*)lcdbase, 0, DISP_GetVRamSize());
    /* transparent front buffer for fb_console display */

#if 1

    LCD_CHECK_RET(LCD_LayerEnable(FB_LAYER, TRUE));

    LCD_CHECK_RET(LCD_LayerSetAddress(FB_LAYER, (UINT32)boot_mode_addr));

    LCD_CHECK_RET(LCD_LayerSetFormat(FB_LAYER, LCD_LAYER_FORMAT_RGB565));

LCD_CHECK_RET(LCD_LayerSetPitch(FB_LAYER, CFG_DISPLAY_WIDTH*2));

    LCD_CHECK_RET(LCD_LayerSetOffset(FB_LAYER, 0, 0));

    LCD_CHECK_RET(LCD_LayerSetSize(FB_LAYER, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT));

    LCD_CHECK_RET(LCD_LayerSetSourceColorKey(FB_LAYER, TRUE, 0x0));

#endif


   /* background buffer for uboot logo display */

    LCD_CHECK_RET(LCD_LayerEnable(FB_LAYER - 1, TRUE));

    LCD_CHECK_RET(LCD_LayerSetAddress(FB_LAYER - 1, (UINT32)fb_addr));

    LCD_CHECK_RET(LCD_LayerSetFormat(FB_LAYER - 1, LCD_LAYER_FORMAT_RGB565));


    LCD_CHECK_RET(LCD_LayerSetOffset(FB_LAYER - 1, 0, 0));

    LCD_CHECK_RET(LCD_LayerSetSize(FB_LAYER - 1, CFG_DISPLAY_WIDTH, CFG_DISPLAY_HEIGHT));

    LCD_CHECK_RET(LCD_LayerSetPitch(FB_LAYER - 1, ALIGN_TO(CFG_DISPLAY_WIDTH, 32)*2));


    if(0 == strncmp(MTK_LCM_PHYSICAL_ROTATION, "180", 3))

    {

LCD_CHECK_RET(LCD_LayerSetRotation(FB_LAYER, LCD_LAYER_ROTATE_180));


LCD_CHECK_RET(LCD_LayerSetRotation(FB_LAYER - 1, LCD_LAYER_ROTATE_180));


    }


}

/mediatek/kernel/drivers/video/disp_drv.c
static const DISP_DRIVER *disp_drv = NULL;
DISP_STATUS DISP_Init(UINT32 fbVA, UINT32 fbPA, BOOL isLcmInited)
{

    DISP_STATUS r = DISP_STATUS_OK;

    if (!disp_drv_init_context()) {

        return DISP_STATUS_NOT_IMPLEMENTED;
    }

// /* power on LCD before config its registers*/

// LCD_CHECK_RET(LCD_Init());

    disp_drv_init_ctrl_if();

// For DSI PHY current leakage SW workaround.

///TODO: HOW!!!

#if !defined (MTK_HDMI_SUPPORT)

if((lcm_params->type!=LCM_TYPE_DSI) && (lcm_params->type!=LCM_TYPE_DPI)){

DSI_PHY_clk_switch(TRUE);
DSI_PHY_clk_switch(FALSE);
}

#endif

    fbVA += DISP_GetFBRamSize();

    fbPA += DISP_GetFBRamSize();

#ifndef BUILD_UBOOT

DISP_InitVSYNC((100000000/lcd_fps) + 1);//us

#endif

    r = (disp_drv->init) ?

        ( disp_drv->init(fbVA, fbPA, isLcmInited)) :


        DISP_STATUS_NOT_IMPLEMENTED;

    {

        DAL_STATUS ret;

        /// DAL init here
        fbVA += disp_drv->get_working_buffer_size();

        fbPA += disp_drv->get_working_buffer_size();
        ret = DAL_Init(fbVA, fbPA);
        ASSERT(DAL_STATUS_OK == ret);
        dal_layerPA = fbPA;
        dal_layerVA = fbVA;
    }

    return r;
}


/mediatek/platform/mt6575/uboot/disp_drv_dsi.c


const DISP_DRIVER *DISP_GetDriverDSI()

{
    static const DISP_DRIVER DSI_DISP_DRV =

    {
        .init                   = dsi_init,
        .enable_power           = dsi_enable_power,
        .update_screen          = dsi_update_screen,
        .get_working_buffer_size = dsi_get_working_buffer_size,
        .get_panel_color_format = dsi_get_panel_color_format,
        .get_working_buffer_bpp = dsi_get_working_buffer_bpp,
        .init_te_control        = init_lcd_te_control,
        .get_dithering_bpp = dsi_get_dithering_bpp,
        .capture_framebuffer = dsi_capture_framebuffer,
        .esd_reset              = dsi_esd_reset,
        .esd_check = dsi_esd_check,
    };

    return &DSI_DISP_DRV;

}

extern LCM_DRIVER *lcm_drv;
static DISP_STATUS dsi_init(UINT32 fbVA, UINT32 fbPA, BOOL isLcmInited)

{
if (!disp_drv_dsi_init_context())
return DISP_STATUS_NOT_IMPLEMENTED;
if(lcm_params->dsi.mode == CMD_MODE) {
init_lcd();
init_dsi(isLcmInited);

if (NULL != lcm_drv->init && !isLcmInited)
{
lcm_drv->init();
}

DSI_clk_HS_mode(0);
DSI_SetMode(lcm_params->dsi.mode);

DPI_PowerOn();
DPI_PowerOff();

init_lcd_te_control();

}

else {

#ifndef BUILD_UBOOT

spin_lock(&g_handle_esd_lock);

#endif

init_intermediate_buffers(fbPA);


    init_lcd();

init_dpi(isLcmInited);

init_dsi(isLcmInited);

if (NULL != lcm_drv->init && !isLcmInited) {

lcm_drv->init();

}


DSI_SetMode(lcm_params->dsi.mode);

#ifndef BUILD_UBOOT


if(lcm_params->dsi.lcm_ext_te_monitor)
{

dsi_vdo_streaming = false;

LCD_TE_SetMode(LCD_TE_MODE_VSYNC_ONLY);

LCD_TE_SetEdgePolarity(LCM_POLARITY_RISING);

LCD_TE_Enable(FALSE);

}

if(lcm_params->dsi.noncont_clock)

DSI_set_noncont_clk(false, lcm_params->dsi.noncont_clock_period);

if(lcm_params->dsi.lcm_int_te_monitor)

DSI_set_int_TE(false, lcm_params->dsi.lcm_int_te_period);

spin_unlock(&g_handle_esd_lock);

#endif

}


return DISP_STATUS_OK;


}
/mediatek/custom/common/kernel/lcm/ili9486_dsi_beetle/ili9486_dsi_beetle.c

LCM_DRIVER ili9486_dsi_beetle_lcm_drv =

{

        .name                   = "ili9486_dsi_beetle",
        .set_util_funcs = lcm_set_util_funcs,
        .get_params     = lcm_get_params,
        .init           = lcm_init,
        .suspend        = lcm_suspend,
        .resume         = lcm_resume,
        .update         = lcm_update,
        .esd_check              = lcm_esd_check,
        .esd_recover    = lcm_esd_recover,

};
//调用到硬件操作的驱动
static void lcm_init(void)

{
SET_RESET_PIN(1);

MDELAY(5);

SET_RESET_PIN(0);
MDELAY(20);
SET_RESET_PIN(1);
MDELAY(120);
push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);


}

你可能感兴趣的:(Mtk android LCD开机启动过程)