Ejemplo n.º 1
0
static inline int accfix_setup_eint(void)
{
	
	/*configure to GPIO function, external interrupt*/
    ACCFIX_DEBUG("[accfix]accfix_setup_eint\n");
	
	mt_set_gpio_mode(GPIO_ACCDET_EINT_PIN, GPIO_ACCDET_EINT_PIN_M_EINT);
    mt_set_gpio_dir(GPIO_ACCDET_EINT_PIN, GPIO_DIR_IN);
	mt_set_gpio_pull_enable(GPIO_ACCDET_EINT_PIN, GPIO_PULL_ENABLE);
	#ifdef ACCFIX_EINT_HIGH_ACTIVE
	mt_set_gpio_pull_select(GPIO_ACCDET_EINT_PIN, GPIO_PULL_DOWN);
	#else
	mt_set_gpio_pull_select(GPIO_ACCDET_EINT_PIN, GPIO_PULL_UP);
	#endif
	
	
	/**
    mt65xx_eint_set_sens(CUST_EINT_ACCDET_NUM, CUST_EINT_ACCDET_SENSITIVE);
	#ifdef ACCFIX_EINT_HIGH_ACTIVE
	mt65xx_eint_set_polarity(CUST_EINT_ACCDET_NUM, 1);
	ACCFIX_DEBUG("[accfix]accfix_setup_eint active high \n");
	#else
	mt65xx_eint_set_polarity(CUST_EINT_ACCDET_NUM, 0);
	ACCFIX_DEBUG("[accfix]accfix_setup_eint active low\n");
	#endif
	**/
	mt65xx_eint_set_hw_debounce(CUST_EINT_ACCDET_NUM, CUST_EINT_ACCDET_DEBOUNCE_CN);
	mt65xx_eint_registration(CUST_EINT_ACCDET_NUM, CUST_EINT_ACCDET_DEBOUNCE_EN, CUST_EINT_ACCDET_POLARITY, accfix_eint_func, 0);
	mt65xx_eint_unmask(CUST_EINT_ACCDET_NUM);  

	
    return 0;
	
}
halReturn_t HalInstallIrqHandler(fwIrqHandler_t irqHandler)
{
	//int				retStatus;
	halReturn_t 	halRet;

	init_waitqueue_head(&mhl_irq_wq);
	
	mhl_irq_task = kthread_create(mhl_irq_kthread, NULL, "hdmi_update_kthread"); 
	wake_up_process(mhl_irq_task);

	
	if(irqHandler == NULL)
	{
		SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalInstallIrqHandler: irqHandler cannot be NULL!\n");
		return HAL_RET_PARAMETER_ERROR;
	}
	halRet = I2cAccessCheck();
	if (halRet != HAL_RET_SUCCESS)
	{
		return halRet;
	}
	#if 0
	if(gMhlDevice.pI2cClient->irq == 0)
	{
		SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalInstallIrqHandler: No IRQ assigned to I2C device!\n");
		return HAL_RET_FAILURE;
	}
#endif


#if 0
	mt_set_gpio_mode(GPIO_MHL_EINT_PIN, GPIO_MODE_01);
	mt_set_gpio_dir(GPIO_MHL_EINT_PIN, GPIO_DIR_IN);
	mt_set_gpio_pull_select(GPIO_MHL_EINT_PIN,  GPIO_PULL_UP);
    mt_set_gpio_pull_enable(GPIO_MHL_EINT_PIN, true);
#endif
	mt65xx_eint_set_sens(CUST_EINT_MHL_NUM, MT65xx_LEVEL_SENSITIVE);
    mt65xx_eint_registration(CUST_EINT_MHL_NUM, 0, MT65XX_EINT_POL_NEG, &mhl8338_irq_handler, 0);

	#if 0
	gMhlDevice.irqHandler = irqHandler;
	retStatus = request_threaded_irq(gMhlDevice.pI2cClient->irq, NULL,
									 HalThreadedIrqHandler,
									 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
									 gMhlI2cIdTable[0].name,
									 &gMhlDevice);
	if(retStatus != 0)
	{
		SII_DEBUG_PRINT(SII_OSAL_DEBUG_TRACE,"HalInstallIrqHandler: request_threaded_irq failed, status: %d\n",
				retStatus);
		gMhlDevice.irqHandler = NULL;
		return HAL_RET_FAILURE;
	}
	#endif
	return HAL_RET_SUCCESS;
}
Ejemplo n.º 3
0
static int tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) {             
    int err = 0;// ret = -1;
    
    #ifdef TPD_NO_GPIO
    u16 temp;
    temp = *(volatile u16 *) TPD_RESET_PIN_ADDR;
    temp = temp | 0x40;
    *(volatile u16 *) TPD_RESET_PIN_ADDR = temp;
    #endif
    i2c_client = client;
    
    printk("MediaTek touch panel i2c probe\n");
    
    #ifndef TPD_NO_GPIO 

    mt_set_gpio_mode(GPIO_CTP_RST_PIN, GPIO_CTP_RST_PIN_M_GPIO);
    mt_set_gpio_dir(GPIO_CTP_RST_PIN, GPIO_DIR_OUT);
    mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ZERO);  
    msleep(10);  
    mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ONE);
   
    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);
    #endif 

    msleep(50);

    I2CDMABuf_va = (u8 *)dma_alloc_coherent(NULL, 4096, &I2CDMABuf_pa, GFP_KERNEL);
    if(!I2CDMABuf_va)
    {
        printk("Allocate Touch DMA I2C Buffer failed!\n");
        return -1;
    }
	
    thread = kthread_run(touch_event_handler, 0, TPD_DEVICE);
    if (IS_ERR(thread)) { 
        err = PTR_ERR(thread);
        TPD_DMESG(TPD_DEVICE " failed to create kernel thread: %d\n", err);
    }
    
    tpd_load_status = 1;
    
    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);
    
    printk("MediaTek touch panel i2c probe success\n");
    
    return 0;
}
Ejemplo n.º 4
0
static void mt_combo_bgf_request_irq(void *data)
{
    mt65xx_eint_set_sens(CUST_EINT_COMBO_BGF_NUM, CUST_EINT_COMBO_BGF_SENSITIVE);
    mt65xx_eint_set_hw_debounce(CUST_EINT_COMBO_BGF_NUM, CUST_EINT_COMBO_BGF_DEBOUNCE_CN);
    mt65xx_eint_registration(CUST_EINT_COMBO_BGF_NUM,
        CUST_EINT_COMBO_BGF_DEBOUNCE_EN,
        CUST_EINT_COMBO_BGF_POLARITY,
        combo_bgf_eirq_handler,
        0);
    mt65xx_eint_mask(CUST_EINT_COMBO_BGF_NUM); /*2*/
    return;
}
Ejemplo n.º 5
0
static void hall_init_hw(void)
{
	mt_set_gpio_mode(GPIO_MHALL_EINT_PIN, GPIO_MHALL_EINT_PIN_M_EINT);
	mt_set_gpio_dir(GPIO_MHALL_EINT_PIN, GPIO_DIR_IN);
	mt_set_gpio_pull_enable(GPIO_MHALL_EINT_PIN, GPIO_PULL_DISABLE); 
	mt_set_gpio_ies(GPIO_MHALL_EINT_PIN, GPIO_IES_ENABLE);

    	mt65xx_eint_set_sens(CUST_EINT_MHALL_NUM, CUST_EINT_MHALL_SENSITIVE);
	mt65xx_eint_set_polarity(CUST_EINT_MHALL_NUM, CUST_EINT_MHALL_POLARITY);
	mt65xx_eint_set_hw_debounce(CUST_EINT_MHALL_NUM, CUST_EINT_MHALL_DEBOUNCE_CN);
	mt65xx_eint_registration(CUST_EINT_MHALL_NUM, CUST_EINT_MHALL_DEBOUNCE_EN, CUST_EINT_MHALL_POLARITY, hall_cover_eint_handler, 0);
	mt65xx_eint_unmask(CUST_EINT_MHALL_NUM);  

}
Ejemplo n.º 6
0
	static void combo_sdio_request_eirq(sdio_irq_handler_t irq_handler, void *data)
	{
	    mt65xx_eint_set_sens(combo_sdio_eint_num, CUST_EINT_WIFI_SENSITIVE); /*CUST_EINT_WIFI_NUM */
	    mt65xx_eint_set_hw_debounce(combo_sdio_eint_num, CUST_EINT_WIFI_DEBOUNCE_CN); /*CUST_EINT_WIFI_NUM */
	    mt65xx_eint_registration(combo_sdio_eint_num/*CUST_EINT_WIFI_NUM */,
	        CUST_EINT_WIFI_DEBOUNCE_EN,
	        CUST_EINT_WIFI_POLARITY,
	        combo_sdio_eirq_handler_stub,
	        0);
	    mt65xx_eint_mask(combo_sdio_eint_num);/*CUST_EINT_WIFI_NUM */
	
	    combo_sdio_eirq_handler = irq_handler;
	    combo_sdio_eirq_data    = data;
	}
