Exemplo n.º 1
0
static ssize_t touch_version_read(struct device *dev,
				  struct device_attribute *attr, char *buf)
{
	char data[16],*write_val=0x40,ret;
	int count,key_sensitivity;
	char i;
	ret = i2c_touchkey_write(devdata, &write_val, 1);
	if (ret){
		for(i=0;i<10;i++){
			msleep(10);
			ret = i2c_touchkey_write(devdata, &write_val, 1);
			if(ret==0)
				break;
		}
		printk("%s: touchkey i2c failed\n", __func__);		
		count = sprintf(buf, "%s\n", "PBA");		
		return count;
	}		

	i2c_touchkey_read(devdata, KEYCODE_REG, data, 16);

	count = sprintf(buf, "0x%x\n", data[1]);

	printk("[touch key] firmware=0x%x,module=0x%x\n", data[1], data[2]);

	return count;
}
Exemplo n.º 2
0
static ssize_t touch_led_control(struct device *dev,
				 struct device_attribute *attr, const char *buf,
				 size_t size)
{
	int ret;

	if (strncmp(buf, "1", 1) == 0)
	{
		if (devdata_led->is_powering_on){
			dev_err(dev, "%s: delay led on \n", __func__);
			devdata_led->is_delay_led_on = true;
			return size;
		}
		ret = i2c_touchkey_write(devdata_led, &devdata_led->backlight_on, 1);
		printk("Touch Key led ON\n");
	}
	else
	{
		if (devdata_led->is_powering_on){
			dev_err(dev, "%s: delay led off skip \n", __func__);
			devdata_led->is_delay_led_on = false;
			return size;
		}
		ret = i2c_touchkey_write(devdata_led, &devdata_led->backlight_off, 1);
		printk("Touch Key led OFF\n");			
	}

	if (ret)
		dev_err(dev, "%s: touchkey led i2c failed\n", __func__);

	return size;
}
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;
}
Exemplo n.º 4
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 ssize_t touch_led_control(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
{
	u8 data;
	u8 led_bright[2]= {LED_BRIGHT_BIT,LED_BRIGHT};
	//data = 1 on, 0 off
	sscanf(buf, "%hhu", &data);
	led_onoff = (data == 0) ? 0 : 1;
	data = (data == 0) ? 2 : 1;

	if (!touchkey_enable)
		return -1;
	i2c_touchkey_write(led_bright, 2);
	i2c_touchkey_write(&data, 1);	// LED on(data=1) or off(data=2)
	return size;
}
Exemplo n.º 6
0
static ssize_t set_touchkey_autocal_testmode(struct device *dev,
				 struct device_attribute *attr, const char *buf,
				 size_t size)
{
	int count = 0;
	u8 set_data;
	int on_off;

	if (sscanf(buf, "%d\n", &on_off) == 1) {
		printk(KERN_ERR "[TouchKey] Test Mode : %d \n", on_off);

		if (on_off == 1) {
			set_data = 0x40;
			count = i2c_touchkey_write(&set_data, 1);
		} else {
			touchkey_ldo_on(0);
			msleep(50);
			touchkey_ldo_on(1);
			msleep(50);
			init_hw();
			msleep(50);
			touchkey_autocalibration();
		}
	} else {
		printk(KERN_ERR "[TouchKey] set_touchkey_autocal_testmode Error\n");
	}

	return count;
}
Exemplo n.º 7
0
static ssize_t touch_sensitivity_control(struct device *dev, struct
device_attribute *attr, const char *buf, size_t size)
{
	unsigned char data = 0x40;
	i2c_touchkey_write(&data, 1);
	return size;
}
void touchkey_resume_func(struct work_struct *p)
{
//	int err = 0;
//	int rc = 0;

	enable_irq(IRQ_TOUCHKEY_INT);
	touchkey_enable = 1;
	msleep(50);
	
#if defined (CONFIG_USA_MODEL_SGH_T989)||defined (CONFIG_USA_MODEL_SGH_I727) || defined (CONFIG_USA_MODEL_SGH_I717)\
	|| defined (CONFIG_USA_MODEL_SGH_T769) || defined(CONFIG_USA_MODEL_SGH_I577) || defined(CONFIG_CAN_MODEL_SGH_I577R)\
	|| defined(CONFIG_USA_MODEL_SGH_I757) || defined(CONFIG_CAN_MODEL_SGH_I757M)
    touchkey_auto_calibration(1/*on*/);
#elif defined (CONFIG_KOR_MODEL_SHV_E110S)
	if (get_hw_rev() >= 0x02)
		touchkey_auto_calibration(1/*on*/);
#elif defined (CONFIG_JPN_MODEL_SC_03D)
	if (get_hw_rev() >= 0x02)
		touchkey_auto_calibration(1/*on*/);
#endif

#if 0
	{
		// temporary code for touchkey led
		int int_data = 0x10;
		msleep(100);
		printk("[TKEY] i2c_touchkey_write : key backligh on\n");
		i2c_touchkey_write((u8*)&int_data, 1);
	}
#endif
}
Exemplo n.º 9
0
static ssize_t touch_led_control(struct device *dev,
				 struct device_attribute *attr, const char *buf,
				 size_t size)
{
	unsigned char data;
	if (sscanf(buf, "%d\n", &data) == 1) {
		printk(KERN_DEBUG "touch_led_control: %d \n", data);
#ifdef CONFIG_KEYPAD_CYPRESS_TOUCH_USE_BLN
               if ((touchkey_enable == 1)) {
                   if (data == 1)
                       set_backlight(BACKLIGHT_ON);
                   if (data == 2) {
                       /* only disable leds if no notification is enabled*/
                       if (BacklightNotification_ongoing)
                               set_backlight(BACKLIGHT_ON);
                       else
                               set_backlight(BACKLIGHT_OFF);
                   }
               } else
                   printk(KERN_DEBUG "touchkey is not enabled.W\n");
#else
		i2c_touchkey_write(&data, 1);
		touchkey_led_status = data;
#endif
	} else
		printk("touch_led_control Error\n");

	return size;
}
Exemplo n.º 10
0
static ssize_t touchkey_back_show(struct device *dev,
				  struct device_attribute *attr, char *buf)
{
	struct touchkey_i2c *tkey_i2c = dev_get_drvdata(dev);
#if defined(CONFIG_MACH_Q1_BD) \
|| (defined(CONFIG_MACH_C1) && defined(CONFIG_TARGET_LOCALE_KOR))
	u8 data[14] = { 0, };
	int ret;
	unsigned char data_sensitivity = 0x40;
	i2c_touchkey_write(tkey_i2c->client, &data_sensitivity, 1);
	mdelay(10);

	ret = i2c_touchkey_read(tkey_i2c->client, KEYCODE_REG, data, 14);

	printk(KERN_DEBUG "called %s data[11] =%d\n", __func__, data[11]);
	back_sensitivity = data[11];
#else
	u8 data[10];
	int ret;

	printk(KERN_DEBUG "called %s\n", __func__);
	ret = i2c_touchkey_read(tkey_i2c->client, KEYCODE_REG, data, 10);
	back_sensitivity = data[9];
#endif
	return sprintf(buf, "%d\n", back_sensitivity);
}
Exemplo n.º 11
0
static void notification_off(struct work_struct *notification_off_work)
{
	int status;

	/* do nothing if there is no active notification */
	if (led_on != 1 || touchkey_enable != 1)
		return;

	/* we have timed out, turn the lights off */
	/* disable the regulators */
	touchkey_led_ldo_on(0);	/* "touch_led" regulator */
	touchkey_ldo_on(0);	/* "touch" regulator */

	/* turn off the backlight */
#ifdef CONFIG_TARGET_CM_KERNEL
	status = 2; /* light off */
#else
	status = 0; /* light off */
#endif
	i2c_touchkey_write((u8 *)&status, 1);
	touchkey_enable = 0;
#ifdef CONFIG_TARGET_CM_KERNEL
	led_on = 0;
#else
	led_on = -1;
#endif

	/* we were using a wakelock, unlock it */
	if (wake_lock_active(&led_wake_lock)) {
		wake_unlock(&led_wake_lock);
	}

	return;
}
Exemplo n.º 12
0
static void cypress_touchkey_early_resume(struct early_suspend *h)
{
	struct cypress_touchkey_devdata *devdata =
		container_of(h, struct cypress_touchkey_devdata, early_suspend);

	printk("%s\n",__FUNCTION__);
	u8 data[6];

	devdata->pdata->touchkey_onoff(TOUCHKEY_ON);
#if 0
	if (i2c_touchkey_write_byte(devdata, devdata->backlight_on)) {
		devdata->is_dead = true;
		devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
		dev_err(&devdata->client->dev, "%s: touch keypad not responding"
				" to commands, disabling\n", __func__);
		return;
	}
#endif
	devdata->is_dead = false;
	enable_irq(devdata->client->irq);
	devdata->is_powering_on = false;
	msleep(50);
	touchkey_auto_calibration(1/*on*/);
	msleep(200); 
	if(touch_key_led_on_off== 1)
		i2c_touchkey_write(devdata, &devdata->backlight_on, 1); 
}
Exemplo n.º 13
0
static ssize_t set_touchkey_autocal_testmode(struct device *dev,
					     struct device_attribute *attr,
					     const char *buf, size_t size)
{
	struct touchkey_i2c *tkey_i2c = dev_get_drvdata(dev);
	int count = 0;
	u8 set_data;
	int on_off;

	if (sscanf(buf, "%d\n", &on_off) == 1) {
		printk(KERN_ERR "[TouchKey] Test Mode : %d\n", on_off);

		if (on_off == 1) {
			set_data = 0x40;
			count = i2c_touchkey_write(tkey_i2c->client,
					&set_data, 1);
		} else {

//			tkey_i2c->pdata->power_on(0);
			touchkey_led_on(tkey_i2c, 0);
			msleep(50);
//			tkey_i2c->pdata->power_on(1);
			touchkey_led_on(tkey_i2c, 1);
			msleep(50);

#if defined(TK_HAS_AUTOCAL)
			touchkey_autocalibration(tkey_i2c);
#endif
		}
	} else {
		printk(KERN_ERR "[TouchKey] touch_led_brightness Error\n");
	}

	return count;
}
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*/); 

}
void touchscreen_state_report(int state)
{
    static const int ledCmd[] = {TK_CMD_LED_ON, TK_CMD_LED_OFF};

    if (touch_led_disabled == 0) {
        if (state == 1) {
            if(touchkey_led_status == TK_CMD_LED_OFF) {
                pr_debug("[Touchkey] %s: enable touchleds\n", __func__);
                i2c_touchkey_write(tkey_i2c_local->client, (u8 *) &ledCmd[0], 1);
                touchkey_led_status = TK_CMD_LED_ON;
            } else {
                if (timer_pending(&touch_led_timer) == 1) {
                    pr_debug("[Touchkey] %s: mod_timer\n", __func__);
                    mod_timer(&touch_led_timer, jiffies + (HZ * touch_led_timeout));
                }
            }
        } else if (state == 0) {
            if (timer_pending(&touch_led_timer) == 1) {
                pr_debug("[Touchkey] %s: mod_timer\n", __func__);
                mod_timer(&touch_led_timer, jiffies + (HZ * touch_led_timeout));
            } else if (touchkey_led_status == TK_CMD_LED_ON){
                pr_debug("[Touchkey] %s: add_timer\n", __func__);
                touch_led_timer.expires = jiffies + (HZ * touch_led_timeout);
                add_timer(&touch_led_timer);
            }
        }
    }
}
Exemplo n.º 16
0
static int __init touchkey_init(void)
{
	int ret = 0;
	int rc;

#ifdef TEST_JIG_MODE
	unsigned char get_touch = 0x40;
#endif

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

	rc = gpio_request(TOUCHKEY_INT, "touchkey_int");
	if (rc < 0) {
		printk(KERN_ERR "unable to request GPIO pin %d\n", TOUCHKEY_INT);
	}
	
	gpio_direction_input(TOUCHKEY_INT);

	gpio_direction_output( TOUCHKEY_SCL , 1 );

	gpio_direction_output( TOUCHKEY_SDA , 1 );

	ret = i2c_add_driver(&touchkey_i2c_driver);

	if (ret) 
	{
		printk(KERN_ERR "[TouchKey] registration failed, module not inserted.ret= %d\n", ret);
	}
#ifdef TEST_JIG_MODE
	i2c_touchkey_write(tkey_i2c->client, &get_touch, 1);
#endif
	return ret;
}
Exemplo n.º 17
0
static int __init touchkey_init(void)
{
	int ret = 0;

#if defined(CONFIG_MACH_M0)
	if (system_rev < TOUCHKEY_FW_UPDATEABLE_HW_REV) {
		printk(KERN_DEBUG "[Touchkey] Doesn't support this board rev %d\n",
				system_rev);
		return 0;
	}
#elif defined(CONFIG_MACH_C1)
	if (system_rev < TOUCHKEY_FW_UPDATEABLE_HW_REV) {
		printk(KERN_DEBUG "[Touchkey] Doesn't support this board rev %d\n",
				system_rev);
		return 0;
	}
#endif

#ifdef TEST_JIG_MODE
	unsigned char get_touch = 0x40;
#endif

	ret = i2c_add_driver(&touchkey_i2c_driver);

	if (ret) {
		printk(KERN_ERR
	       "[TouchKey] registration failed, module not inserted.ret= %d\n",
	       ret);
	}
#ifdef TEST_JIG_MODE
	i2c_touchkey_write(tkey_i2c->client, &get_touch, 1);
#endif
	return ret;
}
Exemplo n.º 18
0
static void cypress_touchkey_early_resume(struct early_suspend *h)
{
	struct cypress_touchkey_devdata *devdata =
		container_of(h, struct cypress_touchkey_devdata, early_suspend);
	
	msleep(1);

	if(devdata->pdata->touchkey_onoff)
		devdata->pdata->touchkey_onoff(TOUCHKEY_ON);

	#if 0
	if (i2c_touchkey_write_byte(devdata, devdata->backlight_on)) {
		devdata->is_dead = true;
	if(devdata->pdata->touchkey_onoff)
		devdata->pdata->touchkey_onoff(TOUCHKEY_OFF);
		dev_err(&devdata->client->dev, "%s: touch keypad not responding"
				" to commands, disabling\n", __func__);
		return;
	}
	#endif
	devdata->is_dead = false;
	enable_irq(devdata->client->irq);
	devdata->is_powering_on = false;

	if (devdata->is_delay_led_on){
		int ret;
		msleep(30); // touch power on time
		ret = i2c_touchkey_write(devdata, &devdata->backlight_on, 1);
		dev_err(&devdata->client->dev,"%s: Touch Key led ON ret = %d\n",__func__, ret);
	}
	devdata->is_delay_led_on = false;
}
Exemplo n.º 19
0
static ssize_t touch_sensitivity_control(struct device *dev,
				  struct device_attribute *attr, char *buf)
{
	int ret;
	unsigned char data = 0x40;
	ret = i2c_touchkey_write(devdata, &data, 1);	
	return ret;
}
static ssize_t touch_sensitivity_control(struct device *dev,
					 struct device_attribute *attr,
					 const char *buf, size_t size)
{
	struct touchkey_i2c *tkey_i2c = dev_get_drvdata(dev);
	unsigned char data = 0x40;
	i2c_touchkey_write(tkey_i2c->client, &data, 1);
	return size;
}
static ssize_t touch_led_control(struct device *dev,
				 struct device_attribute *attr, const char *buf,
				 size_t size)
{
	struct cypress_touchkey_devdata *devdata = dev_get_drvdata(dev);
	int ret;

	if (devdata && !devdata->is_powering_on) {
		if (strncmp(buf, "1", 1) == 0)
			ret = i2c_touchkey_write(devdata, &devdata->backlight_on, 1);
		else
			ret = i2c_touchkey_write(devdata, &devdata->backlight_off, 1);

		if (ret)
			dev_err(dev, "%s: touchkey led i2c failed\n", __func__);
		}
	return size;
}
Exemplo n.º 22
0
static ssize_t touch_led_control(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
{
	u8 data;
	if(user_press_on)
		return size;

	sscanf(buf, "%hhu", &data);
	i2c_touchkey_write(&data, 1);	// LED on(data=1) or off(data=2)
	return size;
}
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;
}
Exemplo n.º 24
0
static ssize_t touch_sensitivity_control(struct device *dev,
					 struct device_attribute *attr,
					 const char *buf, size_t size)
{
	struct touchkey_i2c *tkey_i2c = dev_get_drvdata(dev);
	unsigned char data = 0x40;
	i2c_touchkey_write(tkey_i2c->client, &data, 1);
#if defined(CONFIG_MACH_SUPERIOR_KOR_SKT)
	msleep(20);
#endif
	return size;
}
Exemplo n.º 25
0
static ssize_t touch_led_control(struct device *dev, struct device_attribute *attr, const char *buf, size_t size)
{
	unsigned char data;
	if(sscanf(buf, "%d\n", &data) == 1) {
              printk("touch_led_control: %d \n", data);
		i2c_touchkey_write(&data, 1);
	}
	else
		printk("touch_led_control Error\n");

        return size;
}
void touch_led_timedout_work(struct work_struct *work)
{
    struct touchkey_i2c *tkey_i2c = container_of(work, struct touchkey_i2c, work);
    static const int ledCmd[] = {TK_CMD_LED_ON, TK_CMD_LED_OFF};

    if (touch_led_timeout != 0)
    {
        pr_debug("[Touchkey] %s: disabling touchled\n", __func__);
        i2c_touchkey_write(tkey_i2c->client, (u8 *) &ledCmd[1], 1);
        touchkey_led_status = TK_CMD_LED_OFF;
    }
}
Exemplo n.º 27
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 void melfas_touchkey_switch_early_resume(int FILP_STATE,int firmup_onoff){
	unsigned char data1 = 0x01;
	u8 led_bright[2]= {LED_BRIGHT_BIT,LED_BRIGHT};
	printk(KERN_DEBUG "[TKEY] switch_early_resume +++\n");
	mutex_lock(&melfas_tsk_lock);
	
	if (((Flip_status == FLIP_OPEN) && (!firmup_onoff)) || touchkey_driver == NULL) {
		printk(KERN_DEBUG "[TKEY] FLIP_OPEN ---\n");
		goto end;
		}
	touchkey_pmic_control(1);	
	gpio_set_value(_3_TOUCH_SDA_28V, 1);
	gpio_set_value(_3_TOUCH_SCL_28V, 1);
	msleep(100);

#ifdef USE_IRQ_FREE
	msleep(50);

	printk("%s, %d\n",__func__, __LINE__);
	err = request_threaded_irq(touchkey_driver->client->irq, NULL, touchkey_interrupt,
			IRQF_DISABLED | IRQF_TRIGGER_LOW | IRQF_ONESHOT, "touchkey_int", NULL);
	if (err) {
		printk(KERN_ERR "%s Can't allocate irq .. %d\n", __FUNCTION__, err);
	}
#endif
	if(!firmup_onoff)
	enable_irq(touchkey_driver->client->irq);
	touchkey_enable = 1;
	ssuepend =0;
	if (led_onoff){
		i2c_touchkey_write(led_bright, 2);
		i2c_touchkey_write(&data1, 1);
	}

end:
	mutex_unlock(&melfas_tsk_lock);
	printk(KERN_DEBUG "[TKEY] switch_early_resume---\n");
}
Exemplo n.º 29
0
static ssize_t touch_led_control(struct device *dev,
				 struct device_attribute *attr, const char *buf,
				 size_t size)
{
  u8 data = 0x10;
  if (sscanf(buf, "%d\n", &data) == 1) {
    if (!tempdata->is_powering_on) {
      //printk(KERN_DEBUG "touch_led_control: %d \n", data);
      i2c_touchkey_write(tempdata, &data, sizeof(u8));
    }
  } else
    printk("touch_led_control Error\n");
	return size;
}
static void melfas_touchkey_early_suspend(struct early_suspend *h)
{
	unsigned char data = 0x02;
    printk(KERN_ERR"[TKEY] early_suspend +++\n");
	mutex_lock(&melfas_tsk_lock);
	if(user_press_on == 1)	{
		input_report_key(touchkey_driver->input_dev, TOUCHKEY_KEYCODE_MENU, 0);
		input_sync(touchkey_driver->input_dev);
		printk("[TKEY] force release MENU\n");
	}
	else if(user_press_on == 2)	{
		input_report_key(touchkey_driver->input_dev, TOUCHKEY_KEYCODE_HOME, 0);
		input_sync(touchkey_driver->input_dev);
		printk("[TKEY] force release HOME\n");
	}
	else if(user_press_on == 3)	{
		input_report_key(touchkey_driver->input_dev, TOUCHKEY_KEYCODE_BACK, 0);
		input_sync(touchkey_driver->input_dev);
		printk("[TKEY] force release BACK\n");
	}
	user_press_on = 0;

	if ((touchkey_enable == 0 && is_suspending == 1) || ssuepend == 1) {
	printk(KERN_ERR"[TKEY] already suspend %d,%d,%d---\n",touchkey_enable,is_suspending,ssuepend);
	is_suspending = 1;
	goto end;
	}

	touchkey_enable = 0;
	is_suspending = 1;
	ssuepend = 0;
	led_onoff =0;
	

	if(touchkey_dead)
	{
		printk(KERN_ERR "touchkey died after ESD");
		goto end;
	}
	i2c_touchkey_write(&data, 1);	/*Key LED force off*/
	disable_irq(touchkey_driver->client->irq);
	gpio_set_value(_3_TOUCH_SDA_28V, 0);
	gpio_set_value(_3_TOUCH_SCL_28V, 0);
	touchkey_pmic_control(0);
	msleep(30);

end:
	mutex_unlock(&melfas_tsk_lock);
    printk(KERN_ERR"[TKEY] early_suspend ---\n");
}