コード例 #1
0
static int misc_psensor_open(struct inode *inode_p, struct file *fp)
{

	DBGPRINTK(KERN_DEBUG "[Jackie] misc_psensor_open+\n");
	DBGPRINTK(KERN_DEBUG "[Jackie] misc_psensor_open-\n");
	return 0;
}
コード例 #2
0
static int psensor_config_gpio(void)
{


	DBGPRINTK(KERN_INFO "Jackie: set PS_INT GPIO %d as IN_NoPull\n", PSENSOR_INT_GPIO);
	gpio_tlmm_config(GPIO_CFG(PSENSOR_INT_GPIO, 0, GPIO_INPUT, GPIO_NO_PULL, GPIO_2MA), GPIO_ENABLE);

	DBGPRINTK(KERN_INFO "Jackie: set PS_ENA GPIO %d as GPIO_PULL_UP\n", PSENSOR_ENABLE_GPIO);
	gpio_tlmm_config(GPIO_CFG(PSENSOR_ENABLE_GPIO, 0, GPIO_OUTPUT, GPIO_PULL_UP, GPIO_2MA), GPIO_ENABLE);
	
	gpio_set_value(PSENSOR_ENABLE_GPIO,1);

	return 0;
}
コード例 #3
0
static int __init psensor_init(void)
{
	int ret;

	printk("BootLog, +%s+\n", __func__);

	psensor_power_counter = 0; 

	
	ret = misc_register(&misc_psensor_device);
	if (ret)
	{
		printk("BootLog, -%s-, misc_register error, ret=%d\n", __func__, ret);
		return ret;
	}

	psensor_config_gpio();

	INIT_WORK(&psensor_irqwork, psensor_work_func);
	psensor_irqsetup(PSENSOR_INT_GPIO);

	
	gpio_set_value(PSENSOR_ENABLE_GPIO,1);
	DBGPRINTK(KERN_INFO "Jackie: psensor_init(), pull high PS_SD to disable P-sensor\n");

#if PSENSOR_TEMP_SOLUTION
    
    wake_lock_init(&psensor_wlock, WAKE_LOCK_SUSPEND, "psensor_active");
#endif

	printk("BootLog, -%s-, ret=%d\n", __func__, ret);
	return ret;
}
コード例 #4
0
static void __exit psensor_exit(void)
{
	
	gpio_set_value(PSENSOR_ENABLE_GPIO,1);
	psensor_release_gpio(PSENSOR_ENABLE_GPIO);

#if PSENSOR_TEMP_SOLUTION
	
    wake_lock_destroy(&psensor_wlock);
#endif
	DBGPRINTK(KERN_DEBUG "Jackie: psensor_exit() \n");
}
コード例 #5
0
static void psensor_work_func(struct work_struct *work)
{
	int ps_out_status;
	char *event_string_0[] = { "ps_out=0", NULL };
	char *event_string_1[] = { "ps_out=1", NULL };

	ps_out_status = gpio_get_value(PSENSOR_INT_GPIO);

	
	if(dynamic_log_ebable)
		printk(KERN_ERR "Jackie: PS_INT!! ps_out_status=%d\n", ps_out_status);

	if(ps_out_status == 0)
	{
		
		if ( (system_rev==EVT2_Band125) || (system_rev==EVT2_Band18) )
		{
			kobject_uevent_env(&misc_psensor_device.this_device->kobj, KOBJ_CHANGE, event_string_1);	
			DBGPRINTK(KERN_ERR "Jackie: PS_OUT low...closed, but force return leaved at EVT2 !!\n");
		}
		else
		{
			kobject_uevent_env(&misc_psensor_device.this_device->kobj, KOBJ_CHANGE, event_string_0);
			
			atomic_set(&psensor_approached, 1);
			DBGPRINTK(KERN_ERR "Jackie: PS_OUT low...closed !!\n");
	        }
	}
	else
	{
		kobject_uevent_env(&misc_psensor_device.this_device->kobj, KOBJ_CHANGE, event_string_1);
		
		atomic_set(&psensor_approached, 0);
		DBGPRINTK(KERN_ERR "Jackie: PS_OUT high...leaved !!\n");
	}
}
コード例 #6
0
static int psensor_irqsetup(int psensor_intpin)
{
	int rc;

	set_irq_flags(MSM_GPIO_TO_INT(psensor_intpin), IRQF_VALID | IRQF_NOAUTOEN);
	rc = request_irq(MSM_GPIO_TO_INT(psensor_intpin), &psensor_irqhandler,
			     IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, PSENSOR_NAME, NULL);
	if (rc < 0) {
		DBGPRINTK(KERN_ERR
		       "Could not register for  %s interrupt "
		       "(rc = %d)\n", PSENSOR_NAME, rc);
		rc = -EIO;
	}
	return rc;
}
コード例 #7
0
static int misc_cover_ioctl(struct inode *inode_p, struct file *fp, unsigned int cmd, unsigned long arg)
{
	int ret = 0;

	DBGPRINTK(KERN_ERR "misc_cover_ioctl+\n");

	if (_IOC_TYPE(cmd) != COVER_IOC_MAGIC)
	{
		DBGPRINTK(KERN_ERR "misc_cover_ioctl::Not COVER_IOC_MAGIC\n");
		return -ENOTTY;
	}

	if (_IOC_DIR(cmd) & _IOC_READ)
	{
		ret = !access_ok(VERIFY_WRITE, (void __user*)arg, _IOC_SIZE(cmd));
		if (ret)
		{
			DBGPRINTK(KERN_ERR "misc_cover_ioctl::access_ok check err\n");
			return -EFAULT;
		}
	}

	if (_IOC_DIR(cmd) & _IOC_WRITE)
	{
		ret = !access_ok(VERIFY_READ, (void __user*)arg, _IOC_SIZE(cmd));
		if (ret)
		{
			DBGPRINTK(KERN_ERR "misc_cover_ioctl::access_ok check err\n");
			return -EFAULT;
		}
	}

	switch (cmd)
	{
		case COVER_IOC_DISABLE_DET:
			disable_irq(MSM_GPIO_TO_INT(cover_det_int_gpio));		
			break;		
		case COVER_IOC_ENABLE_DET:
			enable_irq(MSM_GPIO_TO_INT(cover_det_int_gpio));	
			break;	
		case COVER_IOC_TEST_RUN_CPO_SYNC_AND_RESETCHIP:
            #if defined(CONFIG_HW_AUSTIN) 		
			final_sync_files();	
			#endif
			reset_chip();
			break;							
		default:
			DBGPRINTK(KERN_ERR  "back cover: unknown ioctl received! cmd=%d\n", cmd);
			break;		
	}

	DBGPRINTK(KERN_ERR "misc_cover_ioctl-\n");
	return ret;
}
コード例 #8
0
static int misc_psensor_ioctl(struct inode *inode_p, struct file *fp, unsigned int cmd, unsigned long arg)
{
	int ret = 0;
	unsigned int distance;  

	DBGPRINTK(KERN_ERR "[Jackie] misc_psensor_ioctl+\n");

	if (_IOC_TYPE(cmd) != PSENSOR_IOC_MAGIC)
	{
		DBGPRINTK(KERN_ERR "[Jackie] misc_psensor_ioctl::Not PSENSOR_IOC_MAGIC\n");
		return -ENOTTY;
	}

	if (_IOC_DIR(cmd) & _IOC_READ)
	{
		ret = !access_ok(VERIFY_WRITE, (void __user*)arg, _IOC_SIZE(cmd));
		if (ret)
		{
			DBGPRINTK(KERN_ERR "[Jackie] misc_psensor_ioctl::access_ok check err\n");
			return -EFAULT;
		}
	}

	if (_IOC_DIR(cmd) & _IOC_WRITE)
	{
		ret = !access_ok(VERIFY_READ, (void __user*)arg, _IOC_SIZE(cmd));
		if (ret)
		{
			DBGPRINTK(KERN_ERR "[Jackie] misc_psensor_ioctl::access_ok check err\n");
			return -EFAULT;
		}
	}

	switch (cmd)
	{
		case PSENSOR_IOC_ENABLE:
#if PSENSOR_TEMP_SOLUTION
			wake_lock(&psensor_wlock);
#endif
			psensor_powerup();			
		 	
		 	gpio_set_value(PSENSOR_ENABLE_GPIO,0);

			enable_irq(MSM_GPIO_TO_INT(PSENSOR_INT_GPIO));
			enable_irq_wake(MSM_GPIO_TO_INT(PSENSOR_INT_GPIO));
			break;

		case PSENSOR_IOC_DISABLE:

			disable_irq_wake(MSM_GPIO_TO_INT(PSENSOR_INT_GPIO));
			disable_irq(MSM_GPIO_TO_INT(PSENSOR_INT_GPIO));

			
			
			gpio_set_value(PSENSOR_ENABLE_GPIO,1);

			psensor_powerdown();
			
			atomic_set(&psensor_approached, 0);
#if PSENSOR_TEMP_SOLUTION
			wake_lock_timeout(&psensor_wlock, HZ*2);
#endif
			break;

		case PSENSOR_IOC_GET_STATUS:
			if ( (system_rev==EVT2_Band125) || (system_rev==EVT2_Band18) )
			{
				distance = 1; 
				DBGPRINTK(KERN_INFO  "[Jackie] PSENSOR_IOC_GET_STATUS, distance=1 at EVT2\n");
			}
			else
			{
				distance = gpio_get_value(PSENSOR_INT_GPIO);
				DBGPRINTK(KERN_INFO  "[Jackie] PSENSOR_IOC_GET_STATUS, distance=%d\n", distance);
			}

			if (copy_to_user((void __user*) arg, &distance, _IOC_SIZE(cmd)))
			{
				DBGPRINTK(KERN_ERR "[Jackie] misc_psensor_ioctl::PSENSOR_IOC_GET_STATUS:copy_to_user fail-\n");
				ret = -EFAULT;
			}
			break;

		default:
			DBGPRINTK(KERN_ERR  "P-sensor: unknown ioctl received! cmd=%d\n", cmd);
			break;
	}

	DBGPRINTK(KERN_ERR "[Jackie] misc_psensor_ioctl-\n");

	return ret;
}