static void snfc_avail_poll_exit(void)
{
    SNFC_DEBUG_MSG_LOW("[snfc_avail_poll] snfc_avail_poll_exit - start \n");


    SNFC_DEBUG_MSG_LOW("[snfc_avail_poll] snfc_avail_poll_exit - end \n");
}
/*
* Description : open uart collision control
* Input : 
* Output : 
*/
static int snfc_uart_control_open(struct inode *inode, struct file *fp)
{
	int rc = 0;

	if(isopen_snfcuartcontrol == 1)
	{
		SNFC_DEBUG_MSG_LOW("[snfc_uart_control] snfc_uart_control_open - already open \n");
		return 0;
	}
    	SNFC_DEBUG_MSG_LOW("[snfc_uart_control] snfc_uart_control_open - start \n");
	isopen_snfcuartcontrol = 1;

	if(gpio_init ==0)
	{	
		rc = gpio_request(GPIO_SNFC_HSEL, "snfc_hsel");
		if (rc)
		{
			SNFC_DEBUG_MSG("[snfc_intu_poll] gpio_request snfc_intu fail\n");
		}
		rc = gpio_request(GPIO_SNFC_PON, "snfc_pon");
		if (rc)
		{
			SNFC_DEBUG_MSG("[snfc_intu_poll] gpio_request snfc_intu fail\n");
		}

		//snfc_gpio_open(GPIO_SNFC_HSEL,GPIO_DIRECTION_OUT,GPIO_LOW_VALUE);
		//snfc_gpio_open(GPIO_SNFC_PON,GPIO_DIRECTION_OUT,GPIO_LOW_VALUE);
		SNFC_DEBUG_MSG_LOW("[snfc_uart_control] GPIO_SNFC_PON = %d, GPIO_SNFC_HSEL = %d\n",
			snfc_gpio_read(GPIO_SNFC_PON),snfc_gpio_read(GPIO_SNFC_HSEL) );	
		gpio_init = 1;
	}
	SNFC_DEBUG_MSG_LOW("[snfc_uart_control] snfc_uart_control_open - end \n");

	return rc;
}
/*
* Description : open uart collision control
* Input : 
* Output : 
*/
static int snfc_uart_control_open(struct inode *inode, struct file *fp)
{
    int rc = 0;

    if(isopen_snfcuartcontrol == 1)
    {
        SNFC_DEBUG_MSG_LOW("[snfc_uart_control] snfc_uart_control_open - already open \n");
        return 0;
    }
    SNFC_DEBUG_MSG_LOW("[snfc_uart_control] snfc_uart_control_open - start \n");
    isopen_snfcuartcontrol = 1;

    __snfc_uart_control_set_uart_status(UART_STATUS_READY);

        if(gpio_init ==0)
        {
            rc = gpio_request(snfc_gpios.gpio_hvdd,"snfc_hvdd");
            if(rc){
                SNFC_DEBUG_MSG("[snfc_intu_poll] gpio_request snfc_hvdd fail\n");
            }
            snfc_gpio_write(snfc_gpios.gpio_hvdd, GPIO_HIGH_VALUE);

            rc = gpio_request(snfc_gpios.gpio_uicc_con, "snfc_uicc_con");
            {
                SNFC_DEBUG_MSG("[snfc_driver] gpio_request snfc_uicc_con fail\n");
            }
            snfc_gpio_write(snfc_gpios.gpio_uicc_con, GPIO_LOW_VALUE);

            gpio_init = 1;                
        }

    SNFC_DEBUG_MSG_LOW("[snfc_uart_control] snfc_uart_control_open - end \n");

    return rc;
}
/*
* Description : 
* Input : 
* Output : 
*/
static void snfc_uart_control_exit(void)
{
  SNFC_DEBUG_MSG_LOW("[snfc_uart_control] snfc_uart_control_exit - start \n");

  
  SNFC_DEBUG_MSG_LOW("[snfc_uart_control] snfc_uart_control_exit - end \n");
}
/*
* Description : 
* Input : 
* Output : 
*/
static int snfc_uart_control_init(void)
{
	int rc=0;

	SNFC_DEBUG_MSG_LOW("[snfc_uart_control] snfc_uart_control_init - start \n");

	/* register the device file */
	rc = misc_register(&snfc_uart_control_device);
	if (rc)
	{
		SNFC_DEBUG_MSG("[snfc_uart_control] FAIL!! can not register snfc_uart_control \n");
		return rc;
	}
	__snfc_uart_control_set_uart_status(UART_STATUS_READY);
#ifndef	CONFIG_CXD2235AGG_GJ_KDDI
	rc = gpio_request(82,"snfc_hvdd");
	if(rc)
	{
		SNFC_DEBUG_MSG("[snfc_intu_poll] gpio_request snfc_hvdd fail\n");
	}
	snfc_gpio_write(82, GPIO_HIGH_VALUE);	
#endif	
	SNFC_DEBUG_MSG_LOW("[snfc_uart_control] snfc_uart_control_init - end \n");
// 	koto_abnormal = 2;

	return 0;  	
}
/*
 * Description:
 * Input:
 * Output:
 */
