static unsigned int lcm_compare_id(void)
{
	int array[4];
	char buffer[5];
	char id_high=0;
	char id_low=0;
	int id=0;

	SET_RESET_PIN(1);
	SET_RESET_PIN(0);
	MDELAY(10);
	SET_RESET_PIN(1);
	MDELAY(200);

	array[0] = 0x00053700;
	dsi_set_cmdq(array, 1, 1);
	read_reg_v2(0xa1, buffer, 5);

	id_high = buffer[2];
	id_low = buffer[3];
	id = (id_high<<8) | id_low;

	#if defined(BUILD_UBOOT)
		//printf("OTM8018B uboot %s \n", __func__);
		//printf("%s id = 0x%08x \n", __func__, id);
	#else
		//printk("OTM8018B kernel %s \n", __func__);
		//printk("%s id = 0x%08x \n", __func__, id);
	#endif

	return (LCM_ID_OTM8018B == id)?1:0;
}
static unsigned int lcm_compare_id(void)
{
    int   array[4];
    char  buffer[5];
    unsigned int id=0;

#if defined(BUILD_LK)
    upmu_set_rg_vgp2_vosel(5);
    upmu_set_rg_vgp2_en(1);

    upmu_set_rg_vgp3_vosel(3);
    upmu_set_rg_vgp3_en(1);
#else
    hwPowerOn(MT6323_POWER_LDO_VGP2, VOL_2800, "Lance_LCM");
    hwPowerOn(MT6323_POWER_LDO_VGP3, VOL_1800, "Lance_LCM");
#endif
    MDELAY(100);

    SET_RESET_PIN(1);
    MDELAY(5);
    SET_RESET_PIN(0);
    MDELAY(30);
    SET_RESET_PIN(1);
    MDELAY(120);

    array[0] = 0x00083700;// read id return two byte,version and id
    dsi_set_cmdq(array, 1, 1);

    read_reg_v2(0xA1,buffer,4);
    id=(buffer[2]<<8)+buffer[3];
	
    Lcd_Log("mycat lcd id: 0x%08x\n", id);
	
    return (LCM_ID == id)?1:0;
}
static unsigned int lcm_compare_id(void)
{
	unsigned int id=0;
	unsigned char buffer[2];
	unsigned int array[16];  

	SET_RESET_PIN(1);
	SET_RESET_PIN(0);
	MDELAY(1);
	
	SET_RESET_PIN(1);
	MDELAY(20); 

	array[0] = 0x00023700;// read id return two byte,version and id
	dsi_set_cmdq(array, 1, 1);
	
	read_reg_v2(0xF4, buffer, 2);
	id = buffer[0]; //we only need ID
    #ifdef BUILD_LK
		printf("%s, LK nt35590 debug: nt35590 id = 0x%08x\n", __func__, id);
    #else
		printk("%s, kernel nt35590 horse debug: nt35590 id = 0x%08x\n", __func__, id);
    #endif

    if(id == LCM_ID_NT35590)
    	return 1;
    else
        return 0;


}
static unsigned int lcm_compare_id(void)
{
	unsigned int id = 0;
	unsigned char buffer[2] = { 0 };
	unsigned int data_array[16];

	SET_RESET_PIN(1);
	SET_RESET_PIN(0);
	MDELAY(5);
	SET_RESET_PIN(1);
	MDELAY(20);

	data_array[0] = 0x00063902;
	data_array[1] = 0x52AA55F0;
	data_array[2] = 0x00000108;
	dsi_set_cmdq(data_array, 3, 1);
	MDELAY(10);

	data_array[0] = 0x00023700;
	dsi_set_cmdq(data_array, 1, 1);
	MDELAY(10);

	read_reg_v2(0xC5, buffer, 2);
	id = buffer[0];

	return (LCM_ID1 == id) ? 1 : 0;
}
static unsigned int lcm_esd_check(void)
{
#ifndef BUILD_LK
	static int ok_count = 0;
	 unsigned char buffer[12];
	 unsigned int array[16];
	 int i;
	 
	 
	if(lcm_esd_test)
  {
      lcm_esd_test = 0;
      return 1;
  }
	 	
	array[0] = 0x00013700;
	dsi_set_cmdq(array, 1, 1);
	//MDELAY(20);
	read_reg_v2(0x0A, buffer, 1);
	 
	printk("mycat$$  ### esd check buffer[0] = 0x%x\r\n",buffer[0]);
	
	if(buffer[0] == 0x9C)//9C
		return 0;
	else
		return 1;
 			
#endif
}
static unsigned int lcm_compare_id(void)
{
    unsigned int id = 0;
    unsigned char buffer[5];
    unsigned int array[16];

    SET_RESET_PIN(1);	//NOTE:should reset LCM firstly
    MDELAY(10);
    SET_RESET_PIN(0);
    MDELAY(50);
    SET_RESET_PIN(1);
    MDELAY(50);

    array[0] = 0x00053700;	// read id return two byte,version and id
    dsi_set_cmdq(array, 1, 1);
    read_reg_v2(0xa1, buffer, 5);
    id = ((buffer[2] << 8) | buffer[3]);	//we only need ID

#ifdef BUILD_LK
    printf("[erick-lk]%s,  otm9605a id = 0x%08x\n", __func__, id);
#else
    printk("[erick-k]%s,  otm9605a id = 0x%08x\n", __func__, id);
#endif
    return (LCM_ID == id&&get_lcd_id()==1)?1:0;

    //return (LCM_ID == id)?1:0;
    // return (get_lcd_id()==0)?1:0;

}
static unsigned int lcm_compare_id(void)
{
	unsigned int id=0;
	unsigned int id1=0;
	unsigned char buffer[2];
	unsigned int array[16];  

	SET_RESET_PIN(1);
	SET_RESET_PIN(0);
	MDELAY(1);
	SET_RESET_PIN(1);
	MDELAY(10);//Must over 6 ms

	array[0]=0x00043902;
	array[1]=0x8983FFB9;// page enable
	dsi_set_cmdq(&array, 2, 1);
	MDELAY(10);

	array[0] = 0x00023700;// return byte number
	dsi_set_cmdq(&array, 1, 1);
	MDELAY(10);

	read_reg_v2(0xF4, buffer, 2);
	id = buffer[0]; 
        id1 = buffer[0]<<8 |buffer[1]; 

	LCM_DBG("[WUHAI] -- hx8389b 0x%x , 0x%x , 0x%x , 0x%x \n",buffer[0],buffer[1],id,id1);

	#if defined(BUILD_UBOOT) || defined(BUILD_LK)
		return 1;//lcm_adc_read_chip_id();			
	#endif
	return 1	;
}
static unsigned int test_compare_id(void)
{
	unsigned int id=0;
	unsigned int id1=0;
	unsigned char buffer[2];
	unsigned int array[16];  

	array[0]=0x00043902;
	array[1]=0x8983FFB9;// page enable
	dsi_set_cmdq(&array, 2, 1);
	MDELAY(10);

	array[0] = 0x00023700;// return byte number
	dsi_set_cmdq(&array, 1, 1);
	MDELAY(10);

	read_reg_v2(0xF4, buffer, 2);
	id = buffer[0]; 
        id1 = buffer[0]<<8 |buffer[1]; 

	LCM_DBG("[WUHAI] -- hx8389b 0x%x , 0x%x , 0x%x , 0x%x \n",buffer[0],buffer[1],id,id1);
	
	if(LCM_ID_HX8389B == id){
			//#if defined(BUILD_UBOOT) || defined(BUILD_LK)
				if(lcm_adc_read_chip_id())
					return 1;
				else
					return  0;//Default LCM
			//#endif
			return 1;
		}
	return 0	;

}
static unsigned int lcm_compare_id(void)
{
	//return 1;
       unsigned int id = 0,id1=0,id2 = 0;
 
    unsigned char buffer[2];
 
   unsigned int data_array[16];
 
    

 
 
    SET_RESET_PIN(1);  //NOTE:should reset LCM firstly
 
    MDELAY(10);
 
    SET_RESET_PIN(0);
 
    MDELAY(10);
 
    SET_RESET_PIN(1);
 
    MDELAY(10);        



    //*************Enable CMD2 Page1  *******************//
 
    data_array[0]=0x00063902;
 
    data_array[1]=0x52AA55F0;
 
    data_array[2]=0x00000108;
 
    dsi_set_cmdq(data_array, 3, 1);
 
    MDELAY(10); 

    
 
    data_array[0] = 0x00023700;// read id return two byte,version and id
 
    dsi_set_cmdq(data_array, 1, 1);
 
    MDELAY(10); 

    
 
    read_reg_v2(0xC5, buffer, 2);
 
    id1 = buffer[0]; //we only need ID
 
    id2= buffer[1]; //we test buffer 1

    id = (id1<<8) | id2;
    return (0x5517 == id)?1:0;

}
Beispiel #10
0
static unsigned int lcm_compare_id(void)
{
	unsigned int id = 0, id2 = 0;
	unsigned char buffer[4];
	unsigned int array[16];

//	push_table(lcm_compare_id_setting, sizeof(lcm_compare_id_setting) / sizeof(struct LCM_setting_table), 1);
	
//Ivan
// 00 = MTK Config = Type 0 Instruction = Short Packet read/write
// 37 = DSI Data type = Set Maximum return packet size
// 0003 = data length = 3 bytes data to read
//Data = 00/11/22/33	
//	config_gpio();
/*
	SET_RESET_PIN(1);  //NOTE:should reset LCM firstly
	MDELAY(10);
	SET_RESET_PIN(0);
	MDELAY(10);
	SET_RESET_PIN(1);
	MDELAY(120);	

	array[0] = 0x00013700;// read id return two byte,version and id
	dsi_set_cmdq(array, 1, 1);
	MDELAY(10);	
	
	read_reg_v2(0xDB, buffer, 1);
	id = buffer[0]; //we only need ID
*/

	SET_RESET_PIN(1);  //NOTE:should reset LCM firstly
	MDELAY(10);
	SET_RESET_PIN(0);
	MDELAY(10);
	SET_RESET_PIN(1);
	MDELAY(120);	
	buffer[0] = 0;
	buffer[1] = 0;
	buffer[2] = 0;
	buffer[3] = 0;	
	
	array[0]=0x00063902;
	array[1]=0x52AA55F0;
	array[2]=0x00000108;
	dsi_set_cmdq(&array, 3, 1);
	MDELAY(10); 

	array[0] = 0x00023700;// read id return two byte,version and id
	dsi_set_cmdq(array, 1, 1);
	MDELAY(10); 
	
	read_reg_v2(0xC5, buffer, 2);
	id = buffer[0]; //we only need ID
	id2= buffer[1]; //we test buffer 1	

	LCM_DBG("ID1 = %x, ID2 = %x, ID3 = %x, ID4 = %x", buffer[0],buffer[1],buffer[2],buffer[3]);	
//	return (LCM_ID == id)?1:0;
	return 1;
}
Beispiel #11
0
static unsigned int lcm_compare_id(void)
{
	unsigned int data_array[16];
	unsigned int id=0;
        unsigned char buff[3];
        unsigned char id_04;

	SET_RESET_PIN(1);
	MDELAY(1);
	SET_RESET_PIN(0);
	MDELAY(10);
	SET_RESET_PIN(1);	
	MDELAY(50);
        
 	data_array[0]=0x00043902;
	data_array[1]=0x9483FFB9;
	dsi_set_cmdq(&data_array,2,1);
	MDELAY(10);

	data_array[0]=0x13BA1502;
	dsi_set_cmdq(&data_array,1,1);
	MDELAY(10);
    
	data_array[0] = 0x00033700;
	dsi_set_cmdq(&data_array, 1, 1);
    	MDELAY(10); 
        
	read_reg_v2(0x04,buff, 3);
        id_04 = buff[0];
        
	mt_set_gpio_mode(142,0);  // gpio mode   high
	mt_set_gpio_pull_enable(142,0);
	mt_set_gpio_dir(142,0);  //input
	id = mt_get_gpio_in(142);//should be 0

#if defined(BUILD_LK)
        printf(" BUILD_LK m_compare_id id_04 =  %x,buff = %x,%x.%x-----------------\n", id_04,buff[0],buff[1],buff[2]);
        printf("BUILD_LK cm_compare_id id =  %x-----------------\n", id);
#elif defined(BUILD_UBOOT)
        printf(" BUILD_UBOOT m_compare_id id_04 =  %x,buff = %x,%x.%x-----------------\n", id_04,buff[0],buff[1],buff[2]);
        printf("BUILD_UBOOT cm_compare_id id =  %x-----------------\n", id);
#else
        printk(" lcm_compare_id id_04 =  %x,buff = %x,%x.%x-----------------\n", id_04,buff[0],buff[1],buff[2]);
        printk("lcm_compare_id id =  %x-----------------\n", id);
#endif
         
        if((id_04 & 0xff) == 0x1C) 
        {
            return 0;
        }
	else if(id == LCM_ID)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}
