Exemplo n.º 1
0
void touchkey_work_func(struct work_struct *p)
{
	u8 data[10];
	int ret;
	int retry = 10;

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

	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, 10);
		menu_sensitivity = data[7];
		back_sensitivity = data[9];
		/******************************************************************
		typedef struct I2CReg
		{
			unsigned char	 BtnStatus;							 		// 0 :
			unsigned char	 Version;								  	// 1 :FW Version
			unsigned char	 PcbStatus;							 		// 2 :Module Version
			unsigned char	 Cmd;									  	// 3 :
			unsigned char	 Chip_id;								  	// 4 :0x55(DEFAULT_CHIP_ID) 0
			unsigned char	 Sens;									   	// 5 :sensitivity grade(0x00(slow),0x01(mid),0x02(fast))
			WORD			 DiffData[CSD_TotalSensorCount];   			//  6, 7 - 8, 9
			WORD			 RawData[CSD_TotalSensorCount];  			// 10,11 - 12,13
			WORD			 Baseline[CSD_TotalSensorCount];   			// 14,15 - 16,17
		}I2CReg;
		******************************************************************/
		set_touchkey_debug(data[0]);
		if ((data[0] & ESD_STATE_BIT) || (ret != 0))
        {
			printk(KERN_DEBUG "[TouchKey] 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);
			input_report_key(touchkey_driver->input_dev, touchkey_keycode[3], 0);
			input_report_key(touchkey_driver->input_dev, touchkey_keycode[4], 0);

			retry = 10;
			while (retry--)
            {
				//gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
				mdelay(300);
				init_hw();

				if (i2c_touchkey_read(KEYCODE_REG, data, 3) >= 0)
                {
					printk(KERN_DEBUG "[TouchKey] %s touchkey init success\n",  __func__);
					set_touchkey_debug('O');
					enable_irq(IRQ_TOUCH_INT);
					return;
				}
				printk(KERN_ERR	"[TouchKey] %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;
			//gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
			gpio_direction_output(_3_TOUCH_SDA_28V, 0);
			gpio_direction_output(_3_TOUCH_SCL_28V, 0);
			printk(KERN_DEBUG "[TouchKey] %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);

		if ((checkTSPKEYdebuglevel == KERNEL_SEC_DEBUG_LEVEL_MID) ||
			(checkTSPKEYdebuglevel == KERNEL_SEC_DEBUG_LEVEL_HIGH)) {
			printk(KERN_DEBUG "[TouchKey] release keycode:%d \n",touchkey_keycode[data[0] & KEYCODE_BIT]);
		}
			if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[1])
				printk("menu key sensitivity = %d\n", menu_sensitivity);
			if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[2])
				printk("home key sensitivity = %d\n",back_sensitivity);
            #if 0
			if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[3])
				printk("back key sensitivity = %d\n",back_sensitivity);
			if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[4])
				printk("back key sensitivity = %d\n",back_sensitivity);
            #endif
		} else {
			if (touch_is_pressed) {
				printk(KERN_DEBUG "[TouchKey] 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(KERN_DEBUG "[TouchKey] touchkey release tsp input. \n");
					touch_forced_release();
				}

				input_report_key(touchkey_driver->input_dev,touchkey_keycode[data[0]&KEYCODE_BIT],	 1);
				input_sync(touchkey_driver->input_dev);

				if ((checkTSPKEYdebuglevel == KERNEL_SEC_DEBUG_LEVEL_MID) ||
					(checkTSPKEYdebuglevel == KERNEL_SEC_DEBUG_LEVEL_HIGH)) {
					printk(KERN_DEBUG "[TouchKey] press keycode:%d \n",touchkey_keycode[data[0] & KEYCODE_BIT]);
				}
				if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[1])
					printk("menu key sensitivity = %d\n",menu_sensitivity);
				if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[2])
					printk("back key sensitivity = %d\n",back_sensitivity);
	            #if 0
				if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[3])
					printk("back key sensitivity = %d\n",back_sensitivity);
				if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[4])
					printk("back key sensitivity = %d\n",back_sensitivity);
	            #endif
			}
		}
		if ((checkTSPKEYdebuglevel == KERNEL_SEC_DEBUG_LEVEL_MID) ||
			(checkTSPKEYdebuglevel == KERNEL_SEC_DEBUG_LEVEL_HIGH)) {
			printk(KERN_ERR"## TOUCH KEY - CODE : %d\n ", touchkey_keycode[data[0] & KEYCODE_BIT]);
		}
	}