Ejemplo n.º 7
0
int oem_gpio_request_irq(int gpio, irq_handler_t handler, unsigned long flags,
	    const char *name, void *dev)
{
    mtk_oem_gpio_des *des = NULL;

    des = gpio_des_find_by_gpio(gpio);
    if(des == NULL){
        return -1;
    }
    des->data = dev;
    des->handle = handler;

    mt65xx_eint_registration(des->irq, 1, 1, des->redirect, 0);

    return 0;
}
Ejemplo n.º 8
0
static void mtk_wcn_cmb_sdio_request_eirq(sdio_irq_handler_t irq_handler, void *data)
{
    mtk_wcn_sdio_irq_flag_set (0);
    mtk_wcn_cmb_sdio_eirq_data    = data;
    mtk_wcn_cmb_sdio_eirq_handler = irq_handler;
    mt65xx_eint_set_sens(mtk_wcn_cmb_sdio_eint_num, CUST_EINT_WIFI_SENSITIVE); /*CUST_EINT_WIFI_NUM */
    mt65xx_eint_set_hw_debounce(mtk_wcn_cmb_sdio_eint_num, CUST_EINT_WIFI_DEBOUNCE_CN); /*CUST_EINT_WIFI_NUM */
    mt_set_gpio_pull_enable(mtk_wcn_cmb_sdio_eint_pin, GPIO_PULL_ENABLE);
    mt_set_gpio_pull_select(mtk_wcn_cmb_sdio_eint_pin, GPIO_PULL_UP);
    mt65xx_eint_registration(mtk_wcn_cmb_sdio_eint_num/*CUST_EINT_WIFI_NUM */,
        CUST_EINT_WIFI_DEBOUNCE_EN,
        CUST_EINT_WIFI_POLARITY,
        mtk_wcn_cmb_sdio_eirq_handler_stub,
        0);
    mt65xx_eint_mask(mtk_wcn_cmb_sdio_eint_num);/*CUST_EINT_WIFI_NUM */

}
Ejemplo n.º 9
0
/*
 * register irq handler
 * parmaters pass by inno_core
 * @handler		-	if101 irq handler function pointer
 * @irq_type	-	if101 irq type (falling edge detect or rising)
 */
