MTK LCM Drive Porting

Source: Internet
Author: User
Tags directory create

for LCM-driven porting, the trilogy is generally divided into :

1, hardware IO port configuration;

2, ensure that LCM backlight can be lit normally;

3, LCM Drive transplant;


Hardware circuit:






1. Gpio Configuration

Open Mediatek\dct\drvgen.exe

Select the MEDIATEK\CUSTOM\XIAOXI\KERNEL\DCT\DCT\CODEGEN.DWS configuration file

Configuring the LCM PWM PIN, rst reset pin, DISP_PWM pin, and LCM power control pins




2. Backlight Light

After compiling and burning the system, verify that the LCM backlight can be lit normally, otherwise you can not continue to debug LCD;


3, LCM Drive transplant (take ili9806e as an example)

(1) , MEDIATEK\CUSTOM\COMMON\KERNEL\LCM directory create ili9806 directory, copy driver files to driver file ILI9806.C to the newly created directory; The code automatically links the LCM to the mediatek\custom\common\lk and mediatek\custom\common\uboot directory, so there is no need to copy driver files to LK and uboot;

(2), modify \mediatek\custom\common\kernel\lcm\mt65xx_lcm_list.c, add in lcm_driver_list array:
    extern lcm_driver Ili9806e_lcm_drv;
    #if defined (ILI9806)   
         &ili9806e_lcm_drv ,  //is the lcm_driver structure in ili9488.c
    #endif

(3), open mediatek\config\prj\projectconfig.mk Modify:
Build_lk=yes
custom_kernel_lcm=ili9806//corresponding LCM directory-driven subdirectory name
custom_lk_lcm=ili9806 //corresponding LCM directory-driven subdirectory name
custom_uboot_lcm=ili9806 //corresponding LCM directory-driven subdirectory name
lcm_width=480
lcm_height=800


when the system compiles, the compiler will follow the CUSTOM_KERNEL_LCM,custom_lk_lcm,CUSTOM_UBOOT_LCM find mediatek\custom\common\ kernel\lcm\ili9806 directory, copy the MEDIATEK\CUSTOM\OUT\PRO\KERNEL\LCM directory, participate in the compilation of the system, so there is no name for the driver file name requirements; LK and uboot;

Note: The system will also produce ILI9806 environment variables, this is the mt65xx_lcm_list.c in the #if defined (ILI9806) can be pre-compiled processing;


4, LCM Drive Brief analysis

The Lcm_driver structure represents a LCM object, which contains the LCM parameters;