static int __snfc_avail_poll_get_cen_status(void)
{
    int rc = 0;
    unsigned char read_buf = 0x00;
    int cen_status;

    rc = snfc_i2c_read(0x02, &read_buf, 1);
    if(rc)
    {
        SNFC_DEBUG_MSG("[__snfc_avail_poll_get_cen_status] snfc_i2c_read : %d \n",rc);
        return -1;
    }
    // check bit 7(locken)
    if(read_buf&0x01)
    {
        SNFC_DEBUG_MSG_LOW("[__snfc_avail_poll_get_cen_status] CEN = High (UNLOCK) \n");
        cen_status = GPIO_HIGH_VALUE;
    }
    else
    {
        SNFC_DEBUG_MSG_LOW("[__snfc_avail_poll_get_cen_status] CEN = Low (LOCK) \n");
        cen_status = GPIO_LOW_VALUE;
    }

    return cen_status;
}
static void snfc_driver_exit(void)
{
  SNFC_DEBUG_MSG_LOW("[snfc_driver] snfc_uart_control_exit - start \n");

  /* deregister the device file */
  platform_driver_unregister(&snfc_driver);
  
  SNFC_DEBUG_MSG_LOW("[snfc_driver] snfc_uart_control_exit - end \n");
}
int snfc_i2c_write(unsigned char reg, unsigned char *buf, size_t count)
{
	ssize_t rc = 0;
	unsigned char write_buf[2];
	mm_segment_t old_fs = get_fs();

	SNFC_DEBUG_MSG_LOW("[snfc_i2c] snfc_i2c_write\n");

	set_fs(KERNEL_DS);

	/*                            */
	rc = snfc_i2c_open();
	if (rc)
	{
		SNFC_DEBUG_MSG("[snfc_i2c] ERROR - snfc_i2c_open : %d \n",rc);
		__snfc_i2c_control_set_status(I2C_STATUS_READY);
		return rc;
	}

	/*                   */
	rc = snfc_i2c_set_slave_address(I2C_SNFC_SLAVE_ADDRESS);
	if (rc)
	{
		SNFC_DEBUG_MSG("[snfc_i2c] ERROR - snfc_i2c_set_slave_address : %d \n",rc);
		__snfc_i2c_control_set_status(I2C_STATUS_READY);
		return rc;
	}

	/*               */  
	memset(write_buf,0x00,2*sizeof(unsigned char));
	write_buf[0] = reg;
	write_buf[1] = *buf;

	SNFC_DEBUG_MSG_LOW("[snfc_i2c] write_buf[0][1] : 0x%02x 0x%02x \n",write_buf[0],write_buf[1]);

	/*            */    
	rc = sys_write(fd, write_buf, 2);
	if (rc < 0)
	{
		SNFC_DEBUG_MSG("[snfc_i2c] ERROR - sys_write : %d \n",rc);
		__snfc_i2c_control_set_status(I2C_STATUS_READY);
		return rc;
	}

	/*             */
	rc = snfc_i2c_release();
	if (rc)
	{
		SNFC_DEBUG_MSG("[snfc_i2c] ERROR - snfc_i2c_release : %d \n",rc);
		__snfc_i2c_control_set_status(I2C_STATUS_READY);
		return rc;
	}

	set_fs(old_fs);

	return 0;
}
/*
 * Description:
 * Input:
 * Output:
 */