int inno_irq_setup(void (*interrupthandler)(void ))
{
	mt_set_gpio_mode(GPIO_CMMB_EINT_PIN, GPIO_CMMB_EINT_PIN_M_EINT);                 //set to eint MODE for enable eint function
	mt_set_gpio_dir(GPIO_CMMB_EINT_PIN, GPIO_DIR_IN); 
#if 1
	mt_set_gpio_pull_enable(GPIO_CMMB_EINT_PIN, 1);
	mt_set_gpio_pull_select(GPIO_CMMB_EINT_PIN,  1);
#endif
	inno_msg("CMMB GPIO EINT PIN mode:num:%d, %d, dir:%d,pullen:%d,pullup%d",GPIO_CMMB_EINT_PIN,mt_get_gpio_mode(GPIO_CMMB_EINT_PIN),
			mt_get_gpio_dir(GPIO_CMMB_EINT_PIN),mt_get_gpio_pull_enable(GPIO_CMMB_EINT_PIN),mt_get_gpio_pull_select(GPIO_CMMB_EINT_PIN));    

	mt65xx_eint_set_sens(CUST_EINT_CMMB_NUM, CUST_EINT_EDGE_SENSITIVE);
	mt65xx_eint_registration(CUST_EINT_CMMB_NUM, CUST_EINT_DEBOUNCE_DISABLE, CUST_EINT_POLARITY_LOW, interrupthandler, 0);         // 0:auto mask is no
	mt65xx_eint_unmask(CUST_EINT_CMMB_NUM);   
	//    mt65xx_eint_mask(CUST_EINT_CMMB_NUM);   
	return 0;
}
Ejemplo n.º 10
0
static int mt8193_init(void)
{        
    MT8193_DRV_FUNC();
    memset((void*)&r_hdmi_timer, 0, sizeof(r_hdmi_timer));
    r_hdmi_timer.expires  = jiffies + 1000/(1000/HZ);   // wait 1s to stable
    r_hdmi_timer.function = hdmi_poll_isr;     
    r_hdmi_timer.data     = 0;
    init_timer(&r_hdmi_timer);
    add_timer(&r_hdmi_timer);

	memset((void*)&r_cec_timer, 0, sizeof(r_cec_timer));
    r_cec_timer.expires  = jiffies + 1000/(1000/HZ);   // wait 1s to stable
    r_cec_timer.function = cec_poll_isr;     
    r_cec_timer.data     = 0;
    init_timer(&r_cec_timer);
    add_timer(&r_cec_timer);
	
    init_waitqueue_head(&hdmi_timer_wq);
    hdmi_timer_task = kthread_create(hdmi_timer_kthread, NULL, "hdmi_timer_kthread"); 
    wake_up_process(hdmi_timer_task);

    init_waitqueue_head(&cec_timer_wq);
    cec_timer_task = kthread_create(cec_timer_kthread, NULL, "cec_timer_kthread"); 
    wake_up_process(cec_timer_task);

    init_waitqueue_head(&mt8193_nlh_wq);
    mt8193_nlh_task = kthread_create(mt8193_nlh_kthread, NULL, "mt8193_nlh_kthread"); 
    wake_up_process(mt8193_nlh_task);

    #if defined(CONFIG_HAS_EARLYSUSPEND)
    register_early_suspend(&mt8193_hdmi_early_suspend_desc);
    #endif

	mt_set_gpio_mode(GPIO_HDMI_EINT_PIN, GPIO_MODE_01);
    mt_set_gpio_dir(GPIO_HDMI_EINT_PIN, GPIO_DIR_IN);
    mt_set_gpio_pull_enable(GPIO_HDMI_EINT_PIN, true);
    mt_set_gpio_pull_select(GPIO_HDMI_EINT_PIN,  GPIO_PULL_UP);

    mt65xx_eint_set_sens(CUST_EINT_EINT_HDMI_HPD_NUM, CUST_EINT_EDGE_SENSITIVE);
    mt65xx_eint_registration(CUST_EINT_EINT_HDMI_HPD_NUM, 0, CUST_EINT_POLARITY_LOW, &_mt8193_irq_handler, 0);

    mt65xx_eint_unmask(CUST_EINT_EINT_HDMI_HPD_NUM);  
	
    return 0;
}
Ejemplo n.º 11
0
INT32
wmt_plat_eirq_ctrl (
    ENUM_PIN_ID id,
    ENUM_PIN_STATE state
    )
{
    INT32 iret;

    // TODO: [ChangeFeature][GeorgeKuo]: use another function to handle this, as done in gpio_ctrls

    if ( (PIN_STA_INIT != state )
        && (PIN_STA_DEINIT != state )
        && (PIN_STA_EINT_EN != state )
        && (PIN_STA_EINT_DIS != state ) ) {
        WMT_WARN_FUNC("WMT-PLAT:invalid PIN_STATE(%d) in eirq_ctrl for PIN(%d)\n", state, id);
        return -1;
    }

    iret = -2;
    switch (id) {
    case PIN_BGF_EINT:
#ifdef GPIO_COMBO_BGF_EINT_PIN
        if (PIN_STA_INIT == state) {
            mt65xx_eint_set_sens(CUST_EINT_COMBO_BGF_NUM, CUST_EINT_COMBO_BGF_SENSITIVE);
            mt65xx_eint_set_hw_debounce(CUST_EINT_COMBO_BGF_NUM, CUST_EINT_COMBO_BGF_DEBOUNCE_CN);
            mt65xx_eint_registration(CUST_EINT_COMBO_BGF_NUM,
                CUST_EINT_COMBO_BGF_DEBOUNCE_EN,
                CUST_EINT_COMBO_BGF_POLARITY,
                wmt_plat_bgf_eirq_cb,
                0);
            mt65xx_eint_mask(CUST_EINT_COMBO_BGF_NUM); /*2*/
        }
        else if (PIN_STA_EINT_EN == state) {
             mt65xx_eint_unmask(CUST_EINT_COMBO_BGF_NUM);
             WMT_DBG_FUNC("WMT-PLAT:BGFInt (en) \n");
        }
        else if (PIN_STA_EINT_DIS == state) {
            mt65xx_eint_mask(CUST_EINT_COMBO_BGF_NUM);
            WMT_DBG_FUNC("WMT-PLAT:BGFInt (dis) \n");
        }
        else {
            mt65xx_eint_mask(CUST_EINT_COMBO_BGF_NUM);
            /* de-init: nothing to do in ALPS, such as un-registration... */
        }
#else
        WMT_INFO_FUNC("WMT-PLAT:BGF EINT not defined\n", state);
#endif
        iret = 0;
        break;

    case PIN_ALL_EINT:
#ifdef GPIO_COMBO_ALL_EINT_PIN
        if (PIN_STA_INIT == state) {
            #if 0
            mt65xx_eint_set_sens(CUST_EINT_COMBO_ALL_NUM, CUST_EINT_COMBO_ALL_SENSITIVE);
            mt65xx_eint_set_hw_debounce(CUST_EINT_COMBO_ALL_NUM, CUST_EINT_COMBO_ALL_DEBOUNCE_CN);
            mt65xx_eint_registration(CUST_EINT_COMBO_ALL_NUM,
                CUST_EINT_COMBO_ALL_DEBOUNCE_EN,
                CUST_EINT_COMBO_ALL_POLARITY,
                combo_bgf_eirq_handler,
                0);
            #endif
            mt65xx_eint_mask(CUST_EINT_COMBO_ALL_NUM); /*2*/
            WMT_DBG_FUNC("WMT-PLAT:ALLInt (INIT but not used yet) \n");
        }
        else if (PIN_STA_EINT_EN == state) {
             /*mt65xx_eint_unmask(CUST_EINT_COMBO_ALL_NUM);*/
             WMT_DBG_FUNC("WMT-PLAT:ALLInt (EN but not used yet) \n");
        }
        else if (PIN_STA_EINT_DIS == state) {
            mt65xx_eint_mask(CUST_EINT_COMBO_ALL_NUM);
            WMT_DBG_FUNC("WMT-PLAT:ALLInt (DIS but not used yet) \n");
        }
        else {
            mt65xx_eint_mask(CUST_EINT_COMBO_ALL_NUM);
            WMT_DBG_FUNC("WMT-PLAT:ALLInt (DEINIT but not used yet) \n");
            /* de-init: nothing to do in ALPS, such as un-registration... */
        }
#else
        WMT_INFO_FUNC("WMT-PLAT:ALL EINT not defined\n", state);
#endif
        iret = 0;
        break;

    default:
        WMT_WARN_FUNC("WMT-PLAT:unsupported EIRQ(PIN_ID:%d) in eirq_ctrl\n", id);
        iret = -1;
        break;
    }

    return iret;
}
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;
}
static int tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) {             
    int err = 0;
    char buffer[2];
    int status=0;
    i2c_client = client;    
    TPD_DMESG("[mtk-tpd], cy8ctma300 tpd_i2c_probe ++++\n");
    #ifdef TPD_NO_GPIO
    u32 temp;
    
    temp = *(volatile u32 *) TPD_GPIO_GPO_ADDR;
    //temp = temp | 0x40;
    temp = temp |(1<<16) ;
    temp = temp |(1<<17);
    //temp = (temp | 1<<16);
    //mt65xx_reg_sync_write(TPD_GPIO_GPO_ADDR, temp);
    //*(volatile u32 *) TPD_GPIO_GPO_ADDR = temp;
    printk("TPD_GPIO_GPO_ADDR:0x%x\n", *(volatile u32 *) TPD_GPIO_GPO_ADDR);
	
    temp = *(volatile u32 *) TPD_GPIO_OE_ADDR;
    //temp = temp | 0x40;
    temp = temp |(1<<16) ;
    temp = temp |(1<<17);
	//temp = (temp | 1<<16) ;
	//mt65xx_reg_sync_write(TPD_GPIO_OE_ADDR, temp);
   // *(volatile u32 *) TPD_GPIO_OE_ADDR = temp;
    printk("TPD_GPIO_OE_ADDR:0x%x\n", *(volatile u32 *) TPD_GPIO_OE_ADDR);
    #endif
    
    #ifndef TPD_NO_GPIO 
    mt_set_gpio_mode(GPIO_CTP_RST_PIN, GPIO_CTP_RST_PIN_M_GPIO);
    mt_set_gpio_dir(GPIO_CTP_RST_PIN, GPIO_DIR_OUT);
    mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ZERO);  
    msleep(10);  
    mt_set_gpio_mode(GPIO_CTP_EN_PIN, GPIO_CTP_EN_PIN_M_GPIO);
    mt_set_gpio_dir(GPIO_CTP_EN_PIN, GPIO_DIR_OUT);
    mt_set_gpio_out(GPIO_CTP_EN_PIN, GPIO_OUT_ONE);
    
 //   mt_set_gpio_mode(GPIO_CTP_RST_PIN, GPIO_CTP_RST_PIN_M_GPIO);
 //   mt_set_gpio_dir(GPIO_CTP_RST_PIN, GPIO_DIR_OUT);
 //   mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ONE);
 //   msleep(10);
    mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ZERO);
    msleep(1);
    mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ONE);
    
    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);
    #endif 

    msleep(50);
   // buffer[0]=0x00;
   // i2c_client->ext_flag = I2C_WR_FLAG;
   // status=i2c_master_send(i2c_client ,buffer, 0x101);
   TPD_DMESG("1...........\n");
    status = i2c_smbus_read_i2c_block_data(i2c_client, 0x00, 1, &(buffer[0]));
    if(status<0) 
    {
            TPD_DMESG("fwq read error\n");
		TPD_DMESG("[mtk-tpd], cy8ctma300 tpd_i2c_probe failed!!\n");
		status = i2c_smbus_read_i2c_block_data(i2c_client, 0x00, 1, &(buffer[0]));
		if(status<0) {
			TPD_DMESG("[mtk-tpd], cy8ctma300 tpd_i2c_probe retry failed!!\n");
			return status;
		}
    }
    TPD_DMESG("fwq buffer=%x \n",buffer[0]);

    TPD_DMESG("[mtk-tpd], cy8ctma300 tpd_i2c_probe success!!\n");		
    tpd_load_status = 1;
        
    if ((buffer[0] & 0x70) != 0x00) 
    {
        buffer[0] = 0x00; // switch to operation mode
       	
        i2c_smbus_write_i2c_block_data(i2c_client, 0x00, 1, &(buffer[0]));
        if(status < 0)
	 {
	    TPD_DMESG("fwq write error\n");
	 }
        msleep(50);
    }

    thread = kthread_run(touch_event_handler, 0, TPD_DEVICE);
    if (IS_ERR(thread)) { 
        err = PTR_ERR(thread);
        TPD_DMESG(TPD_DEVICE " failed to create kernel thread: %d\n", err);
    }    