Lcm_driver ili9806e_drv = {. Name          = "Ili9806e_txd_dsi_cmd_sp13_lcm_drv",   //device name. Set_util_funcs = Lcm_set_util_ Funcs,    //Get lcm_driver structure. Get_params     = lcm_get_params,  //Get LCM parameters. init           = lcm_init,      // LCM initialization function. suspend        = lcm_suspend,   //lcm hangs. Resume         = lcm_resume,    //lcm restore. compare_id     = lcm_ COMPARE_ID,  //device ID match};

The above function interface is for several important interfaces in the MTK framework;


/* Get the LCM_DRIVER structure of the device */

static void Lcm_set_util_funcs (const Lcm_util_funcs *util) {memcpy (&lcm_util, util, sizeof (LCM_UTIL_FUNCS));}  /* Get LCM various parameters */static void Lcm_get_params (Lcm_params *params) {memset (params, 0, sizeof (lcm_params));   First, the LCM_PARAMS structure is emptied params->type = LCM_TYPE_DSI;   LCM interface type params->width = Frame_width; LCM Display width params->height = frame_height; LCM Display Height/* Set communication mode *///Enable Tearing-freeparams->dbi.te_mode = Lcm_dbi_te_mode_disabled;params->dbi.te_edg        e_polarity = lcm_polarity_rising; /* DSI is divided into two modes, one is the CMD mode, one is the video mode */#if (lcm_dsi_cmd_mode) Params->dsi.mode = Cmd_mode; #elseparams->dsi.mode = Sync_pulse_vdo_mode; #endif/* Set data format *///dsi/* Command MODE setting */params->dsi.   Lane_num= Lcm_two_lane; Two channel mipi//the following defined the Fomat for data coming from LCD Engine.params->dsi.data_format.color_order = Lcm_co   Lor_order_rgb; Params->dsi.data_format.trans_seq = Lcm_dsi_trans_seq_msb_first;params->dsi.data_format.padding = LCm_dsi_padding_on_lsb;params->dsi.data_format.format = lcm_dsi_format_rgb888; Highly depends on LCD driver capability.//not support in mt6573params->dsi.packet_size = 256;//Video mode SETTINGP Arams->dsi.intermediat_buffer_num = 0;params->dsi.ps = Lcm_packed_ps_24bit_rgb888;params->dsi.word_count =        480 * 3;      /* Vertical parameter setting */params->dsi.vertical_sync_active = 4; Width of vertical sync signal params->dsi.vertical_backporch = 16;//10//Vertical sync signal back edge Params->dsi.vertical_frontporch = 20;//8//        The leading edge of the vertical synchronous signal params->dsi.vertical_active_line = frame_height;   /* Horizontal parameter setting */params->dsi.horizontal_sync_active = 10;     The width of the horizontal sync signal params->dsi.horizontal_backporch = 50;    The back edge of the horizontal sync signal is Params->dsi.horizontal_frontporch = 60;        The forefront params->dsi.horizontal_active_pixel of horizontal synchronous signals = frame_width; /* Clock frequency */params->dsi. Pll_clock= 200;}


Reset Pin
#define Set_reset_pin (v) (Lcm_util.set_reset_pin (v))//The Gpio_lcd_rst hard pin is directly used here
Delay function
#define UDELAY (N) (Lcm_util.udelay (n))
#define MDELAY (N) (Lcm_util.mdelay (n))


/* data transfer interface */
//long packet Operation Interface
#define DSI_SET_CMDQ_V3 (para_tbl, size, Force_ Update)       Lcm_util.dsi_set_cmdq_v3 (para_tbl, size, force_update)    //PARA_TBL:LCM_ Setting_table structure, size: size, force_update: Force update flag
#define DSI_SET_CMDQ_V2 (cmd, Count, Ppara, force_update)     LCM_UTIL.DSI_SET_CMDQ_V2 (cmd, Count, Ppare, force_update)//cmd: Command, Count: size, Ppara: parameter, force_update: Force update Flag
Short packet operator Interface
#define DSI_SET_CMDQ (pdata, Queue_size, force_update)       LCM_UTIL.DSI_SET_CMDQ (pdata, Queue_size, force_update)  


Operations such as read/write registers
#define WRITE_CMD (cmd) lcm_util.dsi_write_cmd (cmd)
#define WRITE_REGS (addr, pdata, byte_nums) lcm_util.dsi_write_regs (addr, pdata, bytes_nums)
#define READ_REG (cmd) lcm_util.dsi_dcs_read_lcm_reg (cmd)
#define READ_REG_V2 (cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2 (cmd, buffer, buffer_size)

/* Initialize parameters and function interfaces */

static struct Lcm_setting_table lcm_initialization_setting[] = {/* Data format: command, number of data, data *//command is typically the corresponding register address {0xFF, 5,{0xff,0x98, 0x06,0x04,0x01}},{0x08, 1, {0x10}},{0x21, 1, {0x01}},{0x30, 1, {0x02}},{0x31, 1, {0x02}},{0x40, 1, {0x16}},{0x41, 1, {0x22 }}, ...... {0x53, 1, {0x1A}},//10 {0xFF, 5,{0xff,0x98,0x06,0x04,0x07}},{0x17, 1, {0x12}},//22{0x02, 1, {0x77}},{0xff, 5,{0xff,0x9 8,0x06,0x04,0x00}}, {0x35,1,{0x00}}, {0x36,1,{0x03}},//Flip 180 degrees {0x11,1,{0x00}},{regflag_delay, +, {}},{0x29,1,{ 0x00}},{regflag_delay, {}},{regflag_end_of_table, 0x00, {}}//Data end must use regflag_end_of_table};static void Lcm_init ( void) {
        /* Reset */set_reset_pin (1); Mdelay (10); Set_reset_pin (0);/* Third Change Lava */mdelay (+);//10 Set_reset_pin (1); Mdelay (+/////)        Initialize Data */push_table (lcm_initialization_setting, sizeof (lcm_initialization_setting)/sizeof (struct lcm_setting_table), 1);}

/* Device hangs */

static void Lcm_suspend (void) {#ifdef build_lk   printf ("%s, als/ps bbbbbbbbbbbbbbb \ n", __func__), #elseprintk ("%s, Als/ps bbbbbbbbbbbbbb  \ n ", __func__);   #endifpush_table (lcm_deep_sleep_mode_in_setting, sizeof (lcm_deep_sleep_mode_in_setting)/sizeof (struct LCM_ setting_table), 1); Set_reset_pin (0); Mdelay,//10 set_reset_pin (1); Mdelay (50);}

Because the LCM driver is mapped to the LK layer, the LK layer can only be debugged using printf, but in the kernel layer can only be PRINTK for print debugging, so you can use the macro to build_lk distinguish;

There are two general mechanisms of suspending: simple or deep sleep;

Simple sleep: The device is still working, can be awakened, but there will be a standby power consumption and other issues;

Deep sleep: The device is dormant, basically in a non-working state, so it cannot be awakened;

General program design is to use deep sleep, in the wake of the re-initialization;


/* Device Recovery */

static void Lcm_resume (void) {lcm_init ();//push_table (lcm_sleep_out_setting, sizeof (lcm_sleep_out_setting)/sizeof ( struct lcm_setting_table), 1);}
Re-initialize the device

/* Device ID match */

static unsigned int lcm_compare_id () {unsigned int array[4];    unsigned char buffer[4] = {0,0,0,0};    unsigned char id_high=0;    unsigned char id_low=0;    unsigned char id_low0=0;    unsigned int id=0;    /* First Reset operation */Set_reset_pin (1);    Mdelay (10);    Set_reset_pin (0);    Mdelay (10);    Set_reset_pin (1);    Mdelay (200);    Enable CMD2 Page1 *******************//array[0]=0x00063902;    ARRAY[1]=0X0698FFFF;    array[2]=0x00000104;    DSI_SET_CMDQ (Array, 3, 1);    Array[0] = 0x00043700;    DSI_SET_CMDQ (Array, 1, 1);    Mdelay (10);    READ_REG_V2 (0x00, buffer, 4);     Id_high = buffer[0];    98 array[0] = 0x00043700;    DSI_SET_CMDQ (Array, 1, 1);    Mdelay (10);    READ_REG_V2 (0x01, buffer, 4);     Id_low = buffer[0];    Array[0] = 0x00043700;    DSI_SET_CMDQ (Array, 1, 1);    Mdelay (10);    READ_REG_V2 (0x02, buffer, 4);   Id_low0 = buffer[0]; * id = (ID_HIGH&LT;&LT;16) | (id_low<<8) |id_low0; #ifdef build_lk printf ("ili9806e:id2=%x.\n ", id);    printf ("ili9806e:id4=%x.\n", Id_high);    printf ("ili9806e:id5=%x.\n", Id_low);    printf ("ili9806e:id5=%x.\n", id_low0), #else printk ("ili9806e:id=%x.\n", id);    PRINTK ("ili9806e:id_high=%x.\n", Id_high);    PRINTK ("ili9806e:id_low=%x.\n", Id_low); PRINTK ("ili9806e:id_low=%x.\n", id_low0); #endif return (0x980604 = = ID)? 1:0;}

The data writing format is written in accordance with the MIPI protocol.

Note: If the system only configures one LCM device, the lcm_compare_id interface will not be called and only the system will have more than one device to call the interface for matching;










MTK LCM Drive Porting

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.