#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
	set_touchkey_debug('A');
	enable_irq(IRQ_TOUCH_INT);
}
void touchkey_work_func(struct work_struct *p)
{
	u8 data[10];
	int ret;
	int retry = 10;

#if 0
	if (gpio_get_value(_3_GPIO_TOUCH_INT)) {
		printk(KERN_DEBUG "[TouchKey] Unknown state.\n", __func__);
		enable_irq(IRQ_TOUCH_INT);
		return;
	}
#endif

	set_touchkey_debug('a');

#ifdef CONFIG_CPU_FREQ
	/* set_dvfs_target_level(LEV_800MHZ); */
#endif
#ifdef TEST_JIG_MODE
	ret = i2c_touchkey_read(KEYCODE_REG, data, 10);
#else
	ret = i2c_touchkey_read(KEYCODE_REG, data, 3);
#endif


#ifdef TEST_JIG_MODE
#ifdef CONFIG_TARGET_LOCALE_NA
	menu_sensitivity = data[6];
	home_sensitivity = data[7];
    search_sensitivity = data[8];
    back_sensitivity = data[9];
#else
	menu_sensitivity = data[7];
	back_sensitivity = data[9];
#endif /* CONFIG_TARGET_LOCALE_NA  */
#endif

	/******************************************************************
	typedef struct I2CReg
	{
		unsigned char	 BtnStatus;							 // 0 :
		unsigned char	 Version;								  // 1 :FW Version
		unsigned char	 PcbStatus;							 // 2 :Module Version
		unsigned char	 Cmd;									  // 3 :
		unsigned char	 Chip_id;								  // 4 :0x55(DEFAULT_CHIP_ID) 0
		unsigned char	 Sens;									   // 5 :sensitivity grade(0x00(slow),0x01(mid),0x02(fast))
		WORD			 DiffData[CSD_TotalSensorCount];   //  6, 7 - 8, 9
		WORD			 RawData[CSD_TotalSensorCount];  // 10,11 - 12,13
		WORD			 Baseline[CSD_TotalSensorCount];   // 14,15 - 16,17
	}I2CReg;
	******************************************************************/
	set_touchkey_debug(data[0]);
	if ((data[0] & ESD_STATE_BIT) || (ret != 0)) {
		printk(KERN_DEBUG
		       "[TouchKey] 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);
#ifdef CONFIG_TARGET_LOCALE_NA
		input_report_key(touchkey_driver->input_dev,
			touchkey_keycode[3], 0);
                input_report_key(touchkey_driver->input_dev,
			touchkey_keycode[4], 0);
#endif

		#if defined(CONFIG_TARGET_LOCALE_NAATT)
		input_report_key(touchkey_driver->input_dev,
				touchkey_keycode[3], 0);
		input_report_key(touchkey_driver->input_dev,
				touchkey_keycode[4], 0);
		#endif

		retry = 10;
		while (retry--) {
			gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
			mdelay(300);
			init_hw();

			if (i2c_touchkey_read(KEYCODE_REG, data, 3) >= 0) {
				printk(KERN_DEBUG
				       "[TouchKey] %s touchkey init success\n",
				       __func__);
				set_touchkey_debug('O');
				enable_irq(IRQ_TOUCH_INT);
				return;
			}
			printk(KERN_ERR
			       "[TouchKey] %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;
		gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
		gpio_direction_output(_3_TOUCH_SDA_28V, 0);
		gpio_direction_output(_3_TOUCH_SCL_28V, 0);
		printk(KERN_DEBUG "[TouchKey] %s touchkey died\n",
		       __func__);
		set_touchkey_debug('D');
		return;
	}

#if defined(CONFIG_TARGET_LOCALE_NAATT)
	if (touchkey_keycode[data[0] & KEYCODE_BIT] != KEY_MENU && touchkey_keycode[data[0] & KEYCODE_BIT] != KEY_BACK
		&&  touchkey_keycode[data[0] & KEYCODE_BIT] != KEY_ENTER && touchkey_keycode[data[0] & KEYCODE_BIT] != KEY_END) {
#elif defined(CONFIG_TARGET_LOCALE_NA)
	if (touchkey_keycode[data[0] & KEYCODE_BIT] != KEY_MENU && touchkey_keycode[data[0] & KEYCODE_BIT] != KEY_BACK &&
		touchkey_keycode[data[0] & KEYCODE_BIT] != KEY_HOME && touchkey_keycode[data[0] & KEYCODE_BIT] != KEY_SEARCH) {
#else
	if (touchkey_keycode[data[0] & KEYCODE_BIT] != KEY_MENU && touchkey_keycode[data[0] & KEYCODE_BIT] != KEY_BACK) {
#endif
		enable_irq(IRQ_TOUCH_INT);
		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(KERN_DEBUG "[TouchKey] release keycode:%d \n",
		       touchkey_keycode[data[0] & KEYCODE_BIT]);
		*/

#ifdef TEST_JIG_MODE
#ifdef CONFIG_TARGET_LOCALE_NA
                if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[1])
                        printk("search key sensitivity = %d\n", search_sensitivity);

                if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[2])
                        printk("back key sensitivity = %d\n",back_sensitivity);

                if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[3])
                        printk("home key sensitivity = %d\n", home_sensitivity);

                if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[4])
                        printk("menu key sensitivity = %d\n", menu_sensitivity);
#else
		if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[1])
			printk("menu key sensitivity = %d\n", menu_sensitivity);

		if (touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[2])
			printk("back key sensitivity = %d\n",back_sensitivity);
#endif /*CONFIG_TARGET_LOCALE_NA */
#endif
	} else {
		if (touch_is_pressed) {
			printk(KERN_DEBUG
			       "[TouchKey] 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(KERN_DEBUG "[TouchKey] touchkey release tsp input. \n");*/
				touch_forced_release();
			}

			input_report_key(touchkey_driver->input_dev,  touchkey_keycode[data[0] & KEYCODE_BIT], 1);
			input_sync(touchkey_driver->input_dev);

			/*
			printk(KERN_DEBUG
			       "[TouchKey] press keycode:%d \n",
			       touchkey_keycode[data[0] & KEYCODE_BIT]);
			*/

#ifdef TEST_JIG_MODE
#ifdef CONFIG_TARGET_LOCALE_NA
	                if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[1])
	                        printk("search key sensitivity = %d\n", search_sensitivity);

	                if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[2])
	                        printk("back key sensitivity = %d\n",back_sensitivity);

	                if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[3])
	                        printk("home key sensitivity = %d\n", home_sensitivity);

	                if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[4])
	                        printk("menu key sensitivity = %d\n", menu_sensitivity);