static int snfc_rfs_release (struct inode *inode, struct file *fp)
{

    SNFC_DEBUG_MSG_LOW("[snfc_rfs] snfc_rfs_release - start \n");

    SNFC_DEBUG_MSG_LOW("[snfc_rfs] snfc_rfs_release - end \n");

    return 0;
}
static void snfc_avail_poll_exit(void)
{
    SNFC_DEBUG_MSG_LOW("[snfc_avail_poll] snfc_avail_poll_exit - start \n");

    /* deregister the device file */
    misc_deregister(&snfc_avail_poll_device);

    SNFC_DEBUG_MSG_LOW("[snfc_avail_poll] snfc_avail_poll_exit - end \n");
}
/*
 * Description:
 * Input:
 * Output:
 */
static int snfc_avail_poll_release (struct inode *inode, struct file *fp)
{
    int rc = 0;

    SNFC_DEBUG_MSG_LOW("[snfc_avail_poll] snfc_avail_poll_release - start \n");

    SNFC_DEBUG_MSG_LOW("[snfc_avail_poll] snfc_avail_poll_release - end \n");

    return rc;
}
static int snfc_avail_poll_init(void)
{
    int rc;

    SNFC_DEBUG_MSG_LOW("[snfc_avail_poll] snfc_avail_poll_init - start \n");

    SNFC_DEBUG_MSG_LOW("[snfc_avail_poll] snfc_avail_poll_init - end \n");

    return 0;
}
示例#13
0
/*
 * Description:
 * Input:
 * Output:
 */
static int snfc_rfs_open (struct inode *inode, struct file *fp)
{
    int rc = 0;

    SNFC_DEBUG_MSG_LOW("[snfc_rfs] snfc_rfs_open - start \n");

    SNFC_DEBUG_MSG_LOW("[snfc_rfs] snfc_rfs_open - end \n");

    return rc;
}
static int snfc_uart_control_init(void)
{
//	int rc=0;

	SNFC_DEBUG_MSG_LOW("[snfc_uart_control] snfc_uart_control_init - start \n");

	SNFC_DEBUG_MSG_LOW("[snfc_uart_control] snfc_uart_control_init - end \n");

	return 0;  	
}
示例#15
0
static int snfc_rfs_init(void)
{
    int rc = 0;

    SNFC_DEBUG_MSG_LOW("[snfc_rfs] snfc_rfs_init - start \n");

    SNFC_DEBUG_MSG_LOW("[snfc_rfs] snfc_rfs_init - end \n");

    return rc;
}
示例#16
0
/*
 * Description: Notify a change in the device status. A blocking function
 * Input: 
 * Output: Intu changed form low to high - 1, Intu changed from high to low - 0
 */
