int swtp_mod_eint_init(void)
{
    int init_value = 0;
    unsigned int init_flag = CUST_EINTF_TRIGGER_HIGH;

    mt_set_gpio_mode(SWTP_GPIO_EINT_PIN, SWTP_GPIO_EINT_MODE);
    mt_set_gpio_dir(SWTP_GPIO_EINT_PIN, SWTP_GPIO_EINT_DIR);
    mt_set_gpio_pull_enable(SWTP_GPIO_EINT_PIN, SWTP_GPIO_EINT_PULL);

    init_value = mt_get_gpio_in(SWTP_GPIO_EINT_PIN);
    if(init_value == SWTP_TRIGGERING) {
        init_flag = SWTP_OPPOSE_EINT_TYPE; //CUST_EINTF_TRIGGER_LOW;
        swtp_eint_state = EINT_PIN_PLUG_IN;
    }
    else {
        init_flag = SWTP_EINT_TYPE; //CUST_EINTF_TRIGGER_HIGH;
        swtp_eint_state = EINT_PIN_PLUG_OUT;
    }

    mt_eint_set_sens(SWTP_EINT_NUM, SWTP_SENSITIVE_TYPE);
    mt_eint_set_hw_debounce(SWTP_EINT_NUM, SWTP_DEBOUNCE_CN);
    mt_eint_registration(SWTP_EINT_NUM, init_flag, swtp_eint_handler, 0);

    return 0;
}
Пример #2
0
static void hw_register_irq(void)
{
	
	mt_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, EINTF_TRIGGER_LOW, tpd_eint_handler, 0);
	mt_eint_mask(CUST_EINT_TOUCH_PANEL_NUM);
	
	return ;
}
Пример #3
0
static void mtk_wcn_cmb_sdio_request_eirq(sdio_irq_handler_t irq_handler, void *data)
{
#if	CONFIG_EINT_DEVICE_TREE
	struct device_node *node;
	u32 ints[2] = {0,0};
	int ret = -EINVAL;
#endif
    printk( KERN_INFO "enter %s\n", __func__);
    mtk_wcn_sdio_irq_flag_set (0);
    mtk_wcn_cmb_sdio_eirq_data    = data;
    mtk_wcn_cmb_sdio_eirq_handler = irq_handler;
    #if 1
#if	CONFIG_EINT_DEVICE_TREE
	node = of_find_compatible_node(NULL, NULL, "mediatek, WIFI-eint");
	if(node) {
		of_property_read_u32_array(node, "debounce", ints, ARRAY_SIZE(ints));
		mt_gpio_set_debounce(ints[0], ints[1]);
		wifi_irq = irq_of_parse_and_map(node, 0);
		ret = request_irq(wifi_irq, mtk_wcn_cmb_sdio_eirq_handler_stub, IRQF_TRIGGER_NONE,"WIFI-eint", NULL);
		printk(KERN_DEBUG "WIFI EINT irq %d !!\n",wifi_irq);
		atomic_set(&wifi_irq_flag, 0);/*default: irq enable*/

		if(ret)
			printk(KERN_ERR "WIFI EINT IRQ LINE NOT AVAILABLE!!\n");
		else {
			mtk_wcn_cmb_sdio_disable_eirq();/*not ,chip state is power off*/
		}
	}
	else
		printk(KERN_ERR "[%s] can't find wifi eint compatible node\n",__func__);
#else
    mt_eint_registration(mtk_wcn_cmb_sdio_eint_num,
            		CUST_EINT_WIFI_TYPE,
                mtk_wcn_cmb_sdio_eirq_handler_stub,
                0);
#endif
    #else
	{
		int i_ret = 0;
		i_ret = request_irq(mtk_wcn_cmb_sdio_eint_num,
				(irq_handler_t)mtk_wcn_cmb_sdio_eirq_handler_stub,
				IRQF_TRIGGER_LOW,
				"SDIO_EXT_IRQ",
				NULL);
		if (i_ret)
		    printk( KERN_ERR "request_irq for SDIO ext IRQ failed, i_ret(%d)\n", i_ret);
		else
		    printk( KERN_ERR "request_irq for SDIO ext IRQ succeed, i_ret(%d)\n", i_ret);
	}
    #endif
    
#if	CONFIG_EINT_DEVICE_TREE
#else
    mt_eint_mask(mtk_wcn_cmb_sdio_eint_num);/*CUST_EINT_WIFI_NUM */
#endif
	printk(KERN_INFO "exit %s\n", __func__);

}
Пример #4
0
static void och165twad_mhall_eint_config_polarity(u8 polarity)
{
	MHALL_ERR("%s: penny   \n", __func__);
	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_eint_set_sens(CUST_EINT_MHALL_NUM, CUST_EINT_MHALL_SENSITIVE);
	mt_eint_set_hw_debounce(CUST_EINT_MHALL_NUM, CUST_EINT_MHALL_DEBOUNCE_CN);
	mt_eint_registration(CUST_EINT_MHALL_NUM, CUST_EINT_MHALL_TYPE, och165twad_mhall_eint_interrupt_handler, 0); 
	mt_eint_unmask(CUST_EINT_MHALL_NUM);
}
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);
    mt_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_TYPE, tpd_eint_interrupt_handler, 1);
    mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM);
    
    printk("MediaTek touch panel i2c probe success\n");
    
    return 0;
}
Пример #6
0
static int txc_irq_init(struct txc_data *txc)
{
	int ret;
	int irq;

	mt_set_gpio_dir(GPIO_IR_EINT_PIN, GPIO_DIR_IN);
	mt_set_gpio_mode(GPIO_IR_EINT_PIN, GPIO_MODE_00);
	mt_eint_set_sens(CUST_EINT_INTI_INT_NUM, MT_EDGE_SENSITIVE);
	mt_eint_registration(CUST_EINT_INTI_INT_NUM, EINTF_TRIGGER_FALLING, txc_irq_handler, 0);
	mt_eint_unmask(CUST_EINT_INTI_INT_NUM);

	return ret;
}
Пример #7
0
static void bq24196_irq_init(void)
{
	int ret;

	/*unmask CHRG_FAULT and BAT_FAULT */
	ret = bq24196_i2c_update_reg(bq_data, BQ24196_REG_MISC_CONTROL, 0x3, 0x3);

        mt_set_gpio_dir(GPIO_BQ_INT_PIN, GPIO_DIR_IN);
        mt_set_gpio_mode(GPIO_BQ_INT_PIN, GPIO_MODE_00);
        mt_eint_set_sens(GPIO_BQ_INT_NUM, MT_LEVEL_SENSITIVE);

        mt_eint_registration(GPIO_BQ_INT_NUM, EINTF_TRIGGER_LOW, bq24196_irq_handler, 0);
        mt_eint_unmask(GPIO_BQ_INT_NUM);
}
Пример #8
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));    
	// rename the functions mt65xx_eint_xx by mt_eint_xx   rui
	mt_eint_registration(CUST_EINT_CMMB_NUM, EINTF_TRIGGER_FALLING, interrupthandler, 0);         // 0:auto mask is no
	mt_eint_unmask(CUST_EINT_CMMB_NUM);   
	//    mt_eint_mask(CUST_EINT_CMMB_NUM);   
	return 0;
}
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;
    //mt_eint_set_sens(mtk_wcn_cmb_sdio_eint_num, CUST_EINT_WIFI_SENSITIVE); /*CUST_EINT_WIFI_NUM */
    //mt_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);
    mt_eint_registration(mtk_wcn_cmb_sdio_eint_num,
        CUST_EINT_WIFI_POLARITY,
        mtk_wcn_cmb_sdio_eirq_handler_stub,
        0);
    mt_eint_mask(mtk_wcn_cmb_sdio_eint_num);/*CUST_EINT_WIFI_NUM */

}
Пример #10
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;
    #if CUST_EINT_WIFI_DEBOUNCE_EN
    mt_eint_set_hw_debounce(mtk_wcn_cmb_sdio_eint_num, CUST_EINT_WIFI_DEBOUNCE_CN); /*CUST_EINT_WIFI_NUM */
    #endif
    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);
    mt_eint_registration(mtk_wcn_cmb_sdio_eint_num/*CUST_EINT_WIFI_NUM */,
        CUST_EINT_WIFI_TYPE,
        mtk_wcn_cmb_sdio_eirq_handler_stub,
        0);
    mt_eint_mask(mtk_wcn_cmb_sdio_eint_num);/*CUST_EINT_WIFI_NUM */

}
Пример #11
0
int hall_setup_eint(void)
{
	/*configure to GPIO function, external interrupt*/
	mt_set_gpio_mode(GPIO_HALL_COVER_PIN, GPIO_HALL_COVER_PIN_M_EINT);
	mt_set_gpio_dir(GPIO_HALL_COVER_PIN, GPIO_DIR_IN);
	mt_set_gpio_pull_enable(GPIO_HALL_COVER_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_HALL_COVER_PIN, GPIO_PULL_UP);
	
	HALL_LOG("hall_setup_eint 111\n");
	
	mt_eint_set_hw_debounce(CUST_EINT_HALL_COVER_NUM , CUST_EINT_HALL_COVER_DEBOUNCE_CN);
	mt_eint_registration(CUST_EINT_HALL_COVER_NUM , CUST_EINT_HALL_COVER_TYPE, hall_eint_func, 0);
	mt_eint_unmask(CUST_EINT_HALL_COVER_NUM );  

  HALL_LOG("hall_setup_eint 222\n");

  return 0;
}
Пример #12
0
int c2k_gpio_request_irq(int gpio, irq_handler_t handler, unsigned long flags,
	    const char *name, void *dev)
{
    mtk_c2k_gpio_des *des = NULL;

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

	printk("[C2K] c2k_gpio_request_irq eintnum %d\n", des->irq);
    //mt_eint_registration(des->irq, des->deb_en, des->pol, des->redirect, 0);
    mt_eint_registration(des->irq, des->pol, des->redirect, 0);
	
    return 0;
}
Пример #13
0
void static otg_int_init(void)
{
#ifdef ID_PIN_USE_EX_EINT
	mt_set_gpio_mode(GPIO_OTG_IDDIG_EINT_PIN, GPIO_OTG_IDDIG_EINT_PIN_M_USB_IDDIG);
	mt_set_gpio_dir(GPIO_OTG_IDDIG_EINT_PIN, GPIO_DIR_IN);
	mt_set_gpio_pull_enable(GPIO_OTG_IDDIG_EINT_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_OTG_IDDIG_EINT_PIN, GPIO_PULL_UP);

	mt_eint_set_sens(IDDIG_EINT_PIN, MT_LEVEL_SENSITIVE);
	mt_eint_set_hw_debounce(IDDIG_EINT_PIN,64);
	mt_eint_registration(IDDIG_EINT_PIN, EINTF_TRIGGER_LOW, mt_usb_ext_iddig_int, FALSE);
#else
	u32 phy_id_pull = 0;
	phy_id_pull = __raw_readl(U2PHYDTM1);
	phy_id_pull |= ID_PULL_UP;
	__raw_writel(phy_id_pull,U2PHYDTM1);

	musb_writel(mtk_musb->mregs,USB_L1INTM,IDDIG_INT_STATUS|musb_readl(mtk_musb->mregs,USB_L1INTM));
#endif
}
Пример #14
0
int c2k_gpio_request_irq(int gpio, irq_handler_t handler, unsigned long flags,
			 const char *name, void *dev)
{
	struct mtk_c2k_gpio_des *des = NULL;

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

#if defined(CONFIG_MTK_LEGACY)
	pr_debug("[C2K] c2k_gpio_request_irq eintnum %d\n", des->irq);
	/*mt_eint_registration(des->irq, des->deb_en, des->pol, des->redirect, 0); */
	mt_eint_registration(des->irq, des->pol, des->redirect, 0);
#else
	pr_info("[C2K] c2k_gpio_request_irq gpio %d irq %d\n", gpio, des->irq);
	/*mt_eint_registration(des->irq, des->pol, des->redirect, 0); */
	request_irq(des->irq, handler, flags, name, dev);
#endif

	return 0;
}
Пример #15
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;
 }