#else

			if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[1])
				printk("menu key sensitivity = %d\n",menu_sensitivity);

			if(touchkey_keycode[data[0] & KEYCODE_BIT] == touchkey_keycode[2])
				printk("back key sensitivity = %d\n",back_sensitivity);
#endif /*CONFIG_TARGET_LOCALE_NA */
#endif
		}
	}

#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
	set_touchkey_debug('A');
	enable_irq(IRQ_TOUCH_INT);
}

static irqreturn_t touchkey_interrupt(int irq, void *dummy)
{
#ifdef CONFIG_TOUCHKEY_BLN
        printk(KERN_ERR "[TouchKey] interrupt touchkey\n");
#endif
	set_touchkey_debug('I');
	disable_irq_nosync(IRQ_TOUCH_INT);
	queue_work(touchkey_wq, &touchkey_work);

	return IRQ_HANDLED;
}

#ifdef CONFIG_HAS_EARLYSUSPEND
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);


	return 0;
}
Exemplo n.º 3
0
void touchkey_work_func(struct work_struct *p)
{
	u8 data[10];
	int ret;
	int retry = 10;
	int status;

#if 0
	if (gpio_get_value(_3_GPIO_TOUCH_INT)) {
		printk(KERN_DEBUG "[TouchKey] Unknown state.\n", __func__);
		enable_irq(IRQ_TOUCH_INT);
		return;
	}
#endif

	set_touchkey_debug('a');

#ifdef CONFIG_CPU_FREQ
	/* set_dvfs_target_level(LEV_800MHZ); */
#endif
	ret = i2c_touchkey_read(KEYCODE_REG, data, 3);

	/******************************************************************
    typedef struct I2CReg
    {
	unsigned char    BtnStatus;                          // 0 :
	unsigned char    Version;                                 // 1 :FW Version
	unsigned char    PcbStatus;                          // 2 :Module Version
	unsigned char    Cmd;                                     // 3 :
	unsigned char    Chip_id;                                 // 4 :0x55(DEFAULT_CHIP_ID) 0
	unsigned char    Sens;                                     // 5 :sensitivity grade(0x00(slow),0x01(mid),0x02(fast))
	WORD             DiffData[CSD_TotalSensorCount];   //  6, 7 - 8, 9
	WORD             RawData[CSD_TotalSensorCount];  // 10,11 - 12,13
	WORD             Baseline[CSD_TotalSensorCount];   // 14,15 - 16,17
    }I2CReg;
	******************************************************************/
	set_touchkey_debug(data[0]);
	if ((data[0] & ESD_STATE_BIT) || (ret != 0)) {
		printk(KERN_DEBUG "[TouchKey] ESD_STATE_BIT set or I2C fail: data: %d, retry: %d\n", data[0], retry);

		/* release 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--) {
			gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
			mdelay(300);
			init_hw();

			if (i2c_touchkey_read(KEYCODE_REG, data, 3) >= 0) {
				printk(KERN_DEBUG "[TouchKey] %s touchkey init success\n", __func__);
				set_touchkey_debug('O');
				enable_irq(IRQ_TOUCH_INT);
				return;
			}
			printk(KERN_ERR "[TouchKey] %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;
		gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
		gpio_direction_output(_3_TOUCH_SDA_28V, 0);
		gpio_direction_output(_3_TOUCH_SCL_28V, 0);
		printk(KERN_DEBUG "[TouchKey] %s touchkey died\n", __func__);
		set_touchkey_debug('D');
		return;
	}

	if (touchkey_keycode[data[0] & KEYCODE_BIT] != KEY_MENU && touchkey_keycode[data[0] & KEYCODE_BIT] != KEY_BACK) {
		enable_irq(IRQ_TOUCH_INT);
		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(KERN_DEBUG "[TouchKey] release keycode:%d \n", touchkey_keycode[data[0] & KEYCODE_BIT]);
		*/

	} else {
		if (touch_is_pressed) {
			printk(KERN_DEBUG
			       "[TouchKey] 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(KERN_DEBUG "[TouchKey] touchkey release tsp input. \n");
				*/
				touch_forced_release();
			}

			input_report_key(touchkey_driver->input_dev,  touchkey_keycode[data[0] & KEYCODE_BIT], 1);
			input_sync(touchkey_driver->input_dev);

			/*
			  printk(KERN_DEBUG "[TouchKey] press keycode:%d \n", touchkey_keycode[data[0] & KEYCODE_BIT]);
			*/
		}
	}

	/* we have timed out or the lights should be on */
	if (led_timer.expires > jiffies || led_timeout != BL_ALWAYS_OFF) {
		status = 1;
		i2c_touchkey_write((u8 *)&status, 1); /* turn on */
	}

	/* restart the timer */
	if (led_timeout > 0) {
		mod_timer(&led_timer, jiffies + msecs_to_jiffies(led_timeout));
	}

	set_touchkey_debug('A');
	enable_irq(IRQ_TOUCH_INT);
}