Ejemplo n.º 1
0
 static int __devinit tpd_probe(struct i2c_client *client, const struct i2c_device_id *id)
 {	 
	int retval = TPD_OK;
	int panel_version = 0;
	int panel_vendor = 0;
	int iRetry = 3;
	tinno_ts_data *ts;
	int ret = 0;

	if ( tpd_load_status ){
		CTP_DBG("Already probed a TP, needn't to probe any more!");
		return -1;
	}

	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		dev_err(&client->dev,"need I2C_FUNC_I2C");
		ret = -ENODEV;
		goto err_check_functionality_failed;
	}

	ts = kzalloc(sizeof(*ts), GFP_KERNEL);
	if (ts == NULL) {
		ret = -ENOMEM;
		goto err_alloc_data_failed;
	}
	
	CTP_DBG("TPD enter tpd_probe ts=0x%p, TPD_RES_X=%d, TPD_RES_Y=%d, addr=0x%x\n", ts, TPD_RES_X, TPD_RES_Y, client->addr);
	memset(ts, 0, sizeof(*ts));
	g_pts = ts;

	client->timing = I2C_MASTER_CLOCK;
	ts->client = client;
	ts->start_reg = 0x00;
	atomic_set( &ts->ts_sleepState, 0 );
	mutex_init(&ts->mutex);

	i2c_set_clientdata(client, ts);

	fts_6x06_hw_init();
	msleep(120);
	
	fts_iic_init(ts);

	if ( fts_6x06_isp_init(ts) ){
		goto err_isp_register;
	}

	while (iRetry) {
		ret = ft6x06_get_vendor_version(ts, &panel_vendor, &panel_version);
		if ( panel_version < 0 || panel_vendor<0 || ret<0 ){
			CTP_DBG("Product version is %d\n", panel_version);
			fts_6x06_hw_reset();
		}else{
			break;
		}
		iRetry--;
		msleep(15);  
	} 
	if ( panel_version < 0 || panel_vendor<0 || ret<0 ){
		goto err_get_version;
	}
#ifdef TPD_HAVE_BUTTON 
	tinno_update_tp_button_dim(panel_vendor);
#endif
#ifdef CONFIG_TOUCHSCREEN_FT5X05_DISABLE_KEY_WHEN_SLIDE
	if ( fts_keys_init(ts) ){
		fts_keys_deinit();
		goto err_get_version;
	}
#endif

	mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_EINT);
	mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_IN);
	mt_set_gpio_pull_enable(GPIO_CTP_EINT_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_CTP_EINT_PIN, GPIO_PULL_UP);

 	//mt65xx_eint_set_sens(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_SENSITIVE);
    //mt65xx_eint_set_hw_debounce(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_CN);
	//mt65xx_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_EN, CUST_EINT_TOUCH_PANEL_POLARITY, tpd_eint_interrupt_handler, 0); 
    mt_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_TYPE, tpd_eint_interrupt_handler, 1);                    
	
	ts->thread = kthread_run(touch_event_handler, ts, TPD_DEVICE);
	 if (IS_ERR(ts->thread)){ 
		  retval = PTR_ERR(ts->thread);
		  TPD_DMESG(TPD_DEVICE " failed to create kernel thread: %d\n", retval);
			goto err_start_touch_kthread;
	}

	tpd_load_status = 1;
	mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); 
	
	CTP_DBG("Touch Panel Device(%s) Probe PASS\n", fts_get_vendor_name(panel_vendor));
//BEGIN <tp> <DATE20130507> <tp version> zhangxiaofei
{
	extern char tpd_desc[50];
	extern int tpd_fw_version;
	sprintf(tpd_desc, "%s", fts_get_vendor_name(panel_vendor));
	tpd_fw_version = panel_version;
}
//END <tp> <DATE20130507> <tp version> zhangxiaofei

//LINE<tp><DATE20130619><add for focaltech debug>zhangxiaofei
#ifdef FTS_CTL_IIC
        if (ft_rw_iic_drv_init(client) < 0)
            dev_err(&client->dev, "%s:[FTS] create fts control iic driver failed\n",
                    __func__);