#ifndef POLL_MODE //mt6575t fpga debug 0: enable polling mode
    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);
    TPD_DMESG("EINT num=%d\n",CUST_EINT_TOUCH_PANEL_NUM);
#endif 
	TPD_DMESG("[mtk-tpd], cy8ctma300 tpd_i2c_probe ----\n");

    return 0;
}
Ejemplo n.º 14
0
static int pn544_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	int ret;
	struct pn544_dev *pn544_dev;

	printk("pn544 nfc probe step01 is ok\n");
	
	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		pr_err("pn544 %s : need I2C_FUNC_I2C\n", __func__);
		return  -ENODEV;
	}

	printk("pn544 nfc probe step02 is ok\n");

	pn544_dev = kzalloc(sizeof(*pn544_dev), GFP_KERNEL);
	if (pn544_dev == NULL) {
		dev_err(&client->dev, "pn544 failed to allocate memory for module data\n");
		return -ENOMEM;
	}
	memset(pn544_dev, 0, sizeof(struct pn544_dev));
	p_pn544_dev = pn544_dev;

	printk("pn544 nfc probe step03 is ok\n");
	
	client->addr = (client->addr & I2C_MASK_FLAG);
	pn544_dev->client = client;

	/* init mutex and queues */
	init_waitqueue_head(&pn544_dev->read_wq);
	mutex_init(&pn544_dev->read_mutex);
	spin_lock_init(&pn544_dev->irq_enabled_lock);

	pn544_dev->pn544_device.minor = MISC_DYNAMIC_MINOR;
	pn544_dev->pn544_device.name = PN544_DRVNAME;
	pn544_dev->pn544_device.fops = &pn544_dev_fops;

	ret = misc_register(&pn544_dev->pn544_device);
	if (ret) {
		pr_err("pn544 %s : misc_register failed\n", __FILE__);
		goto err_misc_register;
	}
    
	printk("pn544 nfc probe step04 is ok\n");
    
	/* VEN */
	mt_set_gpio_mode(VEN_PIN, GPIO_MODE_00);
	mt_set_gpio_dir(VEN_PIN, GPIO_DIR_OUT);
    
	/* GPIO4 */
	mt_set_gpio_mode(GPIO4_PIN, GPIO_MODE_00);
	mt_set_gpio_dir(GPIO4_PIN, GPIO_DIR_OUT);
    
	/* IRQ */
	mt_set_gpio_mode(IRQ_PIN, GPIO_MODE_01);
	mt_set_gpio_dir(IRQ_PIN, GPIO_DIR_IN);
	mt_set_gpio_pull_enable(IRQ_PIN, true);
	mt_set_gpio_pull_select(IRQ_PIN, GPIO_PULL_DOWN);
    
	printk("pn544 nfc probe step05 is ok\n");
    
	pn544_dev->irq_enabled = true;
	mt65xx_eint_set_sens(EINT_NUM, CUST_EINT_LEVEL_SENSITIVE);
	mt65xx_eint_set_hw_debounce(EINT_NUM, 0);
	mt65xx_eint_registration(EINT_NUM, CUST_EINT_DEBOUNCE_DISABLE, CUST_EINT_POLARITY_HIGH, pn544_dev_irq_handler, 0);
	
	pn544_disable_irq(pn544_dev);
	i2c_set_clientdata(client, pn544_dev);
	
	printk("pn544 nfc probe step06 is ok\n");

	return 0;

