diff --git a/drivers/input/touchscreen/ancora/mcs8000_download.c b/drivers/input/touchscreen/ancora/mcs8000_download.c index 7d31b012b9c..75397ae67f7 100644 --- a/drivers/input/touchscreen/ancora/mcs8000_download.c +++ b/drivers/input/touchscreen/ancora/mcs8000_download.c @@ -9,7 +9,7 @@ #include #include #include -// + #include #include @@ -26,12 +26,6 @@ // //============================================================ -//#include "ESCAPE_R01_V02.c" // Master Binary data -//#include "MCS8000_R10_V05_bin.c" -//#include "MCS8000_V98_bin.c" -//#include "mcs8000_bin.c" -//#include "MCS8000_bin_V73.c" -//#include "MCS8000_bin_R11_V08.c" #if defined(CONFIG_MACH_ANCORA_TMO) #include "ANCORA_TMO_FW_R04_V06.c" #include "ANCORA_TMO_FW_R06_V13.c" @@ -40,8 +34,7 @@ #include "ANCORA_FW_R50_V15.c" #endif -UINT8 ucVerifyBuffer[MELFAS_TRANSFER_LENGTH]; // You may melloc *ucVerifyBuffer instead of this - +UINT8 ucVerifyBuffer[MELFAS_TRANSFER_LENGTH]; //--------------------------------- // Downloading functions @@ -105,8 +98,7 @@ static void mcsdl_print_result(int nRet); void melfas_send_download_enable_command(void) { - // TO DO : Fill this up - + //Unused function } #endif @@ -125,10 +117,10 @@ void melfas_send_download_enable_command(void) int mcsdl_ISC_download_binary_data(void) { int nRet; - #if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD +#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD melfas_send_download_enable_command(); mcsdl_delay(MCSDL_DELAY_100US); - #endif +#endif MELFAS_DISABLE_BASEBAND_ISR(); // Disable Baseband touch interrupt ISR. MELFAS_DISABLE_WATCHDOG_TIMER_RESET(); // Disable Baseband watchdog timer @@ -145,10 +137,10 @@ int mcsdl_ISC_download_binary_data(void) int mcsdl_ISC_download_binary_data_G2(void) { int nRet; - #if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD +#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD melfas_send_download_enable_command(); mcsdl_delay(MCSDL_DELAY_100US); - #endif +#endif MELFAS_DISABLE_BASEBAND_ISR(); // Disable Baseband touch interrupt ISR. MELFAS_DISABLE_WATCHDOG_TIMER_RESET(); // Disable Baseband watchdog timer @@ -165,10 +157,10 @@ int mcsdl_ISC_download_binary_data_G2(void) int mcsdl_download_binary_data(void) { int nRet; - #if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD +#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD melfas_send_download_enable_command(); mcsdl_delay(MCSDL_DELAY_100US); - #endif +#endif MELFAS_DISABLE_BASEBAND_ISR(); // Disable Baseband touch interrupt ISR. MELFAS_DISABLE_WATCHDOG_TIMER_RESET(); // Disable Baseband watchdog timer @@ -177,9 +169,9 @@ int mcsdl_download_binary_data(void) // Run Download //------------------------ nRet = mcsdl_download( (const UINT8*) MELFAS_binary, (const UINT16)MELFAS_binary_nLength , 0); - #if MELFAS_2CHIP_DOWNLOAD_ENABLE +#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 +#endif MELFAS_ROLLBACK_BASEBAND_ISR(); // Roll-back Baseband touch interrupt ISR. MELFAS_ROLLBACK_WATCHDOG_TIMER_RESET(); // Roll-back Baseband watchdog timer @@ -190,10 +182,10 @@ int mcsdl_download_binary_data(void) int mcsdl_download_binary_data_55T(void) { int nRet; - #if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD +#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD melfas_send_download_enable_command(); mcsdl_delay(MCSDL_DELAY_100US); - #endif +#endif MELFAS_DISABLE_BASEBAND_ISR(); // Disable Baseband touch interrupt ISR. MELFAS_DISABLE_WATCHDOG_TIMER_RESET(); // Disable Baseband watchdog timer @@ -214,10 +206,10 @@ int mcsdl_download_binary_data_55T(void) int mcsdl_download_binary_data_G2(void) { int nRet; - #if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD +#if MELFAS_USE_PROTOCOL_COMMAND_FOR_DOWNLOAD melfas_send_download_enable_command(); mcsdl_delay(MCSDL_DELAY_100US); - #endif +#endif MELFAS_DISABLE_BASEBAND_ISR(); // Disable Baseband touch interrupt ISR. MELFAS_DISABLE_WATCHDOG_TIMER_RESET(); // Disable Baseband watchdog timer @@ -250,8 +242,8 @@ int mcsdl_download_binary_file(void) // 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) + // IdxNum : 0 (Master Chip Download) + // IdxNum : 1 (2Chip Download) // //================================================== @@ -263,15 +255,14 @@ int mcsdl_download_binary_file(void) 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 ){ + 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{ - + } else { nRet = MCSDL_RET_WRONG_BINARY; } } @@ -279,14 +270,9 @@ int mcsdl_download_binary_file(void) 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 +#if MELFAS_ENABLE_DBG_PRINT mcsdl_print_result( nRet ); - #endif - - #if 0 - if( pData != NULL ) // free memory alloced. - free(pData); - #endif +#endif return ( nRet == MCSDL_RET_SUCCESS ); @@ -298,40 +284,40 @@ int mcsdl_download_binary_file(void) // //------------------------------------------------------------------ -static int mcsdl_download(const UINT8 *pBianry, const UINT16 unLength, INT8 IdxNum ) +static int mcsdl_download(const UINT8 *pBinary, const UINT16 unLength, INT8 IdxNum ) { int nRet; //--------------------------------- // Check Binary Size //--------------------------------- - if( unLength >= MELFAS_FIRMWARE_MAX_SIZE ){ + if( unLength >= MELFAS_FIRMWARE_MAX_SIZE ) { nRet = MCSDL_RET_PROGRAM_SIZE_IS_WRONG; goto MCSDL_DOWNLOAD_FINISH; } - #if MELFAS_ENABLE_DBG_PROGRESS_PRINT +#if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" - Starting download...\n"); - #endif +#endif //--------------------------------- // Make it ready //--------------------------------- - #if MELFAS_ENABLE_DBG_PROGRESS_PRINT +#if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Ready\n"); - #endif +#endif mcsdl_set_ready(); //--------------------------------- // Erase Flash //--------------------------------- - #if MELFAS_ENABLE_DBG_PROGRESS_PRINT +#if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Erase\n"); - #endif +#endif nRet = mcsdl_erase_flash(IdxNum); @@ -341,28 +327,28 @@ static int mcsdl_download(const UINT8 *pBianry, const UINT16 unLength, INT8 IdxN //--------------------------------- // Program Flash //--------------------------------- - #if MELFAS_ENABLE_DBG_PROGRESS_PRINT +#if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Program "); - #endif +#endif - nRet = mcsdl_program_flash( (UINT8*)pBianry, (UINT16)unLength, IdxNum ); + nRet = mcsdl_program_flash( (UINT8*)pBinary, (UINT16)unLength, IdxNum ); if( nRet != MCSDL_RET_SUCCESS ) goto MCSDL_DOWNLOAD_FINISH; //--------------------------------- // Verify flash //--------------------------------- - #if MELFAS_ENABLE_DBG_PROGRESS_PRINT +#if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Verify "); - #endif +#endif - nRet = mcsdl_verify_flash( (UINT8*)pBianry, (UINT16)unLength, IdxNum ); + nRet = mcsdl_verify_flash( (UINT8*)pBinary, (UINT16)unLength, IdxNum ); if( nRet != MCSDL_RET_SUCCESS ) { - nRet = mcsdl_verify_flash( (UINT8*)pBianry, (UINT16)unLength, IdxNum ); + nRet = mcsdl_verify_flash( (UINT8*)pBinary, (UINT16)unLength, IdxNum ); if( nRet != MCSDL_RET_SUCCESS ) { - nRet = mcsdl_verify_flash( (UINT8*)pBianry, (UINT16)unLength, IdxNum ); + nRet = mcsdl_verify_flash( (UINT8*)pBinary, (UINT16)unLength, IdxNum ); if( nRet != MCSDL_RET_SUCCESS ) goto MCSDL_DOWNLOAD_FINISH; @@ -375,14 +361,14 @@ static int mcsdl_download(const UINT8 *pBianry, const UINT16 unLength, INT8 IdxN MCSDL_DOWNLOAD_FINISH : - #if MELFAS_ENABLE_DBG_PRINT - mcsdl_print_result( nRet ); // Show result - #endif +#if MELFAS_ENABLE_DBG_PRINT + mcsdl_print_result( nRet ); +#endif - #if MELFAS_ENABLE_DBG_PROGRESS_PRINT +#if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" > Rebooting\n"); printk(" - Fin.\n\n"); - #endif +#endif mcsdl_reboot_mcs(); @@ -416,7 +402,7 @@ static int mcsdl_erase_flash(INT8 IdxNum) mcsdl_read_flash_from( &readBuffer[16], 0x7FF0, 16, IdxNum); // Compare with '0xFF' - for(i=0; i<32; i++){ + for(i=0; i<32; i++) { if( readBuffer[i] != 0xFF ) return MCSDL_RET_ERASE_FLASH_VERIFY_FAILED; } @@ -439,12 +425,10 @@ static int mcsdl_program_flash( UINT8 *pDataOriginal, UINT16 unLength, INT8 IdxN pData = pDataOriginal; ucLength = MELFAS_TRANSFER_LENGTH; - -//kang - while( (addr*4) < (int)unLength){ + while( (addr*4) < (int)unLength) { - if( ( unLength - (addr*4) ) < MELFAS_TRANSFER_LENGTH ){ + if( ( unLength - (addr*4) ) < MELFAS_TRANSFER_LENGTH ) { ucLength = (UINT8)(unLength - (addr*4) ); } @@ -472,9 +456,9 @@ static int mcsdl_program_flash( UINT8 *pDataOriginal, UINT16 unLength, INT8 IdxN //--------------------------------- addr +=1; - #if MELFAS_ENABLE_DBG_PROGRESS_PRINT +#if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk("#"); - #endif +#endif mcsdl_program_flash_part(pData); @@ -488,7 +472,7 @@ static int mcsdl_program_flash( UINT8 *pDataOriginal, UINT16 unLength, INT8 IdxN mcsdl_delay(MCSDL_DELAY_40US); - for(i=0; i<6; i++){ + for(i=0; i<6; i++) { if( i==2 ) mcsdl_delay(MCSDL_DELAY_20US); else if( i==3 ) mcsdl_delay(MCSDL_DELAY_40US); @@ -496,10 +480,6 @@ static int mcsdl_program_flash( UINT8 *pDataOriginal, UINT16 unLength, INT8 IdxN MCSDL_GPIO_SCL_SET_HIGH(); mcsdl_delay(MCSDL_DELAY_10US); MCSDL_GPIO_SCL_SET_LOW(); mcsdl_delay(MCSDL_DELAY_10US); } - - #if MELFAS_ENABLE_DBG_PROGRESS_PRINT - //printk("\n"); - #endif mcsdl_unselect_isp_mode(); @@ -545,9 +525,9 @@ static int mcsdl_verify_flash( UINT8 *pDataOriginal, UINT16 unLength, INT8 IdxNu ucLength = MELFAS_TRANSFER_LENGTH; - while( (addr*4) < (int)unLength){ + while( (addr*4) < (int)unLength) { - if( ( unLength - (addr*4) ) < MELFAS_TRANSFER_LENGTH ){ + if( ( unLength - (addr*4) ) < MELFAS_TRANSFER_LENGTH ) { ucLength = (UINT8)(unLength - (addr*4) ); } @@ -572,9 +552,9 @@ static int mcsdl_verify_flash( UINT8 *pDataOriginal, UINT16 unLength, INT8 IdxNu addr+=1; - #if MELFAS_ENABLE_DBG_PROGRESS_PRINT +#if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk("#"); - #endif +#endif @@ -586,7 +566,7 @@ static int mcsdl_verify_flash( UINT8 *pDataOriginal, UINT16 unLength, INT8 IdxNu MCSDL_GPIO_SDA_SET_HIGH(); - for(i=0; i<6; i++){ + for(i=0; i<6; i++) { if( i==2 ) mcsdl_delay(MCSDL_DELAY_3US); else if( i==3 ) mcsdl_delay(MCSDL_DELAY_40US); @@ -599,17 +579,17 @@ static int mcsdl_verify_flash( UINT8 *pDataOriginal, UINT16 unLength, INT8 IdxNu // Comparing //-------------------- - for(j=0; j<(int)ucLength; j++){ + for(j=0; j<(int)ucLength; j++) { - #if MELFAS_ENABLE_DBG_PROGRESS_PRINT +#if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" %02X", ucVerifyBuffer[j] ); - #endif +#endif - if( ucVerifyBuffer[j] != pData[j] ){ + if( ucVerifyBuffer[j] != pData[j] ) { - #if MELFAS_ENABLE_DBG_PROGRESS_PRINT +#if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk("\n [Error] Address : 0x%04X : 0x%02X - 0x%02X\n", addr, pData[j], ucVerifyBuffer[j] ); - #endif +#endif nRet = MCSDL_RET_PROGRAM_VERIFY_FAILED; @@ -620,10 +600,6 @@ static int mcsdl_verify_flash( UINT8 *pDataOriginal, UINT16 unLength, INT8 IdxNu pData += ucLength; - #if MELFAS_ENABLE_DBG_PROGRESS_PRINT - //printk("\n"); - #endif - mcsdl_unselect_isp_mode(); } @@ -631,9 +607,9 @@ static int mcsdl_verify_flash( UINT8 *pDataOriginal, UINT16 unLength, INT8 IdxNu MCSDL_VERIFY_FLASH_FINISH: - #if MELFAS_ENABLE_DBG_PROGRESS_PRINT +#if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk("\n"); - #endif +#endif mcsdl_unselect_isp_mode(); @@ -649,10 +625,10 @@ static void mcsdl_read_flash( UINT8 *pBuffer) mcsdl_delay(MCSDL_DELAY_40US); - for (i=0; i< 5; i++){ + for (i=0; i< 5; i++) { MCSDL_GPIO_SCL_SET_HIGH(); mcsdl_delay(MCSDL_DELAY_10US); MCSDL_GPIO_SCL_SET_LOW(); mcsdl_delay(MCSDL_DELAY_10US); - } + } mcsdl_read_32bits( pBuffer ); } @@ -667,18 +643,18 @@ static int mcsdl_read_flash_from( UINT8 *pBuffer, UINT16 unStart_addr, UINT16 un UINT16 addr; UINT32 wordData; - if( unLength >= MELFAS_FIRMWARE_MAX_SIZE ){ + if( unLength >= MELFAS_FIRMWARE_MAX_SIZE ) { return MCSDL_RET_PROGRAM_SIZE_IS_WRONG; } addr = 0; ucLength = MELFAS_TRANSFER_LENGTH; - #if MELFAS_ENABLE_DBG_PROGRESS_PRINT +#if MELFAS_ENABLE_DBG_PROGRESS_PRINT printk(" %04X : ", unStart_addr ); - #endif +#endif - for( i = 0; i < (int)unLength; i+=(int)ucLength ){ + for( i = 0; i < (int)unLength; i+=(int)ucLength ) { addr = (UINT16)i; if(IdxNum > 0) @@ -690,7 +666,7 @@ static int mcsdl_read_flash_from( UINT8 *pBuffer, UINT16 unStart_addr, UINT16 un mcsdl_write_bits( wordData, 18 ); - if( ( unLength - addr ) < MELFAS_TRANSFER_LENGTH ){ + if( ( unLength - addr ) < MELFAS_TRANSFER_LENGTH ) { ucLength = (UINT8)(unLength - addr); } @@ -701,20 +677,16 @@ static int mcsdl_read_flash_from( UINT8 *pBuffer, UINT16 unStart_addr, UINT16 un mcsdl_read_flash( &pBuffer[addr]); - #if MELFAS_ENABLE_DBG_PROGRESS_PRINT - for(j=0; j<(int)ucLength; j++){ +#if MELFAS_ENABLE_DBG_PROGRESS_PRINT + for(j=0; j<(int)ucLength; j++) { printk("%02X ", pBuffer[j] ); } - #endif +#endif mcsdl_unselect_isp_mode(); } - #if MELFAS_ENABLE_DBG_PROGRESS_PRINT - //printk("\n"); - #endif - return MCSDL_RET_SUCCESS; } @@ -728,11 +700,6 @@ static void mcsdl_set_ready(void) MCSDL_VDD_SET_LOW(); // power - //MCSDL_CE_SET_LOW(); - //MCSDL_CE_SET_OUTPUT(); - - //MCSDL_SET_GPIO_I2C(); - MCSDL_GPIO_SDA_SET_LOW(); MCSDL_GPIO_SDA_SET_OUTPUT(); @@ -745,7 +712,6 @@ static void mcsdl_set_ready(void) mcsdl_delay(MCSDL_DELAY_25MS); // Delay for Stable VDD MCSDL_VDD_SET_HIGH(); - //MCSDL_CE_SET_HIGH(); MCSDL_GPIO_SDA_SET_HIGH(); @@ -777,34 +743,8 @@ static void mcsdl_reboot_mcs(void) mcsdl_vdd_on(); - msleep(300); -/* - MCSDL_VDD_SET_LOW(); - - //MCSDL_CE_SET_LOW(); - //MCSDL_CE_SET_OUTPUT(); - - MCSDL_GPIO_SDA_SET_HIGH(); - MCSDL_GPIO_SDA_SET_OUTPUT(); - - MCSDL_GPIO_SCL_SET_HIGH(); - MCSDL_GPIO_SCL_SET_OUTPUT(); - - //MCSDL_SET_HW_I2C(); - - MCSDL_RESETB_SET_LOW(); - MCSDL_RESETB_SET_OUTPUT(); - - mcsdl_delay(MCSDL_DELAY_25MS); // Delay for Stable VDD - - MCSDL_RESETB_SET_INPUT(); - MCSDL_VDD_SET_HIGH(); - - MCSDL_RESETB_SET_HIGH(); - //MCSDL_CE_SET_HIGH(); + msleep(300); - mcsdl_delay(MCSDL_DELAY_30MS); // Delay '25 msec' -*/ } @@ -854,9 +794,9 @@ static void mcsdl_select_isp_mode(UINT8 ucMode) // Entering ISP mode : Part 2 - Only Mass Erase //--------------------------------------------------- - if( ucMode == ISP_MODE_ERASE_FLASH ){ + if( ucMode == ISP_MODE_ERASE_FLASH ) { mcsdl_delay(MCSDL_DELAY_7US); - for(i=0; i<4; i++){ + for(i=0; i<4; i++) { if( i==2 ) mcsdl_delay(MCSDL_DELAY_25MS); else if( i==3 ) mcsdl_delay(MCSDL_DELAY_150US); @@ -872,14 +812,11 @@ static void mcsdl_unselect_isp_mode(void) { int i; - // MCSDL_GPIO_SDA_SET_HIGH(); - // MCSDL_GPIO_SDA_SET_OUTPUT(); - MCSDL_RESETB_SET_LOW(); mcsdl_delay(MCSDL_DELAY_3US); - for(i=0; i<10; i++){ + for(i=0; i<10; i++) { MCSDL_GPIO_SCL_SET_HIGH(); mcsdl_delay(MCSDL_DELAY_3US); MCSDL_GPIO_SCL_SET_LOW(); mcsdl_delay(MCSDL_DELAY_3US); @@ -895,11 +832,11 @@ static void mcsdl_read_32bits( UINT8 *pData ) MCSDL_GPIO_SDA_SET_INPUT(); - for (i=3; i>=0; i--){ + for (i=3; i>=0; i--) { pData[i] = 0; - for (j=0; j<8; j++){ + for (j=0; j<8; j++) { pData[i] <<= 1; @@ -922,7 +859,7 @@ static void mcsdl_write_bits(UINT32 wordData, int nBits) MCSDL_GPIO_SDA_SET_LOW(); MCSDL_GPIO_SDA_SET_OUTPUT(); - for (i=0; i Public Configration download.\n"); } - //for (i = 0; i < 3; i++) { - //if (dl_enable_bit & (1 << i)) + { //--------------------------------- // Make it ready @@ -1133,12 +1069,9 @@ static int mcsdl_ISC_download(const UINT8 *pBianry, const UINT16 unLength, INT8 fw_status = mcsdl_ISC_read_firmware_status(); - if (fw_status == 0x01) - { + if (fw_status == 0x01) { printk(" Firmware update mode enter success!!!\n"); - } - else - { + } else { printk(" Error detected!! firmware status is 0x%02x.\n", fw_status); nRet = MCSDL_FIRMWARE_UPDATE_MODE_ENTER_FAILED; goto MCSDL_DOWNLOAD_FINISH; @@ -1150,7 +1083,7 @@ static int mcsdl_ISC_download(const UINT8 *pBianry, const UINT16 unLength, INT8 // FIRMWARE UPDATE //-------------------------------------------------------------- printk(" FIRMWARE UPDATE\n\n"); - nRet = mcsdl_ISC_firmware_update((UINT8 *)pBianry, (UINT16)unLength, flash_start[0],flash_end[0]); + nRet = mcsdl_ISC_firmware_update((UINT8 *)pBinary, (UINT16)unLength, flash_start[0],flash_end[0]); if(nRet != MCSDL_RET_SUCCESS) goto MCSDL_DOWNLOAD_FINISH; @@ -1164,7 +1097,7 @@ static int mcsdl_ISC_download(const UINT8 *pBianry, const UINT16 unLength, INT8 MCSDL_DOWNLOAD_FINISH : #if MELFAS_ENABLE_DBG_PRINT - mcsdl_ISC_print_result( nRet ); // Show result + mcsdl_ISC_print_result( nRet ); #endif #if MELFAS_ENABLE_DBG_PROGRESS_PRINT @@ -1188,8 +1121,6 @@ static void mcsdl_ISC_set_ready(void) MCSDL_VDD_SET_LOW(); // power - //MCSDL_SET_GPIO_I2C(); - MCSDL_GPIO_ISC_SDA_SET_OUTPUT(1); MCSDL_GPIO_SDA_SET_HIGH(); @@ -1198,8 +1129,6 @@ static void mcsdl_ISC_set_ready(void) MCSDL_RESETB_SET_INPUT(); - //MCSDL_CE_SET_HIGH; - //MCSDL_CE_SET_OUTPUT(); mcsdl_delay(MCSDL_DELAY_60MS); // Delay for Stable VDD MCSDL_VDD_SET_HIGH(); @@ -1222,12 +1151,12 @@ static UINT8 mcsdl_ISC_read_data(UINT8 addr) mcsdl_delay(MCSDL_DELAY_10MS); mcsdl_i2c_start(); - // 1byte read + wordData = (ISC_MODE_SLAVE_ADDRESS << 1 | 0x01) << 24; mcsdl_ISC_write_bits( wordData, 8 ); flash_start = mcsdl_read_byte(); wordData = (0x01) << 31; - mcsdl_ISC_write_bits( wordData, 1 ); //Nack + mcsdl_ISC_write_bits( wordData, 1 ); mcsdl_i2c_stop(); return flash_start; } @@ -1249,19 +1178,19 @@ static UINT8 mcsdl_ISC_read_firmware_status() UINT32 wordData = 0x00000000; UINT8 fw_status; mcsdl_i2c_start(); - // WRITE 0xAF + wordData = (ISC_MODE_SLAVE_ADDRESS << 1) << 24 | (0xAF << 16); mcsdl_ISC_write_bits( wordData, 16 ); mcsdl_i2c_stop(); mcsdl_delay(MCSDL_DELAY_100MS); mcsdl_i2c_start(); - // 1byte read + wordData = (ISC_MODE_SLAVE_ADDRESS << 1 | 0x01) << 24; mcsdl_ISC_write_bits( wordData, 8 ); fw_status = mcsdl_read_byte(); wordData = (0x01) << 31; - mcsdl_ISC_write_bits( wordData, 1 ); //Nack + mcsdl_ISC_write_bits( wordData, 1 ); mcsdl_i2c_stop(); return fw_status; } @@ -1308,7 +1237,7 @@ static UINT8 mcsdl_ISC_firmware_update(UINT8 *_pBinary_reordered, UINT16 _unDown CRC_send_buf = (CRC_send_buf<<4) | (XOR_bit_3 <<3) | (CRC_check_buf>>1 & 0x0007); CRC_check_buf = CRC_send_buf; } - // printk(" CRC_check_buf 0x%02x, 0x%02x\n", (UINT8)(CRC_check_buf >> 8 & 0xFF), (UINT8)(CRC_check_buf & 0xFF)); + #endif if (nOffset < _unDownload_size/1024 +1) { @@ -1320,7 +1249,6 @@ static UINT8 mcsdl_ISC_firmware_update(UINT8 *_pBinary_reordered, UINT16 _unDown write_buffer[i*4+2] = _pBinary_reordered[(flash_start+nOffset)*1024+j*32+i*4+1]; write_buffer[i*4+1] = _pBinary_reordered[(flash_start+nOffset)*1024+j*32+i*4+2]; write_buffer[i*4+0] = _pBinary_reordered[(flash_start+nOffset)*1024+j*32+i*4+3]; - //printk(" write buffer : 0x%02x,0x%02x,0x%02x,0x%02x\n", write_buffer[i*4+0],write_buffer[i*4+1],write_buffer[i*4+2],write_buffer[i*4+3]); #if MELFAS_CRC_CHECK_ENABLE for (n = 0; n < 4; n++) { @@ -1336,7 +1264,6 @@ static UINT8 mcsdl_ISC_firmware_update(UINT8 *_pBinary_reordered, UINT16 _unDown CRC_check_buf = CRC_send_buf; } } - //printk(" CRC_check_buf 0x%02x, 0x%02x\n", (UINT8)(CRC_check_buf >> 8 & 0xFF), (UINT8)(CRC_check_buf & 0xFF)); #endif } @@ -1355,7 +1282,6 @@ static UINT8 mcsdl_ISC_firmware_update(UINT8 *_pBinary_reordered, UINT16 _unDown wordData = (write_buffer[0] << 24) | (write_buffer[1]<< 16); mcsdl_ISC_write_bits( wordData, 16 ); - //printk(" CRC_data = 0x%02x 0x%02x\n",write_buffer[0],write_buffer[1]); mcsdl_delay(MCSDL_DELAY_100US); #endif mcsdl_i2c_stop(); @@ -1363,12 +1289,9 @@ static UINT8 mcsdl_ISC_firmware_update(UINT8 *_pBinary_reordered, UINT16 _unDown #if MELFAS_CRC_CHECK_ENABLE fw_status = mcsdl_ISC_read_firmware_status(); - if(fw_status == 0x03) - { + if(fw_status == 0x03) { printk(" Firmware update success!!!\n"); - } - else - { + } else { printk(" Error detected!! firmware status is 0x%02x.\n", fw_status); return MCSDL_FIRMWARE_UPDATE_FAILED; } @@ -1423,12 +1346,12 @@ static void mcsdl_delay(UINT32 nCount) case MCSDL_DELAY_20US : udelay(20); break; - case MCSDL_DELAY_40US : - udelay(40); - break; - case MCSDL_DELAY_70US : - udelay(70); - break; + case MCSDL_DELAY_40US : + udelay(40); + break; + case MCSDL_DELAY_70US : + udelay(70); + break; case MCSDL_DELAY_100US : udelay(100); break; @@ -1465,17 +1388,15 @@ static void mcsdl_delay(UINT32 nCount) case MCSDL_DELAY_45MS : msleep(45); break; - break; - case MCSDL_DELAY_60MS : - msleep(60); - break; - case MCSDL_DELAY_100MS : - mdelay(100); - break; + case MCSDL_DELAY_60MS : + msleep(60); + break; + case MCSDL_DELAY_100MS : + mdelay(100); + break; default : break; - }// Please, Use your delay function - + } } @@ -1491,31 +1412,38 @@ static void mcsdl_delay(UINT32 nCount) static void mcsdl_print_result(int nRet) { - if( nRet == MCSDL_RET_SUCCESS ){ + if( nRet == MCSDL_RET_SUCCESS ) { printk(" > MELFAS Firmware downloading SUCCESS.\n"); - }else{ + } else { printk(" > MELFAS Firmware downloading FAILED : "); - switch( nRet ){ - - case MCSDL_RET_SUCCESS : printk("MCSDL_RET_SUCCESS\n" ); break; - case MCSDL_RET_ERASE_FLASH_VERIFY_FAILED : printk("MCSDL_RET_ERASE_FLASH_VERIFY_FAILED\n" ); break; - case MCSDL_RET_PROGRAM_VERIFY_FAILED : printk("MCSDL_RET_PROGRAM_VERIFY_FAILED\n" ); break; - - case MCSDL_RET_PROGRAM_SIZE_IS_WRONG : printk("MCSDL_RET_PROGRAM_SIZE_IS_WRONG\n" ); break; - case MCSDL_RET_VERIFY_SIZE_IS_WRONG : printk("MCSDL_RET_VERIFY_SIZE_IS_WRONG\n" ); break; - case MCSDL_RET_WRONG_BINARY : printk("MCSDL_RET_WRONG_BINARY\n" ); break; - - case MCSDL_RET_READING_HEXFILE_FAILED : printk("MCSDL_RET_READING_HEXFILE_FAILED\n" ); break; - case MCSDL_RET_FILE_ACCESS_FAILED : printk("MCSDL_RET_FILE_ACCESS_FAILED\n" ); break; - case MCSDL_RET_MELLOC_FAILED : printk("MCSDL_RET_MELLOC_FAILED\n" ); break; - - case MCSDL_RET_WRONG_MODULE_REVISION : printk("MCSDL_RET_WRONG_MODULE_REVISION\n" ); break; - - default : printk("UNKNOWN ERROR. [0x%02X].\n", nRet ); break; + switch( nRet ) { + + case MCSDL_RET_SUCCESS : printk("MCSDL_RET_SUCCESS\n" ); + break; + case MCSDL_RET_ERASE_FLASH_VERIFY_FAILED : printk("MCSDL_RET_ERASE_FLASH_VERIFY_FAILED\n" ); + break; + case MCSDL_RET_PROGRAM_VERIFY_FAILED : printk("MCSDL_RET_PROGRAM_VERIFY_FAILED\n" ); + break; + case MCSDL_RET_PROGRAM_SIZE_IS_WRONG : printk("MCSDL_RET_PROGRAM_SIZE_IS_WRONG\n" ); + break; + case MCSDL_RET_VERIFY_SIZE_IS_WRONG : printk("MCSDL_RET_VERIFY_SIZE_IS_WRONG\n" ); + break; + case MCSDL_RET_WRONG_BINARY : printk("MCSDL_RET_WRONG_BINARY\n" ); + break; + case MCSDL_RET_READING_HEXFILE_FAILED : printk("MCSDL_RET_READING_HEXFILE_FAILED\n" ); + break; + case MCSDL_RET_FILE_ACCESS_FAILED : printk("MCSDL_RET_FILE_ACCESS_FAILED\n" ); + break; + case MCSDL_RET_MELLOC_FAILED : printk("MCSDL_RET_MELLOC_FAILED\n" ); + break; + case MCSDL_RET_WRONG_MODULE_REVISION : printk("MCSDL_RET_WRONG_MODULE_REVISION\n" ); + break; + default : printk("UNKNOWN ERROR. [0x%02X].\n", nRet ); + break; } printk("\n"); @@ -1525,30 +1453,34 @@ static void mcsdl_print_result(int nRet) static void mcsdl_ISC_print_result(int nRet) { - if( nRet == MCSDL_RET_SUCCESS ) - { + if( nRet == MCSDL_RET_SUCCESS ) { printk(" Firmware downloading SUCCESS.\n"); - } - else - { + } else { printk(" Firmware downloading FAILED : "); - switch( nRet ) - { - case MCSDL_RET_SUCCESS : printk(" MCSDL_RET_SUCCESS\n" ); break; - case MCSDL_FIRMWARE_UPDATE_MODE_ENTER_FAILED : printk(" MCSDL_FIRMWARE_UPDATE_MODE_ENTER_FAILED\n" ); break; - case MCSDL_RET_PROGRAM_VERIFY_FAILED : printk(" MCSDL_RET_PROGRAM_VERIFY_FAILED\n" ); break; - - case MCSDL_RET_PROGRAM_SIZE_IS_WRONG : printk(" MCSDL_RET_PROGRAM_SIZE_IS_WRONG\n" ); break; - case MCSDL_RET_VERIFY_SIZE_IS_WRONG : printk(" MCSDL_RET_VERIFY_SIZE_IS_WRONG\n" ); break; - case MCSDL_RET_WRONG_BINARY : printk(" MCSDL_RET_WRONG_BINARY\n" ); break; - - case MCSDL_RET_READING_HEXFILE_FAILED : printk(" MCSDL_RET_READING_HEXFILE_FAILED\n" ); break; - case MCSDL_RET_FILE_ACCESS_FAILED : printk(" MCSDL_RET_FILE_ACCESS_FAILED\n" ); break; - case MCSDL_RET_MELLOC_FAILED : printk(" MCSDL_RET_MELLOC_FAILED\n" ); break; - - case MCSDL_RET_WRONG_MODULE_REVISION : printk(" MCSDL_RET_WRONG_MODULE_REVISION\n" ); break; - - default : printk(" UNKNOWN ERROR. [0x%02X].\n", nRet ); break; + switch( nRet ) { + case MCSDL_RET_SUCCESS : printk(" MCSDL_RET_SUCCESS\n" ); + break; + case MCSDL_FIRMWARE_UPDATE_MODE_ENTER_FAILED : printk(" MCSDL_FIRMWARE_UPDATE_MODE_ENTER_FAILED\n" ); + break; + case MCSDL_RET_PROGRAM_VERIFY_FAILED : printk(" MCSDL_RET_PROGRAM_VERIFY_FAILED\n" ); + break; + case MCSDL_RET_PROGRAM_SIZE_IS_WRONG : printk(" MCSDL_RET_PROGRAM_SIZE_IS_WRONG\n" ); + break; + case MCSDL_RET_VERIFY_SIZE_IS_WRONG : printk(" MCSDL_RET_VERIFY_SIZE_IS_WRONG\n" ); + break; + case MCSDL_RET_WRONG_BINARY : printk(" MCSDL_RET_WRONG_BINARY\n" ); + break; + case MCSDL_RET_READING_HEXFILE_FAILED : printk(" MCSDL_RET_READING_HEXFILE_FAILED\n" ); + break; + case MCSDL_RET_FILE_ACCESS_FAILED : printk(" MCSDL_RET_FILE_ACCESS_FAILED\n" ); + break; + case MCSDL_RET_MELLOC_FAILED : printk(" MCSDL_RET_MELLOC_FAILED\n" ); + break; + case MCSDL_RET_WRONG_MODULE_REVISION : printk(" MCSDL_RET_WRONG_MODULE_REVISION\n" ); + break; + + default : printk(" UNKNOWN ERROR. [0x%02X].\n", nRet ); + break; } printk("\n"); @@ -1588,29 +1520,7 @@ void mcsdl_delay_test(INT32 nCount) MCSDL_GPIO_SCL_SET_HIGH(); - for( i=0; iaddr[[ %x ]\n", __func__, p_client->addr); - - if (1 != i2c_transfer(p_client->adapter, &msg, 1)) - { + if (1 != i2c_transfer(p_client->adapter, &msg, 1)) { printk("%s set data pointer fail! reg(%x)\n", __func__, reg); return -EIO; } @@ -284,8 +281,7 @@ static int melfas_mcs8000_i2c_read(struct i2c_client* p_client, u8 reg, u8* data msg.len = len; msg.buf = data; - if (1 != i2c_transfer(p_client->adapter, &msg, 1)) - { + if (1 != i2c_transfer(p_client->adapter, &msg, 1)) { printk("%s fail! reg(%x)\n", __func__, reg); return -EIO; } @@ -299,8 +295,7 @@ static int melfas_mcs8000_read_version(void) u8 buf[2] = {0,}; ret = melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, MCSTS_MODULE_VER_REG, buf, 2); - if (ret == 0) - { + if (ret == 0) { melfas_mcs8000_ts->hw_rev = buf[0]; melfas_mcs8000_ts->fw_ver = buf[1]; @@ -312,9 +307,7 @@ static int melfas_mcs8000_read_version(void) } printk("%s :HW Ver : 0x%02x, FW Ver : 0x%02x\n", __func__, buf[0], buf[1]); - } - else - { + } else { melfas_mcs8000_ts->hw_rev = 0; melfas_mcs8000_ts->fw_ver = 0; @@ -322,13 +315,10 @@ static int melfas_mcs8000_read_version(void) } ret = melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, MCSTS_WINDOW_VER_REG, buf, 1); - if (ret == 0) - { + if (ret == 0) { melfas_mcs8000_ts->window_ver=buf[0]; printk("%s :Window Ver : %d\n", __func__, buf[0]); - } - else - { + } else { melfas_mcs8000_ts->window_ver=0; printk("%s :Window Ver : error\n", __func__); } @@ -347,25 +337,20 @@ static void melfas_mcs8000_read_resolution(void) printk("%s :buf[0] : 0x%02x, buf[1] : 0x%02x, buf[2] : 0x%02x\n", __func__,buf[0],buf[1],buf[2]); - if((buf[0] == 0)||(buf[0] == 0)||(buf[0] == 0)){ + if((buf[0] == 0)||(buf[0] == 0)||(buf[0] == 0)) { melfas_mcs8000_ts->info.max_x = 320; melfas_mcs8000_ts->info.max_y = 480; printk("%s : Can't find Resolution!\n", __func__); - } - - else{ + } else { max_x = buf[1] | ((uint16_t)(buf[0] & 0x0f) << 8); max_y = buf[2] | (((uint16_t)(buf[0] & 0xf0) >> 4) << 8); melfas_mcs8000_ts->info.max_x = max_x; - melfas_mcs8000_ts->info.max_y = max_y; + melfas_mcs8000_ts->info.max_y = max_y; printk("%s :max_x: %d, max_y: %d\n", __func__, melfas_mcs8000_ts->info.max_x, melfas_mcs8000_ts->info.max_y); - } } - - else - { + } else { melfas_mcs8000_ts->info.max_x = 320; melfas_mcs8000_ts->info.max_y = 480; @@ -380,23 +365,17 @@ static ssize_t registers_show_mcs8000(struct device *dev, struct device_attribut int status, mode_ctl, hw_rev, fw_ver; - if (0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, MCSTS_STATUS_REG, buf1, 2)) - { + if (0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, MCSTS_STATUS_REG, buf1, 2)) { status = buf1[0]; mode_ctl = buf1[1]; - } - else - { + } else { printk("%s : Can't find status, mode_ctl!\n", __func__); } - if (0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, MCSTS_MODULE_VER_REG, buf2, 2)) - { + if (0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, MCSTS_MODULE_VER_REG, buf2, 2)) { hw_rev = buf2[0]; fw_ver = buf2[1]; - } - else - { + } else { printk("%s : Can't find HW Ver, FW ver!\n", __func__); } @@ -438,7 +417,6 @@ static ssize_t gpio_store_mcs8000( { if(strncmp(buf, "ON", 2) == 0 || strncmp(buf, "on", 2) == 0) { mcsdl_vdd_on(); - //gpio_set_value(GPIO_TOUCH_EN, GPIO_LEVEL_HIGH); printk("[TOUCH] enable.\n"); mdelay(200); } @@ -464,33 +442,24 @@ static ssize_t firmware_show_mcs8000(struct device *dev, struct device_attribute u8 buf1[2] = {0,}; int hw_rev, fw_ver; - - if (0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, MCSTS_MODULE_VER_REG, buf1, 2)) - { + if (0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, MCSTS_MODULE_VER_REG, buf1, 2)) { hw_rev = buf1[0]; fw_ver = buf1[1]; sprintf(buf,"HW Ver : 0x%02x, FW Ver : 0x%02x\n", hw_rev, fw_ver); - } - else - { + } else { printk("%s : Can't find HW Ver, FW ver!\n", __func__); } return sprintf(buf, "%s", buf); } - static ssize_t firmware_store_mcs8000( struct device *dev, struct device_attribute *attr, const char *buf, size_t size) -{ - - // Unused +{ return size; } - - static ssize_t debug_show_mcs8000(struct device *dev, struct device_attribute *attr, char *buf) { return sprintf(buf, "%d", debug_level); @@ -515,19 +484,17 @@ static uint8_t tkey_sensitivity_read(void) sens_min = 0xFF ; /* Document errata!!! */ sens_max = 0x00 ; - for (sens_sum = n = 0 ; n < 3 ; n++) - { - if (melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, MCSTS_TKEY_RT_STRNTH_REG, &tkey_sens, 1) != 0) - { + for (sens_sum = n = 0 ; n < 3 ; n++) { + if (melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, MCSTS_TKEY_RT_STRNTH_REG, &tkey_sens, 1) != 0) { printk(KERN_ERR "tkey_sensitivity_read read fail!!!\n") ; break ; } - // tkey_sens &= 0x1F ; Document errata!!! + printk(KERN_DEBUG "tkey_sens : %d\n", tkey_sens) ; sens_sum += tkey_sens ; if (sens_min > tkey_sens) sens_min = tkey_sens ; - if (sens_max < tkey_sens) + if (sens_max < tkey_sens) sens_max = tkey_sens ; } tkey_sens = sens_sum - sens_min - sens_max ; /* median */ @@ -560,8 +527,7 @@ static ssize_t tkey_sens_pline_show_mcs8000(struct device *dev, struct device_at int n ; char str[20] ; - if (melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, MCSTS_TKEY_THD_REG, &noise_thd, 1) != 0) - { + if (melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, MCSTS_TKEY_THD_REG, &noise_thd, 1) != 0) { printk(KERN_ERR "[tkey_sens_pline_show] Fail to read noise_threshold<0x3F>!\n") ; return sprintf(buf, "0,0,0,0") ; } @@ -607,7 +573,7 @@ static ssize_t tkey_noise_thd_show_mcs8000(struct device *dev, struct device_att } /* else */ printk(KERN_ERR "TKEY_THRESHOLD : error\n") ; - return sprintf(buf, "0") ; // TODO: + return sprintf(buf, "0") ; } static ssize_t touch_led_control(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) @@ -622,8 +588,7 @@ static ssize_t touch_led_control(struct device *dev, struct device_attribute *at printk("touch_led_control : %d\n", data); #endif - if(data == 1 && led_state == TKEY_LED_OFF) - { + if(data == 1 && led_state == TKEY_LED_OFF) { rc = vreg_enable(vreg_ldo2); if (rc) { @@ -633,9 +598,7 @@ static ssize_t touch_led_control(struct device *dev, struct device_attribute *at } led_state = TKEY_LED_ON; - } - else if(data == 2 && led_state == TKEY_LED_ON) - { + } else if(data == 2 && led_state == TKEY_LED_ON) { rc = vreg_disable(vreg_ldo2); if (rc) { @@ -673,13 +636,11 @@ static DEVICE_ATTR(tkey_sens_pline, S_IRUGO, tkey_sens_pline_show_mcs8000, NULL) static DEVICE_ATTR(tkey_noise_thd, S_IRUGO, tkey_noise_thd_show_mcs8000, NULL); static DEVICE_ATTR(brightness, 0666, NULL, touch_led_control); #ifdef QT_ATCOM_TEST - static DEVICE_ATTR(key_threshold, S_IRUGO | S_IWUSR, key_threshold_show, key_threshold_store); #endif #ifdef QT_ATCOM_TEST struct device *qt602240_atcom_test; -//struct work_struct qt_touch_update_work; unsigned int qt_firm_status_data=0; @@ -703,21 +664,15 @@ void firmware_update() printk("[F/W D/L] Entry mcsdl_download_binary_data\n"); #if defined(CONFIG_MACH_ANCORA_TMO) - if(melfas_mcs8000_ts->window_ver==MELFAS_WINDOW_55T) - { + if(melfas_mcs8000_ts->window_ver==MELFAS_WINDOW_55T) { ret = mcsdl_download_binary_data_55T(); - } - else//if(melfas_mcs8000_ts->window_ver==MELFAS_WINDOW_70T) - { + } else { ret = mcsdl_download_binary_data(); } #else - if(melfas_mcs8000_ts->hw_rev == 0x03) // GFF - { + if(melfas_mcs8000_ts->hw_rev == 0x03) { ret = mcsdl_download_binary_data(); - } - else //if(melfas_mcs8000_ts->hw_rev == 0x50) // G2 - { + } else { ret = mcsdl_download_binary_data_G2(); } #endif @@ -729,7 +684,7 @@ void firmware_update() printk("[TSP] firmware update result. ret = %d\n", ret); - if(ret > 0){ + if(ret > 0) { if (melfas_mcs8000_ts->hw_rev < 0) { printk(KERN_ERR "i2c_transfer failed\n");; } @@ -740,8 +695,7 @@ void firmware_update() printk("[TOUCH] Firmware update success! [Melfas H/W version: 0x%02x., Current F/W version: 0x%02x.]\n", melfas_mcs8000_ts->hw_rev, melfas_mcs8000_ts->fw_ver); qt_firm_status_data=2; - } - else { + } else { qt_firm_status_data=3; printk("[TOUCH] Firmware update failed.. %d RESET!\n", ret); mcsdl_vdd_off(); @@ -776,7 +730,7 @@ void firmware_update_manual() printk("[TSP] firmware update result. ret = %d\n", ret); - if(ret > 0){ + if(ret > 0) { if (melfas_mcs8000_ts->hw_rev < 0) { printk(KERN_ERR "i2c_transfer failed\n"); } @@ -787,8 +741,7 @@ void firmware_update_manual() printk("[TOUCH] Firmware update success! [Melfas H/W version: 0x%02x., Current F/W version: 0x%02x.]\n", melfas_mcs8000_ts->hw_rev, melfas_mcs8000_ts->fw_ver); qt_firm_status_data=2; - } - else { + } else { qt_firm_status_data=3; printk("[TOUCH] Firmware update failed.. %d RESET!\n", ret); mcsdl_vdd_off(); @@ -811,9 +764,9 @@ static ssize_t set_qt_update_show(struct device *dev, struct device_attribute *a if(qt_firm_status_data == 3) { count = sprintf(buf,"FAIL\n"); - } - else + } else { count = sprintf(buf,"OK\n"); + } return count; } @@ -821,18 +774,14 @@ static ssize_t set_qt_update_show(struct device *dev, struct device_attribute *a static ssize_t set_qt_firm_version_show(struct device *dev, struct device_attribute *attr, char *buf) { #if defined(CONFIG_MACH_ANCORA) - if(melfas_mcs8000_ts->hw_rev == 0x03) // GFF TSP - { + if(melfas_mcs8000_ts->hw_rev == 0x03) { // GFF TSP return sprintf(buf, "0x%02x\n", NEW_FIRMWARE_VERSION_GFF); // kernel source version - } - else if(melfas_mcs8000_ts->hw_rev == 0x50) // G2 TSP - { + } else if(melfas_mcs8000_ts->hw_rev == 0x50) { // G2 TSP return sprintf(buf, "0x%02x\n", NEW_FIRMWARE_VERSION_G2); // kernel source version } #else - if(melfas_mcs8000_ts->window_ver==MELFAS_WINDOW_55T) // Window panel 0.55T - { - return sprintf(buf, "0x%02x\n", NEW_FIRMWARE_VERSION_55T);// kernel source version + if(melfas_mcs8000_ts->window_ver==MELFAS_WINDOW_55T) { // Window panel 0.55T + return sprintf(buf, "0x%02x\n", NEW_FIRMWARE_VERSION_55T);// kernel source version } #endif else // Window panel 0.7T @@ -857,15 +806,13 @@ static ssize_t set_qt_firm_status_show(struct device *dev, struct device_attribu if(qt_firm_status_data == 1) { count = sprintf(buf,"Downloading\n"); - } - else if(qt_firm_status_data == 2) { + } else if(qt_firm_status_data == 2) { count = sprintf(buf,"PASS\n"); - } - else if(qt_firm_status_data == 3) { + } else if(qt_firm_status_data == 3) { count = sprintf(buf,"FAIL\n"); - } - else + } else { count = sprintf(buf,"PASS\n"); + } return count; } @@ -880,12 +827,11 @@ static DEVICE_ATTR(set_qt_hw_version_read, 0664, set_qt_hw_version_read_show, NU void melfas_mcs8000_upgrade(void) { -// unused } static void melfas_ts_work_func(struct work_struct *work) { -// struct melfas_ts_data *ts = container_of(work, struct melfas_ts_data, work); + int ret = 0, i; uint8_t buf[30]; uint8_t output_rawbuf[100]; @@ -899,25 +845,13 @@ static void melfas_ts_work_func(struct work_struct *work) printk(KERN_ERR "melfas_ts_work_func : TS NULL\n"); #endif - - //if(testmode) return IRQ_HANDLED; - - /** - Simple send transaction: - S Addr Wr [A] Data [A] Data [A] ... [A] Data [A] P - Simple recv transaction: - S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P - */ - buf[0] = TS_READ_START_ADDR; - for (i = 0; i < 10; i++) - { + for (i = 0; i < 10; i++) { ret = i2c_master_send(melfas_mcs8000_ts->client, buf, 1); #if DEBUG_PRINT printk(KERN_ERR "melfas_ts_work_func : i2c_master_send [%d]\n", ret); #endif - if (ret >= 0) - { + if (ret >= 0) { ret = i2c_master_recv(melfas_mcs8000_ts->client, buf, TS_READ_REGS_LEN); #if DEBUG_PRINT printk(KERN_ERR "melfas_ts_work_func : i2c_master_recv [%d]\n", ret); @@ -933,14 +867,11 @@ static void melfas_ts_work_func(struct work_struct *work) } - if (ret < 0) - { + if (ret < 0) { printk(KERN_ERR "melfas_ts_work_func: i2c failed\n"); enable_irq(melfas_mcs8000_ts->client->irq); return ; - } - else // Five Multi Touch Interface - { + } else { if(buf[0] == 0x0f) { // ESD check mcsdl_vdd_off(); mdelay(500); @@ -960,32 +891,26 @@ static void melfas_ts_work_func(struct work_struct *work) keyEvent = (buf[5*MELFAS_MAX_TOUCH + 2] >> 4) & 0x01; keystrength = (buf[5*MELFAS_MAX_TOUCH + 3]); - for (i = 0; i < MELFAS_MAX_TOUCH; i++) - { + for (i = 0; i < MELFAS_MAX_TOUCH; i++) { g_Mtouch_info[i].posX = ((buf[2 + 5*i] >> 4) << 8) + buf[3 + 5*i]; g_Mtouch_info[i].posY = ((buf[2 + 5*i] & 0x0F) << 8) + buf[4 + 5*i]; g_Mtouch_info[i].width = buf[5 + 5*i]; g_Mtouch_info[i].strength = buf[6 + 5*i]; - if (g_Mtouch_info[i].width != 0) - { + if (g_Mtouch_info[i].width != 0) { g_Mtouch_info[i].state = 1; keyEvent = 0; // during touch event, ignore key event - } - else - { + } else { g_Mtouch_info[i].state = 0; } } - if (touchNumber > MELFAS_MAX_TOUCH) - { + if (touchNumber > MELFAS_MAX_TOUCH) { enable_irq(melfas_mcs8000_ts->client->irq); return; } - for (i = 0; i < MELFAS_MAX_TOUCH; i++) - { + for (i = 0; i < MELFAS_MAX_TOUCH; i++) { if ((g_Mtouch_info[i].posX == 0) || (g_Mtouch_info[i].posY == 0)) continue; @@ -1005,8 +930,7 @@ static void melfas_ts_work_func(struct work_struct *work) #if DEBUG_PRINT printk("melfas_ts_work_func: keyEvent : %d, touchkey_status[%d] : %d, keyState: %d\n", keyEvent, keyID, touchkey_status[keyID], keyState); #endif - if ( (keyID != preKeyID) && (touchkey_status[preKeyID] != 0)) - { + if ( (keyID != preKeyID) && (touchkey_status[preKeyID] != 0)) { #if defined(CONFIG_MACH_ANCORA_TMO) input_report_key(melfas_mcs8000_ts->input_dev, touchkey_keycodes[preKeyID-1], 0); #else @@ -1018,26 +942,22 @@ static void melfas_ts_work_func(struct work_struct *work) touchkey_status[preKeyID] = 0; } - if (keyEvent && (touchkey_status[keyID] != keyState)) - { + if (keyEvent && (touchkey_status[keyID] != keyState)) { #if defined(CONFIG_MACH_ANCORA_TMO) input_report_key(melfas_mcs8000_ts->input_dev, touchkey_keycodes[keyID-1], keyState); touchkey_status[keyID] = keyState; preKeyID = keyID; #else - if(board_hw_revision < 4) - { + if(board_hw_revision < 4) { input_report_key(melfas_mcs8000_ts->input_dev, touchkey_keycodes[keyID-1], keyState); touchkey_status[keyID] = keyState; preKeyID = keyID; - } - else if(board_hw_revision >= 4) - { + } else if(board_hw_revision >= 4) { input_report_key(melfas_mcs8000_ts->input_dev, touchkey_keycodes_rev04[keyID-1], keyState); touchkey_status[keyID] = keyState; preKeyID = keyID; - } + } #endif #if DEBUG_PRINT printk(KERN_ERR "[TKEY] ID : %d, keyState: %d\n", keyID, keyState); @@ -1050,10 +970,8 @@ static void melfas_ts_work_func(struct work_struct *work) enable_irq(melfas_mcs8000_ts->client->irq); } - void melfas_mcs8000_ts_work_func(struct work_struct *work) { -// Don't used } irqreturn_t melfas_mcs8000_ts_irq_handler(int irq, void *dev_id) @@ -1215,16 +1133,14 @@ static int check_debug_data(struct mcs8000_ts_driver *ts) if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, TS_READ_EXCITING_CH_ADDR, read_buf, 1)) { exciting_ch = read_buf[0]; // 16 printk("Excitin Ch : read_buf[0] = 0x%02x \n", read_buf[0]); - } - else { + } else { printk("can't read EXCITING CH \n"); } if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, TS_READ_SENSING_CH_ADDR, read_buf, 1)) { sensing_ch = read_buf[0]; // 11 printk("Sensing Ch : read_buf[0] = 0x%02x \n", read_buf[0]); - } - else { + } else { printk("can't read SENSING CH \n"); } @@ -1252,8 +1168,7 @@ static int check_debug_data(struct mcs8000_ts_driver *ts) if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, 0xB2 , read_data_buf, read_data_len)) { printk("[0] = 0x%02x, [1] = 0x%02x, [2] = 0x%02x ", read_data_buf[0], read_data_buf[1], read_data_buf[2]); printk("[3] = 0x%02x ... [%d] = 0x%02x \n", read_data_buf[3], read_data_len-1, read_data_buf[read_data_len-1]); - } - else { + } else { printk("can't read Reference Data \n"); } @@ -1268,17 +1183,6 @@ static int check_debug_data(struct mcs8000_ts_driver *ts) } } - -#if 1 - printk("[TSP] inspection_data"); - - for (i = 0; i < 11*16; i++) { - if (0 == i % 16) - printk("\n"); - printk("0x%4x, ", inspection_data[i]); - } - printk("\n"); -#endif msleep(200); @@ -1314,8 +1218,7 @@ static int atoi(char *str) int count = 0; if( str == NULL ) return -1; - while( str[count] != NULL && str[count] >= '0' && str[count] <= '9' ) - { + while( str[count] != NULL && str[count] >= '0' && str[count] <= '9' ) { result = result * 10 + str[count] - '0'; ++count; } @@ -1355,24 +1258,20 @@ static void check_delta_data(struct mcs8000_ts_driver *ts) if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, TS_READ_EXCITING_CH_ADDR, read_buf, 1)) { exciting_ch = read_buf[0]; // 16 printk("Excitin Ch : read_buf[0] = 0x%02x \n", read_buf[0]); - } - else { + } else { printk("can't read EXCITING CH \n"); } if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, TS_READ_SENSING_CH_ADDR, read_buf, 1)) { sensing_ch = read_buf[0]; // 11 printk("Sensing Ch : read_buf[0] = 0x%02x \n", read_buf[0]); - } - else { + } else { printk("can't read SENSING CH \n"); } /* Read Cm Delta Data */ - for (i = 0; i < sensing_ch; i++) - { - for (j = 0; j < exciting_ch; j++) - { + for (i = 0; i < sensing_ch; i++) { + for (j = 0; j < exciting_ch; j++) { write_command[0] = RMI_ADDR_TESTMODE; write_command[1] = 0x42; //cmd id write_command[2] = j; //TX CH.(exciting ch.) @@ -1390,33 +1289,20 @@ static void check_delta_data(struct mcs8000_ts_driver *ts) if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, UNIVERSAL_CMD_RESULT_SIZE , read_buf, 1)) { read_data_len = read_buf[0]; printk("read_data_len = 0x%02x \n ", read_data_len); - } - else { + } else { printk("can't read UNIVERSAL_CMD_RESULT_SIZE \n"); } if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, UNIVERSAL_CMD_RESULT , read_data_buf, read_data_len)) { printk("[0] = 0x%02x, [1] = 0x%02x \n", read_data_buf[0], read_data_buf[1]); - } - else { + } else { printk("can't read UNIVERSAL_CMD_RESULT Data \n"); } CmDelta_data[(i * exciting_ch) + j] = (read_data_buf[1] << 8) + read_data_buf[0]; } - } - -#if 1 - printk("[TSP] CmDelta_data"); - - for (i = 0; i < 11*16; i++) { - if (0 == i % 16) - printk("\n"); - printk("0x%04x, ", CmDelta_data[i]); - } - printk("\n"); -#endif + } msleep(200); @@ -1434,7 +1320,6 @@ static void check_delta_data(struct mcs8000_ts_driver *ts) static ssize_t set_all_delta_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { int status = 0; - //struct mcs8000_ts_driver *ts = dev_get_drvdata(dev); check_delta_data(melfas_mcs8000_ts); @@ -1477,16 +1362,14 @@ static void check_intensity_data(struct mcs8000_ts_driver *ts) if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, TS_READ_EXCITING_CH_ADDR, read_buf, 1)) { exciting_ch = read_buf[0]; // 16 printk("Excitin Ch : read_buf[0] = 0x%02x \n", read_buf[0]); - } - else { + } else { printk("can't read EXCITING CH \n"); } if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, TS_READ_SENSING_CH_ADDR, read_buf, 1)) { sensing_ch = read_buf[0]; // 11 printk("Sensing Ch : read_buf[0] = 0x%02x \n", read_buf[0]); - } - else { + } else { printk("can't read SENSING CH \n"); } @@ -1511,8 +1394,7 @@ static void check_intensity_data(struct mcs8000_ts_driver *ts) if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, 0xB2 , read_data_buf, read_data_len)) { printk("[0] = 0x%02x, [1] = 0x%02x, [2] = 0x%02x ", read_data_buf[0], read_data_buf[1], read_data_buf[2]); printk("[3] = 0x%02x ... [%d] = 0x%02x \n", read_data_buf[3], read_data_len-1, read_data_buf[read_data_len-1]); - } - else { + } else { printk("can't read Reference Data \n"); } @@ -1521,17 +1403,6 @@ static void check_intensity_data(struct mcs8000_ts_driver *ts) } -#if 1 - printk("[TSP] inspection_data"); - - for (i = 0; i < 11*16; i++) { - if (0 == i % 16) - printk("\n"); - printk("0x%4x, ", inspection_data[i]); - } - printk("\n"); -#endif - /* Read Dummy Data */ printk("Read Dummy Data : START \n"); write_command[0] = 0x09; // Low level data output mode @@ -1553,8 +1424,7 @@ static void check_intensity_data(struct mcs8000_ts_driver *ts) if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, 0xB2 , read_data_buf, read_data_len)) { printk("[0] = 0x%02x, [1] = 0x%02x, [2] = 0x%02x ", read_data_buf[0], read_data_buf[1], read_data_buf[2]); printk("[3] = 0x%02x ... [%d] = 0x%02x \n", read_data_buf[3], read_data_len-1, read_data_buf[read_data_len-1]); - } - else { + } else { printk("can't read Dummy Data \n"); } } @@ -1580,8 +1450,7 @@ static void check_intensity_data(struct mcs8000_ts_driver *ts) if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, 0xB2 , read_data_buf, read_data_len)) { printk("[0] = 0x%02x, [1] = 0x%02x, [2] = 0x%02x ", read_data_buf[0], read_data_buf[1], read_data_buf[2]); printk("[3] = 0x%02x ... [%d] = 0x%02x \n", read_data_buf[3], read_data_len-1, read_data_buf[read_data_len-1]); - } - else { + } else { printk("can't read Intensity Data \n"); } @@ -1590,17 +1459,6 @@ static void check_intensity_data(struct mcs8000_ts_driver *ts) } -#if 1 - printk("[TSP] lntensity_data"); - - for (i = 0; i < 11*16; i++) { - if (0 == i % 16) - printk("\n"); - printk("0x%02x, ", lntensity_data[i]); - } - printk("\n"); -#endif - enable_irq(ts->client->irq); msleep(200); @@ -1770,11 +1628,7 @@ static DEVICE_ATTR(keypad_enable, S_IRUGO|S_IWUSR, keypad_enable_show, static DEVICE_ATTR(set_module_on, S_IRUGO | S_IWUSR | S_IWGRP, set_tsp_module_on_show, NULL); static DEVICE_ATTR(set_module_off, S_IRUGO | S_IWUSR | S_IWGRP, set_tsp_module_off_show, NULL); static DEVICE_ATTR(set_all_refer, S_IRUGO | S_IWUSR | S_IWGRP, set_all_refer_mode_show, NULL); -#if 0 // Change authority for CTS, but if you want to make LCD TEST MODE and then enable. -static DEVICE_ATTR(disp_all_refdata, S_IRWXU|S_IRWXG|S_IRWXO, disp_all_refdata_show, disp_all_refdata_store); -#else static DEVICE_ATTR(disp_all_refdata, S_IRUGO|S_IWUSR|S_IWGRP, disp_all_refdata_show, disp_all_refdata_store); -#endif static DEVICE_ATTR(set_all_delta, S_IRUGO | S_IWUSR | S_IWGRP, set_all_delta_mode_show, NULL); static DEVICE_ATTR(disp_all_deltadata, S_IRUGO | S_IWUSR | S_IWGRP, disp_all_deltadata_show, disp_all_deltadata_store); static DEVICE_ATTR(set_all_intensity, S_IRUGO | S_IWUSR | S_IWGRP, set_all_intensity_mode_show, NULL); @@ -1792,7 +1646,7 @@ static DEVICE_ATTR(set_delta4, S_IRUGO | S_IWUSR | S_IWGRP, set_intensity4_mode_ static DEVICE_ATTR(set_threshould, S_IRUGO | S_IWUSR | S_IWGRP, set_tsp_threshold_mode_show, NULL); /* touch threshold return */ -static struct attribute *sec_touch_facotry_attributes[] = { +static struct attribute *sec_touch_factory_attributes[] = { &dev_attr_set_module_on.attr, &dev_attr_set_module_off.attr, &dev_attr_set_all_refer.attr, @@ -1817,7 +1671,7 @@ static struct attribute *sec_touch_facotry_attributes[] = { }; static struct attribute_group sec_touch_factory_attr_group = { - .attrs = sec_touch_facotry_attributes, + .attrs = sec_touch_factory_attributes, }; #endif //TSP_FACTORY_TEST @@ -1836,8 +1690,7 @@ static ssize_t set_tsp_firm_version_read_show(struct device *dev, struct device_ melfas_mcs8000_ts->hw_rev = read_ver[0]; melfas_mcs8000_ts->fw_ver = read_ver[1]; printk("%s :HW Ver : 0x%02x, FW Ver : 0x%02x\n", __func__, read_ver[0], read_ver[1]); - } - else { + } else { printk("%s : can't read TSP F/W version \n",__func__); } @@ -1846,7 +1699,7 @@ static ssize_t set_tsp_firm_version_read_show(struct device *dev, struct device_ static ssize_t set_tsp_threshold_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { - //struct mcs8000_ts_driver *ts = dev_get_drvdata(dev); + u8 threshold=32; return sprintf(buf, "%d\n", threshold); @@ -1897,16 +1750,14 @@ static ssize_t reference_show_mcs8000(struct device *dev, struct device_attribut if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, TS_READ_EXCITING_CH_ADDR, read_buf, 1)) { Tx_Channel = read_buf[0]; // 16 printk("Excitin Ch : read_buf[0] = 0x%02x \n", read_buf[0]); - } - else { + } else { printk("can't read Tx_Channel \n"); } if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, TS_READ_SENSING_CH_ADDR, read_buf, 1)) { Rx_Channel = read_buf[0]; // 11 printk("Sensing Ch : read_buf[0] = 0x%02x \n", read_buf[0]); - } - else { + } else { printk("can't read Rx_Channel \n"); } @@ -1931,23 +1782,19 @@ static ssize_t reference_show_mcs8000(struct device *dev, struct device_attribut if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, 0xB2 , read_data_buf, read_data_len)) { printk("read_data[0] = 0x%02x, read_buf[1] = 0x%02x, read_data[2] = 0x%02x ", read_data_buf[0], read_data_buf[1], read_data_buf[2]); printk("read_buf[3] = 0x%02x \n read_buf[%d] = 0x%02x \n", read_data_buf[3], read_data_len-1, read_data_buf[read_data_len-1]); - } - else { + } else { printk("can't read Reference Data \n"); } - for(j = 0 ; j < Tx_Channel ; j++) - { + for(j = 0 ; j < Tx_Channel ; j++) { ref[i][j] = (read_data_buf[j*2] <<8) + read_data_buf[j*2+1]; } } - for (i = 0; i < Rx_Channel ; i++) - { + for (i = 0; i < Rx_Channel ; i++) { printk("[TSP]"); - for(j = 0 ; j < Tx_Channel ; j++) - { + for(j = 0 ; j < Tx_Channel ; j++) { printk(" %5d", ref[i][j]); } printk("\n"); @@ -1965,9 +1812,7 @@ static ssize_t raw_store_mcs8000(struct device *dev, struct device_attribute *at { testmode = 1; printk("[TSP] %s start. line : %d, \n", __func__,__LINE__); - } - else if(strncasecmp(buf, "stop", 4) == 0) - { + } else if(strncasecmp(buf, "stop", 4) == 0) { printk("[TSP] %s stop. line : %d, \n", __func__,__LINE__); @@ -1977,9 +1822,7 @@ static ssize_t raw_store_mcs8000(struct device *dev, struct device_attribute *at msleep(300); testmode = 0; - } - else - { + } else { printk("[TSP] %s error-unknown command. line : %d, \n", __func__,__LINE__); } @@ -1988,8 +1831,6 @@ static ssize_t raw_store_mcs8000(struct device *dev, struct device_attribute *at static ssize_t raw_show_mcs8000(struct device *dev, struct device_attribute *attr, char *buf) { - - //if(!testmode) return 0; u8 read_buf[2] = {0,}; u8 write_command[2]; @@ -2010,20 +1851,18 @@ static ssize_t raw_show_mcs8000(struct device *dev, struct device_attribute *att if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, TS_READ_EXCITING_CH_ADDR, read_buf, 1)) { Tx_Channel = read_buf[0]; // 16 printk("Tx_Channel : read_buf[0] = 0x%02x \n", read_buf[0]); - } - else { + } else { printk("can't read Tx_Channel \n"); } if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, TS_READ_SENSING_CH_ADDR, read_buf, 1)) { Rx_Channel = read_buf[0]; // 11 printk("Rx_Channel : read_buf[0] = 0x%02x \n", read_buf[0]); - } - else { + } else { printk("can't read Rx_Channel \n"); } -//////////////////////// Read garbage Data of 0xB2 Data buffer /////////////////// +/* Read garbage Data of 0xB2 Data buffer */ /* Read Raw Data */ write_command[0] = 0x09; // Low level data output mode write_command[1] = 0x01; // Raw Data @@ -2049,14 +1888,11 @@ static ssize_t raw_show_mcs8000(struct device *dev, struct device_attribute *att printk("read_data[0]=0x%02x, [1]=0x%02x, [2]=0x%02x ", read_data_buf1[0], read_data_buf1[1], read_data_buf1[2]); printk("[3]=0x%02x ... [%d]=0x%02x \n", read_data_buf1[3], read_data_len-1, read_data_buf1[read_data_len-1]); break; - } - else { + } else { printk("can't read Reference Data \n"); } - } - + } } -////////////////////////////////////////////////////////////////////////////////// /* Read Raw Data */ write_command[0] = 0x09; // Low level data output mode @@ -2077,35 +1913,31 @@ static ssize_t raw_show_mcs8000(struct device *dev, struct device_attribute *att read_data_len = (Tx_Channel*2); // 32 : 2 byte data - for (k = 0; k < 10; k++) - { + for (k = 0; k < 10; k++) { if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, 0xB2 , read_data_buf1, read_data_len)) { printk("read_data[0]=0x%02x, [1]=0x%02x, [2]=0x%02x ", read_data_buf1[0], read_data_buf1[1], read_data_buf1[2]); printk("[3]=0x%02x ... [%d]=0x%02x \n", read_data_buf1[3], read_data_len-1, read_data_buf1[read_data_len-1]); break; - } - else { + } else { printk("can't read Reference Data \n"); } } printk("[TSP]"); - for(j = 0 ; j < Tx_Channel ; j++) - { + for(j = 0 ; j < Tx_Channel ; j++) { ref1[i][j] = (read_data_buf1[j*2] <<8) + read_data_buf1[j*2+1]; printk(" %5d", ref1[i][j]); } printk("\n"); } -//////////////////////// Read garbage Data of 0xB2 Data buffer /////////////////// +/* Read garbage Data of 0xB2 Data buffer */ /* Read Intensity Data */ write_command[0] = 0x09; // Low level data output mode write_command[1] = 0x04; // Intensity Data ret = melfas_i2c_write(melfas_mcs8000_ts->client, (char *)write_command, 2); printk("Read Intensity Data \n"); - for (i = 0; i < Rx_Channel ; i++) - { + for (i = 0; i < Rx_Channel ; i++) { /* wating for the interrupt */ while (gpio_get_value(gpio)) { @@ -2120,20 +1952,17 @@ static ssize_t raw_show_mcs8000(struct device *dev, struct device_attribute *att if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, 0xB2 , read_data_buf2, read_data_len)) { printk("read_data[0]=0x%02x, [1]=0x%02x, [2]=0x%02x ", read_data_buf2[0], read_data_buf2[1], read_data_buf2[2]); printk("[3]=0x%02x ... [%d]=0x%02x \n", read_data_buf2[3], read_data_len-1, read_data_buf2[read_data_len-1]); - } - else { + } else { printk("can't read Intensity Data \n"); } } -////////////////////////////////////////////////////////////////////////////////// /* Read Intensity Data */ write_command[0] = 0x09; // Low level data output mode write_command[1] = 0x04; // Intensity Data ret = melfas_i2c_write(melfas_mcs8000_ts->client, (char *)write_command, 2); printk("Read Intensity Data \n"); - for (i = 0; i < Rx_Channel ; i++) - { + for (i = 0; i < Rx_Channel ; i++) { /* wating for the interrupt */ while (gpio_get_value(gpio)) { @@ -2148,15 +1977,13 @@ static ssize_t raw_show_mcs8000(struct device *dev, struct device_attribute *att if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, 0xB2 , read_data_buf2, read_data_len)) { printk("read_data[0]=0x%02x, [1]=0x%02x, [2]=0x%02x ", read_data_buf2[0], read_data_buf2[1], read_data_buf2[2]); printk("[3]=0x%02x ... [%d]=0x%02x \n", read_data_buf2[3], read_data_len-1, read_data_buf2[read_data_len-1]); - } - else { + } else { printk("can't read Intensity Data \n"); } printk("[TSP]"); - for(j = 0 ; j < Tx_Channel ; j++) - { + for(j = 0 ; j < Tx_Channel ; j++) { ref2[i][j] = read_data_buf2[j]; printk(" %5d", ref2[i][j]); } @@ -2164,21 +1991,12 @@ static ssize_t raw_show_mcs8000(struct device *dev, struct device_attribute *att } - for (i = 0; i < Rx_Channel ; i++) - { - for(j = 0 ; j < Tx_Channel ; j++) - { + for (i = 0; i < Rx_Channel ; i++) { + for(j = 0 ; j < Tx_Channel ; j++) { written_bytes += sprintf(buf+written_bytes, "%d %d\n", ref1[i][j], ref2[i][j]) ; } } -/* - msleep(20); - melfas_mcs8000_ts_suspend(PMSG_SUSPEND); - msleep(200); - melfas_mcs8000_ts_resume(); -*/ - gpio_tlmm_config(GPIO_CFG(GPIO_I2C0_SCL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),GPIO_CFG_ENABLE); gpio_tlmm_config(GPIO_CFG(GPIO_I2C0_SDA, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),GPIO_CFG_ENABLE); gpio_set_value(GPIO_I2C0_SCL, 0); // TOUCH SCL DIS @@ -2216,16 +2034,14 @@ static ssize_t diff_show_mcs8000(struct device *dev, struct device_attribute *at if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, TS_READ_EXCITING_CH_ADDR, read_buf, 1)) { Tx_Channel = read_buf[0]; // 16 printk("Excitin Ch : read_buf[0] = 0x%02x \n", read_buf[0]); - } - else { + } else { printk("can't read Tx_Channel \n"); } if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, TS_READ_SENSING_CH_ADDR, read_buf, 1)) { Rx_Channel = read_buf[0]; // 11 printk("Sensing Ch : read_buf[0] = 0x%02x \n", read_buf[0]); - } - else { + } else { printk("can't read Rx_Channel \n"); } @@ -2234,8 +2050,7 @@ static ssize_t diff_show_mcs8000(struct device *dev, struct device_attribute *at write_command[1] = 0x04; // Intensity Data ret = melfas_i2c_write(melfas_mcs8000_ts->client, (char *)write_command, 2); - for (i = 0; i < Rx_Channel ; i++) - { + for (i = 0; i < Rx_Channel ; i++) { /* wating for the interrupt */ while (gpio_get_value(gpio)) { @@ -2249,22 +2064,18 @@ static ssize_t diff_show_mcs8000(struct device *dev, struct device_attribute *at if( 0 == melfas_mcs8000_i2c_read(melfas_mcs8000_ts->client, 0xB2 , read_data_buf, read_data_len)) { printk("read_data[0] = 0x%02x, read_buf[1] = 0x%02x, read_data[2] = 0x%02x ", read_data_buf[0], read_data_buf[1], read_data_buf[2]); printk("read_buf[3] = 0x%02x \n read_buf[%d] = 0x%02x \n", read_data_buf[3], read_data_len-1, read_data_buf[read_data_len-1]); - } - else { + } else { printk("can't read Intensity Data \n"); } - for(j = 0 ; j < Tx_Channel ; j++) - { + for(j = 0 ; j < Tx_Channel ; j++) { ref[i][j] = read_data_buf[j]; } } - for (i = 0; i < Rx_Channel ; i++) - { + for (i = 0; i < Rx_Channel ; i++) { printk("[TSP]"); - for(j = 0 ; j < Tx_Channel ; j++) - { + for(j = 0 ; j < Tx_Channel ; j++) { printk(" %5d", ref[i][j]); } printk("\n"); @@ -2341,7 +2152,7 @@ int melfas_mcs8000_ts_probe(struct i2c_client *client, __func__, rc); } - if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C/*I2C_FUNC_SMBUS_BYTE_DATA*/)) { + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { printk(KERN_ERR "melfas_mcs8000_ts_probe: need I2C_FUNC_I2C\n"); ret = -ENODEV; goto err_check_functionality_failed; @@ -2361,8 +2172,7 @@ int melfas_mcs8000_ts_probe(struct i2c_client *client, version_read = TRUE; printk("[TSP] Read Version Success !!\n"); break; - } - else { + } else { version_read = FALSE; printk("[TSP] Read Version Failed !!\n"); } @@ -2378,16 +2188,12 @@ int melfas_mcs8000_ts_probe(struct i2c_client *client, melfas_mcs8000_ts->hw_rev, melfas_mcs8000_ts->fw_ver, NEW_FIRMWARE_VERSION); #if defined(CONFIG_MACH_ANCORA_TMO) - if(melfas_mcs8000_ts->window_ver==MELFAS_WINDOW_55T) // Window panel 0.55T - { - if((board_hw_revision >= 4) && (melfas_mcs8000_ts->fw_ver < NEW_FIRMWARE_VERSION_55T) && (version_read == TRUE)) - { + if(melfas_mcs8000_ts->window_ver==MELFAS_WINDOW_55T) { // Window panel 0.55T + if((board_hw_revision >= 4) && (melfas_mcs8000_ts->fw_ver < NEW_FIRMWARE_VERSION_55T) && (version_read == TRUE)) { printk("[TSP] firmware update window 0.55T\n"); firmware_update(); } - } - else //if(melfas_mcs8000_ts->window_ver==MELFAS_WINDOW_70T) // Window panel 0.7T - { + } else { //if(melfas_mcs8000_ts->window_ver==MELFAS_WINDOW_70T) // Window panel 0.7T if((melfas_mcs8000_ts->hw_rev == 0x08)&&(board_hw_revision >= 4) && (melfas_mcs8000_ts->fw_ver < NEW_FIRMWARE_VERSION) && (version_read == TRUE)) { printk("[TSP] firmware update window 0.7T\n"); @@ -2397,19 +2203,14 @@ int melfas_mcs8000_ts_probe(struct i2c_client *client, INIT_WORK(&melfas_mcs8000_ts->work, melfas_ts_work_func); #else - if ((melfas_mcs8000_ts->hw_rev == 0x03) && (melfas_mcs8000_ts->fw_ver < NEW_FIRMWARE_VERSION_GFF) && (version_read == TRUE)) - { + if ((melfas_mcs8000_ts->hw_rev == 0x03) && (melfas_mcs8000_ts->fw_ver < NEW_FIRMWARE_VERSION_GFF) && (version_read == TRUE)) { printk("[TSP] firmware update window 0.7T TSP H/W rev.03 GFF \n"); firmware_update(); - } - else if((melfas_mcs8000_ts->hw_rev == 0x50) && (melfas_mcs8000_ts->fw_ver < NEW_FIRMWARE_VERSION_G2) && (version_read == TRUE)) - { + } else if((melfas_mcs8000_ts->hw_rev == 0x50) && (melfas_mcs8000_ts->fw_ver < NEW_FIRMWARE_VERSION_G2) && (version_read == TRUE)) { printk("[TSP] firmware update window 0.7T TSP H/W rev.50 G2 \n"); firmware_update(); - } - else - { - printk("[TSP] Have the Latest firmware \n"); + } else { + printk("[TSP] Have the Latest firmware \n"); } INIT_WORK(&melfas_mcs8000_ts->work, melfas_ts_work_func); @@ -2466,8 +2267,7 @@ int melfas_mcs8000_ts_probe(struct i2c_client *client, ret = request_irq(melfas_mcs8000_ts->client->irq, melfas_mcs8000_ts_irq_handler, IRQF_DISABLED , melfas_mcs8000_ts->client->name, melfas_mcs8000_ts); if(ret == 0) { printk(KERN_INFO "melfas_mcs8000_ts_probe: Start touchscreen %s \n", melfas_mcs8000_ts->input_dev->name); - } - else { + } else { printk("request_irq failed\n"); } @@ -2512,13 +2312,13 @@ void melfas_mcs8000_ts_gen_touch_up(void) { int i=0; - // report up key if needed - for (i = 0; i < MELFAS_MAX_TOUCH; i++) - { + /* report up key if needed */ + for (i = 0; i < MELFAS_MAX_TOUCH; i++) { printk(KERN_ERR "melfas_ts_work_func: Touch ID: %d, state: %d \n", i, g_Mtouch_info[i].state); - if ((g_Mtouch_info[i].posX == 0) || (g_Mtouch_info[i].posY == 0)) + if ((g_Mtouch_info[i].posX == 0) || (g_Mtouch_info[i].posY == 0)) { continue; + } if(g_Mtouch_info[i].state == 1) { g_Mtouch_info[i].state = 0; @@ -2539,7 +2339,7 @@ int melfas_mcs8000_ts_suspend(pm_message_t mesg) printk("%s\n", __func__); melfas_mcs8000_ts->suspended = true; disable_irq(melfas_mcs8000_ts->client->irq); - melfas_mcs8000_ts_gen_touch_up(); + melfas_mcs8000_ts_gen_touch_up(); gpio_tlmm_config(GPIO_CFG(GPIO_I2C0_SCL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),GPIO_CFG_ENABLE); gpio_tlmm_config(GPIO_CFG(GPIO_I2C0_SDA, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),GPIO_CFG_ENABLE); @@ -2561,7 +2361,7 @@ int melfas_mcs8000_ts_suspend(pm_message_t mesg) gpio_set_value(GPIO_I2C0_SDA, 0); // TOUCH SDA DIS #if defined(CONFIG_MACH_ANCORA_TMO) - //release home key before entering suspend mode + //release home key before entering suspend mode if(touchkey_status[2]) input_report_key(melfas_mcs8000_ts->input_dev, touchkey_keycodes[1], 0); #endif @@ -2594,26 +2394,10 @@ int melfas_mcs8000_ts_resume() pr_err("%s: LDO2 vreg disable failed (%d)\n", __func__, rc); else led_state = TKEY_LED_ON; - } - + } + return 0; } -#if 0 // blocked for now.. we will gen touch when suspend func is called -int tsp_preprocess_suspend(void) -{ - // this function is called before kernel calls suspend functions - // so we are going suspended if suspended==false - if(melfas_mcs8000_ts->suspended == false) { - // fake as suspended - melfas_mcs8000_ts->suspended = true; - - //generate and report touch event - melfas_mcs8000_ts_gen_touch_up(); - } - return 0; -} -#endif - #ifdef CONFIG_HAS_EARLYSUSPEND void melfas_mcs8000_ts_early_suspend(struct early_suspend *h) @@ -2635,14 +2419,11 @@ int melfas_mcs8000_i2c_probe(struct i2c_client *client,const struct i2c_device_i return 0; } -#define USE_TS_TA_DETECT_CHANGE_REG 1 -#if USE_TS_TA_DETECT_CHANGE_REG int set_tsp_for_ta_detect(int state) { return 1; } EXPORT_SYMBOL(set_tsp_for_ta_detect); -#endif static int __devexit melfas_mcs8000_i2c_remove(struct i2c_client *client) { @@ -2731,7 +2512,7 @@ int __init melfas_mcs8000_ts_init(void) pr_err("Failed to create device file(%s)!\n", dev_attr_tkey_sensitivity.attr.name); if (device_create_file(mcs8000_ts_dev, &dev_attr_tkey_sens_pline) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_tkey_sens_pline.attr.name); - if (device_create_file(mcs8000_ts_dev, &dev_attr_tkey_noise_thd) < 0) + if (device_create_file(mcs8000_ts_dev, &dev_attr_tkey_noise_thd) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_tkey_noise_thd.attr.name); if (device_create_file(mcs8000_ts_dev, &dev_attr_brightness) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_brightness.attr.name); @@ -2814,7 +2595,7 @@ void __exit melfas_mcs8000_ts_exit(void) if (melfas_mcs8000_ts_wq) destroy_workqueue(melfas_mcs8000_ts_wq); } -//late_initcall(melfas_mcs8000_ts_init); + module_init(melfas_mcs8000_ts_init); module_exit(melfas_mcs8000_ts_exit);