static unsigned int lcm_compare_id(void)
{
#if 0
	unsigned int id=0;
	unsigned char buffer[2];
	unsigned int array[16];

	SET_RESET_PIN(1);
	SET_RESET_PIN(0);
	MDELAY(1);
	SET_RESET_PIN(1);
	MDELAY(10);//Must over 6 ms

	array[0]=0x00043902;
	array[1]=0x9483FFB9;// page enable
	dsi_set_cmdq(&array, 2, 1);
	MDELAY(10);

	array[0] = 0x00023700;// return byte number
	dsi_set_cmdq(&array, 1, 1);
	MDELAY(10);

	read_reg_v2(0xF4, buffer, 2);
	id = buffer[0];

#ifdef BUILD_LK
	printf("HX8394D_dsi_truly %s, id = 0x%08x\n", __func__, id);
#else
	printk("HX8394D_dsi_truly %s, id = 0x%08x\n", __func__, id);
#endif

	return (LCM_ID_HX8394D == id)?1:0; 
#else
	unsigned int ret = 0;

	

	ret = mt_get_gpio_in(GPIO17);
#if defined(BUILD_LK)
	printf("%s, [jx]hx8394a GPIO17 = %d \n", __func__, ret);
	printf("------------------lcm_compare_id\n");
#endif	

      if(ret == 1)
      	{
      	    mt_set_gpio_out(GPIO126,1);
      	}
	else{
	    mt_set_gpio_out(GPIO126,0);
	 }

	//mt_set_gpio_mode(GPIO126, GPIO_MODE_00);
    	//mt_set_gpio_dir(GPIO126, GPIO_DIR_OUT);
	//mt_set_gpio_out(GPIO126,1);

	//return (ret == 1)?1:0; 
	return 0; 
#endif
}
static unsigned int lcm_compare_id(void)
{

		int   array[4];
		char  buffer[3];
		char  id0=0;
		char  id1=0;
		char  id2=0;


		SET_RESET_PIN(0);
		MDELAY(200);
		SET_RESET_PIN(1);
		MDELAY(200);
		
	array[0] = 0x00033700;// read id return two byte,version and id
	dsi_set_cmdq(array, 1, 1);

	read_reg_v2(0xDA,buffer, 1);

	
	array[0] = 0x00033700;// read id return two byte,version and id
	dsi_set_cmdq(array, 1, 1);
	read_reg_v2(0xDB,buffer+1, 1);

	
	array[0] = 0x00033700;// read id return two byte,version and id
	dsi_set_cmdq(array, 1, 1);
	read_reg_v2(0xDC,buffer+2, 1);
	
	id0 = buffer[0]; //should be 0x00
	id1 = buffer[1];//should be 0xaa
	id2 = buffer[2];//should be 0x55
	#ifdef BUILD_UBOOT
		printf("zhibin uboot %s\n", __func__);
		printf("%s, id0 = 0x%08x\n", __func__, id0);//should be 0x00
		printf("%s, id1 = 0x%08x\n", __func__, id1);//should be 0xaa
		printf("%s, id2 = 0x%08x\n", __func__, id2);//should be 0x55
	#else
		//printk("zhibin kernel %s\n", __func__);	
	#endif
	
	return 1;


}
static unsigned int lcm_compare_id(void)
{
	unsigned int id=0, id1 = 0,id2 = 0;
	unsigned int check_esd = 0;
	unsigned int array[16]; 
	unsigned char buffer[4];
       int volt = 0;
	unsigned int data[4];
	
	array[0] = 0x00043700;// read id return 4 bytes,version and id
	dsi_set_cmdq(array, 1, 1);
	MDELAY(10);	
	read_reg_v2(0xA1, buffer, 4);
       id1 = buffer[2];
       id2 = buffer[3];
       id = (id1<<8 | id2);
       LCM_DBG("lcm_compare_id read id=0x%x, id1=0x%x, id2=0x%x",id, id1,id2);
    
	array[0] = 0x00033700;// read esd return 3 bytes
	dsi_set_cmdq(array, 1, 1);	
	MDELAY(10);
	read_reg_v2(0x0A, buffer, 3);    
       check_esd = buffer[0];
       LCM_DBG("lcm_compare_id read check_esd=0x%x",check_esd);
 
       if(LCM_ID_OTM1283 == id)
       {
           IMM_GetOneChannelValue(0, data, &volt);
      	    #ifndef BUILD_LK
      	        printk(" lcm_compare_id tcl_oncell lishengli    volt = %d ", volt);
      	    #else
      	        printf(" lcm_compare_id tcl_onclee lishengli   volt = %d ", volt);
      	    #endif
      
      	    if(volt > 100)
      	 	 return 1;
      	    else
      		return 0;
	}
	else
	    return 0;

	//return (LCM_ID_OTM1283 == id)?1:0;
}                                     
static unsigned int lcm_compare_id(void)
{

	int   array[4];
	char  buffer[3];
	char  id0=0;
	char  id1=0;
	char  id2=0;


	lcm_reset();//must be ahead of this function.
		
#if defined BUILD_UBOOT
	if(lcm_adc_read_chip_id())
		return 1;
#endif
		
	array[0] = 0x00033700;// read id return two byte,version and id
	dsi_set_cmdq(array, 1, 1);

	read_reg_v2(0xDA,buffer, 1);

	
	array[0] = 0x00033700;// read id return two byte,version and id
	dsi_set_cmdq(array, 1, 1);
	read_reg_v2(0xDB,buffer+1, 1);

	
	array[0] = 0x00033700;// read id return two byte,version and id
	dsi_set_cmdq(array, 1, 1);
	read_reg_v2(0xDC,buffer+2, 1);
	
	id0 = buffer[0]; //should be 0x00
	id1 = buffer[1];//should be 0xaa
	id2 = buffer[2];//should be 0x55
#ifdef BUILD_UBOOT
	printf("%s, id0 = 0x%08x\n", __func__, id0);//should be 0x00
	printf("%s, id1 = 0x%08x\n", __func__, id1);//should be 0xaa
	printf("%s, id2 = 0x%08x\n", __func__, id2);//should be 0x55
#endif
	
	return 1;
}
static unsigned int lcm_esd_check(void)
{
#ifndef BUILD_LK
	int array[4];
	unsigned char buffer[2];

	if(lcm_esd_test)
	{
	    lcm_esd_test = FALSE;
	    return TRUE;
	}

	/// please notice: the max return packet size is 1
	/// if you want to change it, you can refer to the following marked code
	/// but read_reg currently only support read no more than 4 bytes....
	/// if you need to read more, please let BinHan knows.
	/*
	        unsigned int data_array[16];
	        unsigned int max_return_size = 1;
	        
	        data_array[0]= 0x00003700 | (max_return_size << 16);    
	        
	        dsi_set_cmdq(&data_array, 1, 1);
	*/

	array[0]=0x00043902;
	array[1]=0x9483FFB9;// page enable
	dsi_set_cmdq(array, 2, 1);
//		MDELAY(20);

	array[0]=0x00083902; 
	array[1]=0x009341BA;// page enable 
	array[2]=0x1800A416; 
	dsi_set_cmdq(array, 3, 1); 
//		MDELAY(10); 

	array[0] = 0x00023700;// return byte number
	dsi_set_cmdq(array, 1, 1);
//		MDELAY(10);
	read_reg_v2(0x0a, buffer, 1);

	#ifndef BUILD_LK
	printk("[%s] hct_hx8394f_dsi_vdo_hd_* lcm esd check. arthur %x\n", __FUNCTION__, buffer[0]);
	#endif

	if(buffer[0] == 0x1c)
	{
	    return FALSE;
	}
	else
	{            
	    return TRUE;
	}
#endif
}
static unsigned int lcm_check_state()
{
    unsigned char buffer_1[12] = {0};
    unsigned char buffer_2[12] = {0};
    unsigned char buffer_3[12] = {0};
    unsigned char buffer_4[12] = {0};
    unsigned int array_1[16];
    unsigned int array_2[16];
    unsigned int array_3[16];
    unsigned int array_4[16];
 
     array_1[0] = 0x00013700;
     dsi_set_cmdq(array_1, 1,1);
    read_reg_v2(0x0A, buffer_1,7);
    printk("nt35521_hd720_dsi_vdo_tm buffer_1[0] = %d\n",buffer_1[0]);
	
    array_2[0] = 0x00013700;
    dsi_set_cmdq(array_2, 1,1);	
    read_reg_v2(0x0B, buffer_2,7);
    printk("nt35521_hd720_dsi_vdo_tm buffer_2[0] = %d\n",buffer_2[0]);
	
    array_3[0] = 0x00013700;
    dsi_set_cmdq(array_3, 1,1);	
    read_reg_v2(0x0C, buffer_3,7);
    printk("nt35521_hd720_dsi_vdo_tm buffer_3[0] = %d\n",buffer_3[0]);
		
    array_4[0] = 0x00013700;
    dsi_set_cmdq(array_4, 1,1);	
    read_reg_v2(0x0D, buffer_4,7);	
    printk("nt35521_hd720_dsi_vdo_tm buffer_4[0] = %d\n",buffer_4[0]);
	
    if((buffer_1[0] != 0x9C) || (buffer_2[0] != 0x00) || (buffer_3[0] != 0x70) || (buffer_4[0] != 0x00))/*LCD work status error,need re-initalize*/
    {
        printk("nt35521_hd720_dsi_vdo_tm lcm_esd_check fail! buffer_1[0] = %d buffer_2[0] = %d buffer_3[0] = %d buffer_4[0] = %d\n",buffer_1[0],buffer_2[0],buffer_3[0],buffer_4[0]);
        return FALSE;
    }
    else/*LCD work status ok*/
    {
        printk("nt35521_hd720_dsi_vdo_tm lcm_esd_check ok! buffer_1[0] = %d buffer_2[0] = %d buffer_3[0] = %d buffer_4[0] = %d\n",buffer_1[0],buffer_2[0],buffer_3[0],buffer_4[0]);
        return TRUE;
    }
}
static unsigned int lcm_esd_check(void)
{
#ifndef BUILD_LK

/*
#ifdef BUILD_LK
	printf("ccccccccccccccccccccccccccccccccccccccccccccccccccccc");
#else
	printk(KERN_ERR "ccccccccccccccccccccccccccccccccccccccccccccccccccccc");
	printk(KERN_ERR "ccccccccccccccccccccccccccccccccccccccccccccccccccccc");
	printk(KERN_ERR "ccccccccccccccccccccccccccccccccccccccccccccccccccccc");
#endif
*/
    int array[4];
    char buffer[3]={0};


	array[0] = 0x00013700;
	dsi_set_cmdq(array, 1, 1);
	read_reg_v2(0x0A, buffer, 1);
//#ifndef BUILD_LK
//	printk(KERN_ERR "cccccccccccccccccccccccccccbuf0=%4x\n",buffer[0]);
//#endif
    if(0x9c == buffer[0])
        return FALSE;
    else if(0x02 == buffer[0])
    {
	array[0] = 0x00013700;
	dsi_set_cmdq(array, 1, 1);
	read_reg_v2(0x0A, buffer, 1);
    if(0x9c == buffer[0])
        return FALSE;
    else if(0x02 == buffer[0])
        {
        printk(KERN_ERR "nt35517:read register 0x0A=%4x\n",buffer[0]);
        return TRUE;
         }
    }
#endif


}
static unsigned int lcm_compare_id(void)
{
#if 0
	unsigned int id,id1=0;
	unsigned char buffer[2];
	unsigned int array[16];  

	SET_RESET_PIN(0);
	MDELAY(20); 
	SET_RESET_PIN(1);
	MDELAY(20); 


	array[0]=0x00043902;
	array[1]=0x8983FFB9;// page enable
	dsi_set_cmdq(array, 2, 1);
	//MDELAY(10);
//{0x39,0xBA,7,{0x41,0x93,0x00,0x16,0xA4,0x10,0x18}},	
	array[0]=0x00083902;
	array[1]=0x009341BA;// page enable
	array[2]=0x1810a416;
	dsi_set_cmdq(array, 3, 1);

	array[0] = 0x00043700;// return byte number
	dsi_set_cmdq(array, 1, 1);
	MDELAY(10);

	read_reg_v2(0xF4, buffer, 3);
	id  =  buffer[1]; 
	id1 =  buffer[0];
	
#ifdef BUILD_LK
	printf("%s, id = 0x%08x id1=%x \n", __func__, id,id1);
#else
	printk("%s, id = 0x%08x  id1=%x \n",__func__, id,id1);
#endif

	return (LCM_ID_HX8389B == id)?1:0;
#else

unsigned int ret=0;
ret=mt_get_gpio_in(GPIO92);
#ifdef BUILD_LK
printf("read gpio92 = %d  \n",ret);
#else
printk("read gpio92 = %d  \n",ret);
#endif

return (ret==0)?1:0;
#endif

}
static unsigned int lcm_compare_id()
{
  unsigned int id = 0;
  unsigned int lcd_id=0;
  unsigned char buffer[4];
  unsigned int data_array[16];
  SET_RESET_PIN(1);  //TE:should reset LCM firstly
  MDELAY(1);
  SET_RESET_PIN(0);
  MDELAY(20);
  SET_RESET_PIN(1);
  MDELAY(120);
  #ifdef BUILD_LK
    DSI_clk_HS_mode(1);
  #endif
  MDELAY(10);
  #ifdef BUILD_LK
    DSI_clk_HS_mode(0);
  #endif
 //data_array[0]=0x00063902;
 //data_array[1]=0x52AA55F0; // SET password
 //data_array[2]=0x00000108; 
 push_table(lcm_read_lcm_compare_id, sizeof(lcm_read_lcm_compare_id) / sizeof(struct LCM_setting_table), 1);
 read_reg_v2(0xF4, buffer, 3);
 
 id = buffer[0]; //we only need ID 0x00 0x80 0x00
 #ifndef BUILD_LK
   printk("<6>zhangjun [lcm_compare_id %x,%x,%x\n",buffer[0],buffer[1],buffer[2]);
 #else
   printf("<6>zhangjun [lcm_compare_id %x,%x,%x\n",buffer[0],buffer[1],buffer[2]);
 #endif
	if(0x79!= id)
		return 0;

	mt_set_gpio_mode(GPIO_LCM_ID, GPIO_LCM_ID_M_GPIO);
	mt_set_gpio_dir(GPIO_LCM_ID, GPIO_DIR_IN);		
	mt_set_gpio_pull_enable(GPIO_LCM_ID,GPIO_PULL_DISABLE);
	mt_set_gpio_pull_select(GPIO_LCM_ID,GPIO_PULL_DOWN);
	MDELAY(1);
	lcd_id =  mt_get_gpio_in(GPIO_LCM_ID);
#ifndef BUILD_LK
	printk("<6>vendor jingtai [lcm_compare_id] lcd_id =%x\n",lcd_id);
#else
	printf("<6>vendor jingtai [lcm_compare_id] lcd_id =%x\n",lcd_id);
#endif

	if(lcd_id)
		return 0;
	else
		return 1;

}
static unsigned int lcm_esd_check(void)
{  
    unsigned int  data_array[16];
    unsigned char buffer_0a = 0;    
    unsigned int retval = 0;
    
    dummy_delay ++;

    if (dummy_delay >=10000)
        dummy_delay = 0;
    
    if(dummy_delay %2 == 0)
    {    


	    data_array[0] = 0x00013700;
	    dsi_set_cmdq(data_array, 1, 1);
	    read_reg_v2(0x0a,&buffer_0a, 1);



            #ifdef BUILD_LK
	    printf("build lk lcm_esd_check lcm -----------------\n");
	    printf("lcm_esd_check lcm 0x0A is %x-----------------\n", buffer_0a);
            #else
	    printk("not build lk lcm_esd_check lcm -----------------\n");	
            printk("lcm_esd_check lcm 0x0A is %x-----------------\n", buffer_0a);
            #endif
	
	    if (buffer_0a==0x9C)
               
            {	    
			#ifdef BUILD_LK
		   printf("diablox_lcd lcm_esd_check done\n");
			#else
			printk("diablox_lcd lcm_esd_check done\n");
			#endif
		    retval = 0;
	    }else{
			 #ifdef BUILD_LK
		    printf("diablox_lcd lcm_esd_check return true\n");
			#else
			 printk("diablox_lcd lcm_esd_check return true\n");
			#endif
		    retval = 1;
	    }
    }

	return retval;
  
}
static unsigned int lcm_compare_id(void)
{
 
    unsigned int id = 0, id2 = 0;
    unsigned char buffer[3];
    unsigned int data_array[16];

#ifdef BUILD_LK
		  pmic_config_interface(0x0532,5,0x7,5);//add by libo for VGP2 POWER ON
		  pmic_config_interface(0x050C,1,0x1,15);
#else
		  hwPowerOn(MT6323_POWER_LDO_VGP2,VOL_2800,"LCM");
#endif
    MDELAY(100);

    SET_RESET_PIN(1);  //NOTE:should reset LCM firstly
    MDELAY(10);
    SET_RESET_PIN(0);
    MDELAY(10);
    SET_RESET_PIN(1);
    MDELAY(120);	
    
    /*	
    data_array[0] = 0x00110500;		// Sleep Out
    dsi_set_cmdq(data_array, 1, 1);
    MDELAY(120);
    */
    //*************Enable CMD2 Page1  *******************//
    data_array[0]=0x00043902;
    data_array[1]=0x1698FFFF;
    dsi_set_cmdq(data_array, 2, 1);
    MDELAY(20); 
    
    data_array[0] = 0x00033700;// read id return two byte,version and id
    dsi_set_cmdq(data_array, 1, 1);
    MDELAY(20); 
    
    read_reg_v2(0xD3, buffer, 3);
    id = buffer[1]; //we only need ID
    id2= buffer[1] << 8 | buffer[2]; //we test buffer 1
    
 
    Lcd_Log("%s, id=0x%x,id2=0x%x\n", __func__, id,id2);
 
 
     //return (LCM_ID == id2)?1:0;
   return (LCM_ID == id2&&get_lcd_id()==1)?1:0;

	   // return (get_lcd_id()==1)?1:0;

}
static unsigned int lcm_compare_id()
{
//	return 1;
#if 0	
    unsigned int id = 0, id2 = 0;
    unsigned char buffer[2];
    unsigned int data_array[16];

#if defined(BUILD_LK)
	upmu_set_rg_vgp2_vosel(5);
	upmu_set_rg_vgp2_en(1);

	upmu_set_rg_vgp3_vosel(3);
	upmu_set_rg_vgp3_en(1);	
#else
	hwPowerOn(MT6323_POWER_LDO_VGP2, VOL_2800, "Lance_LCM");
       hwPowerOn(MT6323_POWER_LDO_VGP3, VOL_1800, "Lance_LCM");
#endif
    MDELAY(100);


    SET_RESET_PIN(1);
    MDELAY(20);
    SET_RESET_PIN(0);
    MDELAY(50);
    SET_RESET_PIN(1);
    MDELAY(100);

    //*************Enable CMD2 Page1  *******************//
    data_array[0]=0x00043902;
    data_array[1]=0x6983ffb9;//52AA55F0;
    //data_array[2]=0x00000108;
    dsi_set_cmdq(data_array, 3, 1);
    MDELAY(10);

    data_array[0] = 0x00023700;// read id return two byte,version and id
    dsi_set_cmdq(data_array, 1, 1);
    MDELAY(10);

    read_reg_v2(0xF4, buffer, 2);
    id = buffer[0]; //we only need ID

    Lcd_Log("\n %s HX8369A 0x%x , 0x%x , 0x%x \n",__func__,buffer[0],buffer[1],id);

    return (id == LCM_ID)?1:0;
#else
    Lcd_Log("mycat xxxxxx get_lcd_id=0x%x\n",get_lcd_id());
    return (get_lcd_id()==1)?1:0;
#endif
}
static unsigned int lcm_compare_id()
{
#if 0
	unsigned int id = 0, id2 = 0;
	unsigned char buffer[2];

	unsigned int data_array[16];

	SET_RESET_PIN(1);  //NOTE:should reset LCM firstly
	MDELAY(10);
	SET_RESET_PIN(0);
	MDELAY(10);
	SET_RESET_PIN(1);
	MDELAY(120);


	data_array[0]=0x00043902;
	data_array[1]=0x6983FFB9;
	dsi_set_cmdq(&data_array, 2, 1);
	MDELAY(10);

	data_array[0] = 0x00023700;// read id return two byte,version and id
	dsi_set_cmdq(data_array, 1, 1);
	MDELAY(10);

	read_reg_v2(0xF4, buffer, 2);
	id = buffer[0]; //we only need ID
	id2= buffer[1]; //we test buffer 1
#endif

	unsigned int id=0;

   	mt_set_gpio_mode(50,0);  // gpio mode   high
	mt_set_gpio_pull_enable(50,0);
	mt_set_gpio_dir(50,0);  //input
   	//mt_set_gpio_pull_select(50, 1);

	mt_set_gpio_mode(47,0);  // gpio mode   low
	mt_set_gpio_pull_enable(47,0);
	mt_set_gpio_dir(47,0);
	//mt_set_gpio_pull_select(47, 1);

	id = (mt_get_gpio_in(50) <<4) | mt_get_gpio_in(47);

#if defined(BUILD_UBOOT)
	printf("%s, id1 = 0x%08x\n", __func__, id);
#endif

        return (LCM_ID == id)?1:0;
}
static unsigned int lcm_compare_id(void)
{
   	int   array[4];
    char  buffer[10];
    unsigned int id=0;
    char  id0=0;
    char  id1=0;
    char  id2=0;

    //NOTE:should reset LCM firstly
    SET_RESET_PIN(1);  
    MDELAY(10);
    SET_RESET_PIN(0);
    MDELAY(10);
    SET_RESET_PIN(1);
    MDELAY(120);	

    array[0] = 0x00033700;
    dsi_set_cmdq(array, 1, 1);
    read_reg_v2(0xDA,buffer, 1);

    array[0] = 0x00033700;
    dsi_set_cmdq(array, 1, 1);
    read_reg_v2(0xDB,buffer+1, 1);

    array[0] = 0x00033700;
    dsi_set_cmdq(array, 1, 1);
    read_reg_v2(0xDC,buffer+2, 1);

    id0 = buffer[0];  //should be 0x10
    id1 = buffer[1];  //should be 0x80
    id2 = buffer[2];  //should be 0x1a

		id  = (unsigned int)((id0 << 8) | id1);

		 return (id == LCM_ID)?1:0;
}
static unsigned int lcm_compare_id(void)
{
    int array[4];
    char buffer[4]={0,0,0,0};
    char id_high=0;
    char id_low=0;
    int id=0;

    SET_RESET_PIN(1);
    SET_RESET_PIN(0);
    MDELAY(10);
    SET_RESET_PIN(1);
    MDELAY(200);

    array[0]=0x00043902;
    array[1]=0x7983FFB9;
    dsi_set_cmdq(array, 2, 1);

    MDELAY(10);
    array[0]=0x00033902;
    array[1]=0x009351ba;
    dsi_set_cmdq(array, 2, 1);

    MDELAY(10);
    array[0] = 0x00013700;
    dsi_set_cmdq(array, 1, 1);

    MDELAY(10);
    read_reg_v2(0xF4, buffer, 4);//    NC 0x00  0x98 0x16

    id = buffer[0];
    //id_low = buffer[1];
    //id = (id_high<<8) | id_low;

    #ifdef BUILD_LK

        printf("ILI9806 uboot %s \n", __func__);
        printf("%s id = 0x%08x \n", __func__, id);

    #else
        pr_debug("ILI9806 kernel %s \n", __func__);
        pr_debug("%s id = 0x%08x \n", __func__, id);

    #endif


    return (LCM_ID_HX8379 == id)?1:0;

}
static unsigned int lcm_compare_id(void)
{
   unsigned int id = 0, id2 = 0;
    unsigned char buffer[3];
    unsigned int data_array[16];

#ifdef BUILD_LK
	upmu_set_rg_vgp2_vosel(5);
	upmu_set_rg_vgp2_en(1);

	upmu_set_rg_vgp3_vosel(3);
	upmu_set_rg_vgp3_en(1);	
#else
  hwPowerOn(MT6323_POWER_LDO_VGP2,VOL_2800,"LCM");
	hwPowerOn(MT6323_POWER_LDO_VGP3,VOL_1800,"LCM");
#endif
    MDELAY(100);

    SET_RESET_PIN(1);  //NOTE:should reset LCM firstly
    MDELAY(10);
    SET_RESET_PIN(0);
    MDELAY(50);
    SET_RESET_PIN(1);
    MDELAY(180);	
    

  /*  data_array[0]=0x00043902;
    data_array[1]=0x1698FFFF;
    dsi_set_cmdq(data_array, 2, 1);
    MDELAY(20); */
    
    data_array[0] = 0x00043700;// read id return two byte,version and id
    dsi_set_cmdq(data_array, 1, 1);
    MDELAY(20); 
    
    read_reg_v2(0xD3, buffer, 4);
    id = buffer[2]; //we only need ID
    id2= buffer[1] << 8 | buffer[2]; //we test buffer 1
    
 
    Lcd_Log("MYCAT ILI9806 A40318 %s, id=0x%x,id2=0x%x\n", __func__, id,id2);
 
 
    return (LCM_ID == id2)?1:0;
	//return 1;

	   // return (get_lcd_id()==1)?1:0;

}
static unsigned int lcm_compare_id(void)
{
    unsigned int id = 0, id2 = 0;
    unsigned char buffer[3];
    unsigned int data_array[16];

#if defined(BUILD_LK)
	upmu_set_rg_vgp2_vosel(5);
	upmu_set_rg_vgp2_en(1);
#else
	hwPowerOn(MT6323_POWER_LDO_VGP2, VOL_2800, "Lance_LCM");
#endif
    MDELAY(100);

    SET_RESET_PIN(1);  //NOTE:should reset LCM firstly
    MDELAY(10);
    SET_RESET_PIN(0);
    MDELAY(10);
    SET_RESET_PIN(1);
    MDELAY(120);	
    
    /*	
    data_array[0] = 0x00110500;		// Sleep Out
    dsi_set_cmdq(data_array, 1, 1);
    MDELAY(120);
    */
    //*************Enable CMD2 Page1  *******************//
    data_array[0]=0x00043902;
    data_array[1]=0x1698FFFF;
    dsi_set_cmdq(data_array, 2, 1);
    MDELAY(20); 
    
    data_array[0] = 0x00033700;// read id return two byte,version and id
    dsi_set_cmdq(data_array, 1, 1);
    MDELAY(20); 
    
    read_reg_v2(0xD3, buffer, 3);
    id = buffer[1]; //we only need ID
    id2= buffer[1] << 8 | buffer[2]; //we test buffer 1
    
 
    Lcd_Log("MYCAT Read lcd id %s, id=0x%x,id2=0x%x\n", __func__, id,id2);
 
 
    return (LCM_ID == id2)?1:0;

	   // return (get_lcd_id()==1)?1:0;

}
static unsigned int lcm_esd_check(void)
{
    unsigned int result = TRUE;
    unsigned int data_array[16];
    unsigned char buffer[16] = {0};

    data_array[0] = 0x00013700;
    dsi_set_cmdq(data_array, 1, 1);

    read_reg_v2(0x0A, buffer, 1);
    if (buffer[0] == 0x9C)
        result = FALSE;

    return result;
}
int fbconfig_get_esd_check_exec(void)
{
	int array[4];
	esd_check_buffer = kmalloc(sizeof(char) * (6 + esd_check_para_num), GFP_KERNEL);
	if (esd_check_buffer == NULL) {
		DISP_DRV_WRAN("sxk=>esd_check :esd_check_buffer kmalloc fail!!\n");
		return -2;
	}
	array[0] = 0x00013700;
	array[0] = 0x3700 + (esd_check_para_num << 16);
	DISP_DRV_WRAN("sxk=>esd_check : arrar[0]=0x%x\n", array[0]);
	dsi_set_cmdq(array, 1, 1);
	read_reg_v2(esd_check_addr, esd_check_buffer, 6 + esd_check_para_num);
	return 0;
}