err_dma_alloc:
	misc_deregister(&pn544_dev->pn544_device);
err_misc_register:
	mutex_destroy(&pn544_dev->read_mutex);
	kfree(pn544_dev);
	p_pn544_dev = NULL;
    
	return ret;
}
Ejemplo n.º 15
0
/*
static int tpd_i2c_detect(struct i2c_client *client, struct i2c_board_info *info) {
    strcpy(info->type, "mtk-tpd");
    return 0;
}
*/
static int tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) {             
    int err = 0;
    char buffer[8];
    int status=0;
    i2c_client = client;    
    
    #ifdef TPD_NO_GPIO
    u16 temp;
    temp = *(volatile u16 *) TPD_RESET_PIN_ADDR;
    temp = temp | 0x40;
    *(volatile u16 *) TPD_RESET_PIN_ADDR = temp;
    #endif
    
    #ifndef TPD_NO_GPIO 
    mt_set_gpio_mode(GPIO_CTP_RST_PIN, GPIO_CTP_RST_PIN_M_GPIO);
    mt_set_gpio_dir(GPIO_CTP_RST_PIN, GPIO_DIR_OUT);
    mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ZERO);  
    msleep(10);  
#ifdef TPD_POWER_SOURCE_CUSTOM
    hwPowerOn(TPD_POWER_SOURCE_CUSTOM, VOL_2800, "TP");
