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

}
Ejemplo n.º 2
0
// ********************* LOW-LEVEL ISSP SUBROUTINE SECTION ********************
// ****************************************************************************
// ****                        PROCESSOR SPECIFIC                          ****
// ****************************************************************************
// ****                      USER ATTENTION REQUIRED                       ****
// ****************************************************************************
// RemoveTargetVDD()
// Remove power from the target PSoC's Vdd pin.
// ****************************************************************************
void RemoveTargetVDD(void)
{
    #if 0
    gpio_tlmm_config(LED_26V_EN);
    gpio_tlmm_config(EXT_TSP_SCL);
    gpio_tlmm_config(EXT_TSP_SDA);
    gpio_tlmm_config(EXT_TSP_RST);
    
    gpio_out(LED_26V_EN, GPIO_LOW_VALUE);
    gpio_out(EXT_TSP_SCL, GPIO_LOW_VALUE);
    gpio_out(EXT_TSP_SDA, GPIO_LOW_VALUE);
    gpio_out(EXT_TSP_RST, GPIO_LOW_VALUE);
    #else
#if !defined(CONFIG_KOR_MODEL_SHV_E160S) && !defined(CONFIG_KOR_MODEL_SHV_E160K) && !defined (CONFIG_KOR_MODEL_SHV_E160L)
	printk("[TKEY] %s: tkey_vdd_enable(OFF)\n", __func__);
#endif
	tkey_vdd_enable(0);
    #endif
    //gpio_direction_output(_3_GPIO_TOUCH_EN, 0);
}
Ejemplo n.º 3
0
// ********************* LOW-LEVEL ISSP SUBROUTINE SECTION ********************
// ****************************************************************************
// ****                        PROCESSOR SPECIFIC                          ****
// ****************************************************************************
// ****                      USER ATTENTION REQUIRED                       ****
// ****************************************************************************
// ApplyTargetVDD()
// Provide power to the target PSoC's Vdd pin through a GPIO.
// ****************************************************************************
void ApplyTargetVDD(void)
{
    gpio_direction_input(GPIO_TOUCHKEY_SDA);
    gpio_direction_input(GPIO_TOUCHKEY_SCL);
#if !defined(CONFIG_KOR_MODEL_SHV_E160S) && !defined(CONFIG_KOR_MODEL_SHV_E160K) && !defined (CONFIG_KOR_MODEL_SHV_E160L)
    printk("[TKEY] %s: tkey_vdd_enable(ON) \n", __func__);
#endif
    tkey_vdd_enable(1);

    // gpio_direction_output(_3_GPIO_TOUCH_EN, 1);
    //	Set_MAX8998_PM_OUTPUT_Voltage(LDO13, VCC_2p800);	
    //	Set_MAX8998_PM_REG(ELDO13, 1);

    mdelay(3);

    //for(temp=0; temp < 16;temp++) {
    //    clk_busy_wait(1000); // gave the more delay, changed the LDO
    //    dog_kick();
    //}
}
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;
	}
static irqreturn_t touchkey_interrupt(int irq, void *dummy)  // ks 79 - threaded irq(becuase of pmic gpio int pin)-> when reg is read in work_func, data0 is always release. so temporarily move the work_func to threaded irq.
{
    u8 data[3];
    int ret;
    int retry = 10;

    set_touchkey_debug('I');
    disable_irq_nosync(IRQ_TOUCHKEY_INT);

	tkey_vdd_enable(1); 

	set_touchkey_debug('a');
	ret = i2c_touchkey_read(KEYCODE_REG, data, 1);

	if(g_debug_switch)
		printk("[TKEY] DATA0 %d\n", data[0]);

	if (get_hw_rev() <= 0x04){
        if (data[0] > 80)  {
            data[0] = data[0] - 80; 
            printk("[TKEY] DATA0 change [%d] \n", data[0]);
        }
    }

	set_touchkey_debug(data[0]);
	if ((data[0] & ESD_STATE_BIT) || (ret != 0)) {
		printk("[TKEY] 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--) {
			mdelay(300);
			init_hw();
            if (i2c_touchkey_read(KEYCODE_REG, data, 3) >= 0) {
                printk("[TKEY] %s touchkey init success\n", __func__);
				set_touchkey_debug('O');
				enable_irq(IRQ_TOUCHKEY_INT);
				return IRQ_NONE;
			}
            printk("[TKEY] %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;
		printk("[TKEY] %s touchkey died\n", __func__);
		set_touchkey_debug('D');
		return IRQ_NONE;
	}

	if (data[0] & UPDOWN_EVENT_BIT) {
		if(press_check == touchkey_keycode[data[0] & KEYCODE_BIT]){
			input_report_key(touchkey_driver->input_dev, touchkey_keycode[data[0] & KEYCODE_BIT], 0);
			touchkey_pressed &= ~(1 << (data[0] & KEYCODE_BIT));
			input_sync(touchkey_driver->input_dev);
			if(g_debug_switch)			
				printk(KERN_DEBUG "touchkey release keycode:%d \n", touchkey_keycode[data[0] & KEYCODE_BIT]);
		}else{
			input_report_key(touchkey_driver->input_dev, press_check, 0);
	        }
			press_check = 0;
	} else {
		if (touch_is_pressed) {   
			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
			}
			input_report_key(touchkey_driver->input_dev, touchkey_keycode[data[0] & KEYCODE_BIT], 1);
			touchkey_pressed |= (1 << (data[0] & KEYCODE_BIT));
			input_sync(touchkey_driver->input_dev);
			press_check = touchkey_keycode[data[0] & KEYCODE_BIT];
			if(g_debug_switch)				
				printk(KERN_DEBUG "touchkey press keycode:%d \n", touchkey_keycode[data[0] & KEYCODE_BIT]);
		}
	}
	set_touchkey_debug('A');
	enable_irq(IRQ_TOUCHKEY_INT);
    //queue_work(touchkey_wq, &touchkey_work);
	return IRQ_HANDLED;
}