コード例 #1
0
static void snfc_hw_rev_exit(void)
{
    SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] snfc_pon_exit - start \n");

    /* Deregister the device file */
    misc_deregister(&snfc_hw_rev_device);

    SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] snfc_pon_exit - end \n");
}
コード例 #2
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;
}
コード例 #3
0
/*
* Description :
* Input :
* Output :
*/
static int snfc_hw_rev_open (struct inode *inode, struct file *fp)
{
    int rc = 0;

    SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] snfc_hw_rev_open - start \n");

    if(isopen_snfchwrev == 1)
    {
        SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] snfc_hw_rev_open - already open \n");
        return 0;
    }
    SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] snfc_hw_rev_open - end \n");

    isopen_snfchwrev = 1;

    return rc;
}
コード例 #4
0
/*
* Description :
* Input :
* Output :
*/
static int snfc_hw_rev_release (struct inode *inode, struct file *fp)
{
    SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] snfc_hw_rev_release - start \n");

    if(isopen_snfchwrev ==0)
    {
        SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] snfc_hw_rev_release - not open \n");
        return -1;
    }

    SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] snfc_hw_rev_release - end \n");

    isopen_snfchwrev = 0;

    return 0;

}
コード例 #5
0
static int snfc_hw_rev_init(void)
{
    int rc = 0;

    SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] snfc_hw_rev_init - start \n");

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

    SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] snfc_hw_rev_init - end \n");

    return 0;
}
コード例 #6
0
void __snfc_i2c_control_set_status(_e_snfc_i2c_status i2c_status)
{
//                                                  

	g_i2c_status = i2c_status;

	SNFC_DEBUG_MSG_MIDDLE("[snfc_i2c_control] i2c status %d -> %d\n", current_status, g_i2c_status );

	return;
}
/*
* Description : open uart collision control
* Input : 
* Output : 
*/
void __snfc_uart_control_set_uart_status(_e_snfc_uart_status uart_status)
{
	_e_snfc_uart_status current_status = g_uartcollisoncontrol;
	
	if(current_status == uart_status)
		return;
	
	g_uartcollisoncontrol = uart_status;
	SNFC_DEBUG_MSG_MIDDLE("[snfc_uart_control] uart status %d -> %d\n", current_status, g_uartcollisoncontrol );

	return;
}
コード例 #8
0
/*
 * 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;
}
コード例 #9
0
/*
* Description : open uart collision control
* Input : 
* Output : 
*/
void __snfc_uart_control_set_uart_status(_e_snfc_uart_status uart_status)
{
	_e_snfc_uart_status current_status = g_uartcollisoncontrol;
	
	if(current_status == uart_status)
		return;

	if(current_status > UART_STATUS_READY && uart_status > UART_STATUS_READY)
		SNFC_DEBUG_MSG("[snfc_uart_control] current status %d, %d device tries to use uart",current_status,uart_status);
	
	g_uartcollisoncontrol = uart_status;
	SNFC_DEBUG_MSG_MIDDLE("[snfc_uart_control] uart status %d -> %d\n", current_status, g_uartcollisoncontrol );

	return;
}
コード例 #10
0
/*
* Description : open uart collision control
* Input :
* Output :
*/
void __snfc_uart_control_set_uart_status(_e_snfc_uart_status uart_status)
{
    _e_snfc_uart_status current_status = g_uartcollisoncontrol;

       if ( current_status == UART_STATUS_FOR_FELICA && uart_status != UART_STATUS_FOR_FELICA )
              snfc_avali_poll_felica_status();

    if(current_status == uart_status)
        return;

    g_uartcollisoncontrol = uart_status;
    SNFC_DEBUG_MSG_MIDDLE("[snfc_uart_control] uart status %d -> %d\n", current_status, g_uartcollisoncontrol );

    return;
}
コード例 #11
0
void __snfc_i2c_control_set_status(_e_snfc_i2c_status i2c_status)
{
#ifdef FEATURE_DEBUG_MIDDLE
    _e_snfc_i2c_status current_status = g_i2c_status;
#endif
    g_i2c_status = i2c_status;

#ifdef FEATURE_DEBUG_MIDDLE
    if(current_status > I2C_STATUS_READY && g_i2c_status > I2C_STATUS_READY)
        SNFC_DEBUG_MSG("[snfc_i2c_control] i2c status %d, but other device tries to use i2c \n", current_status);
#endif

    SNFC_DEBUG_MSG_MIDDLE("[snfc_i2c_control] i2c status %d -> %d\n", current_status, g_i2c_status );

    return;
}
コード例 #12
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;
}
コード例 #13
0
/*
 * Description:
 * Input:
 * Output:
 */