#endif
#ifdef TPD_POWER_SOURCE_1800
    hwPowerOn(TPD_POWER_SOURCE_1800, VOL_1800, "TP");
#endif
#ifdef GPIO_CTP_EN_PIN
    mt_set_gpio_mode(GPIO_CTP_EN_PIN, GPIO_CTP_EN_PIN_M_GPIO);
    mt_set_gpio_dir(GPIO_CTP_EN_PIN, GPIO_DIR_OUT);
    mt_set_gpio_out(GPIO_CTP_EN_PIN, GPIO_OUT_ONE);
    msleep(5);
#endif
    
 //   mt_set_gpio_mode(GPIO_CTP_RST_PIN, GPIO_CTP_RST_PIN_M_GPIO);
 //   mt_set_gpio_dir(GPIO_CTP_RST_PIN, GPIO_DIR_OUT);
 //   mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ONE);
 //   msleep(10);
    mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ZERO);
    msleep(1);
    mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ONE);

    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);
    #endif 

    msleep(10);
    buffer[0] =  0x00;
    buffer[1] =  0x03;
    i2c_master_send(i2c_client,buffer,2);
    msleep(50);
    status = i2c_master_recv(i2c_client, buffer, 8);
    
    if(status<0) {
        TPD_DMESG("[mtk-tpd], cy8ctma300 tpd_i2c_probe failed!!\n");
        return status;
    }
    TPD_DMESG("[mtk-tpd], cy8ctma300 tpd_i2c_probe success!!\n");		
    if(buffer[2] == 0x31)
    tpd_load_status = 1;
    buffer[0] =  0x00;
    buffer[1] =  0x05;
    i2c_master_send(i2c_client,buffer,2);
    //status = i2c_master_recv(i2c_client, buffer, 3);
    msleep(50);
    buffer[0] =  0x00;
    buffer[1] =  0x21;
    buffer[2] =  0x07;
    buffer[3] =  0x01;
    buffer[4] =  0x00;
    i2c_master_send(i2c_client,buffer,5);
    msleep(50);


    thread = kthread_run(touch_event_handler, 0, TPD_DEVICE);
    if (IS_ERR(thread)) { 
        err = PTR_ERR(thread);
        TPD_DMESG(TPD_DEVICE " failed to create kernel thread: %d\n", err);
    }
    
    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);
    
    return 0;
}
Ejemplo n.º 16
0
/**
  * Specific initialization, when driver module is inserted.
  *
  *  - Request control of the GPIOs
  *  - Initialize the I2C driver & IRQ
  *  - enable the irq if REFIOH is not available (so that device is not stuck on emission)
  *  - Set REFIOH high if I2C_PROBE_NEEDS_REFIOH (lowered by probe cb), low otherwise
  *  
  * @return 0 if successfull, or error code
  */