Пример #16
0
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
    //mt_eint_set_sens(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_SENSITIVE);
    mt_eint_set_hw_debounce(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_DEBOUNCE_DISABLE);
    mt_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, EINTF_TRIGGER_FALLING, tpd_eint_interrupt_handler, 1);
    mt_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;
}
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, "mhl_irq_kthread"); 
	wake_up_process(mhl_irq_task);

    #ifdef MTK_SMARTBOOK_SUPPORT
    //add by kirby
    init_waitqueue_head(&smartbook_wq);
	smartbook_task = kthread_create(smartbook_kthread, NULL, "smartbook_kthread"); 
	wake_up_process(smartbook_task);
    #endif
	
	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

#ifdef CUST_EINT_MHL_NUM
	///mt_eint_set_sens(CUST_EINT_MHL_NUM, MT_LEVEL_SENSITIVE);
	///mt_eint_set_hw_debounce(CUST_EINT_MHL_NUM, CUST_EINT_MHL_DEBOUNCE_CN);
    mt_eint_registration(CUST_EINT_MHL_NUM, CUST_EINT_MHL_TYPE, &mhl8338_irq_handler, 0);
    mt_eint_unmask(CUST_EINT_MHL_NUM);
#else
    printk("%s,%d Error: CUST_EINT_MHL_NUM is not defined\n", __func__, __LINE__);