static ssize_t snfc_intu_read(struct file *pf, char *pbuf, size_t size, loff_t *pos)
{
	int rc = 0;
	int current_intu_status = GPIO_LOW_VALUE;
	//int new_intu_status = GPIO_LOW_VALUE;
	int return_val;

	SNFC_DEBUG_MSG_LOW("[snfc_intu_poll] snfc_intu_read - start \n");

	/* Parameters check*/
	if(pf == NULL || pbuf == NULL || size == !1 /*|| pos == NULL*/) //need to know meaning of pos, size is fixed to 1
	{
		SNFC_DEBUG_MSG("[snfc_intu_poll] ERROR pf = %p , buf = %p, size = %d, pos = %d\n",pf,pbuf,(int)size,(int)pos);
		return -1;    
	}

	/* Get intu status */
	current_intu_status = snfc_gpio_read(GPIO_SNFC_INTU);
	SNFC_DEBUG_MSG_LOW("[snfc_intu_poll] current intu value is %d",current_intu_status);

	intu_sig=0;
	enable_irq_wake(gpio_to_irq(GPIO_SNFC_INTU));
	enable_irq(gpio_to_irq(GPIO_SNFC_INTU));
	SNFC_DEBUG_MSG_LOW("enable_irq intu irq");
	
	rc = wait_event_interruptible(intuwq,intu_sig);	

	if(intu_sig==0)
	{
		disable_irq_nosync(gpio_to_irq(GPIO_SNFC_INTU));
		disable_irq_wake(gpio_to_irq(GPIO_SNFC_INTU));		
		return_val = 1;
	}
	else
		return_val = 0;

	intu_sig=0;
	
	SNFC_DEBUG_MSG_LOW("snfc_intu_poll] wait_event_interruptible(),rc =%d !!!\n",rc);

	//current_intu_status = snfc_gpio_read(GPIO_SNFC_INTU);

	rc = copy_to_user((void*)pbuf, (void*)&return_val, size);
	if(rc)
	{
		SNFC_DEBUG_MSG("[snfc_intu_poll] ERROR -  copy_to_user \n");
		return rc;
	}

	SNFC_DEBUG_MSG_LOW("[snfc_intu_poll] snfc_intu_read - end \n");

	return size;
}
示例#17
0
static void snfc_intu_exit(void)
{
	SNFC_DEBUG_MSG_LOW("[snfc_intu_poll] snfc_intu_poll_exit - start \n");

	disable_irq_nosync(gpio_to_irq(GPIO_SNFC_INTU));
	disable_irq_wake(gpio_to_irq(GPIO_SNFC_INTU));  

	/* deregister the device file */
	misc_deregister(&snfc_intu_device);

	SNFC_DEBUG_MSG_LOW("[snfc_intu_poll] snfc_intu_poll_exit - end \n");
}
/*
 * Description:
 * Input:
 * Output:
 */
static ssize_t snfc_avail_poll_read(struct file *pf, char *pbuf, size_t size, loff_t *pos)
{
    //unsigned char read_buf = 0x00;
    int loop = 1;
    int available_poll = -1;
    int rc = -1;
    int rfs_status = -1, cen_status = -1, uart_status = -1;

    SNFC_DEBUG_MSG_LOW("[snfc_avail_poll] snfc_avail_poll_read - start \n");

    /* Check parameters */
    if( NULL == pf || NULL == pbuf /*|| size == NULL*/ /*|| pos == NULL*/)
    {
        SNFC_DEBUG_MSG("[snfc_avail_poll] file error pf = %p, pbuf = %p, size = %d, pos = %d\n", pf, pbuf, (int)size,(int)pos);
        return -1;
    }

    do{
               rc = 0;
         cen_status = __snfc_avail_poll_get_cen_status();
               uart_status = __snfc_uart_control_get_uart_status();
         rfs_status = __snfc_avail_poll_get_rfs_status();

         SNFC_DEBUG_MSG_MIDDLE("[snfc_avail_poll] current rfs_status : %d, cen_status : %d, uart_status : %d \n",rfs_status, cen_status, uart_status);
         if(rfs_status == GPIO_HIGH_VALUE && cen_status == GPIO_HIGH_VALUE && uart_status != UART_STATUS_FOR_FELICA)
            {
                available_poll = 1;
                rc = copy_to_user(pbuf, &available_poll, size);

             SNFC_DEBUG_MSG_LOW("[snfc_avail_poll] snfc_avail_poll_read stop, polling available!! \n");
                return 1;
            } else {
                snfcpollavail_sig = 0;
            }
            if(koto_state == 10)
                break;

         if( rfs_status != GPIO_HIGH_VALUE /*&& cen_status == GPIO_HIGH_VALUE && uart_status != UART_STATUS_FOR_FELICA*/){
                mdelay(1);
            } else {
                rc = wait_event_interruptible( snfcpollavailwq, snfcpollavail_sig );
            }

            if ( rc == -ERESTARTSYS)
                return -1;
     }while(loop == 1 && rc >= 0);


    SNFC_DEBUG_MSG_LOW("[snfc_avail_poll] snfc_avail_poll_read - end \n");

    return 1;
}
示例#19
0
static irqreturn_t snfc_int_low_isr(int irq, void *dev_id)
{
	SNFC_DEBUG_MSG_LOW("[snfc_intu_poll] snfc_int_low_isr - start \n");
	disable_irq_nosync(gpio_to_irq(GPIO_SNFC_INTU));
	disable_irq_wake(gpio_to_irq(GPIO_SNFC_INTU));  
	/* Wake up waiting readers */
	wake_up(&intuwq);
	intu_sig = 1;

	SNFC_DEBUG_MSG_LOW("[snfc_intu_poll] snfc_int_low_isr - end \n");

	return IRQ_HANDLED;
}
/*
* Description:
* Input:
* Output:
*/
static int snfc_cen_open (struct inode *inode, struct file *fp)
{
    if(1 == isopen)
    {
        SNFC_DEBUG_MSG_LOW("[snfc_cen] snfc_cen_open - already open \n");
        return 0;
    }
    else
    {
        SNFC_DEBUG_MSG_LOW("[snfc_cen] snfc_cen_open - start \n");
        isopen = 1;
    }
    return 0;
}
/*
 * Description:
 * Input:
 * Output:
 */
