/*
 * 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;
}
/*
* 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;
}
Example #3
0
/*
 * Description:
 * Input:
 * Output:
 */
static ssize_t snfc_cen_write(struct file *fp, const char *buf, size_t count, loff_t *pos)
{
	unsigned char write_buf = 0x00/*, read_buf = 0x00*/;
	int rc = -1;


#ifdef FEATURE_DEBUG_LOW  
	SNFC_DEBUG_MSG("[snfc_cen][write] snfc_cen_write - start \n");
#endif

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

	if(NULL == buf)
	{
		SNFC_DEBUG_MSG("[snfc_cen][write] ERROR buf \n");
		return -1;    
	}

	if(1 != count)
	{
		SNFC_DEBUG_MSG("[snfc_cen][write] ERROR count, count = %d \n", count);
		//return -1;    
	}

	if(NULL == pos)
	{
		SNFC_DEBUG_MSG("[snfc_cen][write] ERROR file \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;
	}

#ifdef FEATURE_DEBUG_LOW  
	SNFC_DEBUG_MSG("[snfc_cen][write] copy_from_user(%d) \n",*buf);
#endif

	/* check user data */
	if(*buf == 1) 
	{
#ifdef FEATURE_DEBUG_LOW  
		SNFC_DEBUG_MSG("[snfc_cen][write] CEN = High (UNLOCK) \n");
#endif
		write_buf = 0x81; // set unlock  
		mutex_lock(&nfc_cen_mutex);	
		rc = snfc_i2c_write(0x02, &write_buf, 1);
		mutex_unlock(&nfc_cen_mutex);   
		mdelay(2);		
	}
	else if(*buf == 0) 
	{
#ifdef FEATURE_DEBUG_LOW  
		SNFC_DEBUG_MSG("[snfc_cen][write] CEN = Low (LOCK) \n");
#endif
		write_buf = 0x80; // set lock
		mutex_lock(&nfc_cen_mutex);
		rc = snfc_i2c_write(0x02, &write_buf, 1);
		mutex_unlock(&nfc_cen_mutex);  
		mdelay(2);				
	}
	else if(*buf == 2)
	{
		write_buf = 0x80; // set lock
		mutex_lock(&nfc_cen_mutex);
		rc = snfc_i2c_write(0x02, &write_buf, 1);
		mutex_unlock(&nfc_cen_mutex);  
#ifdef FEATURE_DEBUG_LOW  
		SNFC_DEBUG_MSG("[snfc_cen][write] CEN = Low & Hgh(LOCK) \n");
#endif		
		mdelay(1);	

		write_buf = 0x81; // set unlock
		mutex_lock(&nfc_cen_mutex);
		rc = snfc_i2c_write(0x02, &write_buf, 1);
		mutex_unlock(&nfc_cen_mutex);  
#ifdef FEATURE_DEBUG_LOW  
		SNFC_DEBUG_MSG("[snfc_cen][write] CEN = Low & Hgh(UNLOCK) \n");
#endif		
	}
	/* read register value before writing new value */
	//  rc = snfc_i2c_read(0x02, &read_buf, 1);
	//  mdelay(1);

	/* write new value */
	//rc = snfc_i2c_write(0x02, &write_buf, 1);
	//mdelay(2);

	/* read register value after writing new value */
	//  rc = snfc_i2c_read(0x02, &read_buf, 1);
	//  mdelay(1);


#ifdef FEATURE_DEBUG_LOW  
	SNFC_DEBUG_MSG("[snfc_cen][write] snfc_cen_write - end \n");
#endif

	return 1;
}
/*
* 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;
}