예제 #1
0
int mcsdl_download_binary_data(struct melfas_tsi_platform_data *data)
{
    int nRet;

/* code for samsung */
	melfas_i2c_gpio_scl();
	melfas_i2c_gpio_sda();
	MCSDL_RESETB_SET_OUTPUT(0);   
	MCSDL_GPIO_SDA_SET_LOW();
	MCSDL_GPIO_SCL_SET_LOW();   
	MCSDL_RESETB_SET_LOW();
/* code for samsung */
	
#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD
    melfas_send_download_enable_command();
    mcsdl_delay(MCSDL_DELAY_100US);
#endif

    MELFAS_DISABLE_BASEBAND_ISR();					// Disable Baseband touch interrupt ISR.
    MELFAS_DISABLE_WATCHDOG_TIMER_RESET();			// Disable Baseband watchdog timer

    //------------------------
    // Run Download
    //------------------------
    nRet = mcsdl_download((const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength , 0, data);
#if MELFAS_2CHIP_DOWNLOAD_ENABLE
    nRet = mcsdl_download((const UINT8*) MELFAS_binary_2, (const UINT16)MELFAS_binary_nLength_2, 1, data);  // Slave Binary data download
#endif
    MELFAS_ROLLBACK_BASEBAND_ISR();					// Roll-back Baseband touch interrupt ISR.
    MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET();			// Roll-back Baseband watchdog timer

    return (nRet == MCSDL_RET_SUCCESS);
}
예제 #2
0
int mcsdl_download_binary_data(void)
{
	int nRet;
	#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD
	melfas_send_download_enable_command();
	mcsdl_delay(MCSDL_DELAY_100US);
	#endif

//	MELFAS_DISABLE_BASEBAND_ISR();					// Disable Baseband touch interrupt ISR.
        #if MELFAS_TS_WATCHDOG_SET_RESET
	MELFAS_DISABLE_WATCHDOG_TIMER_RESET();			// Disable Baseband watchdog timer
	#endif
	//------------------------
	// Run Download
	//------------------------
	nRet = mcsdl_download( (const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength , 0);
    #if MELFAS_2CHIP_DOWNLOAD_ENABLE
	nRet = mcsdl_download( (const UINT8*) MELFAS_binary_2, (const UINT16)MELFAS_binary_nLength_2, 1); // Slave Binary data download
    #endif
	MELFAS_ROLLBACK_BASEBAND_ISR();					// Roll-back Baseband touch interrupt ISR.
        #if MELFAS_TS_WATCHDOG_SET_RESET
	MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET();			// Roll-back Baseband watchdog timer
	#endif

	return ( nRet == MCSDL_RET_SUCCESS );
}
예제 #3
0
int mcsdl_download_binary_data( int TSP_HW_ver )
{
	int nRet;

	#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD
	melfas_send_download_enable_command();
	mcsdl_delay(MCSDL_DELAY_100US);
	#endif

	MELFAS_DISABLE_BASEBAND_ISR();					// Disable Baseband touch interrupt ISR.
	MELFAS_DISABLE_WATCHDOG_TIMER_RESET();			// Disable Baseband watchdog timer

	//------------------------
	// Run Download
	//------------------------

	if( TSP_HW_ver == 0x08 )  //Board Revision #02
		nRet = mcsdl_download( (const UINT8*) MELFAS_binary_HW_ver08, (const UINT16)MELFAS_binary_nLength_HW_ver08 );
	else if( TSP_HW_ver == 0x06 )  //Board Revision #03
		nRet = mcsdl_download( (const UINT8*) MELFAS_binary_HW_ver06, (const UINT16)MELFAS_binary_nLength_HW_ver06 );
	else if( TSP_HW_ver == 0x09 )  //Board Revision #03
		nRet = mcsdl_download( (const UINT8*) MELFAS_binary_HW_ver09, (const UINT16)MELFAS_binary_nLength_HW_ver09 );
	else if( TSP_HW_ver == 0x40 )  //Board Revision #03
		nRet = mcsdl_download( (const UINT8*) MELFAS_binary_HW_ver40, (const UINT16)MELFAS_binary_nLength_HW_ver40 );
	else
		printk("[TSP] %s, %d, Error TSP_HW_ver=%d\n",__func__,__LINE__, TSP_HW_ver);

	MELFAS_ROLLBACK_BASEBAND_ISR();					// Roll-back Baseband touch interrupt ISR.
	MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET();			// Roll-back Baseband watchdog timer

	return ( nRet == MCSDL_RET_SUCCESS );
}
int mcsdl_download_binary_data(void)
{
	int nRet;
	
	printk(KERN_INFO "(%s) start. \n",__func__);
			
#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD
	melfas_send_download_enable_command();
	mcsdl_delay(MCSDL_DELAY_100US);
#endif

	MELFAS_DISABLE_BASEBAND_ISR(); // Disable Baseband touch interrupt ISR.
	MELFAS_DISABLE_WATCHDOG_TIMER_RESET(); // Disable Baseband watchdog timer

	//------------------------
	// Run Download
	//------------------------
	nRet = mcsdl_download((const UINT8*) MELFAS_binary,
			(const UINT16) MELFAS_binary_nLength, 0);
#if MELFAS_2CHIP_DOWNLOAD_ENABLE
	nRet = mcsdl_download( (const UINT8*) MELFAS_binary_2, (const UINT16)MELFAS_binary_nLength_2, 1); // Slave Binary data download
#endif
	MELFAS_ROLLBACK_BASEBAND_ISR(); // Roll-back Baseband touch interrupt ISR.
	MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET(); // Roll-back Baseband watchdog timer
	
	printk(KERN_INFO "(%s) finish. \n",__func__);

	return nRet ;
}
예제 #5
0
int mcsdl_download_binary_data(INT32 hw_ver)
{
	int nRet;
	#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD
	melfas_send_download_enable_command();
	mcsdl_delay(MCSDL_DELAY_100US);
	#endif

	MELFAS_DISABLE_BASEBAND_ISR();					// Disable Baseband touch interrupt ISR.
	MELFAS_DISABLE_WATCHDOG_TIMER_RESET();			// Disable Baseband watchdog timer

	//------------------------
	// Run Download
	//------------------------
	if(hw_ver == 0x12)
	nRet = mcsdl_download( (const UINT8*) MELFAS_12_binary, (const UINT16)MELFAS_12_binary_nLength , 0);
	else if(hw_ver == 0x20)
	nRet = mcsdl_download( (const UINT8*) MELFAS_20_binary, (const UINT16)MELFAS_20_binary_nLength , 0);
	else if(hw_ver == 0x30)
	nRet = mcsdl_download( (const UINT8*) MELFAS_30_binary, (const UINT16)MELFAS_30_binary_nLength , 0);
    else if(hw_ver == 0x40)
    nRet = mcsdl_download( (const UINT8*) MELFAS_40_binary, (const UINT16)MELFAS_40_binary_nLength , 0);
	else if(hw_ver == 0x50)
	nRet = mcsdl_download( (const UINT8*) MELFAS_50_binary, (const UINT16)MELFAS_50_binary_nLength , 0);
	else
	return (MCSDL_RET_WRONG_MODULE_REVISION) ;
	#if MELFAS_2CHIP_DOWNLOAD_ENABLE
    	nRet = mcsdl_download( (const UINT8*) MELFAS_binary_2, (const UINT16)MELFAS_binary_nLength_2, 1); // Slave Binary data download
    #endif
	MELFAS_ROLLBACK_BASEBAND_ISR();					// Roll-back Baseband touch interrupt ISR.
	MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET();			// Roll-back Baseband watchdog timer

	return ( nRet == MCSDL_RET_SUCCESS );
}
int mms100_ISP_download_binary_data(int dl_mode)
{
	int nRet = 0;
	int retry_cnt = 0;

#if 0
	#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD
	melfas_send_download_enable_command();
	mcsdl_delay(MCSDL_DELAY_100US);
	#endif

	MELFAS_DISABLE_BASEBAND_ISR();					// Disable Baseband touch interrupt ISR.
	MELFAS_DISABLE_WATCHDOG_TIMER_RESET();			// Disable Baseband watchdog timer

#endif

	//------------------------
	// Run Download
	//------------------------

	for (retry_cnt = 0; retry_cnt < 5; retry_cnt++) {
        if(dl_mode == 0x01) //MELFAS_ISP_DOWNLOAD
    		nRet = mcsdl_download( (const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength , 0);
        else //MELFAS_ISC_DOWNLOAD
        {
			nRet = mcsdl_download( (const UINT8*) MELFAS_MMS100_Initial_binary, (const UINT16)MELFAS_MMS100_Initial_nLength , 0);
        }

#if MELFAS_2CHIP_DOWNLOAD_ENABLE
        if(!nRet)
        {
            if(dl_mode == 0x01) //MELFAS_ISP_DOWNLOAD
                nRet = mcsdl_download( (const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength, 1); // Slave Binary data download
            else //MELFAS_ISC_DOWNLOAD
                nRet = mcsdl_download( (const UINT8*) MELFAS_MMS100_Initial_binary, (const UINT16)MELFAS_MMS100_Initial_nLength , 1);
        }
#endif

		if (!nRet)
			break;
	}

	MELFAS_ROLLBACK_BASEBAND_ISR();					// Roll-back Baseband touch interrupt ISR.
	MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET();			// Roll-back Baseband watchdog timer

// wcjeong - unused code
//fw_error:
	if (nRet) {
		mcsdl_erase_flash(0);
		mcsdl_erase_flash(1);
	}
	return nRet;
}
int mms100_ISP_download_binary_data(int dl_mode)
{
	int nRet = 0;

	//-----------------------------------------------------
	//                                                    
	int retry_cnt = 0;

#if 0
	#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD
	melfas_send_download_enable_command();
	mcsdl_delay(MCSDL_DELAY_100US);
	#endif

	MELFAS_DISABLE_BASEBAND_ISR();					// Disable Baseband touch interrupt ISR.
	MELFAS_DISABLE_WATCHDOG_TIMER_RESET();			// Disable Baseband watchdog timer

#endif


	MELFAS_DISABLE_TS_ISR();					// Disable Baseband touch interrupt ISR.

	//------------------------
	// Run Download
	//------------------------

	//-----------------------------------------------------
	//                                                    
	for (retry_cnt = 0; retry_cnt < 5; retry_cnt++) 
	{
        if(dl_mode == 0x01) //MELFAS_ISP_DOWNLOAD
    			nRet = mcsdl_download( (const UINT8*) lgit_MELFAS_binary, (const UINT16)lgit_MELFAS_binary_nLength , 0);
        else //MELFAS_ISC_DOWNLOAD
        {
        	nRet = mcsdl_download( (const UINT8*) MELFAS_MMS100_Initial_binary, (const UINT16)MELFAS_MMS100_Initial_nLength , 0);
        }

	if (!nRet)
			break;
	}

	MELFAS_ENABLE_TS_ISR();

/*
fw_error:
	if (nRet) {
		mcsdl_erase_flash(0);
		mcsdl_erase_flash(1);
	}*/
	return nRet;
}
int mcsdl_download_binary_data(void)
{
    int ret;

    #if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD

    melfas_send_download_enable_command();

    mcsdl_delay(MCSDL_DELAY_100US);

    #endif

    MELFAS_DISABLE_BASEBAND_ISR();                    // Disable Baseband touch interrupt ISR.
    MELFAS_DISABLE_WATCHDOG_TIMER_RESET();            // Disable Baseband watchdog timer

    //------------------------
    // Run Download
    //------------------------  

//    ret = mcsdl_download( (const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength );
//    ret = mcsdl_download( MTH_SINSTINCTQ_R01_V03_bin, MTH_SINSTINCTQ_R01_V03_bin_nLength );
//    ret = mcsdl_download( MTH_SM900_R63_V12_bin, MTH_SM900_R63_V12_bin_nLength );
//    ret = mcsdl_download( MTH_SM900_R63_V13_bin, MTH_SM900_R63_V13_bin_nLength );
//    ret = mcsdl_download( MTH_SM900_R63_V14_bin, MTH_SM900_R63_V14_bin_nLength );
//    ret = mcsdl_download( MTH_SM900_R63_V15_bin, MTH_SM900_R63_V15_bin_nLength );
    ret = mcsdl_download( MELFAS_binary, MELFAS_binary_nLength );

    MELFAS_ROLLBACK_BASEBAND_ISR();                    // Roll-back Baseband touch interrupt ISR.
    MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET();            // Roll-back Baseband watchdog timer

    #if MELFAS_ENABLE_DBG_PRINT

        mcsdl_print_result( ret );            // Show result

    #endif


    return ( ret == MCSDL_RET_SUCCESS );
}
예제 #9
0
int mcsdl_download_binary_data(UINT8 master_dl_retry, int val,unsigned char fw_ver, unsigned char comp_ver)
{
	int nRet;
#ifdef FW_FROM_FILE
	struct file *filp;
	spinlock_t           lock;
	loff_t  pos;
	int     ret = 0;
	long fw1_size = 0;
	long fw2_size = 0;
	mm_segment_t oldfs;
	unsigned char *fw_data1;
	unsigned char *fw_data2;

	oldfs = get_fs();
	set_fs(get_ds());

	filp = filp_open(MELFAS_FW1, O_RDONLY, 0);
	if (IS_ERR(filp)) {
		pr_err("file open error:%d\n", (s32)filp);
		return -1;
	}

	fw1_size = filp->f_path.dentry->d_inode->i_size;
	pr_info("Size of the file : %ld(bytes)\n", fw1_size);

	fw_data1 = kmalloc(fw1_size, GFP_KERNEL);
	memset(fw_data1, 0, fw1_size);

	pos = 0;
	memset(fw_data1, 0, fw1_size);
	ret = vfs_read(filp, (char __user *)fw_data1, fw1_size, &pos);

	if(ret != fw1_size) {
		pr_err("Failed to read file %s (ret = %d)\n", MELFAS_FW1, ret);
		kfree(fw_data1);
		filp_close(filp, current->files);
		return -1;
	}

	filp_close(filp, current->files);

	filp = filp_open(MELFAS_FW2, O_RDONLY, 0);
	if (IS_ERR(filp)) {
		pr_err("file open error:%d\n", (s32)filp);
		return -1;
	}

	fw2_size = filp->f_path.dentry->d_inode->i_size;
	pr_info("Size of the file : %ld(bytes)\n", fw2_size);

	fw_data2 = kmalloc(fw2_size, GFP_KERNEL);
	memset(fw_data2, 0, fw2_size);

	pos = 0;
	memset(fw_data2, 0, fw2_size);
	ret = vfs_read(filp, (char __user *)fw_data2, fw2_size, &pos);

	if(ret != fw2_size) {
		pr_err("Failed to read file %s (ret = %d)\n", MELFAS_FW2, ret);
		kfree(fw_data2);
		filp_close(filp, current->files);
		return -1;
	}

	filp_close(filp, current->files);

	set_fs(oldfs);
	spin_lock_init(&lock);
	spin_lock(&lock);
#endif

	#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD
	melfas_send_download_enable_command();
	mcsdl_delay(MCSDL_DELAY_100US);
	#endif

	MELFAS_DISABLE_BASEBAND_ISR();					// Disable Baseband touch interrupt ISR.
	MELFAS_DISABLE_WATCHDOG_TIMER_RESET();			// Disable Baseband watchdog timer

	//------------------------
	// Run Download
	//------------------------
#ifdef FW_FROM_FILE
    if(MELFAS_ISP_DOWNLOAD || master_dl_retry)
	{
	nRet = mcsdl_download( (const UINT8*) fw_data1, (const UINT16)fw1_size, 0);
	if (nRet)
		goto fw_error;
#if MELFAS_2CHIP_DOWNLOAD_ENABLE
    nRet = mcsdl_download( (const UINT8*) fw_data1, (const UINT16)fw1_size, 1);
	if (nRet)
		goto fw_error;
	spin_unlock(&lock);
#endif
	}
#else
	/* For F/W Download by using ISC Mode */
	/* We need to implement some conditions */

    if (MELFAS_ISP_DOWNLOAD || master_dl_retry) {
	if (val == 1) {
		if(comp_ver==0){ //for M3C EVB 사용안함
			nRet = mcsdl_download( (const UINT8*) MELFAS_binary1, (const UINT16)MELFAS_binary_nLength1, 0);
		}
		else if(comp_ver==1) //for M4 EU suntel,Telus suntel
			nRet = mcsdl_download( (const UINT8*) MELFAS_binary2, (const UINT16)MELFAS_binary_nLength2, 0);
		else if(comp_ver==2) //for M4 EU Inotek,Telus inotek
			nRet = mcsdl_download( (const UINT8*) MELFAS_binary3, (const UINT16)MELFAS_binary_nLength3, 0);
		else if(comp_ver==3) // for M4 dual, Bell 초기 버전
			nRet = mcsdl_download( (const UINT8*) MELFAS_binary4, (const UINT16)MELFAS_binary_nLength4, 0);
		else if(comp_ver==4)//E617(Bell 최신 버전) 
			nRet = mcsdl_download( (const UINT8*) MELFAS_binary5, (const UINT16)MELFAS_binary_nLength5, 0);
		else //for M4 dual 초기 버전 펌웨어 업데이트 진행 안함
			nRet = mcsdl_download( (const UINT8*) MELFAS_binary6, (const UINT16)MELFAS_binary_nLength6, 0);
		if (nRet)
			goto fw_error;
	}
    	#if MELFAS_2CHIP_DOWNLOAD_ENABLE
    		//nRet = mcsdl_download( (const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength, 1); // Slave Binary data download
		//if (nRet)
		//	goto fw_error;
    	#endif
	}
    
#endif
	MELFAS_ROLLBACK_BASEBAND_ISR();					// Roll-back Baseband touch interrupt ISR.
	MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET();			// Roll-back Baseband watchdog timer
	//return 0;
	
	return nRet;
fw_error:
	mcsdl_erase_flash(0);
	mcsdl_erase_flash(1);
#ifdef FW_FROM_FILE
	spin_unlock(&lock);
#endif
	return nRet;
}
예제 #10
0
int mcsdl_download_binary_file(void)
{
	int nRet;
    int i;

	UINT8  *pBinary[2] = {NULL,NULL};
	UINT16 nBinary_length[2] ={0,0};
    UINT8 IdxNum = MELFAS_2CHIP_DOWNLOAD_ENABLE;
	//==================================================
	//
	//	1. Read '.bin file'
	//   2. *pBinary[0]       : Binary data(Master)
	//       *pBinary[1]       : Binary data(Slave)
	//	   nBinary_length[0] : Firmware size(Master)
	//	   nBinary_length[1] : Firmware size(Slave)
	//	3. Run mcsdl_download( pBinary[IdxNum], nBinary_length[IdxNum], IdxNum);
        //       IdxNum : 0 (Master Chip Download)
        //       IdxNum : 1 (2Chip Download)
	//
	//==================================================

	#if 0

		// TO DO : File Process & Get file Size(== Binary size)
		//			This is just a simple sample

		FILE *fp;
		INT  nRead;

		//------------------------------
		// Open a file
		//------------------------------

    if (fopen(fp, "MELFAS_FIRMWARE.bin", "rb") == NULL)
    {
        return MCSDL_RET_FILE_ACCESS_FAILED;
    }

		//------------------------------
		// Get Binary Size
		//------------------------------

		fseek( fp, 0, SEEK_END );

		nBinary_length = (UINT16)ftell(fp);

		//------------------------------
		// Memory allocation
		//------------------------------

		pBinary = (UINT8*)malloc( (INT)nBinary_length );

    if (pBinary == NULL)
    {

        return MCSDL_RET_FILE_ACCESS_FAILED;
    }

		//------------------------------
		// Read binary file
		//------------------------------

		fseek( fp, 0, SEEK_SET );

		nRead = fread( pBinary, 1, (INT)nBinary_length, fp );		// Read binary file

    if (nRead != (INT)nBinary_length)
    {

        fclose(fp);												// Close file

        if (pBinary != NULL)										// free memory alloced.
            free(pBinary);

        return MCSDL_RET_FILE_ACCESS_FAILED;
    }

		//------------------------------
		// Close file
		//------------------------------

		fclose(fp);

	#endif

#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD
    melfas_send_download_enable_command();
    mcsdl_delay(MCSDL_DELAY_100US);
#endif

    MELFAS_DISABLE_BASEBAND_ISR();                  // Disable Baseband touch interrupt ISR.
    MELFAS_DISABLE_WATCHDOG_TIMER_RESET();          // Disable Baseband watchdog timer

    for (i = 0;i <= IdxNum;i++)
    {
        if (pBinary[i] != NULL && nBinary_length[i] > 0 && nBinary_length[i] < 32*1024)
        {
            //------------------------
            // Run Download
            //------------------------
            nRet = mcsdl_download((const UINT8 *)pBinary[i], (const UINT16)nBinary_length[i], i);
        }
        else
        {
            nRet = MCSDL_RET_WRONG_BINARY;
        }
    }

    MELFAS_ROLLBACK_BASEBAND_ISR();                 // Roll-back Baseband touch interrupt ISR.
    MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET();         // Roll-back Baseband watchdog timer

	#if MELFAS_ENABLE_DBG_PRINT
	mcsdl_print_result( nRet );
	#endif

	return ( nRet == MCSDL_RET_SUCCESS );

}
int mms100_ISP_download_binary_data(int dl_mode)
{
	int nRet = 0;
	int retry_cnt = 0;

	mt_set_gpio_mode(GPIO_I2C1_SDA_PIN, GPIO_I2C1_SDA_PIN_M_GPIO);
	mt_set_gpio_dir(GPIO_I2C1_SDA_PIN, GPIO_DIR_OUT);
	mt_set_gpio_pull_enable(GPIO_I2C1_SDA_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_I2C1_SDA_PIN, GPIO_PULL_UP);

	mt_set_gpio_mode(GPIO_I2C1_SCA_PIN, GPIO_I2C1_SCA_PIN_M_GPIO);
	mt_set_gpio_dir(GPIO_I2C1_SCA_PIN, GPIO_DIR_OUT);
	mt_set_gpio_pull_enable(GPIO_I2C1_SCA_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_I2C1_SCA_PIN, GPIO_PULL_DOWN);

	mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_GPIO);
	mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_OUT);
	mt_set_gpio_pull_enable(GPIO_CTP_EINT_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_CTP_EINT_PIN, 2);

#if 0
	#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD
	melfas_send_download_enable_command();
	mcsdl_delay(MCSDL_DELAY_100US);
	#endif

	MELFAS_DISABLE_BASEBAND_ISR();					// Disable Baseband touch interrupt ISR.
	MELFAS_DISABLE_WATCHDOG_TIMER_RESET();			// Disable Baseband watchdog timer

#endif

	//------------------------
	// Run Download
	//------------------------

	for (retry_cnt = 0; retry_cnt < 5; retry_cnt++) {
        if(dl_mode == 0x01) //MELFAS_ISP_DOWNLOAD
    		nRet = mcsdl_download( (const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength , 0);
        else //MELFAS_ISC_DOWNLOAD
        {
            //nRet = mcsdl_download( (const UINT8*) MELFAS_MMS100_Initial_binary, (const UINT16)MELFAS_MMS100_Initial_nLength , 0);
        }

		if (!nRet)
			break;
	}

	MELFAS_ROLLBACK_BASEBAND_ISR();					// Roll-back Baseband touch interrupt ISR.
	MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET();			// Roll-back Baseband watchdog timer

	mt_set_gpio_mode(GPIO_I2C1_SDA_PIN, GPIO_I2C1_SDA_PIN_M_SDA);
	mt_set_gpio_dir(GPIO_I2C1_SDA_PIN, GPIO_DIR_OUT);
	mt_set_gpio_pull_enable(GPIO_I2C1_SDA_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_I2C1_SDA_PIN, GPIO_PULL_UP);

	mt_set_gpio_mode(GPIO_I2C1_SCA_PIN, GPIO_I2C1_SCA_PIN_M_SCL);
	mt_set_gpio_dir(GPIO_I2C1_SCA_PIN, GPIO_DIR_OUT);
	mt_set_gpio_pull_enable(GPIO_I2C1_SCA_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_I2C1_SCA_PIN, GPIO_PULL_UP);

fw_error:
	if (nRet) {
		mcsdl_erase_flash(0);
		mcsdl_erase_flash(1);
	}

	return nRet;
}
예제 #12
0
int mcsdl_download_binary_file(void)
{
	int nRet;

	UINT8  *pBinary = NULL;
	UINT16 nBinary_length =0;

	//==================================================
	//
	//	1. Read '.bin file'
	//  2. *pBinary       : Binary data
	//	   nBinary_length : Firmware size
	//	3. Run mcsdl_download( pBinary, nBinary_length);
	//
	//==================================================

	#if 0

		// TO DO : File Process & Get file Size(== Binary size)
		//			This is just a simple sample

		FILE *fp;
		INT  nRead;

		//------------------------------
		// Open a file
		//------------------------------

		if( fopen( fp, "MELFAS_FIRMWARE.bin", "rb" ) == NULL ){
			return MCSDL_RET_FILE_ACCESS_FAILED;
		}

		//------------------------------
		// Get Binary Size
		//------------------------------

		fseek( fp, 0, SEEK_END );

		nBinary_length = (UINT16)ftell(fp);

		//------------------------------
		// Memory allocation
		//------------------------------

		pBinary = (UINT8*)malloc( (INT)nBinary_length );

		if( pBinary == NULL ){

			return MCSDL_RET_FILE_ACCESS_FAILED;
		}

		//------------------------------
		// Read binary file
		//------------------------------

		fseek( fp, 0, SEEK_SET );

		nRead = fread( pBinary, 1, (INT)nBinary_length, fp );		// Read binary file

		if( nRead != (INT)nBinary_length ){

			fclose(fp);												// Close file

			if( pBinary != NULL )										// free memory alloced.
				free(pBinary);

			return MCSDL_RET_FILE_ACCESS_FAILED;
		}

		//------------------------------
		// Close file
		//------------------------------

		fclose(fp);

	#endif

	if( pBinary != NULL && nBinary_length > 0 && nBinary_length < 32*1024 ){

		#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD
		melfas_send_download_enable_command();
		mcsdl_mcs7000_delay(MCSDL_DELAY_100US);
		#endif

		MELFAS_DISABLE_BASEBAND_ISR();					// Disable Baseband touch interrupt ISR.
		MELFAS_DISABLE_WATCHDOG_TIMER_RESET();			// Disable Baseband watchdog timer

		//------------------------
		// Run Download
		//------------------------
		nRet = mcsdl_download( (const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength );

		MELFAS_ROLLBACK_BASEBAND_ISR();					// Roll-back Baseband touch interrupt ISR.
		MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET();			// Roll-back Baseband watchdog timer

	}else{

		nRet = MCSDL_RET_WRONG_BINARY;
	}

	#if MELFAS_ENABLE_DBG_PRINT
	mcsdl_print_result( nRet );
	#endif

	#if 0
		if( pData != NULL )										// free memory alloced.
			free(pData);
	#endif

	return ( nRet == MCSDL_RET_SUCCESS );

}
예제 #13
0
int mms100_ISP_download_binary_data(int dl_mode)
{
	int nRet = 0;
	int retry_cnt = 0;

	/*
	//get gpio info _S


	printk("[JHLog] SDA GPIO INFO : Mode = %d, Dir = %d, PullEn = %d, PullSelect = %d",

	mt_get_gpio_mode(GPIO_I2C0_SDA_PIN),

	mt_get_gpio_dir(GPIO_I2C0_SDA_PIN),

	mt_get_gpio_pull_enable(GPIO_I2C0_SDA_PIN),

	mt_get_gpio_pull_select(GPIO_I2C0_SDA_PIN)

	);



	printk("[JHLog] SCA GPIO INFO : Mode = %d, Dir = %d, PullEn = %d, PullSelect = %d",

	mt_get_gpio_mode(GPIO_I2C0_SCA_PIN),

	mt_get_gpio_dir(GPIO_I2C0_SCA_PIN),

	mt_get_gpio_pull_enable(GPIO_I2C0_SCA_PIN),

	mt_get_gpio_pull_select(GPIO_I2C0_SCA_PIN)

	);



	printk("[JHLog] EINT GPIO INFO : Mode = %d, Dir = %d, PullEn = %d, PullSelect = %d",

	mt_get_gpio_mode(GPIO_CTP_EINT_PIN),


	mt_get_gpio_dir(GPIO_CTP_EINT_PIN),

	mt_get_gpio_pull_enable(GPIO_CTP_EINT_PIN),

	mt_get_gpio_pull_select(GPIO_CTP_EINT_PIN)

	);
	//get gpio info _E

	*/

	//set GPIO SDA/SCA/EINT_S

//                                                                   
#if 0 // ori
	mt_set_gpio_mode(GPIO_I2C0_SDA_PIN, GPIO_I2C0_SDA_PIN_M_GPIO);
	mt_set_gpio_dir(GPIO_I2C0_SDA_PIN, GPIO_DIR_OUT);
	mt_set_gpio_pull_enable(GPIO_I2C0_SDA_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_I2C0_SDA_PIN, GPIO_PULL_UP);

	mt_set_gpio_mode(GPIO_I2C0_SCA_PIN, GPIO_I2C0_SCA_PIN_M_GPIO);
	mt_set_gpio_dir(GPIO_I2C0_SCA_PIN, GPIO_DIR_OUT);
	mt_set_gpio_pull_enable(GPIO_I2C0_SCA_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_I2C0_SCA_PIN, GPIO_PULL_DOWN);

	mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_GPIO);
	mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_OUT);
	mt_set_gpio_pull_enable(GPIO_CTP_EINT_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_CTP_EINT_PIN, 2);
#else // blood V3 RevA test
	mt_set_gpio_mode(GPIO_I2C1_SDA_PIN, GPIO_I2C1_SDA_PIN_M_GPIO);
	mt_set_gpio_dir(GPIO_I2C1_SDA_PIN, GPIO_DIR_OUT);
	mt_set_gpio_pull_enable(GPIO_I2C1_SDA_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_I2C1_SDA_PIN, GPIO_PULL_UP);

	mt_set_gpio_mode(GPIO_I2C1_SCA_PIN, GPIO_I2C1_SCA_PIN_M_GPIO);
	mt_set_gpio_dir(GPIO_I2C1_SCA_PIN, GPIO_DIR_OUT);
	mt_set_gpio_pull_enable(GPIO_I2C1_SCA_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_I2C1_SCA_PIN, GPIO_PULL_DOWN);

	mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_GPIO);
	mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_OUT);
	mt_set_gpio_pull_enable(GPIO_CTP_EINT_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_CTP_EINT_PIN, 2);
#endif
//                                                                   

	//set GPIO SDA/SCA/EINT_E

#if 0
	#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD
	melfas_send_download_enable_command();
	mcsdl_delay(MCSDL_DELAY_100US);
	#endif

	MELFAS_DISABLE_BASEBAND_ISR();					// Disable Baseband touch interrupt ISR.
	MELFAS_DISABLE_WATCHDOG_TIMER_RESET();			// Disable Baseband watchdog timer

#endif

	//------------------------
	// Run Download
	//------------------------
	//nRet = mcsdl_download( (const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength , 0);
	//printk("mmsdownload ret =%d", nRet);

	for (retry_cnt = 0; retry_cnt < 5; retry_cnt++) {
        if(dl_mode == 0x01) //MELFAS_ISP_DOWNLOAD
    		nRet = mcsdl_download( (const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength , 0);
        else //MELFAS_ISC_DOWNLOAD
            {
//                nRet = mcsdl_download( (const UINT8*) MELFAS_MMS100_Initial_binary, (const UINT16)MELFAS_MMS100_Initial_nLength , 0);
            }
#if MELFAS_2CHIP_DOWNLOAD_ENABLE
        if(!nRet)
        {
            if(dl_mode == 0x01) //MELFAS_ISP_DOWNLOAD
                nRet = mcsdl_download( (const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength, 1); // Slave Binary data download
            else //MELFAS_ISC_DOWNLOAD
//                nRet = mcsdl_download( (const UINT8*) MELFAS_MMS100_Initial_binary, (const UINT16)MELFAS_MMS100_Initial_nLength , 1);
        }
#endif
		if (!nRet)
			break;
	}


	MELFAS_ROLLBACK_BASEBAND_ISR();					// Roll-back Baseband touch interrupt ISR.
	MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET();			// Roll-back Baseband watchdog timer

	//Restore GPIO Setting_S

//                                                                   
#if 0 // ori
	mt_set_gpio_mode(GPIO_I2C0_SDA_PIN, GPIO_I2C0_SDA_PIN_M_SDA);	// joohyung.lee
	mt_set_gpio_dir(GPIO_I2C0_SDA_PIN, GPIO_DIR_OUT);
	mt_set_gpio_pull_enable(GPIO_I2C0_SDA_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_I2C0_SDA_PIN, GPIO_PULL_UP);

	mt_set_gpio_mode(GPIO_I2C0_SCA_PIN, GPIO_I2C0_SCA_PIN_M_SCL);	// joohyung.lee
	mt_set_gpio_dir(GPIO_I2C0_SCA_PIN, GPIO_DIR_OUT);
	mt_set_gpio_pull_enable(GPIO_I2C0_SCA_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_I2C0_SCA_PIN, GPIO_PULL_UP);

	mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_EINT);	// joohyung.lee
	mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_IN);
	mt_set_gpio_pull_enable(GPIO_CTP_EINT_PIN, GPIO_PULL_ENABLE);
	mt_set_gpio_pull_select(GPIO_CTP_EINT_PIN, GPIO_PULL_UP);
#else // blood V3 RevA test
mt_set_gpio_mode(GPIO_I2C1_SDA_PIN, GPIO_I2C1_SDA_PIN_M_SDA);   // joohyung.lee
mt_set_gpio_dir(GPIO_I2C1_SDA_PIN, GPIO_DIR_OUT);
mt_set_gpio_pull_enable(GPIO_I2C1_SDA_PIN, GPIO_PULL_ENABLE);
mt_set_gpio_pull_select(GPIO_I2C1_SDA_PIN, GPIO_PULL_UP);

mt_set_gpio_mode(GPIO_I2C1_SCA_PIN, GPIO_I2C1_SCA_PIN_M_SCL);   // joohyung.lee
mt_set_gpio_dir(GPIO_I2C1_SCA_PIN, GPIO_DIR_OUT);
mt_set_gpio_pull_enable(GPIO_I2C1_SCA_PIN, GPIO_PULL_ENABLE);
mt_set_gpio_pull_select(GPIO_I2C1_SCA_PIN, GPIO_PULL_UP);

mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_EINT);  // joohyung.lee
mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_IN);
mt_set_gpio_pull_enable(GPIO_CTP_EINT_PIN, GPIO_PULL_ENABLE);
mt_set_gpio_pull_select(GPIO_CTP_EINT_PIN, GPIO_PULL_UP);
#endif
//                                                                   

	//Restore GPIO Setting_E