#endif

//BEGIN <touch panel> <DATE20130831> <tp proximity> zhangxiaofei
#if defined TPD_PROXIMITY
	struct hwmsen_object obj_ps;
	int err=0;
	
	obj_ps.polling = 0;//interrupt mode
	obj_ps.sensor_operate = tpd_ps_operate;
	if((err = hwmsen_attach(ID_PROXIMITY, &obj_ps)))
	{
		APS_ERR("proxi_fts attach fail = %d\n", err);
	}
	else
	{
		APS_ERR("proxi_fts attach ok = %d\n", err);
	}		
#endif
//END <touch panel> <DATE20130831> <tp proximity> zhangxiaofei

//BEGIN<touch panel><date20131028><tp auto update>yinhuiyong
#if defined(FTS_AUTO_TP_UPGRADE)
		focaltech_auto_upgrade();
#endif
//END<touch panel><date20131028><tp auto update>yinhuiyong
	return 0;
   
err_start_touch_kthread:
	mt_eint_mask(CUST_EINT_TOUCH_PANEL_NUM); 
err_get_version:
err_isp_register:
  #ifdef CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP
	hwPowerDown(MT65XX_POWER_LDO_VGP2, "touch"); 
  #endif	
	fts_6x06_isp_exit();
	mutex_destroy(&ts->mutex);
	g_pts = NULL;
	kfree(ts);
err_alloc_data_failed:
err_check_functionality_failed:
	CTP_DBG("Touch Panel Device Probe FAIL\n");
	return -1;
 }
static int tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) 
{
	int err = 0;
	TPD_DEBUG("ft5316 tpd_i2c_probe\n");
	if (ft5316_i2c_client != NULL)
	return 1;

	ft5316_i2c_client = client;
	TPD_DEBUG("ft5316_i2c_client addr ==== %X \n", ft5316_i2c_client->addr);
	tinno_tp_power_off();
	tinno_tp_power_on();

	int i = 0;
	while(i++ <5){
		err=tinno_ts_get_fw_version();
		TPD_DEBUG("Product  version ==== %X \n", panel_version);
		if(err > 0)
			break;
		else
			continue;
	}
	if ( err < 0 ){
	    TPD_DEBUG("Product  version %X is invalid.\n", panel_version);
	    goto err_detect_failed;
	}

	tpd_load_status = 1;
	
	  

    /* added in android 2.2, for configuring EINT2 */
    mt_set_gpio_mode(TPIO_EINT, GPIO_CTP_EINT_PIN_M_EINT);
    mt_set_gpio_pull_enable(TPIO_EINT, GPIO_PULL_ENABLE);
    mt_set_gpio_pull_select(TPIO_EINT,GPIO_PULL_UP);
    mt65xx_eint_set_sens(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_SENSITIVE);
    mt65xx_eint_set_hw_debounce(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_CN);
    mt65xx_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_EN, CUST_EINT_TOUCH_PANEL_POLARITY, tpd_eint_interrupt_handler, 1);    
    mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM);

    mutex_init(&tp_mutex);	
#ifdef CONFIG_TOUCHSCREEN_FT5X05_SUPPORT_ISP
	magnum_fts_isp_register(ft5316_i2c_client);

#endif/*CONFIG_TOUCHSCREEN_FT5X05_SUPPORT_ISP*/
    tpd_status = 1;
  thread = kthread_run(touch_event_handler, 0, TPD_DEVICE);
	    if (IS_ERR(thread)) { 
	        err = PTR_ERR(thread);
	        TPD_DEBUG(TPD_DEVICE " failed to create kernel thread: %d\n", err);
    }

    //edit by Magnum 2012-12-25
#ifdef  TP_AUTO_UPGRADE
		focaltech_auto_upgrade();
#endif

    TPD_DEBUG("tpd_i2c_probe OK\n");	
   
    return 0;

err_detect_failed:
    TPD_DEBUG("tpd_i2c_probe ERROR\n");
    ft5316_i2c_client = NULL;
    tinno_tp_power_off();
   return 1;
}