static ssize_t snfc_cen_write(struct file *fp, const char *buf, size_t count, loff_t *pos)
{

    //struct snfc_i2c_dev *snfc_i2c_dev = fp->private_data;

    unsigned char write_buf = 0x00/*, read_buf = 0x00*/;
    int rc = -1;

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

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

    /* copy from user data */
    rc = copy_from_user(&write_buf, buf, count);
    if(rc)
    {
        SNFC_DEBUG_MSG("[snfc_cen][write] ERROR - copy_from_user \n");
        return -1;
    }

    SNFC_DEBUG_MSG_LOW("[snfc_cen][write] copy_from_user(%d) \n",*buf);

    /* check user data */
    if(*buf == 1)
    {
        SNFC_DEBUG_MSG_MIDDLE("[snfc_cen][write] CEN = High (UNLOCK) \n");

        write_buf = 0x81; // set unlock
        mutex_lock(&nfc_cen_mutex);
        rc = snfc_i2c_write(0x02, &write_buf, 1, snfc_i2c_dev.client);
        mutex_unlock(&nfc_cen_mutex);
        mdelay(2);
        snfc_avali_poll_cen_status(GPIO_HIGH_VALUE);
    }
    else if(*buf == 0)
    {
        SNFC_DEBUG_MSG_MIDDLE("[snfc_cen][write] CEN = Low (LOCK) \n");

        write_buf = 0x80; // set lock
        mutex_lock(&nfc_cen_mutex);
        rc = snfc_i2c_write(0x02, &write_buf, 1, snfc_i2c_dev.client);
        mutex_unlock(&nfc_cen_mutex);
        mdelay(2);
        snfc_avali_poll_cen_status(GPIO_LOW_VALUE);
    }
    else if(*buf == 2)
    {
        write_buf = 0x80; // set lock
        mutex_lock(&nfc_cen_mutex);
        rc = snfc_i2c_write(0x02, &write_buf, 1, snfc_i2c_dev.client);
        mutex_unlock(&nfc_cen_mutex);
        SNFC_DEBUG_MSG_MIDDLE("[snfc_cen][write] CEN = Low & Hgh(LOCK) \n");

        mdelay(1);

        write_buf = 0x81; // set unlock
        mutex_lock(&nfc_cen_mutex);
        rc = snfc_i2c_write(0x02, &write_buf, 1, snfc_i2c_dev.client);
        mutex_unlock(&nfc_cen_mutex);
        SNFC_DEBUG_MSG_MIDDLE("[snfc_cen][write] CEN = Low & Hgh(UNLOCK) \n");
    }

    SNFC_DEBUG_MSG_LOW("[snfc_cen][write] snfc_cen_write - end \n");

    return 1;
}
コード例 #14
0
/*
* Description : 
* Input : 
* Output : 
*/
static long snfc_uart_control_ioctl(struct file *flip, unsigned int cmd, unsigned long arg)
{
	//ioctl_buf *k_buf;
	//int i,err;
	int size;
	_e_snfc_uart_status current_status;
	int autopoll_wait_cnt;
	int break_cnt;
	unsigned char write_buf = 0x00/*, read_buf = 0x00*/;
	int rc =0;
	
	size = _IOC_SIZE(cmd);
	SNFC_DEBUG_MSG_MIDDLE("[snfc_uart_control] snfc_uart_control_ioctl - start,cmd =%d\n", cmd);
		
	current_status = __snfc_uart_control_get_uart_status();
	if( current_status == UART_STATUS_FOR_FELICA )
	{
		SNFC_DEBUG_MSG("[snfc_uart_control] snfc_uart_control_ioctl, UART is used to FeliCa\n");
		return -1;
	}

	__snfc_uart_control_set_uart_status(UART_STATUS_FOR_NFC);	

	switch(cmd)
	{
		case IOCTL_SNFC_START_SETTING :
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_SETTING - start\n");
			if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
				break;
			snfc_gpio_write(GPIO_SNFC_HSEL, GPIO_HIGH_VALUE);			
			snfc_gpio_write(GPIO_SNFC_PON, GPIO_HIGH_VALUE);
			mdelay(10); 
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_SETTING - end\n");
			break;
			
		case IOCTL_SNFC_START_AUTOPOLL :
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_AUTOPOLL - start\n");
			autopoll_wait_cnt = 0;
			break_cnt = 0;
			if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
				break;
			snfc_gpio_write(GPIO_SNFC_HSEL, GPIO_HIGH_VALUE);	
			snfc_gpio_write(GPIO_SNFC_PON, GPIO_HIGH_VALUE);

			#ifndef CONFIG_CXD2235AGG_GJ_KDDI	
				//SNFC_DEBUG_MSG("[snfc_uart_control] !!!! RFS disable start !!!!\n");
				disable_irq(gpio_to_irq(gpio_rfs));
			#endif
			
			mdelay(10);
			autopoll_status = 1;		
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_AUTOPOLL - end\n");
			break;
			
		case IOCTL_SNFC_START_RW :
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_RW - start\n");
			if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
				break;
			snfc_gpio_write(GPIO_SNFC_HSEL, GPIO_HIGH_VALUE);				
			snfc_gpio_write(GPIO_SNFC_PON, GPIO_HIGH_VALUE);
			mdelay(10);
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_RW - end\n");
			break;
			
		case IOCTL_SNFC_START_TARGET :
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_TARGET - start\n");
			if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
				break;	
			snfc_gpio_write(GPIO_SNFC_HSEL, GPIO_HIGH_VALUE);				
			snfc_gpio_write(GPIO_SNFC_PON, GPIO_HIGH_VALUE);
			if(GPIO_HIGH_VALUE == snfc_gpio_read(gpio_rfs))
				mdelay(10);
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_TARGET - end\n");
			break;
			
		case IOCTL_SNFC_START_INTU :
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_INTU - start\n");
			if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
				break;
			snfc_gpio_write(GPIO_SNFC_HSEL, GPIO_HIGH_VALUE);				
			snfc_gpio_write(GPIO_SNFC_PON, GPIO_HIGH_VALUE);
			//mdelay(10);
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_INTU - end\n");
			break;
			
		case IOCTL_SNFC_START_WAITSIMBOOT:
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_WAITSIMBOOT - start\n");
			if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
				break;
			snfc_gpio_write(GPIO_SNFC_HSEL, GPIO_HIGH_VALUE);	
			snfc_gpio_write(GPIO_SNFC_PON, GPIO_HIGH_VALUE);
			mdelay(10);
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_WAITSIMBOOT - end\n");		
			break;
			
		case IOCTL_SNFC_HSEL_UP:
			forced_hsel_up_flag = 1;
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_hsel_up\n");	
			snfc_gpio_write(GPIO_SNFC_HSEL, GPIO_HIGH_VALUE);	
			break;
			
		case IOCTL_SNFC_HSEL_DOWN:	
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_hsel_down\n");	
			snfc_gpio_write(GPIO_SNFC_HSEL, GPIO_LOW_VALUE);
			forced_hsel_up_flag = 0;
			if(forced_pon_up_flag == 0 && forced_hsel_up_flag == 0)
				__snfc_uart_control_set_uart_status(UART_STATUS_READY);
			break;
			
		case IOCTL_SNFC_PON_UP:
			forced_pon_up_flag = 1;
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_pon_up\n");	
			snfc_gpio_write(GPIO_SNFC_PON, GPIO_HIGH_VALUE);
			mdelay(10);
			break;
			
		case IOCTL_SNFC_PON_DOWN:	
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_pon_down\n");	
			forced_pon_up_flag = 0;
			snfc_gpio_write(GPIO_SNFC_PON, GPIO_LOW_VALUE);	
			if(forced_pon_up_flag == 0 && forced_hsel_up_flag == 0)
				__snfc_uart_control_set_uart_status(UART_STATUS_READY);
			break;

		case IOCTL_SNFC_BOOT_CEN_HI:		//Kernel init only
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_boot_hi\n");
			SNFC_DEBUG_MSG_MIDDLE("[snfc_uart_control] CEN = High (UNLOCK) \n");
			write_buf = 0x81; // set unlock  
			//mutex_lock(&nfc_cen_mutex);	
			rc = snfc_i2c_write(0x02, &write_buf, 1);
			//mutex_unlock(&nfc_cen_mutex);   
			break;
			
		case IOCTL_SNFC_BOOT_CEN_LO:	//Kernel init only
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_boot_low\n");
			SNFC_DEBUG_MSG_MIDDLE("[snfc_uart_control] CEN = Low (LOCK) \n");
			write_buf = 0x80; // set lock
			//mutex_lock(&nfc_cen_mutex);
			rc = snfc_i2c_write(0x02, &write_buf, 1);
			//mutex_unlock(&nfc_cen_mutex);  			
			break;

		case IOCTL_SNFC_HVDD_DOWN_SET:
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_hvdd_down\n");
			while(koto_abnormal == 10)
			{
				if(snfc_poweroff_flag == 1)
				{
					break;
				}
				usleep(100);
			}		
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_hvdd_down HVDD %d\n",snfc_gpio_read(86));
			break;
			
		case IOCTL_SNFC_END :
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_END - start\n");
			if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
			{
				SNFC_DEBUG_MSG("[snfc_uart_control] pon & hsel forced up!! pon and/or sel will keep high\n");
				break;
			}
			if(current_status != UART_STATUS_FOR_NFC)
			{
				SNFC_DEBUG_MSG("[snfc_uart_control] IOCTL_SNFC_END, UART is not used to NFC\n");
				//return -2;
			}				
			snfc_gpio_write(GPIO_SNFC_HSEL, GPIO_LOW_VALUE);
			snfc_gpio_write(GPIO_SNFC_PON, GPIO_LOW_VALUE);	
			__snfc_uart_control_set_uart_status(UART_STATUS_READY);
			
			#ifndef CONFIG_CXD2235AGG_GJ_KDDI	
				if(autopoll_status == 1) 
				{
					//SNFC_DEBUG_MSG("[snfc_uart_control] !!!! RFS disable end !!!!\n");
					enable_irq(gpio_to_irq(gpio_rfs));
				}
			#endif
			
			autopoll_status = 0;
			SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_END - end (hsel low)(pon low)\n");
			break;			
			
	}
	SNFC_DEBUG_MSG_LOW("[snfc_uart_control] snfc_uart_control_ioctl - end\n");

	return 0;
}
コード例 #15
0
/*
* Description :
* Input :
* Output :
*/
static ssize_t snfc_hw_rev_read(struct file *pf, char *pbuf, size_t size, loff_t *pos)
{
    int rc = 0;
    int rev = lge_get_board_revno();
    int retrev;

    switch(rev)
    {
        case HW_REV_A:
            SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] read hw as rev.a\n");
            retrev = 'a';
            break;
        case HW_REV_B:
            SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] read hw as rev.b\n");
            retrev = 'b';
            break;
        case HW_REV_C:
            SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] read hw as rev.c\n");
            retrev = 'c';
            break;
        case HW_REV_D:
            SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] read hw as rev.d\n");
            retrev = 'd';
            break;
        case HW_REV_E:
            SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] read hw as rev.e\n");
            retrev = 'e';
            break;
        case HW_REV_F:
            SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] read hw as rev.f\n");
            retrev = 'f';
            break;
        case HW_REV_G:
            SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] read hw as rev.g\n");
            retrev = 'g';
            break;
        case HW_REV_H:
            SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] read hw as rev.h\n");
            retrev = 'g';
            break;
        case HW_REV_1_0:
            SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] read hw as rev.1.0\n");
            retrev = '0';
            break;
        case HW_REV_1_1:
            SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] read hw as rev.1.1\n");
            retrev = '1';
            break;
        case HW_REV_1_2:
            SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] read hw as rev.1.2\n");
            retrev = '2';
            break;
        default:
            SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] read hw as unknown\n");
    }

    rc = copy_to_user((void*)pbuf, (void*)&retrev, size);
    if(rc)
    {
        SNFC_DEBUG_MSG_MIDDLE("[snfc_hw_rev] ERROR -  copy_to_user \n");
        return rc;
    }

    return size;
}
コード例 #16
0
/*
* Description :
* Input :
* Output :
*/
static long snfc_uart_control_ioctl(struct file *flip, unsigned int cmd, unsigned long arg)
{
    //ioctl_buf *k_buf;
    //int i,err;
    int size;
    _e_snfc_uart_status current_status;
       int break_cnt;
    int autopoll_wait_cnt;
    unsigned char write_buf = 0x00/*, read_buf = 0x00*/;
    int rc =0;
    int snfcbootmode;

    size = _IOC_SIZE(cmd);
    SNFC_DEBUG_MSG_MIDDLE("[snfc_uart_control] snfc_uart_control_ioctl - start,cmd =%d\n", cmd);

    if(cmd == IOCTL_SNFC_READ_BOOTMODE){
            snfcbootmode = lge_get_boot_mode();
            SNFC_DEBUG_MSG("[snfc_uart_control] read boot mode %d \n",snfcbootmode);
             // 0 : NORMAL, 1 : CHARGER, 2 : CHARGERLOGO, 3 : FACTORY, 4 : FACTORY2, 5 : PIFBOOT, 6 : PIFBOOT2, 7 : MINIOS
            return snfcbootmode;
    }
    current_status = __snfc_uart_control_get_uart_status();
    if( current_status == UART_STATUS_FOR_FELICA )
    {
        SNFC_DEBUG_MSG("[snfc_uart_control] snfc_uart_control_ioctl, UART is used to FeliCa\n");
        return -1;
    }

    __snfc_uart_control_set_uart_status(UART_STATUS_FOR_NFC);

    switch(cmd)
    {
        case IOCTL_SNFC_START_SETTING :
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_SETTING - start\n");
            if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
                break;
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_HIGH_VALUE);
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_HIGH_VALUE);
            mdelay(10);
                  SNFC_DEBUG_MSG_LOW("[snfc_uart_control] hsel %d, pon %d\n",
                    snfc_gpios.gpio_hsel,snfc_gpios.gpio_pon);
                  SNFC_DEBUG_MSG_LOW("[snfc_driver] GPIO_SNFC_PON = %d, GPIO_SNFC_HSEL = %d, GPIO_SNFC_HBDD = %d\n",
                    snfc_gpio_read(snfc_gpios.gpio_pon),snfc_gpio_read(snfc_gpios.gpio_hsel),snfc_gpio_read(snfc_gpios.gpio_hvdd)  );
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_SETTING - end\n");
            break;

        case IOCTL_SNFC_START_AUTOPOLL :
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_AUTOPOLL - start\n");
            autopoll_wait_cnt = 0;
            break_cnt = 0;
            if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
                break;
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_HIGH_VALUE);
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_HIGH_VALUE);
            mdelay(10);
            autopoll_status = 1;
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_AUTOPOLL - end\n");
            break;

        case IOCTL_SNFC_START_RW :
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_RW - start\n");
            if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
                break;
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_HIGH_VALUE);
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_HIGH_VALUE);
            mdelay(10);
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_RW - end\n");
            break;

        case IOCTL_SNFC_START_TARGET :
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_TARGET - start\n");
            if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
                break;
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_HIGH_VALUE);
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_HIGH_VALUE);
            if(GPIO_HIGH_VALUE == snfc_gpio_read(snfc_gpios.gpio_rfs))
                mdelay(10);
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_TARGET - end\n");
            break;

        case IOCTL_SNFC_START_INTU :
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_INTU - start\n");
            if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
                break;
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_HIGH_VALUE);
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_HIGH_VALUE);
            //mdelay(10);
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_INTU - end\n");
            break;

        case IOCTL_SNFC_START_WAITSIMBOOT:
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_WAITSIMBOOT - start\n");
            if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
                break;
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_HIGH_VALUE);
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_HIGH_VALUE);
            mdelay(10);
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_START_WAITSIMBOOT - end\n");
            break;

        case IOCTL_SNFC_HSEL_UP:
            forced_hsel_up_flag = 1;
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_hsel_up\n");
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_HIGH_VALUE);
            break;

        case IOCTL_SNFC_HSEL_DOWN:
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_hsel_down\n");
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_LOW_VALUE);
            forced_hsel_up_flag = 0;
            if(forced_pon_up_flag == 0 && forced_hsel_up_flag == 0)
                __snfc_uart_control_set_uart_status(UART_STATUS_READY);
            break;

        case IOCTL_SNFC_PON_UP:
            forced_pon_up_flag = 1;
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_pon_up\n");
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_HIGH_VALUE);
            mdelay(10);
            break;

        case IOCTL_SNFC_PON_DOWN:
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_pon_down\n");
            forced_pon_up_flag = 0;
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_LOW_VALUE);
            if(forced_pon_up_flag == 0 && forced_hsel_up_flag == 0)
                __snfc_uart_control_set_uart_status(UART_STATUS_READY);
            break;

        case IOCTL_SNFC_BOOT_CEN_HI:        //Kernel init only
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_boot_hi\n");
            SNFC_DEBUG_MSG_MIDDLE("[snfc_uart_control] CEN = High (UNLOCK) \n");
            write_buf = 0x81; // set unlock
            //mutex_lock(&nfc_cen_mutex);
            rc = snfc_i2c_write(0x02, &write_buf, 1, snfc_i2c_dev.client);
            //mutex_unlock(&nfc_cen_mutex);
            break;

        case IOCTL_SNFC_BOOT_CEN_LO:    //Kernel init only
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] ioctl_snfc_boot_low\n");
            SNFC_DEBUG_MSG_MIDDLE("[snfc_uart_control] CEN = Low (LOCK) \n");
            write_buf = 0x80; // set lock
            //mutex_lock(&nfc_cen_mutex);
            rc = snfc_i2c_write(0x02, &write_buf, 1, snfc_i2c_dev.client);
            //mutex_unlock(&nfc_cen_mutex);
            break;

           case IOCTL_SNFC_HVDD_DOWN_SET:
                 SNFC_DEBUG_MSG("snfc_uart_control] before HVDD Down\n");
                 snfc_hvdd_wait_rfs_low();
                 break;

        case IOCTL_SNFC_END :
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_END - start\n");
            if(forced_pon_up_flag == 1 || forced_hsel_up_flag == 1)
            {
                SNFC_DEBUG_MSG("[snfc_uart_control] pon & hsel forced up!! pon and/or sel will keep high\n");
                break;
            }
            if(current_status != UART_STATUS_FOR_NFC)
            {
                SNFC_DEBUG_MSG("[snfc_uart_control] IOCTL_SNFC_END, UART is not used to NFC\n");
                //return -2;
            }
            snfc_gpio_write(snfc_gpios.gpio_hsel, GPIO_LOW_VALUE);
            snfc_gpio_write(snfc_gpios.gpio_pon, GPIO_LOW_VALUE);
            __snfc_uart_control_set_uart_status(UART_STATUS_READY);

            autopoll_status = 0;
            SNFC_DEBUG_MSG_LOW("[snfc_uart_control] IOCTL_SNFC_END - end (hsel low)(pon low)\n");
            break;

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

    return 0;
}