示例#1
0
static irqreturn_t touchkey_interrupt(int irq, void *dev_id)
{
	struct touchkey_i2c *tkey_i2c = dev_id;
	u8 data[3];
	int ret;
	int retry = 10;
	int keycode_type = 0;
	int pressed;

	set_touchkey_debug('a');

	retry = 3;
	while (retry--) {
		ret = i2c_touchkey_read(tkey_i2c->client, KEYCODE_REG, data, 3);
		if (!ret)
			break;
		else {
			printk(KERN_DEBUG
			       "[TouchKey] i2c read failed, ret:%d, retry: %d\n",
			       ret, retry);
			continue;
		}
	}
	if (ret < 0)
		return IRQ_HANDLED;

	set_touchkey_debug(data[0]);

	keycode_type = (data[0] & TK_BIT_KEYCODE);
	pressed = !(data[0] & TK_BIT_PRESS_EV);

	if (keycode_type <= 0 || keycode_type >= touchkey_count) {
		printk(KERN_DEBUG "[Touchkey] keycode_type err\n");
		return IRQ_HANDLED;
	}

	if (pressed)
		set_touchkey_debug('P');

	if (get_tsp_status() && pressed)
		printk(KERN_DEBUG "[TouchKey] touchkey pressed but don't send event because touch is pressed.\n");
	else {
		input_report_key(tkey_i2c->input_dev,
				 touchkey_keycode[keycode_type], pressed);
		input_sync(tkey_i2c->input_dev);
		/* printk(KERN_DEBUG "[TouchKey] keycode:%d pressed:%d\n",
		   touchkey_keycode[keycode_index], pressed); */

		#if defined(CONFIG_TARGET_LOCALE_KOR)
		if (g_debug_tkey == true) {
			printk(KERN_DEBUG "[TouchKey] keycode[%d]=%d pressed:%d\n",
			keycode_type, touchkey_keycode[keycode_type], pressed);
		} else {
			printk(KERN_DEBUG "[TouchKey] pressed:%d\n", pressed);
		}
		#endif
	}
	set_touchkey_debug('A');
	return IRQ_HANDLED;
}
示例#2
0
static ssize_t touchkey_enable_disable(struct device *dev,
				       struct device_attribute *attr,
				       const char *buf, size_t size)
{
#if 0
	printk("touchkey_enable_disable %c \n", *buf);
	if (*buf == '0') {
		set_touchkey_debug('d');
		disable_irq(IRQ_TOUCH_INT);
		gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
#if !(defined(CONFIG_ARIES_NTT) || defined(CONFIG_S5PC110_DEMPSEY_BOARD))
		gpio_direction_output(_3_GPIO_TOUCH_CE, 0);
#endif
		touchkey_enable = -2;
	} else if (*buf == '1') {
		if (touchkey_enable == -2) {
			set_touchkey_debug('e');
			gpio_direction_output(_3_GPIO_TOUCH_EN, 1);
#if !(defined(CONFIG_ARIES_NTT) || defined(CONFIG_S5PC110_DEMPSEY_BOARD))
			gpio_direction_output(_3_GPIO_TOUCH_CE, 1);
#endif
			touchkey_enable = 1;
			enable_irq(IRQ_TOUCH_INT);
		}
	} else {
		printk("touchkey_enable_disable: unknown command %c \n", *buf);
	}
#endif
	return size;
}
示例#3
0
static int sec_touchkey_early_suspend(struct early_suspend *h)
{
	struct touchkey_i2c *tkey_i2c =
		container_of(h, struct touchkey_i2c, early_suspend);
	int ret;
	int i;


#if defined(CONFIG_S2VE_TOUCHKEY_REV05)

	set_touchkey_debug('S');
	printk(KERN_DEBUG "[TouchKey] sec_touchkey_early_suspend\n");
	touchkey_suspended = 1;	
	printk(KERN_ERR"sec_touchkey_early_suspend++\n");
	touchkey_led_on(tkey_i2c, 0);
	disable_irq(tkey_i2c->irq);
	
	gpio_set_value(TOUCHKEY_SDA, 1); 
	gpio_set_value(TOUCHKEY_SCL, 1); 
	Touchkey_PowerOnOff(0);

	msleep(10);
	enable_irq(tkey_i2c->irq);

#else	

	gpio_set_value(TOUCHKEY_SDA, 1); 
	gpio_set_value(TOUCHKEY_SCL, 1); 	

	disable_irq(tkey_i2c->irq);
	ret = cancel_work_sync(&tkey_i2c->update_work);
	if (ret) {
		printk(KERN_DEBUG "[Touchkey] enable_irq ret=%d\n", ret);
		enable_irq(tkey_i2c->irq);
	}

	/* release keys */
	for (i = 1; i < touchkey_count; ++i) {
		input_report_key(tkey_i2c->input_dev,
				 touchkey_keycode[i], 0);
	}
	input_sync(tkey_i2c->input_dev);

	touchkey_enable = 0;
	set_touchkey_debug('S');
	printk(KERN_DEBUG "[TouchKey] sec_touchkey_early_suspend\n");
	if (touchkey_enable < 0) {
		printk(KERN_DEBUG "[TouchKey] ---%s---touchkey_enable: %d\n",
		       __func__, touchkey_enable);
		return 0;
	}

#endif	

	return 0;
}
static void melfas_touchkey_early_suspend(struct early_suspend *h)
{
#ifdef CONFIG_GENERIC_BLN
    if(0) {
#else
    if(1) {
#endif
	    touchkey_enable = 0;
    }
	    set_touchkey_debug('S');
	    printk(KERN_DEBUG "melfas_touchkey_early_suspend\n");
	    if (touchkey_enable < 0) {
		    printk("---%s---touchkey_enable: %d\n", __FUNCTION__,
		           touchkey_enable);
		    return;
	    }

	   disable_irq(IRQ_TOUCH_INT);
       touchkey_power_off();
}

static void melfas_touchkey_early_resume(struct early_suspend *h)
{
	set_touchkey_debug('R');
	printk(KERN_DEBUG "melfas_touchkey_early_resume\n");
	if (touchkey_enable < 0) {
		printk("---%s---touchkey_enable: %d\n", __FUNCTION__,
		       touchkey_enable);
		return;
	}
#ifndef CONFIG_S5PC110_DEMPSEY_BOARD
	gpio_direction_output(_3_GPIO_TOUCH_EN, 1);
#endif
#if !(defined(CONFIG_ARIES_NTT) || defined(CONFIG_S5PC110_DEMPSEY_BOARD))
	gpio_direction_output(_3_GPIO_TOUCH_CE, 1);
#endif
	init_hw();
	msleep(50);

	//clear interrupt
	if (readl(gpio_pend_mask_mem) & (0x1 << 1))
		writel(readl(gpio_pend_mask_mem) | (0x1 << 1),
		       gpio_pend_mask_mem);

	enable_irq(IRQ_TOUCH_INT);
	touchkey_enable = 1;

}
示例#5
0
static int melfas_touchkey_early_suspend(struct early_suspend *h)
{
	int i;
	int ret;

	touchkey_enable = 0;
	set_touchkey_debug('S');
	printk(KERN_DEBUG "[TouchKey] melfas_touchkey_early_suspend\n");
	if (touchkey_enable < 0) {
		printk(KERN_DEBUG "[TouchKey] ---%s---touchkey_enable: %d\n",       __func__
, touchkey_enable);
		return 0;
	}

	ret = cancel_work_sync(&touch_update_work);
	if (ret) {
		printk(KERN_DEBUG "[Touchkey] enable_irq ret=%d\n", ret);
		enable_irq(IRQ_TOUCH_INT);
	}
	disable_irq(IRQ_TOUCH_INT);

	/* touchkey force release */
	for (i = 1; i < 5; i++)
		input_report_key(touchkey_driver->input_dev,
			touchkey_keycode[i], 0);
	input_sync(touchkey_driver->input_dev);

	touchkey_ldo_on(0);


	return 0;
}
static void melfas_touchkey_early_resume(struct early_suspend *h)
{
	set_touchkey_debug('R');
	printk(KERN_DEBUG "melfas_touchkey_early_resume\n");
	if (touchkey_enable < 0) {
		printk("---%s---touchkey_enable: %d\n", __FUNCTION__,
		       touchkey_enable);
		return;
	}
#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_USE_BLN
	touchkey_power_on();
#else
	gpio_direction_output(_3_GPIO_TOUCH_EN, 1);
#if !defined(CONFIG_ARIES_NTT)
	gpio_direction_output(_3_GPIO_TOUCH_CE, 1);
#endif
#endif
	msleep(50);

	//clear interrupt
	if (readl(gpio_pend_mask_mem) & (0x1 << 1))
		writel(readl(gpio_pend_mask_mem) | (0x1 << 1),
		       gpio_pend_mask_mem);

	enable_irq(IRQ_TOUCH_INT);
	touchkey_enable = 1;

}
static void melfas_touchkey_early_resume(struct early_suspend *h)
{
	set_touchkey_debug('R');
	printk(KERN_DEBUG "[TKEY] melfas_touchkey_early_resume\n");
	if (touchkey_enable < 0) {
		printk("[TKEY] %s touchkey_enable: %d\n", __FUNCTION__, touchkey_enable);
		return;
	}

		tkey_vdd_enable(1);
		gpio_request(GPIO_TOUCHKEY_SCL, "TKEY_SCL");
		gpio_direction_input(GPIO_TOUCHKEY_SCL);
		gpio_request(GPIO_TOUCHKEY_SDA, "TKEY_SDA");
		gpio_direction_input(GPIO_TOUCHKEY_SDA);
		init_hw();

if(touchled_cmd_reversed) {
			touchled_cmd_reversed = 0;
			msleep(100);

			if(!touchkey_enable )
				touchkey_enable = 1; 
			i2c_touchkey_write(&touchkey_led_status, 1);
			printk("[TKEY] LED RESERVED !! LED returned on touchkey_led_status = %d\n", touchkey_led_status);
	}
if (get_hw_rev() >=0x02){		
	tkey_led_vdd_enable(1); 	
}	

enable_irq(IRQ_TOUCHKEY_INT);
touchkey_enable = 1;
msleep(50);
touchkey_auto_calibration(1/*on*/); 

}
示例#8
0
static void melfas_touchkey_early_resume(struct early_suspend *h)
{
	set_touchkey_debug('R');
	printk(KERN_DEBUG "melfas_touchkey_early_resume\n");
	if (touchkey_enable < 0) {
		printk("---%s---touchkey_enable: %d\n", __FUNCTION__,
		       touchkey_enable);
		return;
	}
	gpio_direction_output(_3_GPIO_TOUCH_EN, 1);
#if !(defined(CONFIG_ARIES_NTT) || defined(CONFIG_S5PC110_CELOX_BOARD))
	gpio_direction_output(_3_GPIO_TOUCH_CE, 1);
#endif
	msleep(50);

	//clear interrupt
#if defined(CONFIG_S5PC110_CELOX_BOARD)		
	if (readl(gpio_pend_mask_mem) & (0x1 << 5))
		writel(readl(gpio_pend_mask_mem) | (0x1 << 5),
		       gpio_pend_mask_mem);
#else
	if (readl(gpio_pend_mask_mem) & (0x1 << 1))
		writel(readl(gpio_pend_mask_mem) | (0x1 << 1),
		       gpio_pend_mask_mem);
#endif

	enable_irq(IRQ_TOUCH_INT);
	touchkey_enable = 1;

}
示例#9
0
static int melfas_touchkey_early_suspend(struct early_suspend *h)
{
	touchkey_enable = 0;
	set_touchkey_debug('S');
	printk(KERN_DEBUG "[TouchKey] melfas_touchkey_early_suspend\n");

	if (touchkey_enable < 0) {
		printk(KERN_DEBUG "[TouchKey] ---%s---touchkey_enable: %d\n", __func__, touchkey_enable);
		return 0;
	}

	disable_irq(IRQ_TOUCH_INT);
	gpio_direction_input(_3_GPIO_TOUCH_INT);

#if 0
	gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
	gpio_direction_output(_3_TOUCH_SDA_28V, 0);
	gpio_direction_output(_3_TOUCH_SCL_28V, 0);
	s3c_gpio_setpull(_3_GPIO_TOUCH_INT, S3C_GPIO_PULL_DOWN);
#endif

	/* disable ldo18 */
	touchkey_led_ldo_on(0);

	/* disable ldo11 */
	touchkey_ldo_on(0);
	screen_on = 0;
	return 0;
}
static void melfas_touchkey_early_resume(struct early_suspend *h)
{
	set_touchkey_debug('R');
    printk(KERN_DEBUG "melfas_touchkey_early_resume : %x\n", touchkey_enable);

	if (touchkey_enable == 1)
		return;

	mutex_lock(&melfas_touchkey_use);

    if(touchkey_enable < 0)
    {
        printk(KERN_DEBUG "---%s---touchkey_enable: %d\n",__FUNCTION__, touchkey_enable);
		mutex_unlock(&melfas_touchkey_use);
        return;
    }
	gpio_direction_output(_3_GPIO_TOUCH_EN, 1);
	gpio_direction_output(_3_GPIO_TOUCH_CE, 1);

    msleep(50);

	//clear interrupt
	if (readl(gpio_pend_mask_mem) & (0x1 << 1))
        writel(readl(gpio_pend_mask_mem)|(0x1<<1), gpio_pend_mask_mem); 

	enable_irq(IRQ_TOUCH_INT);
	touchkey_enable = 1;

	mutex_unlock(&melfas_touchkey_use);

}
static void melfas_touchkey_early_suspend(struct early_suspend *h)
{
    set_touchkey_debug('S');
    printk(KERN_DEBUG "melfas_touchkey_early_suspend : %x\n", touchkey_enable);

	if (touchkey_enable == 0)
		return;

	mutex_lock(&melfas_touchkey_use);

    if(touchkey_enable < 0)
    {		
        printk(KERN_DEBUG "---%s---touchkey_enable: %d\n",__FUNCTION__, touchkey_enable);
		mutex_unlock(&melfas_touchkey_use);
        return;
    }
    disable_irq(IRQ_TOUCH_INT);
    gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
    gpio_direction_output(_3_GPIO_TOUCH_CE, 0);
    gpio_direction_output(_3_TOUCH_SDA_28V, 0);
    gpio_direction_output(_3_TOUCH_SCL_28V, 0);
    touchkey_enable = 0;	

    mutex_unlock(&melfas_touchkey_use);

}
示例#12
0
static irqreturn_t touchkey_interrupt(int irq, void *dummy)
{
	set_touchkey_debug('I');
	disable_irq_nosync(IRQ_TOUCH_INT);
	queue_work(touchkey_wq, &touchkey_work);
	
	return IRQ_HANDLED;
}
示例#13
0
static irqreturn_t touchkey_interrupt(int irq, void *dummy)
{
	set_touchkey_debug('I');
#ifndef CONFIG_S5PC110_DEMPSEY_BOARD
	disable_irq_nosync(IRQ_TOUCH_INT);
#endif
	queue_work(touchkey_wq, &touchkey_work);

	return IRQ_HANDLED;
}
static int melfas_touchkey_late_resume(struct early_suspend *h)
{
#ifdef TEST_JIG_MODE
	unsigned char get_touch = 0x40;
#endif

	set_touchkey_debug('R');
	printk(KERN_DEBUG "[TouchKey] melfas_touchkey_late_resume\n");

	/* enable ldo11 */
	touchkey_ldo_on(1);

	if (touchkey_enable < 0) {
		printk(KERN_DEBUG "[TouchKey] ---%s---touchkey_enable: %d\n",
		       __func__, touchkey_enable);
		return 0;
	}
	gpio_direction_output(_3_GPIO_TOUCH_EN, 1);
	gpio_direction_output(_3_TOUCH_SDA_28V, 1);
	gpio_direction_output(_3_TOUCH_SCL_28V, 1);

	gpio_direction_output(_3_GPIO_TOUCH_INT, 1);
	set_irq_type(IRQ_TOUCH_INT, IRQF_TRIGGER_FALLING);
	s3c_gpio_cfgpin(_3_GPIO_TOUCH_INT, _3_GPIO_TOUCH_INT_AF);
	s3c_gpio_setpull(_3_GPIO_TOUCH_INT, S3C_GPIO_PULL_NONE);
	msleep(50);

	touchkey_led_ldo_on(1);

#ifdef WHY_DO_WE_NEED_THIS
	/* clear interrupt */
	if (readl(gpio_pend_mask_mem) & (0x1 << 1)) {
		writel(readl(gpio_pend_mask_mem) | (0x1 << 1),
		       gpio_pend_mask_mem);
	}
#endif

	enable_irq(IRQ_TOUCH_INT);
	touchkey_enable = 1;

	if (touchled_cmd_reversed) {
		touchled_cmd_reversed = 0;
		i2c_touchkey_write(&touchkey_led_status, 1);
		printk("LED returned on\n");
	}

#ifdef TEST_JIG_MODE
	i2c_touchkey_write(&get_touch, 1);
#endif

	return 0;
}
static ssize_t touchkey_enable_disable(struct device *dev,
				       struct device_attribute *attr,
				       const char *buf, size_t size)
{
#if 0
	printk("touchkey_enable_disable %c \n", *buf);
	if (*buf == '0') {
		set_touchkey_debug('d');
		disable_irq(IRQ_TOUCH_INT);
#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_USE_BLN
		touchkey_power_off();
#else
		gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
#if !defined(CONFIG_ARIES_NTT)
		gpio_direction_output(_3_GPIO_TOUCH_CE, 0);
#endif
#endif
		touchkey_enable = -2;
	} else if (*buf == '1') {
		if (touchkey_enable == -2) {
			set_touchkey_debug('e');
#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_USE_BLN
			touchkey_power_on();
#else
			gpio_direction_output(_3_GPIO_TOUCH_EN, 1);
#if !defined(CONFIG_ARIES_NTT)
			gpio_direction_output(_3_GPIO_TOUCH_CE, 1);
#endif
#endif
			touchkey_enable = 1;
			enable_irq(IRQ_TOUCH_INT);
		}
	} else {
		printk("touchkey_enable_disable: unknown command %c \n", *buf);
	}
#endif
	return size;
}
示例#16
0
static int sec_touchkey_late_resume(struct early_suspend *h)
{
	struct touchkey_i2c *tkey_i2c =
		container_of(h, struct touchkey_i2c, early_suspend);
#ifdef TEST_JIG_MODE
	unsigned char get_touch = 0x40;
#endif

	set_touchkey_debug('R');
	printk(KERN_DEBUG "[TouchKey] sec_touchkey_late_resume\n");


#if defined(CONFIG_S2VE_TOUCHKEY_REV05)
	printk(KERN_ERR"sec_touchkey_late_resume++\n");
	Touchkey_PowerOnOff(1);
	gpio_set_value(TOUCHKEY_SDA, 0); 
	gpio_set_value(TOUCHKEY_SCL, 0); 

	touchkey_led_on(tkey_i2c, 1);
	touchkey_suspended = 0;
#else

	if (touchkey_enable < 0) {
		printk(KERN_DEBUG "[TouchKey] ---%s---touchkey_enable: %d\n",
		       __func__, touchkey_enable);
		return 0;
	}
	msleep(50);

	touchkey_enable = 1;

#if defined(TK_HAS_AUTOCAL)
	touchkey_autocalibration(tkey_i2c);
#endif

	if (touchled_cmd_reversed) {
		touchled_cmd_reversed = 0;
		i2c_touchkey_write(tkey_i2c->client,
			(u8 *) &touchkey_led_status, 1);
		printk(KERN_DEBUG "[Touchkey] LED returned on\n");
	}
#ifdef TEST_JIG_MODE
	i2c_touchkey_write(tkey_i2c->client, &get_touch, 1);
#endif

	enable_irq(tkey_i2c->irq);

#endif
	return 0;
}
static void melfas_touchkey_early_suspend(struct early_suspend *h)
{
	set_touchkey_debug('S');
	if (touchkey_enable < 0) {
		printk("---%s---touchkey_enable: %d\n", __FUNCTION__,
		       touchkey_enable);
		return;
	}
	touchkey_enable = 0;
	disable_irq(IRQ_TOUCH_INT);
	gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
	gpio_direction_output(_3_GPIO_TOUCH_CE, 0);
	gpio_direction_output(_3_TOUCH_SDA_28V, 0);
	gpio_direction_output(_3_TOUCH_SCL_28V, 0);
}
static ssize_t touchkey_enable_disable(struct device *dev,
				       struct device_attribute *attr,
				       const char *buf, size_t size)
{
#if 0
	printk("touchkey_enable_disable %c \n", *buf);
	if (*buf == '0') {
		set_touchkey_debug('d');
		disable_irq(IRQ_TOUCH_INT);
		gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
		touchkey_enable = -2;
	} else if (*buf == '1') {
		if (touchkey_enable == -2) {
			set_touchkey_debug('e');
			gpio_direction_output(_3_GPIO_TOUCH_EN, 1);
			touchkey_enable = 1;
			enable_irq(IRQ_TOUCH_INT);
		}
	} else {
		printk("touchkey_enable_disable: unknown command %c \n", *buf);
	}
#endif
	return size;
}
示例#19
0
static void melfas_touchkey_early_suspend(struct early_suspend *h)
{
	touchkey_enable = 0;
	set_touchkey_debug('S');
	printk(KERN_DEBUG "melfas_touchkey_early_suspend\n");
	if (touchkey_enable < 0) {
		printk("---%s---touchkey_enable: %d\n", __FUNCTION__,
		       touchkey_enable);
		return ;
	}

	disable_irq(IRQ_TOUCH_INT);
	gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
#if !(defined(CONFIG_ARIES_NTT) || defined(CONFIG_S5PC110_CELOX_BOARD))
	gpio_direction_output(_3_GPIO_TOUCH_CE, 0);
#endif
	gpio_direction_output(_3_TOUCH_SDA_28V, 0);
	gpio_direction_output(_3_TOUCH_SCL_28V, 0);
}
static int sec_touchkey_late_resume(struct early_suspend *h)
{
	struct touchkey_i2c *tkey_i2c =
		container_of(h, struct touchkey_i2c, early_suspend);
#ifdef TEST_JIG_MODE
	unsigned char get_touch = 0x40;
#endif

	set_touchkey_debug('R');
	pr_debug("[TouchKey] sec_touchkey_late_resume\n");

	/* enable ldo11 */
	tkey_i2c->pdata->power_on(1);

	if (touchkey_enable < 0) {
		pr_debug("[TouchKey] ---%s---touchkey_enable: %d\n",
		       __func__, touchkey_enable);
		return 0;
	}
	msleep(50);
	tkey_i2c->pdata->led_power_on(1);

	touchkey_enable = 1;

#if defined(TK_HAS_AUTOCAL)
	touchkey_autocalibration(tkey_i2c);
#endif

	if (touchled_cmd_reversed) {
		touchled_cmd_reversed = 0;
		i2c_touchkey_write(tkey_i2c->client,
			(u8 *) &touchkey_led_status, 1);
		pr_debug("[Touchkey] LED returned on\n");
	}
#ifdef TEST_JIG_MODE
	i2c_touchkey_write(tkey_i2c->client, &get_touch, 1);
#endif

	enable_irq(tkey_i2c->irq);

	return 0;
}
示例#21
0
static int melfas_touchkey_late_resume(struct early_suspend *h)
{
	set_touchkey_debug('R');
	printk(KERN_DEBUG "[TouchKey] melfas_touchkey_late_resume\n");


	/* enable ldo20 */
	touchkey_ldo_on(1);

	msleep(100);

#ifdef WHY_DO_WE_NEED_THIS
	/* clear interrupt */
	if (readl(gpio_pend_mask_mem) & (0x1 << 1)) {
		writel(readl(gpio_pend_mask_mem) | (0x1 << 1),
		       gpio_pend_mask_mem);
	}
#endif

	touchkey_enable = 1;
	enable_irq(IRQ_TOUCH_INT);

	if(touchled_cmd_reversed) {
		touchled_cmd_reversed = 0;
		i2c_touchkey_write(&touchkey_led_status, 1);
		printk("LED returned on..\n");
	}

#if 1
		msleep(100);
		touchkey_autocalibration();
#endif

#ifdef TEST_JIG_MODE
	i2c_touchkey_write(&get_touch, 1);
#endif

	return 0;
}
static int sec_touchkey_early_suspend(struct early_suspend *h)
{
	struct touchkey_i2c *tkey_i2c =
		container_of(h, struct touchkey_i2c, early_suspend);
	int ret;
	int i;

	disable_irq(tkey_i2c->irq);
	ret = cancel_work_sync(&tkey_i2c->update_work);
	if (ret) {
		pr_debug("[Touchkey] enable_irq ret=%d\n", ret);
		enable_irq(tkey_i2c->irq);
	}

	/* release keys */
	for (i = 1; i < touchkey_count; ++i) {
		input_report_key(tkey_i2c->input_dev,
				 touchkey_keycode[i], 0);
	}
	input_sync(tkey_i2c->input_dev);

	touchkey_enable = 0;
	set_touchkey_debug('S');
	pr_debug("[TouchKey] sec_touchkey_early_suspend\n");
	if (touchkey_enable < 0) {
		pr_debug("[TouchKey] ---%s---touchkey_enable: %d\n",
		       __func__, touchkey_enable);
		return 0;
	}

	/* disable ldo18 */
	tkey_i2c->pdata->led_power_on(0);

	/* disable ldo11 */
	tkey_i2c->pdata->power_on(0);

	return 0;
}
static void melfas_touchkey_early_suspend(struct early_suspend *h)
{
	touchkey_enable = 0;
	set_touchkey_debug('S');
	printk(KERN_DEBUG "melfas_touchkey_early_suspend\n");
	if (touchkey_enable < 0) {
		printk("---%s---touchkey_enable: %d\n", __FUNCTION__,
		       touchkey_enable);
		return;
	}

	disable_irq(IRQ_TOUCH_INT);
#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_USE_BLN
	touchkey_power_off_with_i2c();
#else
	gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
#if !defined(CONFIG_ARIES_NTT)
	gpio_direction_output(_3_GPIO_TOUCH_CE, 0);
#endif
	gpio_direction_output(_3_TOUCH_SDA_28V, 0);
	gpio_direction_output(_3_TOUCH_SCL_28V, 0);
#endif
}
static void melfas_touchkey_early_suspend(struct early_suspend *h)
{
    int index =0;
    int ret = 0;
    signed char int_data[] ={0x80};

	touchkey_enable = 0;
    set_touchkey_debug('S');
    printk(KERN_DEBUG "melfas_touchkey_early_suspend\n");

    if (touchkey_enable < 0) {
        printk("---%s---touchkey_enable: %d\n", __FUNCTION__, touchkey_enable);
        return;
    }

    disable_irq(IRQ_TOUCHKEY_INT);

		tkey_vdd_enable(0);
		gpio_direction_output(GPIO_TOUCHKEY_SCL, 0);
		gpio_free(GPIO_TOUCHKEY_SCL);
		gpio_direction_output(GPIO_TOUCHKEY_SDA, 0);
		gpio_free(GPIO_TOUCHKEY_SDA);

		for (index = 1; index< sizeof(touchkey_keycode)/sizeof(*touchkey_keycode); index++)
	{
		if(touchkey_pressed & (1<<index))
		{
			input_report_key(touchkey_driver->input_dev, touchkey_keycode[index], 0);
			input_sync(touchkey_driver->input_dev);
			printk ("[TEKY] suspend: release unreleased keycode: [%d]\n", touchkey_keycode[index]);
		}			
	}
	touchkey_pressed = 0;
	touchkey_enable = 0;
	press_check = 0;
	}
示例#25
0
static void melfas_touchkey_early_suspend(struct early_suspend *h)
{
	touchkey_enable = 0;
	set_touchkey_debug('S');
	printk(KERN_DEBUG "melfas_touchkey_early_suspend\n");
	if (touchkey_enable < 0) {
		printk("---%s---touchkey_enable: %d\n", __FUNCTION__,
		       touchkey_enable);
		return;
	}

	disable_irq(IRQ_TOUCH_INT);
#ifndef CONFIG_S5PC110_DEMPSEY_BOARD
	gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
#else
//	Set_MAX8998_PM_OUTPUT_Voltage(LDO13, VCC_2p800);	
	Set_MAX8998_PM_REG(ELDO13, 0);
#endif
#if !(defined(CONFIG_ARIES_NTT) || defined(CONFIG_S5PC110_DEMPSEY_BOARD))
	gpio_direction_output(_3_GPIO_TOUCH_CE, 0);
#endif
	gpio_direction_output(_3_TOUCH_SDA_28V, 0);
	gpio_direction_output(_3_TOUCH_SCL_28V, 0);
}
示例#26
0
static int __init touchkey_init(void)
{
	int ret = 0;
	int retry = 10;
	char data[3] = { 0, };

#if !(defined( CONFIG_S5PC110_T959_BOARD) || defined(CONFIG_S5PC110_KEPLER_BOARD)|| defined(CONFIG_S5PC110_DEMPSEY_BOARD)) 
	#if defined(CONFIG_S5PC110_HAWK_BOARD) || defined(CONFIG_S5PC110_VIBRANTPLUS_BOARD)
	#else
		touchkey_keycode[2] = KEY_ENTER;
	#endif
#endif

#if !(defined(CONFIG_ARIES_NTT) || defined(CONFIG_S5PC110_DEMPSEY_BOARD))
	if (ret = gpio_request(_3_GPIO_TOUCH_CE, "_3_GPIO_TOUCH_CE"))
		printk(KERN_ERR "Failed to request gpio %s:%d\n", __func__, __LINE__);
#endif
#ifndef CONFIG_S5PC110_DEMPSEY_BOARD

	if (ret = gpio_request(_3_GPIO_TOUCH_EN, "_3_GPIO_TOUCH_EN"))
		printk(KERN_ERR "Failed to request gpio %s:%d\n", __func__, __LINE__);
#endif
	if (ret = gpio_request(_3_TOUCH_SDA_28V, "_3_TOUCH_SDA_28V"))
		printk(KERN_ERR "Failed to request gpio %s:%d\n", __func__, __LINE__);
	if (ret = gpio_request(_3_TOUCH_SCL_28V, "_3_TOUCH_SCL_28V"))
		printk(KERN_ERR "Failed to request gpio %s:%d\n", __func__, __LINE__);

	ret = misc_register(&touchkey_update_device);
	if (ret) {
		printk("%s misc_register fail\n", __FUNCTION__);
	}

	if (device_create_file
	    (touchkey_update_device.this_device, &dev_attr_touch_version) < 0) {
		printk("%s device_create_file fail dev_attr_touch_version\n",
		       __FUNCTION__);
		pr_err("Failed to create device file(%s)!\n",
		       dev_attr_touch_version.attr.name);
	}

	if (device_create_file
	    (touchkey_update_device.this_device, &dev_attr_touch_update) < 0) {
		printk("%s device_create_file fail dev_attr_touch_update\n",
		       __FUNCTION__);
		pr_err("Failed to create device file(%s)!\n",
		       dev_attr_touch_update.attr.name);
	}

	if (device_create_file
	    (touchkey_update_device.this_device, &dev_attr_brightness) < 0) {
		printk("%s device_create_file fail dev_attr_touch_update\n",
		       __FUNCTION__);
		pr_err("Failed to create device file(%s)!\n",
		       dev_attr_brightness.attr.name);
	}

	if (device_create_file
	    (touchkey_update_device.this_device,
	     &dev_attr_enable_disable) < 0) {
		printk("%s device_create_file fail dev_attr_touch_update\n",
		       __FUNCTION__);
		pr_err("Failed to create device file(%s)!\n",
		       dev_attr_enable_disable.attr.name);
	}


#if defined (CONFIG_S5PC110_T959_BOARD) || defined(CONFIG_S5PC110_HAWK_BOARD) || defined(CONFIG_S5PC110_VIBRANTPLUS_BOARD)
	
	//NAGSM_Android_SEL_Kernel_Aakash_20100320

	if (device_create_file(touchkey_update_device.this_device, &dev_attr_melfasevtcntrl) < 0)
	{
		printk("%s device_create_file fail dev_attr_melfasevtcntrl\n",__FUNCTION__);
		pr_err("Failed to create device file(%s)!\n", dev_attr_melfasevtcntrl.attr.name);
	}

	//NAGSM_Android_SEL_Kernel_Aakash_20100320
#endif

	touchkey_wq = create_singlethread_workqueue("melfas_touchkey_wq");
	if (!touchkey_wq)
		return -ENOMEM;

	INIT_WORK(&touchkey_work, touchkey_work_func);

	init_hw();

	while (retry--) {
		if (get_touchkey_firmware(data) == 0)	//melfas need delay for multiple read
			break;
	}
	printk("%s F/W version: 0x%x, Module version:0x%x\n", __FUNCTION__,
	       data[1], data[2]);
	touch_version = data[1];
	retry = 3;
#ifdef CONFIG_S5PC110_DEMPSEY_BOARD
		if((HWREV == 0x0C) && ((data[1] < 0x20)|| (data[1] == 0xFF)) ) {
		set_touchkey_debug('U');
		while (retry--) {
			if (ISSP_main() == 0) {
				printk("touchkey_update succeeded\n");
				set_touchkey_debug('C');
				break;
			}
			printk("touchkey_update failed... retry...\n");
			set_touchkey_debug('f');
		}
#ifndef CONFIG_S5PC110_DEMPSEY_BOARD
		if (retry <= 0) {
			gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
#if !(defined(CONFIG_ARIES_NTT) || defined(CONFIG_S5PC110_DEMPSEY_BOARD))
			gpio_direction_output(_3_GPIO_TOUCH_CE, 0);
#endif
			msleep(300);
		}
#endif
		init_hw();	//after update, re initalize.
	}
#endif
	ret = i2c_add_driver(&touchkey_i2c_driver);

	if (ret) {
		printk
		    ("melfas touch keypad registration failed, module not inserted.ret= %d\n",
		     ret);
	}
	return ret;
}
示例#27
0
static int i2c_touchkey_probe(struct i2c_client *client,
			      const struct i2c_device_id *id)
{
//      struct i2c_touchkey_driver * state;
	struct device *dev = &client->dev;
	struct input_dev *input_dev;
	int err = 0;

	printk("melfas i2c_touchkey_probe\n");

	touchkey_driver =
	    kzalloc(sizeof(struct i2c_touchkey_driver), GFP_KERNEL);
	if (touchkey_driver == NULL) {
		dev_err(dev, "failed to create our state\n");
		return -ENOMEM;
	}

	touchkey_driver->client = client;

	touchkey_driver->client->irq = IRQ_TOUCH_INT;
	strlcpy(touchkey_driver->client->name, "melfas-touchkey",
		I2C_NAME_SIZE);

	// i2c_set_clientdata(client, state);

	input_dev = input_allocate_device();

	if (!input_dev)
		return -ENOMEM;

	touchkey_driver->input_dev = input_dev;

	input_dev->name = DEVICE_NAME;
	input_dev->phys = "melfas-touchkey/input0";
	input_dev->id.bustype = BUS_HOST;

	set_bit(EV_SYN, input_dev->evbit);
	set_bit(EV_KEY, input_dev->evbit);
	set_bit(touchkey_keycode[1], input_dev->keybit);
	set_bit(touchkey_keycode[2], input_dev->keybit);
	set_bit(touchkey_keycode[3], input_dev->keybit);
	set_bit(touchkey_keycode[4], input_dev->keybit);

	err = input_register_device(input_dev);
	if (err) {
		input_free_device(input_dev);
		return err;
	}

	gpio_pend_mask_mem = ioremap(INT_PEND_BASE, 0x10);
//       INIT_DELAYED_WORK(&touch_resume_work, touchkey_resume_func);

#ifdef CONFIG_HAS_EARLYSUSPEND
	touchkey_driver->early_suspend.suspend = melfas_touchkey_early_suspend;
	touchkey_driver->early_suspend.resume = melfas_touchkey_early_resume;
	register_early_suspend(&touchkey_driver->early_suspend);
#endif				/* CONFIG_HAS_EARLYSUSPEND */

	touchkey_enable = 1;

	if (request_irq
	    (IRQ_TOUCH_INT, touchkey_interrupt, IRQF_DISABLED, DEVICE_NAME,
	     NULL)) {
		printk(KERN_ERR "%s Can't allocate irq ..\n", __FUNCTION__);
		return -EBUSY;
	}

	set_touchkey_debug('K');
	return 0;
}
示例#28
0
void touchkey_work_func(struct work_struct *p)
{
	u8 data[3];
	int ret;
	int retry = 10;

	set_touchkey_debug('a');
	if (!gpio_get_value(_3_GPIO_TOUCH_INT)) {
		#ifdef CONFIG_CPU_FREQ
		set_dvfs_target_level(LEV_800MHZ);
		#endif
		ret = i2c_touchkey_read(KEYCODE_REG, data, 1);
		set_touchkey_debug(data[0]);
		if ((data[0] & ESD_STATE_BIT) || (ret != 0)) {
			printk
			    ("ESD_STATE_BIT set or I2C fail: data: %d, retry: %d\n",
			     data[0], retry);
			//releae key 
			input_report_key(touchkey_driver->input_dev,
					 touchkey_keycode[1], 0);
			input_report_key(touchkey_driver->input_dev,
					 touchkey_keycode[2], 0);
			retry = 10;
			while (retry--) {
#ifndef CONFIG_S5PC110_DEMPSEY_BOARD
				gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
#endif
				mdelay(300);
				init_hw();
				if (i2c_touchkey_read(KEYCODE_REG, data, 3) >=
				    0) {
					printk("%s touchkey init success\n",
					       __func__);
					set_touchkey_debug('O');
#ifndef CONFIG_S5PC110_DEMPSEY_BOARD
					enable_irq(IRQ_TOUCH_INT);
#endif 
					return;
				}
				printk("%s %d i2c transfer error retry = %d\n",
				       __func__, __LINE__, retry);
			}
			//touchkey die , do not enable touchkey
			//enable_irq(IRQ_TOUCH_INT);
			touchkey_enable = -1;
#ifndef CONFIG_S5PC110_DEMPSEY_BOARD
			gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
#endif
#if !(defined(CONFIG_ARIES_NTT) || defined(CONFIG_S5PC110_DEMPSEY_BOARD))
			gpio_direction_output(_3_GPIO_TOUCH_CE, 0);
#endif
			gpio_direction_output(_3_TOUCH_SDA_28V, 0);
			gpio_direction_output(_3_TOUCH_SCL_28V, 0);
			printk("%s touchkey died\n", __func__);
			set_touchkey_debug('D');
			return;
		}

		if (data[0] & UPDOWN_EVENT_BIT) {
			input_report_key(touchkey_driver->input_dev,
					 touchkey_keycode[data[0] &
							  KEYCODE_BIT], 0);
			input_sync(touchkey_driver->input_dev);
			//printk(" touchkey release keycode: %d\n", touchkey_keycode[data[0] & KEYCODE_BIT]);
			printk(KERN_DEBUG "touchkey release keycode:%d \n",
			       touchkey_keycode[data[0] & KEYCODE_BIT]);

		} else {
			if (touch_state_val == 1) {
				printk(KERN_DEBUG
				       "touchkey pressed but don't send event because touch is pressed. \n");
				set_touchkey_debug('P');
			} else {
				if ((data[0] & KEYCODE_BIT) == 2) {	// if back key is pressed, release multitouch
					//printk("touchkey release tsp input. \n");
					TSP_forced_release();
				}

				input_report_key(touchkey_driver->input_dev,
						 touchkey_keycode[data[0] &
								  KEYCODE_BIT],
						 1);
				input_sync(touchkey_driver->input_dev);
				//printk(" touchkey press keycode: %d\n", touchkey_keycode[data[0] & KEYCODE_BIT]);
				printk(KERN_DEBUG
				       "touchkey press keycode:%d \n",
				       touchkey_keycode[data[0] & KEYCODE_BIT]);
			}
		}
	}
	//clear interrupt
#ifndef CONFIG_S5PC110_DEMPSEY_BOARD
	if (readl(gpio_pend_mask_mem) & (0x1 << 1))
		writel(readl(gpio_pend_mask_mem) | (0x1 << 1),
		       gpio_pend_mask_mem);

	set_touchkey_debug('A');
	enable_irq(IRQ_TOUCH_INT);
#endif 
	set_touchkey_debug('A');
}
示例#29
0
static irqreturn_t touchkey_interrupt(int irq, void *dev_id)
{
	struct touchkey_i2c *tkey_i2c = dev_id;
	u8 data[18];
	int ret;
	int retry = 10;
	int keycode_type = 0;
	int pressed;

	printk("[TouchKey] %s", __func__);

	set_touchkey_debug('a');


	retry = 3;
	while (retry--) {
		ret = i2c_touchkey_read(tkey_i2c->client, KEYCODE_REG, data, 18);
		if (!ret)
			break;
		else {
			printk(KERN_DEBUG
			       "[TouchKey] i2c read failed, ret:%d, retry: %d\n",
			       ret, retry);
			continue;
		}
	}
	if (ret < 0)
		return IRQ_HANDLED;

	menu_sensitivity = data[13];
	back_sensitivity = data[11];

	set_touchkey_debug(data[0]);

	keycode_type = (data[0] & TK_BIT_KEYCODE);
	pressed = !(data[0] & TK_BIT_PRESS_EV);

	if (keycode_type <= 0 || keycode_type >= touchkey_count) {
		printk(KERN_DEBUG "[Touchkey] keycode_type err\n");
		return IRQ_HANDLED;
	}

	if (pressed)
		set_touchkey_debug('P');

	if (get_tsp_status() && pressed)
		printk(KERN_DEBUG "[TouchKey] touchkey pressed"
		       " but don't send event because touch is pressed.\n");
	else {
		input_report_key(touchkey_driver->input_dev,
				 touchkey_keycode[keycode_type], pressed);
		input_sync(touchkey_driver->input_dev);
		/* printk(KERN_DEBUG "[TouchKey] keycode:%d pressed:%d\n",
		   touchkey_keycode[keycode_index], pressed); */
	}

	if (keycode_type == 2)
		printk(KERN_DEBUG "back key sensitivity = %d\n",
		       back_sensitivity);
	if (keycode_type == 4)
		printk(KERN_DEBUG "menu key sensitivity = %d\n",
		       menu_sensitivity);

	set_touchkey_debug('A');
	return IRQ_HANDLED;
}
示例#30
0
static int i2c_touchkey_probe(struct i2c_client *client,
	const struct i2c_device_id *id)
{
//	struct touchkey_platform_data *pdata = client->dev.platform_data;
	struct touchkey_i2c *tkey_i2c;

	struct input_dev *input_dev;
	int err = 0;
	int i;
	int ret;

	printk("[TouchKey] i2c_touchkey_probe\n");

/*	if (pdata == NULL) {
		printk(KERN_ERR "%s: no pdata\n", __func__);
		return -ENODEV;
	}*/

	/*Check I2C functionality */
	ret = i2c_check_functionality(client->adapter, I2C_FUNC_I2C);
	if (ret == 0) {
		printk(KERN_ERR "[Touchkey] No I2C functionality found\n");
		ret = -ENODEV;
		return ret;
	}

	/*Obtain kernel memory space for touchkey i2c */
	tkey_i2c = kzalloc(sizeof(struct touchkey_i2c), GFP_KERNEL);
	if (NULL == tkey_i2c) {
		printk(KERN_ERR "[Touchkey] failed to allocate tkey_i2c.\n");
		return -ENOMEM;
	}

	input_dev = input_allocate_device();

	if (!input_dev) {
		printk(KERN_ERR"[Touchkey] failed to allocate input device\n");
		kfree(tkey_i2c);
		return -ENOMEM;
	}

	input_dev->name = "sec_touchkey";
	input_dev->phys = "sec_touchkey/input0";
	input_dev->id.bustype = BUS_HOST;
	input_dev->dev.parent = &client->dev;

	/*tkey_i2c*/
//	tkey_i2c->pdata = pdata;
	tkey_i2c->input_dev = input_dev;
	tkey_i2c->client = client;

	i2c_set_clientdata(client, tkey_i2c);
	
	tkey_i2c->irq = client->irq;
	tkey_i2c->name = "sec_touchkey";

	set_bit(EV_SYN, input_dev->evbit);
	set_bit(EV_LED, input_dev->evbit);
	set_bit(LED_MISC, input_dev->ledbit);
	set_bit(EV_KEY, input_dev->evbit);

	for (i = 1; i < touchkey_count; i++)
		set_bit(touchkey_keycode[i], input_dev->keybit);

	input_set_drvdata(input_dev, tkey_i2c);

	printk("[TouchKey]: tkey_i2c->irq : %d\n", tkey_i2c->irq);


	ret = input_register_device(input_dev);
	if (ret) {
		printk(KERN_ERR"[Touchkey] failed to register input device\n");
		input_free_device(input_dev);
		kfree(tkey_i2c);
		return err;
	}

	INIT_WORK(&tkey_i2c->update_work, touchkey_update_func);

#if defined(CONFIG_S2VE_TOUCHKEY_REV05)
	Touchkey_PowerOnOff(1);
#endif

	touchkey_enable = 1;

	touchkey_led_on(tkey_i2c, 1);	
	msleep(50);

	/*sysfs*/
	tkey_i2c->dev = device_create(sec_class, NULL, 0, NULL, "sec_touchkey");

	if (IS_ERR(tkey_i2c->dev)) {
		printk("Failed to create device(tkey_i2c->dev)!\n");
		input_unregister_device(input_dev);
	} else {
		dev_set_drvdata(tkey_i2c->dev, tkey_i2c);
		ret = sysfs_create_group(&tkey_i2c->dev->kobj,
					&touchkey_attr_group);
		if (ret) {
			printk(	"[TouchKey]: failed to create sysfs group\n");
		}
	}

	ret = request_threaded_irq(tkey_i2c->irq, NULL /*touchkey_irq_handler*/, touchkey_interrupt,
				IRQF_DISABLED | IRQF_TRIGGER_FALLING /* | IRQF_ONESHOT */, tkey_i2c->name, tkey_i2c);
	if (ret < 0) {
		printk("[Touchkey]: failed to request irq(%d) - %d\n", tkey_i2c->irq, ret);
		input_unregister_device(input_dev);
		return -EBUSY;
	}

#ifdef CONFIG_HAS_EARLYSUSPEND
	tkey_i2c->early_suspend.suspend =
		(void *)sec_touchkey_early_suspend;
	tkey_i2c->early_suspend.resume =
		(void *)sec_touchkey_late_resume;
	register_early_suspend(&tkey_i2c->early_suspend);
#endif


#if 0 //defined(TK_HAS_FIRMWARE_UPDATE)
	ret = touchkey_firmware_update(tkey_i2c);
	if (ret < 0) {
		printk(KERN_ERR	"[Touchkey]: failed firmware updating process (%d)\n", ret);
		input_unregister_device(input_dev);
		return -EBUSY;
	}
#endif

#if defined(TK_HAS_AUTOCAL)
	touchkey_autocalibration(tkey_i2c);
#endif
	printk("[Touchkey]: %s Probe done! \n", __func__);
	set_touchkey_debug('K');
	return 0;
}