static void swtp_eint_handler(void)
{
    unsigned int rfcable_enable;

    mt_eint_mask(SWTP_EINT_NUM);

    if(swtp_eint_state ==  EINT_PIN_PLUG_IN )
    {
	if (SWTP_EINT_TYPE == CUST_EINTF_TRIGGER_HIGH){
		mt_eint_set_polarity(SWTP_EINT_NUM, (1));
	}else{
		mt_eint_set_polarity(SWTP_EINT_NUM, (0));
	}
	swtp_eint_state = EINT_PIN_PLUG_OUT;
	rfcable_enable  = SWTP_MODE_OFF;
    } 
    else 
    {
	if (SWTP_EINT_TYPE == CUST_EINTF_TRIGGER_HIGH){
		mt_eint_set_polarity(SWTP_EINT_NUM, !(1));
	}else{
		mt_eint_set_polarity(SWTP_EINT_NUM, !(0));
	}
	swtp_eint_state = EINT_PIN_PLUG_IN;
        rfcable_enable  = SWTP_MODE_ON;
    }

    printk("[swtp]: rfcable_enable: %d\n", rfcable_enable);

    swtp_set_mode_unlocked(SWTP_CTRL_SUPER_SET,  rfcable_enable);
    mt_eint_unmask(SWTP_EINT_NUM);
}
Esempio n. 2
0
/*----------------------------------------------------------------------------*/
static void hall_eint_work(struct work_struct *work)
{
	int err;
	
	HALL_LOG("hall_eint_work()\n");

		
	if((err = hall_read_status(&g_hall_ptr->hall_status)))
	{
		 HALL_ERR("hall_read_value: %d\n", err);
	}
	
	if (g_hall_ptr->hall_status == 1)
	{
		HALL_ERR("HALL OPEN!!! \n");
		mt_eint_set_polarity(CUST_EINT_HALL_COVER_NUM, MT_POLARITY_LOW);
	}
	else
	{
		HALL_ERR("HALL CLOSE!!! \n");
		mt_eint_set_polarity(CUST_EINT_HALL_COVER_NUM, MT_POLARITY_HIGH);
	}

	input_report_switch(g_hall_ptr->idev, g_hall_ptr->sw_code, g_hall_ptr->hall_status);
	input_sync(g_hall_ptr->idev);

	mt_eint_unmask(CUST_EINT_HALL_COVER_NUM);
}
Esempio n. 3
0
int c2k_gpio_set_irq_type(int gpio, unsigned int type)
{
	int irq, level;

	irq = c2k_gpio_to_irq(gpio);
	if (irq < 0)
		return irq;

	level = c2k_gpio_get_value(gpio);

	if (type == IRQ_TYPE_EDGE_BOTH) {
		if (level)
			type = IRQ_TYPE_EDGE_FALLING;
		else
			type = IRQ_TYPE_EDGE_RISING;
	}

	if (type == IRQ_TYPE_LEVEL_MASK) {
		if (level)
			type = IRQ_TYPE_LEVEL_LOW;
		else
			type = IRQ_TYPE_LEVEL_HIGH;
	}
#ifndef CONFIG_EVDO_DT_VIA_SUPPORT
	c2k_irq_set_type(irq, type);
#endif

#if defined(CONFIG_MTK_LEGACY)
	mt_eint_set_hw_debounce(irq, 0);
	switch (type) {
	case IRQ_TYPE_EDGE_RISING:
		mt_eint_set_sens(irq, MT_EDGE_SENSITIVE);
		mt_eint_set_polarity(irq, MT_POLARITY_HIGH);
		break;
	case IRQ_TYPE_EDGE_FALLING:
		mt_eint_set_sens(irq, MT_EDGE_SENSITIVE);
		mt_eint_set_polarity(irq, MT_POLARITY_LOW);
		break;
	case IRQ_TYPE_LEVEL_HIGH:
		mt_eint_set_sens(irq, MT_LEVEL_SENSITIVE);
		mt_eint_set_polarity(irq, MT_POLARITY_HIGH);
		break;
	case IRQ_TYPE_LEVEL_LOW:
		mt_eint_set_sens(irq, MT_LEVEL_SENSITIVE);
		mt_eint_set_polarity(irq, MT_POLARITY_LOW);
		break;
	default:
		return -EINVAL;
	}
#else
	gpio_set_debounce(gpio, 0);
	irq_set_irq_type(irq, type);
#endif
	/*pr_debug("[C2K]set irq(%d) type(%d) done\n", irq, type); */

	return 0;
}
Esempio n. 4
0
//add by lihua BUG_ID:NULL Description: add node 2013-10-29 (end)
static int mhall_thread_kthread(void *x)
{
    while(1)
    {
	  s32	mhall_value;
        wait_event_interruptible(mhall_thread_wq, atomic_read(&mhall_wakeup_flag));
        atomic_set(&mhall_wakeup_flag, 0);
#if 0
        kpd_pwrkey_pmic_handler(1);
    	msleep(100);
    	kpd_pwrkey_pmic_handler(0);
#endif
//		mt_set_gpio_mode(GPIO_MHALL_EINT_PIN, GPIO_MHALL_EINT_PIN_M_GPIO);
//		mt_set_gpio_dir(GPIO_MHALL_EINT_PIN, GPIO_DIR_IN);
//		mt_set_gpio_pull_enable(GPIO_MHALL_EINT_PIN, GPIO_PULL_DISABLE);
		mhall_value = mt_get_gpio_in(GPIO_MHALL_EINT_PIN);
		MHALL_ERR("%s: fangxing  mhall_value = %d \n",__func__,mhall_value);
		if(mhall_value  == 1 ) {		
		   		input_report_key(mhall_input_dev, KEY_MHALL_UP, 1);
				input_sync(mhall_input_dev);
				msleep(10);
		   		input_report_key(mhall_input_dev, KEY_MHALL_UP, 0);
				input_sync(mhall_input_dev);
//				mt_eint_mask(CUST_EINT_MHALL_NUM);
//				och165twad_mhall_eint_config_polarity(CUST_EINT_POLARITY_LOW); 

                mt_eint_set_polarity(GPIO_MHALL_EINT_PIN,0);
                mt_eint_unmask(CUST_EINT_MHALL_NUM);
                mhall_flag = 1;//add by lihua BUG_ID:NULL Description: add node 2013-10-29

		} else {
		   		input_report_key(mhall_input_dev, KEY_MHALL_DOWN, 1);
				input_sync(mhall_input_dev);
				msleep(10);
		   		input_report_key(mhall_input_dev, KEY_MHALL_DOWN, 0);
				input_sync(mhall_input_dev);
//				mt_eint_mask(CUST_EINT_MHALL_NUM);
//				och165twad_mhall_eint_config_polarity(CUST_EINT_POLARITY_HIGH); 
                mt_eint_set_polarity(GPIO_MHALL_EINT_PIN,1);
                mt_eint_unmask(CUST_EINT_MHALL_NUM);
                mhall_flag = 0;//add by lihua BUG_ID:NULL Description: add node 2013-10-29
		}
    }
}
Esempio n. 5
0
//static void fcover_key_handler(unsigned long data)
static void fcover_key_handler(struct work_struct *work)
{
//	int tmp;
//	fcover_close_flag=new_fcover;
	
	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);

	mdelay(1);
	new_fcover = mt_get_gpio_in(GPIO_FCOVER_EINT_PIN);
		
	mt_set_gpio_mode(GPIO_FCOVER_EINT_PIN, GPIO_EINT_HALL_PIN_M_EINT);

	printk("fcover_key_handler new_fcover=%d\n",new_fcover);

	if(fcover_close_flag != new_fcover)
	{
		spin_lock(&fcover_lock);
		fcover_close_flag = new_fcover;
		spin_unlock(&fcover_lock);
		
		if(fcover_close_flag == 0) // close
		{
//	        	input_report_key(kpd_input_dev, KEY_FCOVER_1, 1);
				input_report_key(kpd_input_dev, KEY_F11, 1);
	        	input_sync(kpd_input_dev);
	        	mdelay(1);
//	            input_report_key(kpd_input_dev, KEY_FCOVER_1, 0); 
				input_report_key(kpd_input_dev, KEY_F11, 0);
	        	input_sync(kpd_input_dev);
				
//				tpd_fcover_setting(fcover_close_flag); 
		
		}
		else  // open
		{
//	        	input_report_key(kpd_input_dev, KEY_FCOVER_2, 1);
				input_report_key(kpd_input_dev, KEY_F12, 1);
	        	input_sync(kpd_input_dev);
	        	mdelay(1);
//	            input_report_key(kpd_input_dev, KEY_FCOVER_2, 0);
				input_report_key(kpd_input_dev, KEY_F12, 0);
	        	input_sync(kpd_input_dev);
				
//				tpd_fcover_setting(fcover_close_flag); 

		}
		
	}
	switch_set_state((struct switch_dev *)&fcover_data, fcover_close_flag);
	mt_eint_set_polarity(FCOVER_KEY_EINT, !fcover_close_flag);
	mt_eint_unmask(FCOVER_KEY_EINT);
}
Esempio n. 6
0
void switch_int_to_device(struct musb *musb)
{
#ifdef ID_PIN_USE_EX_EINT
    mt_eint_set_polarity(IDDIG_EINT_PIN, MT_EINT_POL_POS);
	mt_eint_unmask(IDDIG_EINT_PIN);
#else
	 musb_writel(musb->mregs,USB_L1INTP,0);
	 musb_writel(musb->mregs,USB_L1INTM,IDDIG_INT_STATUS|musb_readl(musb->mregs,USB_L1INTM));
#endif
	 DBG(0,"switch_int_to_device is done\n");
}
Esempio n. 7
0
void switch_int_to_host_and_mask(struct musb *musb)
{
#ifdef ID_PIN_USE_EX_EINT
    mt_eint_set_polarity(IDDIG_EINT_PIN, MT_EINT_POL_NEG);
	mt_eint_mask(IDDIG_EINT_PIN);
#else
	musb_writel(musb->mregs,USB_L1INTM,(~IDDIG_INT_STATUS)&musb_readl(musb->mregs,USB_L1INTM)); //mask before change polarity
	mb();
	musb_writel(musb->mregs,USB_L1INTP,IDDIG_INT_STATUS);
#endif
	DBG(0,"swtich_int_to_host_and_mask is done\n");
}
Esempio n. 8
0
static void fcover_key_handler(unsigned long data)
{
	bool pressed;
	u8 old_state = fcover_key_state;
      
	fcover_key_state = !fcover_key_state;
	pressed = (fcover_key_state == !!FCOVER_KEY_POLARITY);
	printk("\r\n leanda fcover_key_eint_handler in pressed=%d, fcover_key_state=%d,old_state=%d \r\n", pressed, fcover_key_state, old_state);
	if(pressed) // close
	{
			fcover_close_flag = 0;
        	input_report_key(kpd_input_dev, KEY_FCOVER_1, 1);
        	input_sync(kpd_input_dev);
        	mdelay(1);
            input_report_key(kpd_input_dev, KEY_FCOVER_1, 0);
        	input_sync(kpd_input_dev);
        	printk("report Linux keycode = %u\n", KEY_FCOVER_1);
			
//======================test=========================
#ifdef KERNEL_OPEN_FCOVER
			if(lcm_backlight_flag == 1)
			{
				kpd_backlight_handler(1, KPD_PWRKEY_MAP);
				input_report_key(kpd_input_dev, KPD_PWRKEY_MAP, 1);
				input_sync(kpd_input_dev);
				printk("report Linux keycode = %u\n", KPD_PWRKEY_MAP);
				mdelay(1);
				kpd_backlight_handler(0, KPD_PWRKEY_MAP);
				input_report_key(kpd_input_dev, KPD_PWRKEY_MAP, 0);
				input_sync(kpd_input_dev);
				printk("report Linux keycode = %u\n", KPD_PWRKEY_MAP);
			}
#endif
//======================end===========================			
	}
	else  // open
	{
			fcover_close_flag = 1;
        	input_report_key(kpd_input_dev, KEY_FCOVER_2, 1);
        	input_sync(kpd_input_dev);
        	mdelay(1);
             input_report_key(kpd_input_dev, KEY_FCOVER_2, 0);
        	input_sync(kpd_input_dev);
        	printk("report Linux keycode = %u\n", KEY_FCOVER_2);
	}

	/* for detecting the return to old_state */
	mt_eint_set_polarity(FCOVER_KEY_EINT, old_state);
	mt_eint_unmask(FCOVER_KEY_EINT);
}
Esempio n. 9
0
static void gpio_keys_gpio_delayed_work_func(struct work_struct *work)
{
	struct gpio_button_data *bdata =
		container_of(work, struct gpio_button_data, delayed_work.work);

	unsigned char gpio_in = 0, pol = FALLING;

	mutex_lock(&bdata->key_mutex);
	gpio_in = mt_get_gpio_in(bdata->button->gpio);
	pol = mt_eint_get_polarity(bdata->button->irq);

#ifdef KEYPAD_DEBUG
	printk("[Hall] %s: %s %s, gpio_in:%d pol:%s\n",
			__func__,
			bdata->button->desc,
			(atomic_read(&bdata->key_pressed) == PRESSED) ? "Press" : "Release",
			gpio_in,
			pol == RISING ? "Rise" : "Fall");
#endif
	if((atomic_read(&bdata->key_pressed) == PRESSED) && (gpio_in == 1) && (pol == RISING)) {
		mt_eint_mask(bdata->button->irq);
		mt_eint_set_polarity(bdata->button->irq, FALLING);

		atomic_set(&bdata->key_pressed, RELEASED);
		input_report_key(bdata->input, bdata->button->code, RELEASED);
		input_sync(bdata->input);
		mt_eint_unmask(bdata->button->irq);

#ifdef MEIZU_TP_NOTIFIER
		if(bdata->irq == M7X_HALL_IRQ_NUM)
		     gpio_key_notify(atomic_read(&bdata->key_pressed),NULL);
#endif

#ifdef KEYPAD_DEBUG
		printk("[Hall] %s: Force Release!!\n", __func__);
#endif
	}
	mutex_unlock(&bdata->key_mutex);
}
Esempio n. 10
0
static void txc_ps_handler(struct work_struct *work)
{
    struct txc_data *txc = container_of(work, struct txc_data, ps_dwork.work);
    struct i2c_client *client = txc_info->client;
    u8 psdata=0;
    u16 alsdata = 0;
    int ps_data = PS_UNKONW;
    u8 sendvalue;
    int res;
    u8 data;
    int ret;

    ret = pa12201001_read_ps(client,&psdata);

    if (ret < 0) {
	pr_err("%s: txc_write error\n", __func__);
	return ret;
    }
	
	if (txc->ps_data == PS_UNKONW || txc->ps_data == PS_FAR) {
		if(psdata > PA12_PS_FAR_TH_HIGH){
		    mt_eint_set_polarity(CUST_EINT_INTI_INT_NUM, EINTF_TRIGGER_RISING);
		    ps_data = PS_NEAR;

		    sendvalue= PA12_LED_CURR150 | PA12_PS_PRST2 | PA12_ALS_PRST4;
		    res=i2c_write_reg(client,REG_CFG1,sendvalue);
		    if (res < 0) {
			    pr_err("%s: txc_write error\n", __func__);
			    return res;
		    }

		    sendvalue= PA12_PS_INT_HYSTERESIS | PA12_PS_PERIOD6;
		    res=i2c_write_reg(client,REG_CFG3,sendvalue);
		    if (res < 0) {
			    pr_err("%s: txc_write error\n", __func__);
			    return res;
		    }
		} else if (psdata < PA12_PS_NEAR_TH_LOW) {
			ps_data = PS_FAR;
			mt_eint_set_polarity(CUST_EINT_INTI_INT_NUM, MT_EINT_POL_NEG);
		}
	} else if (txc->ps_data == PS_NEAR) {
		if(psdata < PA12_PS_NEAR_TH_LOW){
			mt_eint_set_polarity(CUST_EINT_INTI_INT_NUM, MT_EINT_POL_NEG);
			ps_data = PS_FAR;
			
			sendvalue= PA12_LED_CURR150 | PA12_PS_PRST4;

			res=i2c_write_reg(client,REG_CFG1,sendvalue);
			if (res < 0) {
				pr_err("%s: txc_write error\n", __func__);
				return res;
			}
			sendvalue= PA12_PS_INT_HYSTERESIS | PA12_PS_PERIOD12;
		    	res=i2c_write_reg(client,REG_CFG3,sendvalue);
		    	if (res < 0) {
			    pr_err("%s: txc_write error\n", __func__);
			    return res;
		   	 }
		}
	}

	if (txc->ps_data != ps_data) {
		wake_lock_timeout(&txc->ps_wake_lock, 2*HZ);
		txc->ps_data = ps_data;
		input_report_abs(txc->input_dev, ABS_DISTANCE, ps_data);
		input_sync(txc->input_dev);
		if (ps_data == PS_NEAR) {
			printk("***********near***********\n");	
		} else if (ps_data == PS_FAR) {
			printk("****************far***************\n");		
		}
	}
	ret = i2c_read_reg(txc->client, REG_CFG2, &data);
	if (ret < 0) {
	    pr_err("%s: txc_read error\n", __func__);
	    return ret;
	}
	data &= 0xfe;
	ret = i2c_write_reg(txc->client, REG_CFG2, data);
	if (ret < 0) {
	    pr_err("%s: txc_write error\n", __func__);
	    return ret;
	}
    mt_eint_unmask(CUST_EINT_INTI_INT_NUM);
}