int
open_nfc_custom_init(void)
{
	int             retval = 0;

	struct open_nfc_custom_device *p_device;

	ENTER();
	
	p_device = kmalloc(sizeof(struct open_nfc_custom_device), GFP_KERNEL);
	if (p_device == NULL) {
		return -ENOMEM;
	}
	memset(p_device, 0, sizeof(struct open_nfc_custom_device));

	init_waitqueue_head(&p_device->read_queue);
	init_waitqueue_head(&p_device->reset_queue);
	INIT_WORK(&p_device->irqout_event_work, open_nfc_irqout_worker);
	INIT_WORK(&p_device->reset_event_work, open_nfc_reset_worker);

	mutex_init(&p_device->mutex);

	init_timer(&p_device->sResetTimer);
	init_timer(&p_device->rx_timer);
	
    // Initializing the GPIO209 as clock out of 32K
    mt_set_gpio_mode(GPIO209, 3);   //set to CLKM2
    mt_set_gpio_dir(GPIO209, 1);     //set to output
    mt_set_clock_output(2 , 2 , 1); //set to mode3, clocksrc:32K, divider:1

	/* Initializing the IRQ for the chipset */

   /* irq_gpio setup */
	mt_set_gpio_mode(GPIO_NFC_EINT_PIN, GPIO_NFC_EINT_PIN_M_EINT);
	mt_set_gpio_dir(GPIO_NFC_EINT_PIN, GPIO_DIR_IN);
	mt_set_gpio_pull_enable(GPIO_NFC_EINT_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_NFC_EINT_PIN, GPIO_PULL_DOWN);

	/* ven_gpio setup */
	mt_set_gpio_mode(GPIO_NFC_VEN_PIN, GPIO_NFC_VEN_PIN_M_GPIO);
	mt_set_gpio_dir(GPIO_NFC_VEN_PIN, GPIO_DIR_OUT);

	mt65xx_eint_set_sens(CUST_EINT_NFC_NUM, CUST_EINT_NFC_SENSITIVE);
	mt65xx_eint_set_hw_debounce(CUST_EINT_NFC_NUM, CUST_EINT_NFC_DEBOUNCE_CN);
	mt65xx_eint_registration(CUST_EINT_NFC_NUM, CUST_EINT_NFC_DEBOUNCE_EN, CUST_EINT_NFC_POLARITY, open_nfc_i2c_interrupt, 0);
	//mt65xx_eint_unmask(CUST_EINT_NFC_NUM);
	
	/* Initializing the WAKE_UP for the chipset */
#ifdef WAKE_AND_PURGE_I2C_ON_LOAD
	/* Wake up the chipset now */
  mt_set_gpio_out(GPIO_NFC_VEN_PIN, GPIO_OUT_ONE);
	udelay(2);
  mt_set_gpio_out(GPIO_NFC_VEN_PIN, GPIO_OUT_ZERO);
#endif /* WAKE_AND_PURGE_I2C_ON_LOAD */
	

	/* I2C Driver connection */
    i2c_register_board_info(NFC_I2C_BUSNUM, &nfc_board_info, 1);

	/* Save device context (needed in .probe()) */
	open_nfc_p_device = p_device;

	/* this might be platform-dependent */
	retval = i2c_add_driver(&open_nfc_i2c_driver);
	if (retval < 0) {
		printk(KERN_ERR "open_nfc_custom_open : failed to add I2C driver\n");
		goto end;
	}

	printk(KERN_ERR "Open NFC driver loaded\n");

      end:
	return retval;
}
Ejemplo n.º 17
0
static int tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) {             
	int err = 0,i;
//	uint8_t Firmware_version[3] = {0x20,0x00,0x00};
	i2c_client = client;
       unsigned char tpd_buf[8] = {0};

//	#ifdef TPD_HAVE_POWER_ON_OFF
	//for power on sequence
	tpd_hw_enable();
	mt_set_gpio_mode(GPIO21, 0);
	mt_set_gpio_dir(GPIO21, GPIO_DIR_OUT);
	mt_set_gpio_out(GPIO21, GPIO_OUT_ONE);

    	mdelay(20);


//eint config to gpio
	    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);

	