static ssize_t snfc_cen_read(struct file *fp, char *buf, size_t count, loff_t *pos)
{
    //struct snfc_i2c_dev *snfc_i2c_dev = fp->private_data;

    unsigned char read_buf = 0x00;
    char snfc_cen = -1, rc = -1;

  SNFC_DEBUG_MSG_LOW("[snfc_cen] snfc_cen_read - start \n");

/* Check error */
  if(NULL == fp || NULL == buf || 1 != count || NULL == pos)
  {
    SNFC_DEBUG_MSG("[snfc_cen][read] parameter ERROR \n");
    return -1;
  }

  mutex_lock(&nfc_cen_mutex);
  rc = snfc_i2c_read(0x02, &read_buf, 1, snfc_i2c_dev.client);
  mutex_unlock(&nfc_cen_mutex);

  if(rc)
  {
    SNFC_DEBUG_MSG("[snfc_cen][read] snfc_i2c_read : %d \n",rc);
    return -1;
  }

  // check bit 7(locken)
  if(read_buf&0x01)  // unlock
  {
    SNFC_DEBUG_MSG_MIDDLE("[snfc_cen][read] CEN = High (UNLOCK) \n");
    snfc_cen = (char)GPIO_HIGH_VALUE;
  }
  else  // lock
  {
    SNFC_DEBUG_MSG_MIDDLE("[snfc_cen][read] CEN = Low (LOCK) \n");
    snfc_cen = (char)GPIO_LOW_VALUE;
  }

  rc = copy_to_user(buf, &snfc_cen, count);
  if(rc)
  {
    SNFC_DEBUG_MSG("[snfc_cen][read] ERROR - copy_from_user \n");
    return -1;
  }

  SNFC_DEBUG_MSG_LOW("[snfc_cen][read] snfc_cen_read - end \n");

  return 1;
}
int snfc_uart_control_probe(struct device_node *np)
{
    int rc;

    snfc_gpios.gpio_hsel = of_get_named_gpio_flags(np, "sony,hsel-gpio", 0, NULL);
    snfc_gpios.gpio_pon = of_get_named_gpio_flags(np, "sony,pon-gpio", 0, NULL);
    snfc_gpios.gpio_hvdd = of_get_named_gpio_flags(np, "sony,hvdd-gpio", 0, NULL);
    snfc_gpios.gpio_uicc_con = of_get_named_gpio_flags(np, "sony,uicc_con", 0, NULL);
    //SNFC_DEBUG_MSG("[snfc_driver] of_get_named_gpio_flags gpio_hsel %d gpio_pon %d gpio_hvdd %d\n",
    //    snfc_gpios.gpio_hsel,snfc_gpios.gpio_pon,snfc_gpios.gpio_hvdd );     

    rc = gpio_request(snfc_gpios.gpio_hsel, "snfc_hsel");
    if (rc)
    {
        SNFC_DEBUG_MSG("[snfc_driver] gpio_request snfc_hsel fail\n");
    }
    rc = gpio_request(snfc_gpios.gpio_pon, "snfc_pon");
    if (rc)
    {
        SNFC_DEBUG_MSG("[snfc_driver] gpio_request snfc_pon fail\n");
    }

    SNFC_DEBUG_MSG_LOW("[snfc_driver] GPIO_SNFC_PON = %d, GPIO_SNFC_HSEL = %d\n",
        snfc_gpio_read(snfc_gpios.gpio_pon),snfc_gpio_read(snfc_gpios.gpio_hsel) ); 

    /* register the device file */
    rc = misc_register(&snfc_uart_control_device);
    if (rc)
    {
        SNFC_DEBUG_MSG("[snfc_driver] FAIL!! can not register snfc_uart_control \n");
        return rc;
    }
    return rc;
}
示例#23
0
int snfc_i2c_open (void)
{
	mm_segment_t old_fs = get_fs();
	int i;

	SNFC_DEBUG_MSG_LOW("[snfc_i2c] snfc_i2c_open\n");

	for(i=0; i<I2C_STATUS_LOOP_MAX_CNT; i++)
	{
		if(__snfc_i2c_control_get_status() != I2C_STATUS_FOR_FELICA)
			break;
		usleep(100);
	}
	//                                                                    
	//             
	
	__snfc_i2c_control_set_status(I2C_STATUS_FOR_NFC);

	set_fs(KERNEL_DS);
	fd = sys_open("/dev/i2c-0", O_RDWR|O_NONBLOCK, 0);
	//                                                       
	if (fd < 0)
	{
		SNFC_DEBUG_MSG("[snfc_i2c] ERROR - snfc_i2c_open (/dev/snfc_i2c): %d \n", fd);
		__snfc_i2c_control_set_status(I2C_STATUS_READY);
		return fd;
	}

	set_fs(old_fs);

	return 0;
}
/*
* Description : 
* Input : 
* Output : 
*/
static int snfc_uart_control_release (struct inode *inode, struct file *fp)
{
	if(isopen_snfcuartcontrol == 0)
	{
		SNFC_DEBUG_MSG("[snfc_uart_control] snfc_uart_control_release - not open \n");
		return -1;
	}

	SNFC_DEBUG_MSG_LOW("[snfc_uart_control] snfc_uart_control_release - start \n");

	isopen_snfcuartcontrol = 0;

	SNFC_DEBUG_MSG_LOW("[snfc_uart_control] snfc_uart_control_release - end \n");

	return 0;
}
示例#25
0
/*
 * Description:
 * Input:
 * Output: RFS low : 1 RFS high : 0
 */