fw_error:
	if (nRet) {
		mcsdl_erase_flash(0);
		mcsdl_erase_flash(1);
	}
	return nRet;
}

int mms100_ISP_download_binary_file(void)
{
	int nRet;
    int i;

	UINT8  *pBinary[2] = {NULL,NULL};
	UINT16 nBinary_length[2] ={0,0};
    UINT8 IdxNum = MELFAS_2CHIP_DOWNLOAD_ENABLE;
	//==================================================
	//
	//	1. Read '.bin file'
	//   2. *pBinary[0]       : Binary data(Core + Private Custom)
	//       *pBinary[1]       : Binary data(Public Custom)
	//	   nBinary_length[0] : Firmware size(Core + Private Custom)
	//	   nBinary_length[1] : Firmware size(Public Custom)
	//	3. Run mcsdl_download( pBinary[IdxNum], nBinary_length[IdxNum], IdxNum);
    //       IdxNum : 0 (Master Chip Download)
    //       IdxNum : 1 (2Chip Download)
	//
	//==================================================

	#if 0

		// TO DO : File Process & Get file Size(== Binary size)
		//			This is just a simple sample

		FILE *fp;
		INT  nRead;

		//------------------------------
		// Open a file
		//------------------------------

    if (fopen(fp, "MELFAS_FIRMWARE.bin", "rb") == NULL)
    {
        return MCSDL_RET_FILE_ACCESS_FAILED;
    }

		//------------------------------
		// Get Binary Size
		//------------------------------

		fseek( fp, 0, SEEK_END );

		nBinary_length = (UINT16)ftell(fp);

		//------------------------------
		// Memory allocation
		//------------------------------

		pBinary = (UINT8*)malloc( (INT)nBinary_length );

    if (pBinary == NULL)
    {

        return MCSDL_RET_FILE_ACCESS_FAILED;
    }

		//------------------------------
		// Read binary file
		//------------------------------

		fseek( fp, 0, SEEK_SET );

		nRead = fread( pBinary, 1, (INT)nBinary_length, fp );		// Read binary file

    if (nRead != (INT)nBinary_length)
    {

        fclose(fp);												// Close file

        if (pBinary != NULL)										// free memory alloced.
            free(pBinary);

        return MCSDL_RET_FILE_ACCESS_FAILED;
    }

		//------------------------------
		// Close file
		//------------------------------

		fclose(fp);

	#endif

#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD
    melfas_send_download_enable_command();
    mcsdl_delay(MCSDL_DELAY_100US);
#endif

    MELFAS_DISABLE_BASEBAND_ISR();                  // Disable Baseband touch interrupt ISR.
    MELFAS_DISABLE_WATCHDOG_TIMER_RESET();          // Disable Baseband watchdog timer

    for (i = 0;i <= IdxNum;i++)
    {
        if (pBinary[0] != NULL && nBinary_length[0] > 0 && nBinary_length[0] < MELFAS_FIRMWARE_MAX_SIZE)
        {
            //------------------------
            // Run Download
            //------------------------
            nRet = mcsdl_download((const UINT8 *)pBinary[0], (const UINT16)nBinary_length[0], i);
        }
        else
        {
            nRet = MCSDL_RET_WRONG_BINARY;
        }
    }

    MELFAS_ROLLBACK_BASEBAND_ISR();                 // Roll-back Baseband touch interrupt ISR.
    MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET();         // Roll-back Baseband watchdog timer

	#if MELFAS_ENABLE_DBG_PRINT
	mcsdl_print_result( nRet );
	#endif

	return ( nRet == MCSDL_RET_SUCCESS );

}
예제 #14
0
int mcsdl_download_binary_data(bool touch_id)
{
	int nRet = 0;
	int retry_cnt = 0;
	long fw1_size = 0;
	unsigned char *fw_data1;
#ifdef FW_FROM_FILE
	struct file *filp;
	loff_t  pos;
	int     ret = 0;
	mm_segment_t oldfs;
	spinlock_t	lock;

	oldfs = get_fs();
	set_fs(get_ds());

	filp = filp_open(MELFAS_FW1, O_RDONLY, 0);
	if (IS_ERR(filp)) {
		pr_err("file open error:%d\n", (s32)filp);
		return -1;
	}

	fw1_size = filp->f_path.dentry->d_inode->i_size;
	pr_info("Size of the file : %ld(bytes)\n", fw1_size);

	fw_data1 = kmalloc(fw1_size, GFP_KERNEL);
	memset(fw_data1, 0, fw1_size);

	pos = 0;
	memset(fw_data1, 0, fw1_size);
	ret = vfs_read(filp, (char __user *)fw_data1, fw1_size, &pos);

	if(ret != fw1_size) {
		pr_err("Failed to read file %s (ret = %d)\n", MELFAS_FW1, ret);
		kfree(fw_data1);
		filp_close(filp, current->files);
		return -1;
	}

	filp_close(filp, current->files);

	set_fs(oldfs);
	spin_lock_init(&lock);
	spin_lock(&lock);
#endif

#if 0
	#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD
	melfas_send_download_enable_command();
	mcsdl_delay(MCSDL_DELAY_100US);
	#endif

	MELFAS_DISABLE_BASEBAND_ISR();					// Disable Baseband touch interrupt ISR.
	MELFAS_DISABLE_WATCHDOG_TIMER_RESET();			// Disable Baseband watchdog timer

#endif

	//------------------------
	// Run Download
	//------------------------

#ifdef FW_FROM_FILE
	for (retry_cnt = 0; retry_cnt < 3; retry_cnt++) {
		pr_info("[TSP] ADB - MASTER CHIP Firmware update! try : %d",retry_cnt+1);
		nRet = mcsdl_download( (const UINT8*) fw_data1, (const UINT16)fw1_size, 0);
		if (nRet)
			continue;
#if MELFAS_2CHIP_DOWNLOAD_ENABLE
		pr_info("[TSP] ADB - SLAVE CHIP Firmware update! try : %d",retry_cnt+1);
		nRet = mcsdl_download( (const UINT8*) fw_data1, (const UINT16)fw1_size, 1);
	if (nRet)
		continue;
#endif
	break;	
	}
	
#else	//FW_FROM_FILE

	for (retry_cnt = 0; retry_cnt < 5; retry_cnt++) {
		if (touch_id)
			nRet = mcsdl_download( (const UINT8*) MELFAS_binary_2, (const UINT16)MELFAS_binary_nLength_2, 0);
		else
			nRet = mcsdl_download( (const UINT8*) MELFAS_binary_1, (const UINT16)MELFAS_binary_nLength_1 , 0);

		if (nRet)
			continue;
#if MELFAS_2CHIP_DOWNLOAD_ENABLE
		if (touch_id)
			nRet = mcsdl_download( (const UINT8*) MELFAS_binary_2, (const UINT16)MELFAS_binary_nLength_2, 1); // Slave Binary data download
		else
			nRet = mcsdl_download( (const UINT8*) MELFAS_binary_1, (const UINT16)MELFAS_binary_nLength_1, 1); // Slave Binary data download
		if (nRet)
			continue;
#endif
		break;
	}

#endif	//FW_FROM_FILE

	MELFAS_ROLLBACK_BASEBAND_ISR();					// Roll-back Baseband touch interrupt ISR.
	MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET();			// Roll-back Baseband watchdog timer

fw_error:
	if (nRet) {
		mcsdl_erase_flash(0);
		mcsdl_erase_flash(1);
	}
#ifdef FW_FROM_FILE
	kfree(fw_data1);
	spin_unlock(&lock);
#endif
	return nRet;
}
//============================================================
//
//	Main Download furnction
//
//   1. Run mcsdl_download( pBinary[IdxNum], nBinary_length[IdxNum], IdxNum);
//       IdxNum : 0 (Master Chip Download)
//       IdxNum : 1 (2Chip Download)
//
//
//============================================================
int mcsdl_download_binary_data(UINT8 master_dl_retry)
{
    int nRet;
#ifdef FW_FROM_FILE
	struct file *filp;
	spinlock_t           lock;
	loff_t  pos;
	int     ret = 0;
	long fw1_size = 0;
	long fw2_size = 0;
	mm_segment_t oldfs;
	unsigned char *fw_data1;
	unsigned char *fw_data2;

	oldfs = get_fs();
	set_fs(get_ds());

	filp = filp_open(MELFAS_FW1, O_RDONLY, 0);
	if (IS_ERR(filp)) {
		pr_err("file open error:%d\n", (s32)filp);
		return -1;
	}

	fw1_size = filp->f_path.dentry->d_inode->i_size;
	pr_info("Size of the file : %ld(bytes)\n", fw1_size);

	fw_data1 = kmalloc(fw1_size, GFP_KERNEL);
	memset(fw_data1, 0, fw1_size);

	pos = 0;
	memset(fw_data1, 0, fw1_size);
	ret = vfs_read(filp, (char __user *)fw_data1, fw1_size, &pos);

	if(ret != fw1_size) {
		pr_err("Failed to read file %s (ret = %d)\n", MELFAS_FW1, ret);
		kfree(fw_data1);
		filp_close(filp, current->files);
		return -1;
	}

	filp_close(filp, current->files);

	filp = filp_open(MELFAS_FW2, O_RDONLY, 0);
	if (IS_ERR(filp)) {
		pr_err("file open error:%d\n", (s32)filp);
		return -1;
	}

	fw2_size = filp->f_path.dentry->d_inode->i_size;
	pr_info("Size of the file : %ld(bytes)\n", fw2_size);

	fw_data2 = kmalloc(fw2_size, GFP_KERNEL);
	memset(fw_data2, 0, fw2_size);

	pos = 0;
	memset(fw_data2, 0, fw2_size);
	ret = vfs_read(filp, (char __user *)fw_data2, fw2_size, &pos);

	if(ret != fw2_size) {
		pr_err("Failed to read file %s (ret = %d)\n", MELFAS_FW2, ret);
		kfree(fw_data2);
		filp_close(filp, current->files);
		return -1;
	}

	filp_close(filp, current->files);

	set_fs(oldfs);
	spin_lock_init(&lock);
	spin_lock(&lock);
#endif

#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD
	melfas_send_download_enable_command();
	mcsdl_delay(MCSDL_DELAY_100US);
#endif

	MELFAS_DISABLE_BASEBAND_ISR();					// Disable Baseband touch interrupt ISR.
	MELFAS_DISABLE_WATCHDOG_TIMER_RESET();			// Disable Baseband watchdog timer

	//------------------------
	// Run Download
	//------------------------
#ifdef FW_FROM_FILE
	if(MELFAS_ISP_DOWNLOAD || master_dl_retry)
	{
		nRet = mcsdl_download( (const UINT8*) fw_data1, (const UINT16)fw1_size, 0);
		if (nRet)
			goto fw_error;
	}
#if MELFAS_2CHIP_DOWNLOAD_ENABLE
	nRet = mcsdl_download( (const UINT8*) fw_data2, (const UINT16)fw2_size, 1);
	if (nRet)
		goto fw_error;
	spin_unlock(&lock);
#endif
#else
	if(MELFAS_ISP_DOWNLOAD || master_dl_retry)
	{
		nRet = mcsdl_download( (const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength , 0);
		if (nRet)
			goto fw_error;
	}
#if MELFAS_2CHIP_DOWNLOAD_ENABLE
	nRet = mcsdl_download( (const UINT8*) MELFAS_binary_2, (const UINT16)MELFAS_binary_nLength_2, 1); // Slave Binary data download
	if (nRet)
		goto fw_error;
#endif
#endif
	MELFAS_ROLLBACK_BASEBAND_ISR();					// Roll-back Baseband touch interrupt ISR.
	MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET();			// Roll-back Baseband watchdog timer
	return 0;
fw_error:
	mcsdl_erase_flash(0);
	mcsdl_erase_flash(1);
#ifdef FW_FROM_FILE
	spin_unlock(&lock);
#endif
	return nRet;
}
예제 #16
0
int mcsdl_download_binary_data(int hw_ver) {

    int ret;

#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD
    melfas_send_download_enable_command();
    mcsdl_delay(MCSDL_DELAY_100US);
#endif

    //MELFAS_DISABLE_BASEBAND_ISR();                    // Disable Baseband touch interrupt ISR.
    //MELFAS_DISABLE_WATCHDOG_TIMER_RESET();            // Disable Baseband watchdog timer

    //------------------------
    // Run Download
    //------------------------

    uint8_t* pfirmware = NULL;
    size_t firmware_size = 0;

#ifdef TSP_SDCARD_UPDATE
    uint8_t fromsdcard = false;

    if((firmware_size=tsp_firmware_load("/sdcard/ts/firmware/_ts_firmware_.bin", &pfirmware)) > 1024) {
        printk("[TOUCH] firmware loaded from sdcard (%d)\n",firmware_size);
        printk("[TOUCH] %02x %02x %02x %02x \n",
            pfirmware[0], pfirmware[1], pfirmware[2], pfirmware[3]);
        printk("[TOUCH] %02x %02x %02x %02x \n",
            pfirmware[4], pfirmware[5], pfirmware[6], pfirmware[7]);
        fromsdcard = true;
    }
    else
#endif
    {
		pfirmware = MELFAS_binary_V06;
		firmware_size = MELFAS_binary_nLength_V06;
        printk(KERN_WARNING "[TOUCH] Updated H/W version: 0x%X. firmware is selected![firmware_size:0x%X.]\n", hw_ver, firmware_size);
    }

    if(firmware_size >= 0 && pfirmware != NULL) {
        printk("###############################\n");
        printk("[TOUCH] Firmware Download START\n");
        //printk("system rev is %x\n", system_rev); //Quattro hasn't system_rev value

        ret = mcsdl_download( pfirmware, firmware_size );

#ifdef TSP_SDCARD_UPDATE
        if(fromsdcard)
            tsp_firmware_unload(pfirmware);
#endif
        printk("[TOUCH] Firmware Download END\n");
        printk("#############################\n");
    }

    //MELFAS_ROLLBACK_BASEBAND_ISR();                    // Roll-back Baseband touch interrupt ISR.
    //MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET();            // Roll-back Baseband watchdog timer

#if MELFAS_ENABLE_DBG_PRINT
    mcsdl_print_result( ret );            // Show result
#endif

    return ( ret == MCSDL_RET_SUCCESS );
}