#endif
	#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;
}
Пример #18
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) {
            #if CUST_EINT_COMBO_BGF_DEBOUNCE_EN
            mt_eint_set_hw_debounce(CUST_EINT_COMBO_BGF_NUM, CUST_EINT_COMBO_BGF_DEBOUNCE_CN);
            #endif
            mt_eint_registration(CUST_EINT_COMBO_BGF_NUM,
            		CUST_EINT_COMBO_BGF_POLARITY,
                wmt_plat_bgf_eirq_cb,
                0);
            mt_eint_mask(CUST_EINT_COMBO_BGF_NUM); /*2*/
        }
        else if (PIN_STA_EINT_EN == state) {
             mt_eint_unmask(CUST_EINT_COMBO_BGF_NUM);
             WMT_DBG_FUNC("WMT-PLAT:BGFInt (en) \n");
        }
        else if (PIN_STA_EINT_DIS == state) {
            mt_eint_mask(CUST_EINT_COMBO_BGF_NUM);
            WMT_DBG_FUNC("WMT-PLAT:BGFInt (dis) \n");
        }
        else {
            mt_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
            #if CUST_EINT_COMBO_ALL_DEBOUNCE_EN
            mt_eint_set_hw_debounce(CUST_EINT_COMBO_ALL_NUM, CUST_EINT_COMBO_ALL_DEBOUNCE_CN);
            #endif
            mt_eint_registration(CUST_EINT_COMBO_ALL_NUM,
                CUST_EINT_COMBO_ALL_TYPE,
                combo_bgf_eirq_handler,
                0);
            #endif
            mt_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) {
             /*mt_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) {
            mt_eint_mask(CUST_EINT_COMBO_ALL_NUM);
            WMT_DBG_FUNC("WMT-PLAT:ALLInt (DIS but not used yet) \n");
        }
        else {
            mt_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, 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);
    mt_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_TYPE, tpd_eint_interrupt_handler, 1);
    mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM);
    
    printk("MediaTek touch panel i2c probe success\n");
    
    return 0;
}
Пример #20
0
int cm_register_irq_cb(int type, void(*irq_cb)(void))
{
    #ifdef CONFIG_OF
    unsigned long flags;
    int ret=0;
    #endif

    switch(type)
    {
        case 0:
            //--- Ext MD wdt irq -------
            #ifdef CONFIG_OF
            mt_gpio_set_debounce(ext_md_wdt_eint.irq_id, ext_md_wdt_eint.debounce_time*1000);
            spin_lock_irqsave(&ext_md_wdt_eint.lock, flags);
            ext_md_wdt_eint.eint_cb = irq_cb;
            ext_md_wdt_eint.irq_reg = 1;
            ext_md_wdt_eint.irq_en_cnt=1;
            spin_unlock_irqrestore(&ext_md_wdt_eint.lock, flags);
            ret = request_irq(ext_md_wdt_eint.irq_id, ext_md_wdt_eint_handler, IRQF_TRIGGER_NONE, "emd_wdt-eint", NULL);
            if(ret != 0) {
                EMD_MSG_INF("chr","emd_wdt-eint register fail\n");
                spin_lock_irqsave(&ext_md_wdt_eint.lock, flags);
                ext_md_wdt_eint.eint_cb = NULL;
                ext_md_wdt_eint.irq_reg = 0;
                ext_md_wdt_eint.irq_en_cnt=0;
                spin_unlock_irqrestore(&ext_md_wdt_eint.lock, flags);
            }
            #else
            cm_disable_ext_md_wdt_irq();
            mt_eint_set_hw_debounce(ext_md_wdt_eint.irq_id, ext_md_wdt_eint.debounce_time);
            mt_eint_registration(ext_md_wdt_eint.irq_id,  ext_md_wdt_eint.intr_flag, irq_cb, 0);
            #endif
            break;
        case 1:
            //--- Ext MD wake up irq ------------
            #ifdef CONFIG_OF
            mt_gpio_set_debounce(ext_md_wk_eint.irq_id, ext_md_wk_eint.debounce_time*1000);
            spin_lock_irqsave(&ext_md_wk_eint.lock, flags);
            ext_md_wk_eint.eint_cb = irq_cb;
            ext_md_wk_eint.irq_reg = 1;
            ext_md_wk_eint.irq_en_cnt=1;
            spin_unlock_irqrestore(&ext_md_wk_eint.lock, flags);
            ret = request_irq(ext_md_wk_eint.irq_id, ext_md_wk_eint_handler, IRQF_TRIGGER_NONE, "emd_wkup-eint", NULL);
            if(ret != 0) {
                EMD_MSG_INF("chr","emd_wkup-eint register fail\n");
                spin_lock_irqsave(&ext_md_wk_eint.lock, flags);
                ext_md_wk_eint.eint_cb = NULL;
                ext_md_wk_eint.irq_reg = 0;
                ext_md_wk_eint.irq_en_cnt=0;
                spin_unlock_irqrestore(&ext_md_wk_eint.lock, flags);
            }
            #else
            cm_disable_ext_md_wakeup_irq();
            mt_eint_set_hw_debounce(ext_md_wk_eint.irq_id, ext_md_wk_eint.debounce_time);
            mt_eint_registration(ext_md_wk_eint.irq_id, ext_md_wk_eint.intr_flag, irq_cb, 0);
            #endif
            break;
        case 2:
            //--- Ext MD exception  irq ------------
            #ifdef CONFIG_OF
            mt_gpio_set_debounce(ext_md_exp_eint.irq_id, ext_md_exp_eint.debounce_time*1000);
            spin_lock_irqsave(&ext_md_exp_eint.lock, flags);
            ext_md_exp_eint.eint_cb = irq_cb;
            ext_md_exp_eint.irq_reg = 1;
            ext_md_exp_eint.irq_en_cnt=1;
            spin_unlock_irqrestore(&ext_md_exp_eint.lock, flags);
            ret = request_irq(ext_md_exp_eint.irq_id, ext_md_exp_eint_handler, IRQF_TRIGGER_NONE, "emd_exp-eint", NULL);
            if(ret != 0) {
                EMD_MSG_INF("chr","emd_exp-eint register fail\n");
                spin_lock_irqsave(&ext_md_exp_eint.lock, flags);
                ext_md_exp_eint.eint_cb = NULL;
                ext_md_exp_eint.irq_reg = 0;
                ext_md_exp_eint.irq_en_cnt=0;
                spin_unlock_irqrestore(&ext_md_exp_eint.lock, flags);
            }
            #else
            cm_disable_ext_md_exp_irq();
            mt_eint_set_hw_debounce(ext_md_exp_eint.irq_id, ext_md_exp_eint.debounce_time);
            mt_eint_registration(ext_md_exp_eint.irq_id, ext_md_exp_eint.intr_flag, irq_cb, 0);            
            #endif
            break;
        default:
            EMD_MSG_INF("chr","No support irq!!\n");
            break;
    }

    return 0;
}
static int tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) {
    char wakeup[2] = {0x07,0x02};
    char threshold[2] = {0x09, 0x04};
    char gesture[2]   = {0x08, 0x11};
    char idletime[2]  = {0x0c, 0xff};
    char sleeptime[2]   = {0x0d, 0x01};
    char firmware[2] = {0x0a, 0x44};
    int err = 0;
    i2c_client = client;
    hwPowerDown(TPD_POWER_SOURCE,"TP");
    hwPowerOn(TPD_POWER_SOURCE,VOL_3300,"TP");
    msleep(50);

    /* added in android 2.2, for configuring EINT2 */
    mt_set_gpio_mode(GPIO61, 0x01);
    mt_set_gpio_pull_enable(GPIO61, 1);
    mt_set_gpio_pull_select(GPIO61,1);

    //MT6516_EINT_Set_Sensitivity(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_SENSITIVE);
    //MT6516_EINT_Set_HW_Debounce(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_CN);
    mt_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_TYPE, tpd_eint_interrupt_handler, 1);
    mt_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM);
    //msleep(20);
    if(i2c_master_send(i2c_client,wakeup,2) < 0)
    {
    	TPD_DMESG("I2C transfer error, line: %d\n", __LINE__);
    	return -1; 
    }
    if(i2c_master_send(i2c_client,wakeup,2) < 0)
    {
    	TPD_DMESG("I2C transfer error, line: %d\n", __LINE__);
    	return -1; 
    }
    if(i2c_master_send(i2c_client,threshold,2) < 0)
    {
    	TPD_DMESG("I2C transfer error, line: %d\n", __LINE__);
    	return -1; 
    }
    if(i2c_master_send(i2c_client,gesture,2) < 0)
    {
    	TPD_DMESG("I2C transfer error, line: %d\n", __LINE__);
    	return -1; 
    }
    if(i2c_master_send(i2c_client,idletime,2) < 0)
    {
    	TPD_DMESG("I2C transfer error, line: %d\n", __LINE__);
    	return -1; 
    }
    if(i2c_master_send(i2c_client,sleeptime,2) < 0)
    {
    	TPD_DMESG("I2C transfer error, line: %d\n", __LINE__);
    	return -1;  
    }    
    if(i2c_master_send(i2c_client,firmware,2) < 0)
    {
    	TPD_DMESG("I2C transfer error, line: %d\n", __LINE__);
    	return -1; 
    }  
   tpd_load_status = 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_status = 1;
    
    return 0;
}
Пример #22
0
void cyttsp4_mtk_gpio_interrupt_register()
{
	//mt_eint_set_hw_debounce(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_CN);
	mt_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINTF_TRIGGER_FALLING, eint_interrupt_handler, 0);
	mt_eint_mask(CUST_EINT_TOUCH_PANEL_NUM);
}
Пример #23
0
static int kpd_pdrv_probe(struct platform_device *pdev)
{
	
	int i, r;
	int err = 0;
	
	kpd_ldvt_test_init();//API 2 for kpd LFVT test enviroment settings

	/* initialize and register input device (/dev/input/eventX) */
	kpd_input_dev = input_allocate_device();
	if (!kpd_input_dev)
		return -ENOMEM;

	kpd_input_dev->name = KPD_NAME;
	kpd_input_dev->id.bustype = BUS_HOST;
	kpd_input_dev->id.vendor = 0x2454;
	kpd_input_dev->id.product = 0x6500;
	kpd_input_dev->id.version = 0x0010;
	kpd_input_dev->open = kpd_open;

	//fulfill custom settings	
	kpd_memory_setting();
	
	__set_bit(EV_KEY, kpd_input_dev->evbit);

#if (KPD_PWRKEY_USE_EINT||KPD_PWRKEY_USE_PMIC)
	__set_bit(KPD_PWRKEY_MAP, kpd_input_dev->keybit);
	kpd_keymap[8] = 0;
#endif
	for (i = 17; i < KPD_NUM_KEYS; i += 9)	/* only [8] works for Power key */
		kpd_keymap[i] = 0;

	for (i = 0; i < KPD_NUM_KEYS; i++) {
		if (kpd_keymap[i] != 0)
			__set_bit(kpd_keymap[i], kpd_input_dev->keybit);
	}

#if KPD_AUTOTEST
	for (i = 0; i < ARRAY_SIZE(kpd_auto_keymap); i++)
		__set_bit(kpd_auto_keymap[i], kpd_input_dev->keybit);
#endif

#if KPD_HAS_SLIDE_QWERTY
	__set_bit(EV_SW, kpd_input_dev->evbit);
	__set_bit(SW_LID, kpd_input_dev->swbit);
#endif

#ifdef KPD_PMIC_RSTKEY_MAP
	__set_bit(KPD_PMIC_RSTKEY_MAP, kpd_input_dev->keybit);
#endif

#ifdef AEON_FCOVER_SUPPORT
			   __set_bit(KEY_FCOVER_1, kpd_input_dev->keybit);
			   __set_bit(KEY_FCOVER_2, kpd_input_dev->keybit);
#endif


	kpd_input_dev->dev.parent = &pdev->dev;
	r = input_register_device(kpd_input_dev);
	if (r) {
		printk(KPD_SAY "register input device failed (%d)\n", r);
		input_free_device(kpd_input_dev);
		return r;
	}

	/* register device (/dev/mt6575-kpd) */
	kpd_dev.parent = &pdev->dev;
	r = misc_register(&kpd_dev);
	if (r) {
		printk(KPD_SAY "register device failed (%d)\n", r);
		input_unregister_device(kpd_input_dev);
		return r;
	}

	/* register IRQ and EINT */
	kpd_set_debounce(KPD_KEY_DEBOUNCE);
	r = request_irq(MT_KP_IRQ_ID, kpd_irq_handler, IRQF_TRIGGER_FALLING, KPD_NAME, NULL);
	if (r) {
		printk(KPD_SAY "register IRQ failed (%d)\n", r);
		misc_deregister(&kpd_dev);
		input_unregister_device(kpd_input_dev);
		return r;
	}

#if KPD_PWRKEY_USE_EINT
	mt_eint_register();
#endif

#ifdef AEON_FCOVER_SUPPORT
    printk("leanda AEON_FCOVER_SUPPORT \r\n");
	mt_set_gpio_mode(GPIO_FCOVER_EINT_PIN, GPIO_MODE_01);
	mt_set_gpio_dir(GPIO_FCOVER_EINT_PIN, GPIO_DIR_IN);
	mt_set_gpio_pull_enable(GPIO_FCOVER_EINT_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_FCOVER_EINT_PIN, GPIO_PULL_UP);

        
	mt_eint_set_sens(FCOVER_KEY_EINT, FCOVER_KEY_SENSITIVE);
	mt_eint_set_hw_debounce(FCOVER_KEY_EINT, FCOVER_KEY_DEBOUNCE);
	mt_eint_registration(FCOVER_KEY_EINT, FCOVER_KEY_TYPE,
	                         kpd_fcover_eint_handler, 0);
	mt_eint_unmask(FCOVER_KEY_EINT);  
#endif
//mt_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_TYPE, tpd_eint_interrupt_handler, 1); 

#ifndef KPD_EARLY_PORTING /*add for avoid early porting build err the macro is defined in custom file*/
	long_press_reboot_function_setting();///API 4 for kpd long press reboot function setting
#endif	
	hrtimer_init(&aee_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	aee_timer.function = aee_timer_func;

#if AEE_ENABLE_5_15
    hrtimer_init(&aee_timer_5s, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
    aee_timer_5s.function = aee_timer_5s_func;
#endif

	if((err = kpd_create_attr(&kpd_pdrv.driver)))
	{
		kpd_print("create attr file fail\n");
		kpd_delete_attr(&kpd_pdrv.driver);
		return err;
	}

	return 0;
}
Пример #24
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_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 ){
			TPD_DMESG("Product version is %d\n", panel_version);
			fts_5x06_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);
 
 	mt_eint_set_sens(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_SENSITIVE);
	mt_eint_set_hw_debounce(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_CN);
	mt_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_TYPE, 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);
		  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));