//	#endif

	msleep(20);

	
	#if 0
	for(i = 0;i<5;i++)
	{
		if(tpd_i2c_master_rs_send(i2c_client,Firmware_version,3<<8|1) < 0)
		{
				TPD_DMESG("I2C transfer error, line: %d\n", __LINE__);
		}
		else
		{
			TPD_DMESG(" mcs6024 Hardware version is %x\n",Firmware_version[0]);
			TPD_DMESG(" mcs6024 Firmware version is %x\n",Firmware_version[1]);
			TPD_DMESG(" mcs6024 Panel Type  is %x\n",Firmware_version[2]);
			break;
		}
	}
	if(i == 5)
	{
		TPD_DMESG("mcs6024 tpd_i2c_probe fail\n");
		return -1;
	}
	#endif

	
		
	  thread = kthread_run(touch_event_handler, 0, TPD_DEVICE);
    if (IS_ERR(thread)) { 
        err = PTR_ERR(thread);
        TPD_DMESG(TPD_DEVICE " failed to create kernel thread: %d\n", err);
    }    
    

    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);
	
   tpd_load_status = 1;
    return 0;
}
Ejemplo n.º 18
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 ){
		printk("[ft5x06] %s:Already probed a TP, needn't to probe any more!",__func__);
		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(tinno_ts_data), GFP_KERNEL);
	if (ts == NULL) {
		ret = -ENOMEM;
		goto err_alloc_data_failed;
	}
	
	printk("[ft5x06] %s:TPD enter tpd_probe ts=0x%p, TPD_RES_X=%d, TPD_RES_Y=%d, addr=0x%x\n", __func__, ts, TPD_RES_X, TPD_RES_Y, client->addr);
	memset(ts, 0, sizeof(tinno_ts_data));
	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_5x06_hw_init();
	msleep(120);
	
	fts_iic_init(ts);

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

	while (iRetry) {
		ret = ft5x06_get_vendor_version(ts, &panel_vendor, &panel_version);
		if ( panel_version < 0 || panel_vendor<0 || ret<0 ){
			printk("[ft5x06] %s: Product version is %d\n", __func__, panel_version);
			fts_5x06_hw_reset();
		}else{
            printk("[ft5x06] %s: panel_vendor =%x, panel_version=%x\n", __func__, panel_vendor, panel_version);
			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); 
 
	ts->thread = kthread_run(touch_event_handler, ts, TPD_DEVICE);
	 if (IS_ERR(ts->thread)){ 
		  retval = PTR_ERR(ts->thread);
		  printk("[ft5x06] %s: failed to create kernel thread: %d\n", __func__, retval);
			goto err_start_touch_kthread;
	}

	tpd_load_status = 1;
	mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM); 
	
	printk("[ft5x06] %s:Touch Panel Device(%s) Probe PASS\n", __func__, fts_get_vendor_name(panel_vendor));
//#if defined (TINNO_ANDROID_S9091) || defined (TINNO_ANDROID_S8121) || defined(TINNO_ANDROID_S8111B)
#if 1
{
	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;
}
#endif

//LINE<JIRA_ID><DATE20130402><add for focaltech debug>zenghaihui
#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

    //LINE<JIRA_ID><DATE20130320><add charger flag>zenghaihui
    g_need_refresh_tp_flag = 1;
    
	return 0;
   
err_start_touch_kthread:
	mt65xx_eint_mask(CUST_EINT_TOUCH_PANEL_NUM); 
err_get_version:
err_isp_register:
  #ifdef CONFIG_TOUCHSCREEN_POWER_DOWN_WHEN_SLEEP
	hwPowerDown(MT65XX_POWER_LDO_VGP5, "touch"); 
  #endif	
	fts_5x06_isp_exit();
	mutex_destroy(&ts->mutex);
	g_pts = NULL;
	kfree(ts);
err_alloc_data_failed:
err_check_functionality_failed:
	printk("[ft5x06] %s:Touch Panel Device Probe FAIL\n", __func__);
	return -1;
 }
Ejemplo n.º 19
0
static int tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) {             
    int err = 0, ret = -1;
    u8 cmdbuf[MAX_I2C_LEN]={0x03, 0x03, 0x0A, 0x01, 0x41, 0, 0, 0, 0, 0};
    
    
    #ifdef TPD_NO_GPIO
    u16 temp;
    temp = *(volatile u16 *) TPD_RESET_PIN_ADDR;
    temp = temp | 0x40;
    *(volatile u16 *) TPD_RESET_PIN_ADDR = temp;
    #endif
    i2c_client = client;
    
    printk("MediaTek touch panel i2c probe\n");
    
    #ifndef TPD_NO_GPIO 

    mt_set_gpio_mode(GPIO_CTP_RST_PIN, GPIO_CTP_RST_PIN_M_GPIO);
    mt_set_gpio_dir(GPIO_CTP_RST_PIN, GPIO_DIR_OUT);
    mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ZERO);  
    msleep(10);  
    mt_set_gpio_out(GPIO_CTP_RST_PIN, GPIO_OUT_ONE);
   
    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);
    #endif 

    msleep(50);
    
    I2CDMABuf_va = (u8 *)dma_alloc_coherent(NULL, 4096, &I2CDMABuf_pa, GFP_KERNEL);
    if(!I2CDMABuf_va)
    {
	printk("Allocate Touch DMA I2C Buffer failed!\n");
	return -1;
    }

    i2c_client->addr = i2c_client->addr & I2C_MASK_FLAG | I2C_DMA_FLAG | I2C_ENEXT_FLAG;
    ret = tpd_i2c_write(i2c_client, cmdbuf, 10);
    i2c_client->addr = i2c_client->addr & I2C_MASK_FLAG;
    if (ret != sizeof(cmdbuf))
    {
        TPD_DEBUG("[mtk-tpd] i2c write communcate error: 0x%x\n", ret);
        return -1;
    }
	
    thread = kthread_run(touch_event_handler, 0, TPD_DEVICE);
    if (IS_ERR(thread)) { 
        err = PTR_ERR(thread);
        TPD_DMESG(TPD_DEVICE " failed to create kernel thread: %d\n", err);
    }
    
    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);
    
    printk("MediaTek touch panel i2c probe success\n");
    
    return 0;
}