Beispiel #1
0
static ssize_t proximity_enable_store(struct device *dev, struct device_attribute *attr,  const char *buf, size_t size)
{
    bool new_value;

    if (sysfs_streq(buf, "1"))
        new_value = true;
    else if (sysfs_streq(buf, "0"))
        new_value = false;
    else {
        pr_err("%s: invalid value %d\n", __func__, *buf);
        return -EINVAL;
    }

    printk(KERN_INFO "[GP2A] proximity_enable_store: new_value=%d mode=%d\n", new_value, gp2a_data->cal_mode);   
   
    mutex_lock(&gp2a_data->power_lock);   
   
    if (new_value ){          
        input_report_abs(gp2a_data->prox_input_dev, ABS_DISTANCE, 1);
        input_sync(gp2a_data->prox_input_dev);        
        gp2a_prox_mode(1);        
    }
    else if (!new_value ) 
    {
        gp2a_prox_mode(0);
    }

    mutex_unlock(&gp2a_data->power_lock);
    return size;
}
Beispiel #2
0
static void gp2a_prox_work_func(struct work_struct *work)
{
	unsigned char value;
	unsigned char int_val = GP2A_REG_PROX;
	unsigned char vout = 0;
        int ret=0;

	/* Read VO & INT Clear */	
	debug("[PROXIMITY] %s : \n",__func__);
    
	if((ret=gp2a_i2c_read((u8)(int_val), &value))<0)
	{
            error("gp2a_i2c_read  failed\n");            
            gp2a_prox_reset();
            
            if(proximity_enable == 1)
                gp2a_prox_mode(1);
            else
                gp2a_prox_mode(0);
            
            return;
	}
    
	vout = value & 0x01;
	printk(KERN_INFO "[GP2A] vout = %d \n",vout);

	/* Report proximity information */ 
	proximity_value = vout;

        input_report_abs(gp2a_data->prox_input_dev, ABS_DISTANCE,((vout == 1)? 0:1));
        input_sync(gp2a_data->prox_input_dev);
        mdelay(1);

	/* Write HYS Register */
        gp2a_prox_offset(vout);

	/* Forcing vout terminal to go high */
	value = 0x18;
	gp2a_i2c_write((u8)(GP2A_REG_CON),&value);

	/* enable INT */
	enable_irq(gp2a_data->irq);
	printk(KERN_INFO "[GP2A] enable_irq IRQ_NO:%d\n",gp2a_data->irq);

	/* enabling VOUT terminal in nomal operation */
	value = 0x00;
	gp2a_i2c_write((u8)(GP2A_REG_CON),&value);
	
}
Beispiel #3
0
static int gp2a_prox_ioctl(struct inode *inode, struct file *filp, 
	                        unsigned int ioctl_cmd,  unsigned long arg)
{	int ret = 0;

	if( _IOC_TYPE(ioctl_cmd) != PROX_IOC_MAGIC )
    {
        error("Wrong _IOC_TYPE 0x%x",ioctl_cmd);
        return -ENOTTY;
    }
    if( _IOC_NR(ioctl_cmd) > PROX_IOC_NR_MAX )
    {
        error("Wrong _IOC_NR 0x%x",ioctl_cmd);	
        return -ENOTTY;
    }
	switch (ioctl_cmd)
    {
        case PROX_IOC_NORMAL_MODE:
			{
				debug("PROX_IOC_NORMAL_MODE called");
				if(0==proximity_enable)
				{
					if( (ret = gp2a_prox_mode(1)) < 0 )        
						error("PROX_IOC_NORMAL_MODE failed"); 
				}
				else
					debug("Proximity Sensor is already Normal Mode");
				break;
			}
        case PROX_IOC_SHUTDOWN_MODE:			
			{
				debug("PROX_IOC_SHUTDOWN_MODE called");				
				if(1==proximity_enable)
				{
					if( (ret = gp2a_prox_mode(0)) < 0 )        
						error("PROX_IOC_SHUTDOWN_MODE failed"); 
				}
				else
					debug("Proximity Sensor is already set in Shutdown mode");
				gp2a_report_proximity_value(1);
				break;
			}
		default:
			error("Unknown IOCTL command");
            ret = -ENOTTY;
            break;
	}
	return ret;
}
Beispiel #4
0
static int __devexit gp2a_prox_remove(struct i2c_client *client)
{	
  	debug("%s called",__func__); 
	gp2a_prox_mode(0);
	gp2a_data->gp2a_prox_i2c_client = NULL;
	free_irq(PROX_IRQ,NULL);
	sysfs_remove_group(&client->dev.kobj, &gp2a_prox_attr_group);
	destroy_workqueue(gp2a_prox_wq);
	input_unregister_device(gp2a_data->prox_input_dev);	
	misc_deregister(&gp2a_prox_misc_device);
	kfree(gp2a_data);
	return 0;
}
Beispiel #5
0
static ssize_t gp2a_store_operation_mode(struct device *dev,struct device_attribute *attr,const char *buf, size_t count)
{      
	int ret=0;
	unsigned long mode;
	if((strict_strtoul(buf,10,&mode)<0) || (mode > 2))
		return -EINVAL;
	if(mode != proximity_enable)
	{
		if( (ret = gp2a_prox_mode(mode)) < 0 )
		{
			error("gp2a_prox_mode failed"); 
			return ret;
		}
	}
	return count;
}
Beispiel #6
0
static int gp2a_prox_probe(struct i2c_client *client,const struct i2c_device_id *id)
{
	int ret =0;
	u8 reg_value;
	printk("------ %s start \n", __func__);	

	/* Allocate driver_data */
	gp2a_data = kzalloc(sizeof(struct gp2a_prox_data),GFP_KERNEL);
	if(!gp2a_data)
	{
		error("kzalloc:allocating driver_data error");
		return -ENOMEM;		
	} 
	
	gp2a_data->gp2a_prox_i2c_client = client;
	i2c_set_clientdata(client, gp2a_data);
	
	/*misc device registration*/
    if( (ret = misc_register(&gp2a_prox_misc_device)) < 0 )
    {
        error("gp2a_prox driver misc_register failed");
		goto FREE_GP2A_DATA;
    }
	
	wake_lock_init(&prox_wakelock,WAKE_LOCK_SUSPEND,"prox_wakelock");
	
	/*Initialisation of GPIO_PS_OUT of proximity sensor*/
	s3c_gpio_cfgpin(GPIO_PS_OUT, S3C_GPIO_SFN(GPIO_PS_OUT_STATE));
	s3c_gpio_setpull(GPIO_PS_OUT, S3C_GPIO_PULL_NONE);	
	
	/*Input Device Settings*/
	gp2a_data->prox_input_dev = input_allocate_device();
	if (!gp2a_data->prox_input_dev) 
	{
        error("Not enough memory for gp2a_data->prox_input_dev");
        ret = -ENOMEM;
        goto MISC_DREG;
    }
	gp2a_data->prox_input_dev->name = "gp2a_prox";
	set_bit(EV_SYN,gp2a_data->prox_input_dev->evbit);
	set_bit(EV_ABS,gp2a_data->prox_input_dev->evbit);	
	input_set_abs_params(gp2a_data->prox_input_dev, ABS_DISTANCE, 0, 1, 0, 0);
	ret = input_register_device(gp2a_data->prox_input_dev);
    if (ret) 
	{
        error("Failed to register input device");
		input_free_device(gp2a_data->prox_input_dev);
        goto MISC_DREG;
    }
	debug("Input device settings complete");
	
	/* Workqueue Settings */
    gp2a_prox_wq = create_singlethread_workqueue("gp2a_prox_wq");
    if (!gp2a_prox_wq)
	{
        error("Not enough memory for gp2a_prox_wq");
        ret = -ENOMEM;
        goto INPUT_DEV_DREG;
    }	     
    INIT_WORK(&gp2a_data->work_prox, gp2a_prox_work_func);
	debug("Workqueue settings complete");	

	gp2a_data->irq = -1;	
	set_irq_type(PROX_IRQ, IRQ_TYPE_EDGE_BOTH);	
	if( (ret = request_irq(PROX_IRQ, gp2a_irq_handler,IRQF_DISABLED , "proximity_int", NULL )) )
	{
        error("GP2A request_irq failed IRQ_NO:%d", PROX_IRQ);
        goto DESTROY_WORK_QUEUE;
	} 
	else
		debug("GP2A request_irq success IRQ_NO:%d", PROX_IRQ);
	
	gp2a_data->irq = PROX_IRQ;
	
	/*create sysfs attributes*/
	ret = sysfs_create_group(&client->dev.kobj, &gp2a_prox_attr_group);
    if (ret)
    {
		error("Failed to create sysfs attributes");
		goto FREE_IRQ;
	}
	
	/*Device Initialisation with recommended register values from datasheet*/  	
	reg_value = 0x18;
	if((ret=gp2a_i2c_write(GP2A_REG_CON,&reg_value))<0)
			error("gp2a_i2c_write 1 failed");	
		
	reg_value = 0x08;
	if((ret=gp2a_i2c_write(GP2A_REG_GAIN,&reg_value))<0)
			error("gp2a_i2c_write 2 failed");
	
	reg_value = 0xC2;
	if((ret=gp2a_i2c_write(GP2A_REG_HYS,&reg_value))<0)
			error("gp2a_i2c_write 3 failed");

	reg_value = 0x04;
	if((ret=gp2a_i2c_write(GP2A_REG_CYCLE,&reg_value))<0)
			error("gp2a_i2c_write 4 failed");
	
	/*Pulling the GPIO_PS_OUT Pin High*/
	s3c_gpio_setpull(GPIO_PS_OUT, S3C_GPIO_PULL_UP);

	/*Setting the device into shutdown mode*/
	gp2a_prox_mode(1);

	printk("------ %s end\n", __func__);	
	return ret;

FREE_IRQ:
	free_irq(PROX_IRQ,NULL);
DESTROY_WORK_QUEUE:
	destroy_workqueue(gp2a_prox_wq);
INPUT_DEV_DREG:
	input_unregister_device(gp2a_data->prox_input_dev);	
MISC_DREG:
	misc_deregister(&gp2a_prox_misc_device);
FREE_GP2A_DATA:
	kfree(gp2a_data);
	return ret;
}	
Beispiel #7
0
static int gp2a_prox_probe(struct i2c_client *client,const struct i2c_device_id *id)
{
	int ret =0;
	u8 reg_value;
	struct gp2ap002_platform_data *platform_data;

	printk(KERN_INFO "[GP2A] %s start \n", __func__);	
	
	/* Allocate driver_data */
	gp2a_data = kzalloc(sizeof(struct gp2a_prox_data),GFP_KERNEL);
	if(!gp2a_data)
	{
		error("kzalloc:allocating driver_data error");
		return -ENOMEM;		
	} 
	
    	platform_data = client->dev.platform_data;
	gp2a_data->gp2a_prox_i2c_client = client;
	i2c_set_clientdata(client, gp2a_data);
	
	/*misc device registration*/
	if( (ret = misc_register(&gp2a_prox_misc_device)) < 0 )
	{
		error("gp2a_prox driver misc_register failed");
		goto FREE_GP2A_DATA;
	}
	
	gp2a_data->irq_gpio = platform_data->irq_gpio;		
	/*Initialisation of GPIO_PS_OUT of proximity sensor*/
	if (gpio_request(gp2a_data->irq_gpio, "Proximity Out")) {
		printk(KERN_ERR "Proximity Request GPIO_%d failed!\n", gp2a_data->irq_gpio);
	}
	
	gpio_direction_input(gp2a_data->irq_gpio);

	mutex_init(&gp2a_data->power_lock);
	
	/*Input Device Settings*/
	gp2a_data->prox_input_dev = input_allocate_device();
	if (!gp2a_data->prox_input_dev) 
	{
		error("Not enough memory for gp2a_data->prox_input_dev");
		ret = -ENOMEM;
		goto MISC_DREG;
	}
	gp2a_data->prox_input_dev->name = "proximity_sensor";
	set_bit(EV_SYN,gp2a_data->prox_input_dev->evbit);
	set_bit(EV_ABS,gp2a_data->prox_input_dev->evbit);	

	input_set_capability(gp2a_data->prox_input_dev, EV_ABS, ABS_DISTANCE);    
	input_set_abs_params(gp2a_data->prox_input_dev, ABS_DISTANCE, 0, 1, 0, 0);
	ret = input_register_device(gp2a_data->prox_input_dev);
	if (ret) 
	{
		error("Failed to register input device");
		input_free_device(gp2a_data->prox_input_dev);
		goto MISC_DREG;
	}
	debug("Input device settings complete");
    
	/*create sysfs attributes*/
	ret = sysfs_create_group(&gp2a_data->prox_input_dev->dev.kobj, &gp2a_prox_attr_group);
	if (ret)
	{
		error("Failed to create sysfs attributes");
		goto MISC_DREG;
	}
    
	/* Workqueue Settings */
	gp2a_prox_wq = create_singlethread_workqueue("gp2a_prox_wq");
	if (!gp2a_prox_wq)
	{
		error("Not enough memory for gp2a_prox_wq");
		ret = -ENOMEM;
		goto INPUT_DEV_DREG;
	}	     
	INIT_WORK(&gp2a_data->work_prox, gp2a_prox_work_func);
	debug("Workqueue settings complete");	
            
	/* wake lock init */
	wake_lock_init(&gp2a_data->prx_wake_lock, WAKE_LOCK_SUSPEND,
		"prx_wake_lock");
            
	gp2a_data->irq = platform_data->irq;    
    
        irq_set_irq_type(gp2a_data->irq, IRQ_TYPE_EDGE_FALLING);	
	if( (ret = request_irq(gp2a_data->irq, gp2a_irq_handler,IRQF_DISABLED | IRQF_NO_SUSPEND , "proximity_int", NULL )) )
	{
		error("GP2A request_irq failed IRQ_NO:%d", gp2a_data->irq);
		goto DESTROY_WORK_QUEUE;
	} 
	else
		printk(KERN_INFO "[GP2A] request_irq success IRQ_NO:%d", gp2a_data->irq);
	
	/*Device Initialisation with recommended register values from datasheet*/
	
	reg_value = 0x18;
	if((ret=gp2a_i2c_write(GP2A_REG_CON,&reg_value))<0)
			error("gp2a_i2c_write 1 failed");	
		
	reg_value = 0x08;
	if((ret=gp2a_i2c_write(GP2A_REG_GAIN,&reg_value))<0)
			error("gp2a_i2c_write 2 failed");
	
	reg_value = PROX_NONDETECT;
	if((ret=gp2a_i2c_write(GP2A_REG_HYS,&reg_value))<0)
			error("gp2a_i2c_write 3 failed");
	
	reg_value = 0x04;
	if((ret=gp2a_i2c_write(GP2A_REG_CYCLE,&reg_value))<0)
			error("gp2a_i2c_write 4 failed");

	gp2a_data->cal_mode = 0;
        nondetect = PROX_NONDETECT;
        detect = PROX_DETECT;
    
	/*Pulling the GPIO_PS_OUT Pin High*/
	printk(KERN_INFO "[GP2A] gpio_get_value of GPIO_PS_OUT is %d\n",gpio_get_value(gp2a_data->irq_gpio));

	/*Setting the device into shutdown mode*/
	gp2a_prox_mode(0);

	/* set initial proximity value as 1 */
	input_report_abs(gp2a_data->prox_input_dev, ABS_DISTANCE, 1);
	input_sync(gp2a_data->prox_input_dev);

	printk(KERN_INFO "[GP2A] %s end\n", __func__);	
	return ret;
    
DESTROY_WORK_QUEUE:
	wake_lock_destroy(&gp2a_data->prx_wake_lock);
	destroy_workqueue(gp2a_prox_wq);
INPUT_DEV_DREG:
	input_unregister_device(gp2a_data->prox_input_dev);	
MISC_DREG:
	misc_deregister(&gp2a_prox_misc_device);
FREE_GP2A_DATA:
	kfree(gp2a_data);
	return ret;
}	
Beispiel #8
0
static long gp2a_prox_ioctl(struct file *filp, unsigned int ioctl_cmd,  unsigned long arg)
{	
    int ret = 0;
    short data = 0;
    char cal_mode=0;

    if( _IOC_TYPE(ioctl_cmd) != PROX_IOC_MAGIC )
    {
        error("Wrong _IOC_TYPE 0x%x",ioctl_cmd);
        return -ENOTTY;
    }

    switch (ioctl_cmd)
    {
        case PROX_IOC_NORMAL_MODE:
        {
            printk(KERN_INFO "[GP2A] PROX_IOC_NORMAL_MODE\n");
            if(0==proximity_enable)
            {
                if( (ret = gp2a_prox_mode(1)) < 0 )        
                    error("PROX_IOC_NORMAL_MODE failed"); 
            }
            else
                debug("Proximity Sensor is already Normal Mode");
            break;
        }
        case PROX_IOC_SHUTDOWN_MODE:			
        {
            printk(KERN_INFO "[GP2A] PROX_IOC_SHUTDOWN_MODE\n");				
            if(1==proximity_enable)
            {
            	if( (ret = gp2a_prox_mode(0)) < 0 )        
            		error("PROX_IOC_SHUTDOWN_MODE failed"); 
            }
            else
            	debug("Proximity Sensor is already set in Shutdown mode");
            break;
        }
	case PROX_IOC_SET_CALIBRATION:
        {
		printk(KERN_INFO "[GP2A] PROX_IOC_SET_CALIBRATION\n");                
		if (copy_from_user(&data, (void __user *)arg, sizeof(data)))
			return -EFAULT;

                ret = gp2a_cal_mode_read_file(&cal_mode);
		if (ret < 0 && ret != -ENOENT)
		{
			printk(KERN_INFO "[GP2A] gp2a_cal_mode_read_file() failed\n");
		}else {
		    if(cal_mode >=0 && cal_mode <=2){
                        gp2a_prox_cal_mode(cal_mode);
                        gp2a_data->cal_mode = cal_mode;                    
                        printk(KERN_INFO "[GP2A] cal mode (%d)\n", gp2a_data->cal_mode);
		    } else {
                        gp2a_data->cal_mode = 0;     
		    }
		}
		break;
	}
	case PROX_IOC_GET_CALIBRATION:
        {
		printk(KERN_INFO "[GP2A] PROX_IOC_GET_CALIBRATION\n");      
                data = gp2a_data->cal_mode;
		if (copy_to_user((void __user *)arg, &data, sizeof(data)))
			return -EFAULT;
		break;
	}
	default:
            error("Unknown IOCTL command");
            ret = -ENOTTY;
            break;
    }
    return ret;
}
static int gp2a_prox_probe(struct i2c_client *client,const struct i2c_device_id *id)
{
	int ret =0, out_pin;
	u8 reg_value;

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

	prox_ctrl_regulator(1);
	
	/* Allocate driver_data */
	gp2a_data = kzalloc(sizeof(struct gp2a_prox_data),GFP_KERNEL);
	if(!gp2a_data)
	{
		error("kzalloc:allocating driver_data error");
		return -ENOMEM;		
	} 
	
	gp2a_data->gp2a_prox_i2c_client = client;
	i2c_set_clientdata(client, gp2a_data);
	
	/*misc device registration*/
    if( (ret = misc_register(&gp2a_prox_misc_device)) < 0 )
    {
		error("gp2a_prox driver misc_register failed");
		goto FREE_GP2A_DATA;
    }
	
	/*Input Device Settings*/
	gp2a_data->prox_input_dev = input_allocate_device();
	if (!gp2a_data->prox_input_dev) 
	{
		error("Not enough memory for gp2a_data->prox_input_dev");
		ret = -ENOMEM;
		goto MISC_DREG;
	}
	gp2a_data->prox_input_dev->name = "proximity_sensor";
	set_bit(EV_SYN,gp2a_data->prox_input_dev->evbit);
	set_bit(EV_ABS,gp2a_data->prox_input_dev->evbit);	
	input_set_abs_params(gp2a_data->prox_input_dev, ABS_DISTANCE, 0, 1, 0, 0);
	ret = input_register_device(gp2a_data->prox_input_dev);
	if (ret) 
	{
		error("Failed to register input device");
		input_free_device(gp2a_data->prox_input_dev);
		goto MISC_DREG;
	}
	debug("Input device settings complete");
    
#if USE_INTERRUPT	
	/* Workqueue Settings */
	gp2a_prox_wq = create_singlethread_workqueue("gp2a_prox_wq");
	if (!gp2a_prox_wq)
	{
		error("Not enough memory for gp2a_prox_wq");
		ret = -ENOMEM;
		goto INPUT_DEV_DREG;
	}    
	INIT_WORK(&gp2a_data->work_prox, gp2a_prox_work_func);
	debug("Workqueue settings complete");		


	/*Initialisation of GPIO_PS_OUT of proximity sensor*/
	out_pin = mfp_to_gpio(GPIO_PS_OUT);
	if (gpio_request(out_pin, "Proximity Out")) {
		printk(KERN_ERR "[GP2A] Proximity Request GPIO_%d failed!\n", out_pin);
	}
	
	gpio_direction_input(out_pin);
	gpio_free(out_pin);    
	mdelay(2);
    
	gp2a_data->irq = -1;	
	set_irq_type(PROX_IRQ, IRQ_TYPE_EDGE_FALLING);
	if( (ret = request_irq(PROX_IRQ, gp2a_irq_handler,IRQF_DISABLED | IRQF_NO_SUSPEND , "proximity_int", NULL )) )
	{
		error("GP2A request_irq failed IRQ_NO:%d", PROX_IRQ);
		goto DESTROY_WORK_QUEUE;
	} 
	else
		debug("GP2A request_irq success IRQ_NO:%d", PROX_IRQ);
	
	gp2a_data->irq = PROX_IRQ;	
#endif

	/* wake lock init */
	wake_lock_init(&prx_wake_lock, WAKE_LOCK_SUSPEND, "prx_wake_lock");

	timeA = ktime_set(0,0);
	timeB = ktime_set(0,0);
	
#if 0	
	/*create sysfs attributes*/
	ret = sysfs_create_group(&client->dev.kobj, &gp2a_prox_attr_group);
    if (ret)
    {
		error("Failed to create sysfs attributes");
		goto FREE_IRQ;
	}
#endif    
	
	/*Device Initialisation with recommended register values from datasheet*/
	
	reg_value = 0x18;
	if((ret=gp2a_i2c_write(GP2A_REG_CON,&reg_value))<0)
			error("gp2a_i2c_write 1 failed");	
		
	reg_value = 0x08;
	if((ret=gp2a_i2c_write(GP2A_REG_GAIN,&reg_value))<0)
			error("gp2a_i2c_write 2 failed");
	
	reg_value = 0x40;
	if((ret=gp2a_i2c_write(GP2A_REG_HYS,&reg_value))<0)
			error("gp2a_i2c_write 3 failed");
	
	reg_value = 0x04;
	if((ret=gp2a_i2c_write(GP2A_REG_CYCLE,&reg_value))<0)
			error("gp2a_i2c_write 4 failed");
	
	/*Pulling the GPIO_PS_OUT Pin High*/
	gpio_set_value(GPIO_PS_OUT, 1);
	printk(KERN_INFO "[GP2A] gpio_get_value of GPIO_PS_OUT is %d\n",gpio_get_value(GPIO_PS_OUT));

	/*Setting the device into shutdown mode*/
	gp2a_prox_mode(0);

	printk(KERN_INFO "[GP2A] %s end\n", __func__);	
	return ret;
#if 0 /* prevent CID58528 */
FREE_IRQ:
	free_irq(PROX_IRQ,NULL);
#endif
DESTROY_WORK_QUEUE:
	destroy_workqueue(gp2a_prox_wq);
INPUT_DEV_DREG:
	input_unregister_device(gp2a_data->prox_input_dev);	
MISC_DREG:
	misc_deregister(&gp2a_prox_misc_device);
FREE_GP2A_DATA:
	kfree(gp2a_data);
	return ret;
}	
static void gp2a_prox_work_func(struct work_struct *work)
{	
	unsigned char value;
	unsigned char int_val = GP2A_REG_PROX;
	unsigned char vout = 0;
        int ret=0;

	/* Read VO & INT Clear */	
	debug("[PROXIMITY] %s : \n",__func__);
	if(INT_CLEAR)
	{
		//int_val = GP2A_REG_PROX | (1 <<7);
	}
	
	if((ret=gp2a_i2c_read((u8)(int_val), &value))<0)
	{
            error("gp2a_i2c_read  failed\n");            
            gp2a_prox_reset();
            
            if(proximity_enable == 1)
                gp2a_prox_mode(1);
            else
                gp2a_prox_mode(0);
            
            return;
	}
    
	vout = value & 0x01;
	printk(KERN_INFO "[GP2A] vout = %d \n",vout);

	/* Report proximity information */
	proximity_value = vout;
		
	if(proximity_value ==0)
	{
		timeB = ktime_get();
		
		timeSub = ktime_sub(timeB,timeA);
		debug("[PROXIMITY] timeSub sec = %d, timeSub nsec = %d \n",timeSub.tv.sec,timeSub.tv.nsec);
		
		if (timeSub.tv.sec>=3 )
		{
		    wake_lock_timeout(&prx_wake_lock,HZ/2);
			debug("[PROXIMITY] wake_lock_timeout : HZ/2 \n");
		}
		else
			error("[PROXIMITY] wake_lock is already set \n");
	}

	if(USE_INPUT_DEVICE)
	{
		input_report_abs(gp2a_data->prox_input_dev, ABS_DISTANCE,(int)vout);
	input_sync(gp2a_data->prox_input_dev);
	mdelay(1);
	}

	/* Write HYS Register */
	if(!vout)
	{
		value = 0x40;
	}
	else
	{
		value = 0x20;
	}
	
	gp2a_i2c_write((u8)(GP2A_REG_HYS),&value);

	/* Forcing vout terminal to go high */
	value = 0x18;
	gp2a_i2c_write((u8)(GP2A_REG_CON),&value);

	/* enable INT */
	enable_irq(gp2a_data->irq);
	printk(KERN_INFO "[GP2A] enable_irq IRQ_NO:%d\n",gp2a_data->irq);

	/* enabling VOUT terminal in nomal operation */
	value = 0x00;
	gp2a_i2c_write((u8)(GP2A_REG_CON),&value);
	
}