#if defined (TINNO_ANDROID_S9091) || defined (TINNO_ANDROID_S9050)	
{
	extern char tpd_desc[50];
	extern int tpd_fw_version;
	sprintf(tpd_desc, "%s-%s(0x%X)", DRIVER_NAME, 
				fts_get_vendor_name(panel_vendor),panel_vendor);
	tpd_fw_version = panel_version;
}
#endif
	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_VGP, "touch"); 
  #endif	
	fts_5x06_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;
 }
Пример #25
0
static int kpd_pdrv_probe(struct platform_device *pdev)
{

	int i, r;
	int err = 0;

#ifdef CONFIG_OF
	kp_base = of_iomap(pdev->dev.of_node, 0);
	if (!kp_base) {
		pr_warn(KPD_SAY "KP iomap failed\n");
		return -ENODEV;
	};

	kp_irqnr = irq_of_parse_and_map(pdev->dev.of_node, 0);
	if (!kp_irqnr) {
		pr_warn(KPD_SAY "KP get irqnr failed\n");
		return -ENODEV;
	}
	pr_warn(KPD_SAY "kp base: 0x%p, addr:0x%p,  kp irq: %d\n", kp_base,&kp_base, kp_irqnr);
#endif

	kpd_ldvt_test_init();	/* API 2 for kpd LFVT test enviroment settings */

	/* initialize and register input device (/dev/input/eventX) */
	kpd_input_dev = input_allocate_device();
	if (!kpd_input_dev)
		return -ENOMEM;

	kpd_input_dev->name = KPD_NAME;
	kpd_input_dev->id.bustype = BUS_HOST;
	kpd_input_dev->id.vendor = 0x2454;
	kpd_input_dev->id.product = 0x6500;
	kpd_input_dev->id.version = 0x0010;
	kpd_input_dev->open = kpd_open;
	
#ifdef AEON_FCOVER_SUPPORT	
	spin_lock_init(&fcover_lock);
	fcover_close_flag = 1;
#endif	
	//fulfill custom settings	
	kpd_memory_setting();

	__set_bit(EV_KEY, kpd_input_dev->evbit);

#if (KPD_PWRKEY_USE_EINT || KPD_PWRKEY_USE_PMIC)
	__set_bit(KPD_PWRKEY_MAP, kpd_input_dev->keybit);
	kpd_keymap[8] = 0;
#endif

#if !KPD_USE_EXTEND_TYPE
	for (i = 17; i < KPD_NUM_KEYS; i += 9)	/* only [8] works for Power key */
		kpd_keymap[i] = 0;
#endif

	for (i = 0; i < KPD_NUM_KEYS; i++) {
		if (kpd_keymap[i] != 0)
			__set_bit(kpd_keymap[i], kpd_input_dev->keybit);
	}

#if KPD_AUTOTEST
	for (i = 0; i < ARRAY_SIZE(kpd_auto_keymap); i++)
		__set_bit(kpd_auto_keymap[i], kpd_input_dev->keybit);
#endif

#if KPD_HAS_SLIDE_QWERTY
	__set_bit(EV_SW, kpd_input_dev->evbit);
	__set_bit(SW_LID, kpd_input_dev->swbit);
#endif

#ifdef KPD_PMIC_RSTKEY_MAP
	__set_bit(KPD_PMIC_RSTKEY_MAP, kpd_input_dev->keybit);
#endif

#ifdef KPD_KEY_MAP
		__set_bit(KPD_KEY_MAP, kpd_input_dev->keybit);
#endif

#ifdef AEON_FCOVER_SUPPORT
//			   __set_bit(KEY_FCOVER_1, kpd_input_dev->keybit);
//			   __set_bit(KEY_FCOVER_2, kpd_input_dev->keybit);
			   __set_bit(KEY_F11, kpd_input_dev->keybit);
			   __set_bit(KEY_F12, kpd_input_dev->keybit);		
#endif

	kpd_input_dev->dev.parent = &pdev->dev;
	r = input_register_device(kpd_input_dev);
	if (r) {
		printk(KPD_SAY "register input device failed (%d)\n", r);
		input_free_device(kpd_input_dev);
		return r;
	}

	/* register device (/dev/mt6575-kpd) */
	kpd_dev.parent = &pdev->dev;
	r = misc_register(&kpd_dev);
	if (r) {
		printk(KPD_SAY "register device failed (%d)\n", r);
		input_unregister_device(kpd_input_dev);
		return r;
	}

#ifdef CONFIG_MTK_TC1_FM_AT_SUSPEND
	wake_lock_init(&kpd_suspend_lock, WAKE_LOCK_SUSPEND, "kpd wakelock");
#endif

	/* register IRQ and EINT */
	kpd_set_debounce(KPD_KEY_DEBOUNCE);
#ifdef CONFIG_OF
	r = request_irq(kp_irqnr, kpd_irq_handler, IRQF_TRIGGER_NONE, KPD_NAME, NULL);
#else
	r = request_irq(MT_KP_IRQ_ID, kpd_irq_handler, IRQF_TRIGGER_FALLING, KPD_NAME, NULL);
#endif
	if (r) {
		printk(KPD_SAY "register IRQ failed (%d)\n", r);
		misc_deregister(&kpd_dev);
		input_unregister_device(kpd_input_dev);
		return r;
	}
	mt_eint_register();

#ifndef KPD_EARLY_PORTING	/*add for avoid early porting build err the macro is defined in custom file */
	long_press_reboot_function_setting();	/* /API 4 for kpd long press reboot function setting */
#endif
	hrtimer_init(&aee_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	aee_timer.function = aee_timer_func;

#if AEE_ENABLE_5_15
	hrtimer_init(&aee_timer_5s, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	aee_timer_5s.function = aee_timer_5s_func;
#endif

	if ((err = kpd_create_attr(&kpd_pdrv.driver))) {
		kpd_print("create attr file fail\n");
		kpd_delete_attr(&kpd_pdrv.driver);
		return err;
	}
    pr_warn(KPD_SAY "%s Done\n", __FUNCTION__);
#ifdef AEON_FCOVER_SUPPORT
	fcover_workqueue = create_singlethread_workqueue("fcover");
	INIT_WORK(&fcover_work, fcover_key_handler);
	
	fcover_data.name = "hall";
	fcover_data.index = 0;
	fcover_data.state = fcover_close_flag;
	
	err = switch_dev_register(&fcover_data);
	if(err)
	{
		printk("[Accdet]switch_dev_register returned:%d!\n", err);
//		return 1;
	}

	switch_set_state((struct switch_dev *)&fcover_data, fcover_close_flag);
#ifdef AEON_FCOVER_SUPPORT
	mt_set_gpio_mode(GPIO_FCOVER_EINT_PIN, GPIO_EINT_HALL_PIN_M_GPIO);
	mt_set_gpio_dir(GPIO_FCOVER_EINT_PIN, GPIO_DIR_IN);
	mt_set_gpio_pull_enable(GPIO_FCOVER_EINT_PIN, GPIO_PULL_DISABLE);
//	mt_set_gpio_pull_select(GPIO_FCOVER_EINT_PIN, GPIO_PULL_UP);

	mdelay(20);
	fcover_close_flag = mt_get_gpio_in(GPIO_FCOVER_EINT_PIN);
//	tpd_fcover_setting(fcover_close_flag);

	mt_set_gpio_mode(GPIO_FCOVER_EINT_PIN, GPIO_EINT_HALL_PIN_M_EINT);
	
	mt_eint_set_sens(FCOVER_KEY_EINT, FCOVER_KEY_SENSITIVE);
	mt_eint_set_hw_debounce(FCOVER_KEY_EINT, FCOVER_KEY_DEBOUNCE);
	mt_eint_registration(FCOVER_KEY_EINT, EINTF_TRIGGER_LOW,
	                         kpd_fcover_eint_handler, 0);
	mt_eint_unmask(FCOVER_KEY_EINT);  
	printk(KPD_SAY "xuqian kpd_fcover_eint_handler ..\n");

#else
	mt_set_gpio_mode(GPIO_FCOVER_EINT_PIN, GPIO_EINT_HALL_PIN_M_GPIO);
	mt_set_gpio_dir(GPIO_FCOVER_EINT_PIN, GPIO_DIR_IN);
	mt_set_gpio_pull_enable(GPIO_FCOVER_EINT_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_FCOVER_EINT_PIN, GPIO_PULL_DOWN);
	
#endif

//	err = device_create_file(&(pdev->dev), &dev_attr_kpd_fcover_state);
//	if(err)
//	{
//		printk("create attr file dev_attr_kpd_fcover_state error\n");
////		kpd_delete_attr(&kpd_pdrv.driver);
////		return err;
//	}
//	else
//	{
//		printk("create attr file dev_attr_kpd_fcover_state ok\n");
//	}
#endif
	return 0;
}
Пример #26
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) {
#ifdef GPIO_COMBO_BGF_EINT_PIN

#if CONFIG_EINT_DEVICE_TREE
	struct device_node *node;
	UINT32 ints[2] = {0,0};
	INT32 ret = -EINVAL;

	node = of_find_compatible_node(NULL, NULL, "mediatek, BGF-eint");/*BGF-eint name maybe wrong*/
	if(node) {
		
#if CUST_EINT_COMBO_BGF_DEBOUNCE_EN
		of_property_read_u32_array(node, "debounce", ints, ARRAY_SIZE(ints));
		mt_gpio_set_debounce(ints[0], ints[1]);
#endif
		bfg_irq = irq_of_parse_and_map(node, 0);
		ret = request_irq(bfg_irq, wmt_plat_bgf_eirq_cb, IRQF_TRIGGER_NONE,"BGF-eint", NULL);
		if(ret)
			printk(KERN_ERR "BGF EINT IRQ LINE NOT AVAILABLE!!\n");
		else
			printk(KERN_INFO "BGF EINT request_irq sucess!!\n");
	} else
		printk(KERN_ERR "[%s] can't find BGF eint compatible node\n",__func__);
#else
#if CUST_EINT_COMBO_BGF_DEBOUNCE_EN
            mt_eint_set_hw_debounce(CUST_EINT_COMBO_BGF_NUM, CUST_EINT_COMBO_BGF_DEBOUNCE_CN);
#endif
			mt_eint_registration(CUST_EINT_COMBO_BGF_NUM,
					     CUST_EINT_COMBO_BGF_TYPE, wmt_plat_bgf_eirq_cb, 0);
			mt_eint_mask(CUST_EINT_COMBO_BGF_NUM);	/*2 */
#endif
#endif
		} else if (PIN_STA_EINT_EN == state) {
#if CONFIG_EINT_DEVICE_TREE
			 enable_irq(bfg_irq);
#else
             mt_eint_unmask(CUST_EINT_COMBO_BGF_NUM);
#endif			 
			WMT_DBG_FUNC("WMT-PLAT:BGFInt (en)\n");
		} else if (PIN_STA_EINT_DIS == state) {
#if CONFIG_EINT_DEVICE_TREE
			disable_irq_nosync(bfg_irq);
#else
            mt_eint_mask(CUST_EINT_COMBO_BGF_NUM);
#endif
			WMT_DBG_FUNC("WMT-PLAT:BGFInt (dis)\n");
		} else {
#if CONFIG_EINT_DEVICE_TREE
			disable_irq_nosync(bfg_irq);	
#else
            mt_eint_mask(CUST_EINT_COMBO_BGF_NUM);
#endif
            WMT_DBG_FUNC("WMT-PLAT:BGFInt (dis) \n");
			/* de-init: nothing to do in ALPS, such as un-registration... */
		}
#else
		WMT_INFO_FUNC("WMT-PLAT:BGF EINT not defined\n");
#endif
		iret = 0;
		break;

	case PIN_ALL_EINT:
#ifdef GPIO_COMBO_ALL_EINT_PIN
		if (PIN_STA_INIT == state) {
#if 0
#if CUST_EINT_COMBO_ALL_DEBOUNCE_EN
			mt_eint_set_hw_debounce(CUST_EINT_COMBO_ALL_NUM,
						CUST_EINT_COMBO_ALL_DEBOUNCE_CN);
#endif
			mt_eint_registration(CUST_EINT_COMBO_ALL_NUM,
					     CUST_EINT_COMBO_ALL_TYPE, combo_bgf_eirq_handler, 0);
#endif
			mt_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) {
			/*mt_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) {
			mt_eint_mask(CUST_EINT_COMBO_ALL_NUM);
			WMT_DBG_FUNC("WMT-PLAT:ALLInt (DIS but not used yet)\n");
		} else {
			mt_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");
#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;
}