static ssize_t snfc_rfs_read(struct file *pf, char *pbuf, size_t size, loff_t *pos)
{
    int rc = 0;
    int getvalue = GPIO_LOW_VALUE;
    int rfonoff;

    SNFC_DEBUG_MSG_LOW("[snfc_rfs] snfc_rfs_read - start \n");

    /* Check Parameters */
    if(pf == NULL || pbuf == NULL /*|| size == NULL*/ /*||pos == NULL*/)
    {
        SNFC_DEBUG_MSG("[snfc_rfs] parameters ERROR pf = %p, pbuf = %p, size = %d, pos = %p\n",pf,pbuf,(int)size,pos);
        return -1;
    }

    /* Get GPIO value */
    getvalue = snfc_gpio_read(snfc_gpios.gpio_rfs);

    if((getvalue != GPIO_LOW_VALUE)&&(getvalue != GPIO_HIGH_VALUE))
    {
        SNFC_DEBUG_MSG("[snfc_rfs] ERROR - getvalue is out of range \n");
        return -2;
    }

    /* Copy value to user memory */
    //getvalue = getvalue ? GPIO_LOW_VALUE: GPIO_HIGH_VALUE;
    SNFC_DEBUG_MSG_LOW("[snfc_rfs] RFS pin status : %d \n", getvalue);

    if(getvalue)
        rfonoff = 0;
    else
        rfonoff = 1;

    SNFC_DEBUG_MSG_LOW("[snfc_rfs] rf status : %d \n", rfonoff);

    rc = copy_to_user((void*)pbuf, (void*)&rfonoff, size);
    if(rc)
    {
        SNFC_DEBUG_MSG("[snfc_rfs] ERROR -  copy_to_user \n");
        return rc;
    }

    SNFC_DEBUG_MSG_LOW("[snfc_rfs] snfc_rfs_read - end \n");

    return size;
}
static int snfc_driver_init(void)
{
	int rc=0;

	SNFC_DEBUG_MSG_LOW("[snfc_driver] snfc_uart_control_init - start \n");

    rc = platform_driver_register(&snfc_driver);
	if (rc)
	{
		SNFC_DEBUG_MSG("[snfc_driver] FAIL!! can not register snfc_uart_con_driver \n");
		return rc;
	}  

	SNFC_DEBUG_MSG_LOW("[snfc_driver] snfc_uart_control_init - end \n");

	return 0;  	
}
static ssize_t snfc_avail_poll_read(struct file *pf, char *pbuf, size_t size, loff_t *pos)
{
    //unsigned char read_buf = 0x00;
    int loop = 1;
    int available_poll = -1;
    int rc = -1;
    int rfs_status = -1, cen_status = -1, uart_status = -1;
    int loop_cnt;
    //unsigned char restart_value=0;

    SNFC_DEBUG_MSG_LOW("[snfc_avail_poll] snfc_avail_poll_read - start \n");

    /* Check parameters */
    if( NULL == pf || NULL == pbuf /*|| size == NULL*/ /*|| pos == NULL*/)
    {
        SNFC_DEBUG_MSG("[snfc_avail_poll] file error pf = %p, pbuf = %p, size = %d, pos = %d\n", pf, pbuf, (int)size,(int)pos);
        return -1;
    }

    loop_cnt=0;

    do{
        loop_cnt++;
        rfs_status = __snfc_avail_poll_get_rfs_status();
        cen_status = __snfc_avail_poll_get_cen_status();
        uart_status = __snfc_uart_control_get_uart_status();
        if(loop_cnt == 1000)
        {
            SNFC_DEBUG_MSG_MIDDLE("[snfc_avail_poll] current rfs_status : %d, cen_status : %d, uart_status : %d \n",rfs_status, cen_status, uart_status);
            loop_cnt = 0;
        }
        if(rfs_status == GPIO_HIGH_VALUE && cen_status == GPIO_HIGH_VALUE && uart_status != UART_STATUS_FOR_FELICA)
            break;
        if(koto_abnormal == 10)
            break;
        msleep(1);
    }while(loop);

    available_poll = 1;

    rc = copy_to_user(pbuf, &available_poll, size);

    SNFC_DEBUG_MSG_LOW("[snfc_avail_poll] snfc_avail_poll_read - end \n");

    return 1;
}
示例#28
0
/*
 * Description: snfc intu release
 * Input: 
 * Output: 
 */
static int snfc_intu_release (struct inode *inode, struct file *fp)
{
	SNFC_DEBUG_MSG_LOW("[snfc_intu_poll] felica_rfs_release - start \n");	
	if(isopen_snfcintu == 0)
	{
		#ifdef FEATURE_DEBUG_LOW 
		SNFC_DEBUG_MSG("[snfc_intu_poll] snfc_intu_release - not open \n");
		#endif
		return -1;
	}

	free_irq(gpio_to_irq(GPIO_SNFC_INTU), NULL);

	isopen_snfcintu = 0;
	SNFC_DEBUG_MSG_LOW("[snfc_intu_poll] snfc_intu_release - end \n");

	return 0;
}
static int snfc_avail_poll_init(void)
{
    int rc;

    SNFC_DEBUG_MSG_LOW("[snfc_avail_poll] snfc_avail_poll_init - start \n");

    /* Register the device file */
    rc = misc_register(&snfc_avail_poll_device);
    if (rc < 0)
    {
        SNFC_DEBUG_MSG("[snfc_avail_poll] FAIL!! can not register snfc_avail_poll \n");
        return rc;
    }

    SNFC_DEBUG_MSG_LOW("[snfc_avail_poll] snfc_avail_poll_init - end \n");

    return 0;
}
/*
 * Description:
 * Input:
 * Output:
 */
static int snfc_cen_release (struct inode *inode, struct file *fp)
{


    if(0 == isopen)
    {
        SNFC_DEBUG_MSG_LOW("[snfc_cen] snfc_cen_release - not open \n");

        return -1;
    }
    else
    {
        SNFC_DEBUG_MSG_LOW("[snfc_cen] snfc_cen_release - start \n");

        isopen = 0;
    }

    return 0;
}