void read_log(char *filename, const struct touch_platform_data *pdata)
{
	int fd;
	char* buf = NULL;
	int rx_num = 0;
	int tx_num = 0;
	int data_pos = 0;
	int offset = 0;

	struct touch_platform_data *ppdata = (struct touch_platform_data*)pdata;

	mm_segment_t old_fs = get_fs();
	set_fs(KERNEL_DS);

	fd = sys_open(filename, O_RDONLY, 0);
	buf = kzalloc(1024, GFP_KERNEL);

	TOUCH_INFO_MSG("[%s]read file open %s, fd : %d\n", __FUNCTION__, (fd >= 0)? "success": "fail", fd);

	if (fd >= 0) {
		TOUCH_INFO_MSG("[%s]open read_log funcion in /sns/touch/cap_diff_test.txt\n",__FUNCTION__);
		while(sys_read(fd, buf, 1024)) {

			TOUCH_INFO_MSG("[%s]sys_read success\n",__FUNCTION__);

			for(rx_num = 0; rx_num < (ppdata->rx_ch_count) - 1; rx_num++)
			{
				sscanf(buf + data_pos, "%d%n", &ppdata->rx_cap[rx_num], &offset);
				data_pos += offset;
			}

			for(tx_num = 0; tx_num < (ppdata->tx_ch_count) - 1; tx_num++)
			{
				sscanf(buf + data_pos, "%d%n", &ppdata->tx_cap[tx_num], &offset);
				data_pos += offset;
			}

			TOUCH_INFO_MSG("[%s]rx_num = %d, tx_num = %d\n", __FUNCTION__, rx_num, tx_num);
			TOUCH_INFO_MSG("[%s]rx_ch_count = %d, tx_ch_count = %d\n", __FUNCTION__, ppdata->rx_ch_count, ppdata->tx_ch_count);

			if((rx_num == (ppdata->rx_ch_count) -1) && (tx_num == (ppdata->tx_ch_count) -1))
				break;
		}

		sys_close(fd);
	}

	if(buf)
		kfree(buf);

	set_fs(old_fs);

}
예제 #2
0
static int lge_ts_misc_power(struct lge_ts_misc_info *info, bool on)
{
	int retval = 0;

	if (on == false)
		goto power_off;

	TOUCH_INFO_MSG("Power on \n");

	if (info->vio_lvs1) {
		retval = regulator_enable(info->vio_lvs1);
		if (retval < 0) {
			TOUCH_INFO_MSG("regulator_enable(vio_l6) failed retval = %d\n", retval);
		}
	}

	if (info->vio_l19) {
		retval = regulator_enable(info->vio_l19);
		if (retval < 0) {
			TOUCH_INFO_MSG("regulator_enable(vio_l19) failed retval = %d\n", retval);
		}
	}

	if (info->vdd) {
		retval = regulator_enable(info->vdd);
		if (retval < 0) {
			TOUCH_INFO_MSG("regulator_enable(vdd) failed retval = %d\n", retval);
		}
	}

	goto exit;

power_off:

	TOUCH_INFO_MSG("Power off \n");

	if (info->vdd) {
		regulator_disable(info->vdd);
	}

	if (info->vio_l19) {
		regulator_disable(info->vio_l19);
	}

	if (info->vio_lvs1) {
		regulator_disable(info->vio_lvs1);
	}

exit:
	msleep(10);

	return retval;
}
int write_log(char *filename, char *data)
{
	extern int f54_window_crack;
	extern int f54_window_crack_check_mode;

	int fd;
	char *fname = "/mnt/sdcard/touch_self_test.txt";
	int cap_file_exist = 0;

	if(f54_window_crack||f54_window_crack_check_mode==0) {
		mm_segment_t old_fs = get_fs();
		set_fs(KERNEL_DS);
		if(filename == NULL){
			fd = sys_open(fname, O_WRONLY|O_CREAT|O_APPEND, 0666);
			TOUCH_INFO_MSG("write log in /mnt/sdcard/touch_self_test.txt\n");
		} else{
			fd = sys_open(filename, O_WRONLY|O_CREAT, 0666);
			TOUCH_INFO_MSG("write log in /sns/touch/cap_diff_test.txt\n");
		}

		TOUCH_INFO_MSG("[%s]write file open %s, fd : %d\n", __FUNCTION__, (fd >= 0)? "success": "fail", fd);

		if(fd >= 0) {
			/*because of erro, this code is blocked.*/
			/*if(sys_newstat((char __user *) fname, (struct stat *)&fstat) < 0) {
			  printk("[Touch] cannot read %s stat info\n", fname);
			  } else {
			  if(fstat.st_size > 5 * 1024 * 1024) {
			  printk("[Touch] delete %s\n", fname);
			  sys_unlink(fname);
			  sys_close(fd);

			  fd = sys_open(fname, O_WRONLY|O_CREAT|O_APPEND, 0644);
			  if(fd >= 0) {
			  sys_write(fd, data, strlen(data));
			  }
			  } else {
			  sys_write(fd, data, strlen(data));
			  }
			  sys_close(fd);
			  }*/
			sys_write(fd, data, strlen(data));
			sys_close(fd);

			if(filename != NULL)
				cap_file_exist = 1;
		}
		set_fs(old_fs);
	}
	return cap_file_exist;
}
예제 #4
0
static int lge_ts_misc_parse_dt(struct device *dev, struct lge_ts_misc_info *info)
{
	struct device_node *np = dev->of_node;
	int ret = 0;
	u32 val;
	struct misc_dt_map *itr;
	struct misc_dt_map map[] = {
		{ "irq_wake",			&info->irq_wake,			DT_U32, 0 },
		{ "gpio_int",			&info->gpio_int,			DT_U32, 0 },
		{ "vdd_on",			&info->vdd_on,			DT_U32, 0 },
		{ "vio_l19_on",		&info->vio_l19_on,		DT_U32, 0 },
		{ "vio_l6_on",			&info->vio_l6_on,		DT_U32,	0 },
		{ "vio_lvs1_on",		&info->vio_lvs1_on,		DT_U32, 0 },
		{ "vdd_voltage",		&info->vdd_voltage,		DT_U32, 0 },
		{ "vio_l19_voltage",	&info->vio_l19_voltage,	DT_U32, 0 },
		{ "vio_l6_voltage",	&info->vio_l6_voltage,	DT_U32,	0 },
		{ "vio_lvs1_voltage",	&info->vio_lvs1_voltage,	DT_U32, 0 },
		{ NULL,				NULL,					0,		0 },
	};

	for (itr = map; itr->name; ++itr) {
		val = 0;
		ret = 0;

		switch (itr->type) {
		case DT_U32:
			ret = of_property_read_u32(np, itr->name, &val);
			if (ret == 0) {
				*((u32 *) itr->data) = val;
				TOUCH_INFO_MSG("DT : %s = %d \n", itr->name, val);
			} else {
				*((u32 *) itr->data) = (u32) itr->def_value;
			}
			break;
		default:
			TOUCH_INFO_MSG("DT : Not support type : %d \n", itr->type);
			break;
		}
	}

	return 0;
}
int write_file(char *filename, char *data)
{
	int fd = 0;

	fd = sys_open(filename, O_WRONLY|O_CREAT|O_APPEND, 0666);
	if (fd < 0) {
		TOUCH_INFO_MSG("%s :  Open file error [ %d ]\n",__func__, fd);
		return fd;
	} else {
		sys_write(fd, data, strlen(data));
		sys_close(fd);
	}
	return 0;
}
예제 #6
0
static irqreturn_t lge_ts_misc_irq(int irq, void *dev_id)
{
	struct lge_ts_misc_info *info = dev_id;

	TOUCH_INFO_MSG("Detected \n");

	lge_ts_misc_enable(info, false);
	input_report_key(info->input_dev, KEY_POWER, PRESS_KEY);
	input_sync(info->input_dev);
	/* msleep(20); */
	input_report_key(info->input_dev, KEY_POWER, RELEASE_KEY);
	input_sync(info->input_dev);

	return IRQ_HANDLED;
}
예제 #7
0
static void make_flick_y(struct test_data *t_data, int filter)
{
	int i;

	memset(t_data, 0, sizeof(*t_data));
	memcpy(t_data->y, flick_y, sizeof(flick_y));

	t_data->event_count = sizeof(flick_y) / sizeof(u16);
	t_data->event_index = FIXED_ID;

	if(filter)
		apply_filter(t_data->y, t_data->event_count);

	for(i=0; i<t_data->event_count; i++){
		t_data->x[i] = touch_test_dev->pdata->caps->x_max /2;
		TOUCH_INFO_MSG("[Touch Tester] pos[%4d,%4d]\n", t_data->x[i], t_data->y[i]);
	}
}
int FirmwareUpgrade (struct synaptics_ts_data *ts, const char* fw_path) {

	int ret = 0;
	int fd = -1;
	mm_segment_t old_fs = 0;
	struct stat fw_bin_stat;
	unsigned long read_bytes;

	if (unlikely(fw_path[0] != 0)) {
		old_fs = get_fs();
		set_fs(get_ds());

		fd = sys_open((const char __user *) fw_path, O_RDONLY, 0);
		if (fd < 0) {
			TOUCH_ERR_MSG("Can not read FW binary from %s\n", fw_path);
			ret = -EEXIST;
			goto read_fail;
		}
		ret = sys_newstat((char __user *) fw_path, (struct stat *)&fw_bin_stat);
		if (ret < 0) {
			TOUCH_ERR_MSG("Can not read FW binary stat from %s\n", fw_path);
			goto fw_mem_alloc_fail;
		}

		my_image_size = fw_bin_stat.st_size;
		my_image_bin = kzalloc(sizeof(char) * (my_image_size+1), GFP_KERNEL);
		if (my_image_bin == NULL) {
			TOUCH_ERR_MSG("Can not allocate  memory\n");
			ret = -ENOMEM;
			goto fw_mem_alloc_fail;
		}

		read_bytes = sys_read(fd, (char __user *)my_image_bin, my_image_size);

		/* for checksum */
		*(my_image_bin+my_image_size) = 0xFF;

		TOUCH_INFO_MSG("Touch FW image read %ld bytes from %s\n", read_bytes, fw_path);

	} else {
		my_image_size = ts->fw_info.fw_size-1;
		my_image_bin = (unsigned char *)(&ts->fw_info.fw_start[0]);
	}

	CompleteReflash(ts);
	/*
	   ret = CompleteReflash(ts);
	   if (ret < 0) {
	   TOUCH_ERR_MSG("CompleteReflash_Lockdown fail\n");
	   }
	   */

	if (unlikely(fw_path[0] != 0))
		kfree(my_image_bin);

fw_mem_alloc_fail:
	sys_close(fd);
read_fail:
	set_fs(old_fs);

	return ret;
}
int get_limit(unsigned char Tx, unsigned char Rx, struct i2c_client client, const struct touch_platform_data *pdata, char *breakpoint, int limit_data[32][32])
{
	int p = 0;
	int q = 0;
	int r = 0;
	int cipher = 1;
	int ret = 0;
	int rx_num = 0;
	int tx_num = 0;
	const struct firmware *fwlimit = NULL;

	TOUCH_INFO_MSG("[%s] Tx=[%d], Rx=[%d]\n", __FUNCTION__, (int)Tx, (int)Rx);
	TOUCH_INFO_MSG("[%s] breakpoint = [%s]\n", __FUNCTION__, breakpoint);

	if (pdata->panel_spec == NULL) {
		TOUCH_INFO_MSG("panel_spec_file name is null\n");
		ret =  -1;
		goto exit;
	}

	if(request_firmware(&fwlimit, pdata->panel_spec, &client.dev) < 0) {
		TOUCH_INFO_MSG(" request ihex is failed\n");
		ret =  -1;
		goto exit;
	}

	strcpy(line, fwlimit->data);

	q = strstr(line, breakpoint) - line;

	if (q < 0) {
		TOUCH_INFO_MSG("failed to find breakpoint. The panel_spec_file is wrong");
		ret =  -1;
		goto exit;
	}

	memset(limit_data, 0, (TRX_max * TRX_max) * 4);

	while(1) {
		if (line[q] == ',') {
			cipher = 1;
			for (p = 1; (line[q - p] >= '0') && (line[q - p] <= '9'); p++) {
				limit_data[tx_num][rx_num] += ((line[q - p] - '0') * cipher);
				//printk("[r = %d]limit_data[%d][%d] = %d\n", r, tx_num, rx_num, limit_data[tx_num][rx_num]);
				cipher *= 10;
			}
			if(line[q - p] == '-') {
				limit_data[tx_num][rx_num] = (-1) * (limit_data[tx_num][rx_num]);
				//printk("[r = %d]limit_data[%d][%d] = %d\n", r, tx_num, rx_num, limit_data[tx_num][rx_num]);
			}
			r++;

			if(r % (int)Rx == 0){
				rx_num = 0;
				tx_num++;
			} else {
				rx_num++;
			}
		}
		q++;

		if (r == (int)Tx * (int)Rx) {
			TOUCH_INFO_MSG("panel_spec_file scanning is success\n");
			break;
		}
	}

	if (fwlimit)
		release_firmware(fwlimit);

	return ret;

exit :
	if (fwlimit)
		release_firmware(fwlimit);

	return ret;
}
예제 #10
0
static int __devinit lge_ts_misc_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	struct lge_ts_misc_info *info = NULL;
	struct input_dev *input_dev = NULL;
	int ret = 0;

	info = kzalloc(sizeof(*info), GFP_KERNEL);
	if (info == NULL) {
		TOUCH_INFO_MSG("Failed to allocated memory \n");
		return -ENOMEM;
	}

	input_dev = input_allocate_device();

	if (input_dev == NULL) {
		TOUCH_INFO_MSG("Failed to allocated memory \n");
		return -ENOMEM;
	}

	info->client = client;
	info->input_dev = input_dev;
	i2c_set_clientdata(client, info);

#ifdef CONFIG_OF
	ret = lge_ts_misc_parse_dt(&client->dev, info);
	if (ret) {
		TOUCH_INFO_MSG("Failed to parse device tree \n");
		return -ENODEV;
	}
#endif

	ret = lge_ts_misc_regulator_configure(info, true);
	if (ret) {
		TOUCH_INFO_MSG("Failed to set regulator \n");
		return -ENODEV;
	}

	ret = lge_ts_misc_power(info, true);
	if (ret < 0) {
		TOUCH_INFO_MSG("Failed to regulator on \n");
		return -ENODEV;
	}

	snprintf(info->phys, sizeof(info->phys),
		"%s/input0", dev_name(&client->dev));

	input_dev->name = MISC_DRIVER_NAME;
	input_dev->phys = info->phys;
	input_dev->id.bustype = BUS_I2C;
	input_dev->dev.init_name = MISC_DRIVER_NAME;

	input_set_drvdata(input_dev, info);

	__set_bit(EV_KEY, input_dev->evbit);
	__set_bit(KEY_POWER, input_dev->keybit);

	ret = input_register_device(input_dev);
	if (ret) {
		TOUCH_INFO_MSG("failed to register input dev\n");
		return -EIO;
	}

	if (!info->irq_wake) {
		info->client->irq = 0;
	}

	if (info->client->irq) {
		ret = request_threaded_irq(info->client->irq, NULL, lge_ts_misc_irq,
					IRQF_TRIGGER_HIGH | IRQF_ONESHOT, MISC_DRIVER_NAME, info);
		if (ret) {
			TOUCH_INFO_MSG("failed to register irq\n");
			return -EIO;
		}

#ifdef CONFIG_FB
		info->fb_notifier.notifier_call = lge_ts_misc_fb_notifier_call;
		ret = fb_register_client(&info->fb_notifier);
		if (ret) {
			TOUCH_INFO_MSG("failed to register fb_notifier: %d\n", ret);
		}
#endif
	}

	return 0;
}
예제 #11
0
static int lge_ts_misc_regulator_configure(struct lge_ts_misc_info *info, bool on)
{
	int retval = 0;

	if (on == false)
		goto hw_shutdown;

	if (info->vdd_on && info->vdd == NULL) {
		info->vdd = regulator_get(&info->client->dev, "vdd");
		if (IS_ERR(info->vdd)) {
			TOUCH_INFO_MSG("Failed to get vdd regulator\n");
			return PTR_ERR(info->vdd);
		}
	}

	if (info->vio_l19_on && info->vio_l19 == NULL) {
		info->vio_l19 = regulator_get(&info->client->dev, "vio_l19");
		if (IS_ERR(info->vio_l19)) {
			TOUCH_INFO_MSG("Failed to get vio_l19 regulator\n");
			return PTR_ERR(info->vio_l19);
		}
	}

	if (info->vio_l6_on && info->vio_l6 == NULL) {
		info->vio_l6 = regulator_get(&info->client->dev, "vio_l6");
		if (IS_ERR(info->vio_l6)) {
			TOUCH_INFO_MSG("Failed to get vio_l6 regulator\n");
			return PTR_ERR(info->vio_l6);
		}
	}

	if (info->vio_lvs1_on && info->vio_lvs1 == NULL) {
		info->vio_lvs1 = regulator_get(&info->client->dev, "vio_lvs1");
		if (IS_ERR(info->vio_lvs1)) {
			TOUCH_INFO_MSG("Failed to get vio_l6 regulator\n");
			return PTR_ERR(info->vio_lvs1);
		}
	}

	if (info->vdd && info->vdd_voltage) {
		retval = regulator_set_voltage(info->vdd, info->vdd_voltage, info->vdd_voltage);
		if (retval)
			TOUCH_INFO_MSG("regulator_set_voltage(vdd) failed retval=%d\n", retval);
	}

	if (info->vio_l19 && info->vio_l19_voltage) {
		retval = regulator_set_voltage(info->vio_l19, info->vio_l19_voltage, info->vio_l19_voltage);
		if (retval)
			TOUCH_INFO_MSG("regulator_set_voltage(vio_l19) failed retval=%d\n", retval);
	}

	if (info->vio_l6 && info->vio_l6_voltage) {
		retval = regulator_set_voltage(info->vio_l6, info->vio_l6_voltage, info->vio_l6_voltage);
		if (retval)
			TOUCH_INFO_MSG("regulator_set_voltage(vio_l6) failed retval=%d\n", retval);
	}

	if (info->vio_lvs1 && info->vio_lvs1_voltage) {
		retval = regulator_set_voltage(info->vio_lvs1, info->vio_lvs1_voltage, info->vio_lvs1_voltage);
		if (retval)
			TOUCH_INFO_MSG("regulator_set_voltage(vio_lvs1) failed retval=%d\n", retval);
	}

	return 0;

hw_shutdown:
	if (info->vdd) {
		regulator_put(info->vdd);
	}

	if (info->vio_l19) {
		regulator_put(info->vio_l19);
	}

	if (info->vio_lvs1) {
		regulator_put(info->vio_lvs1);
	}

	return 0;
}
// The following #defines are just needed to define an Image Report BUffer in memory
unsigned char F54_TxToGndReport(void)
{
   unsigned char ImageBuffer[CFG_F54_TXCOUNT];
   unsigned char ImageArray[CFG_F54_TXCOUNT];
   //unsigned char Result[CFG_F54_TXCOUNT];
   unsigned char Result=0;

   int i, k;
   int shift;

   unsigned char command;
   int read_count = 0;

#ifdef F54_Porting
	char buf[512] = {0};
	int ret = 0;

	ret += sprintf(buf+ret, "\nInfo: Tx=%d\n", numberOfTx);
	ret += sprintf(buf+ret, "=====================================================\n");
	ret += sprintf(buf+ret, "\tTransmitter To Ground Short Test\n");
	ret += sprintf(buf+ret, "=====================================================\n");
#else
	printk("\nBin #: 10		Name: Transmitter To Ground Short Test\n");
#endif
	for (i = 0; i < CFG_F54_TXCOUNT; i++)
		 ImageArray[i] = 0;
	
   // Set report mode to run Tx-to-GND
   command = 0x10;
   writeRMI(F54_Data_Base, &command, 1);

   command = 0x00;
   writeRMI(F54_Data_LowIndex, &command, 1);
   writeRMI(F54_Data_HighIndex, &command, 1);
   
   // Set the GetReport bit to run Tx-to-Tx
   command = 0x01;
   writeRMI(F54_Command_Base, &command, 1);

   // Wait until the command is completed
   do {
   	if(++read_count > 10) {
		TOUCH_INFO_MSG("%s[%d], command = %d\n", __func__, __LINE__, command);
		return 0;
	}
      delayMS(1); //wait 1ms
      readRMI(F54_Command_Base, &command, 1);
   } while (command != 0x00);

   readRMI(F54_Data_Buffer, &ImageBuffer[0], 4);

   // One bit per transmitter channel
   k = 0;      
   for (i = 0; i < CFG_F54_TXCOUNT; i++)
   {
		k = i / 8;
		shift = i % 8;
		if(ImageBuffer[k] & (1 << shift)) ImageArray[i] = 1;
   }

#ifdef F54_Porting
	ret += sprintf(buf+ret, " UsedTx:");
#else
	printk("Column:\t");
#endif
	for (i = 0; i < numberOfTx; i++)
	{	
#ifdef F54_Porting
		ret += sprintf(buf+ret, "%5d", TxChannelUsed[i]);
#else	
		printk("Tx%d,\t", TxChannelUsed[i]);
#endif
	}
#ifdef F54_Porting
	ret += sprintf(buf+ret, "\n 1 :    ");
#else	
	printk("\n");
	
	printk("0:\t");
#endif	
	for (i = 0; i < numberOfTx; i++)
	{   
		if(ImageArray[TxChannelUsed[i]])
		{
			Result++;
#ifdef F54_Porting
			ret += sprintf(buf+ret, "%5d", ImageArray[TxChannelUsed[i]]);
#else
			printk("%d,\t", ImageArray[TxChannelUsed[i]]);
#endif
		}
		else
		{
#ifdef F54_Porting
			ret += sprintf(buf+ret, "%2d(*)", ImageArray[TxChannelUsed[i]]);
#else
			printk("%d(*),\t", ImageArray[TxChannelUsed[i]]);
#endif
		}
	}
#ifdef F54_Porting
	ret += sprintf(buf+ret, "\n-----------------------------------------------------\n");
#else	
	printk("\n");
#endif

   /*
   // Check against test limits
   printk("TxToGND Result\n");
   for (i = 0; i < numberOfTx; i++)
   {   
	    if(ImageArray[TxChannelUsed[i]] == TxGNDLimit)
   			Result[i] = 'P'; //Pass
	    else
		    Result[i] = 'F'; //Fail
	    printk("Tx%d = %c\n", TxChannelUsed[i], Result[i]);
   }
	*/
   
   //enable all the interrupts
//	SetPage(0x00);
   //Reset
	command= 0x01;
	writeRMI(F01_Cmd_Base, &command, 1);
	delayMS(200);
	readRMI(F01_Data_Base+1, &command, 1); //Read Interrupt status register to Interrupt line goes to high

	if(Result == numberOfTx)
	{
#ifdef F54_Porting
		ret += sprintf(buf+ret, "RESULT: Pass\n");
		write_log(buf);
#else		
		printk("Test Result: Pass\n");
#endif
		return 1; //Pass
	}
	else
	 {
#ifdef F54_Porting
		ret += sprintf(buf+ret, "RESULT: Fail\n");
		write_log(buf);
#else	 
		 printk("Test Result: Fail\n");
#endif
		 return 0; //Fail
	 }
}
unsigned char F54_HighResistance(int mfts_enable)
{
	unsigned char imageBuffer[6];
	short resistance[3];
	int i, Result=0;
	unsigned char command;
	int read_count = 0;

#ifdef F54_Porting
	int resistanceLimit[3][2] ;//= { {-1000, 450}, {-1000, 450}, {-400, 20} };	//base value * 1000
	int resistanceLimit_target[3][2] = { {-1000, 450}, {-1000, 450}, {-400, 20} };
	int resistanceLimit_jig[3][2] = { {-1000, 450}, {-1000, 450}, {-500, 20} };
	char buf[512] = {0};
	int ret = 0;
	if(mfts_enable)
		memcpy(resistanceLimit, resistanceLimit_jig, sizeof(resistanceLimit));
	else
		memcpy(resistanceLimit, resistanceLimit_target, sizeof(resistanceLimit));
#else
	float resistanceLimit[3][2] = {-1, 0.45, -1, 0.45, -0.4, 0.02};
#endif

#ifdef F54_Porting
	ret += sprintf(buf+ret, "\n=====================================================\n");
	ret += sprintf(buf+ret, "\tHigh Resistance Test\n");
	ret += sprintf(buf+ret, "=====================================================");
#else
	TOUCH_INFO_MSG("\nBin #: 12		Name: High Resistance Test\n");
#endif

	// Set report mode
	command = 0x04;
	writeRMI(F54_Data_Base, &command, 1);

	// Force update
	command = 0x04;
	writeRMI(F54_Command_Base, &command, 1);

	do {
		if(++read_count > 10) {
			TOUCH_INFO_MSG("%s[%d], command = %d\n", __func__, __LINE__, command);
			return 0;
		}
		delayMS(1); //wait 1ms
		readRMI(F54_Command_Base, &command, 1);
	} while (command != 0x00);

	command = 0x02;
	writeRMI(F54_Command_Base, &command, 1);

	read_count = 0;
	do {
		if(++read_count > 10) {
			TOUCH_INFO_MSG("%s[%d], command = %d\n", __func__, __LINE__, command);
			return 0;
		}
		delayMS(1); //wait 1ms
		readRMI(F54_Command_Base, &command, 1);
	} while (command != 0x00);

	command = 0x00;
	writeRMI(F54_Data_LowIndex, &command, 1);
	writeRMI(F54_Data_HighIndex, &command, 1);

	// Set the GetReport bit
	command = 0x01;
	writeRMI(F54_Command_Base, &command, 1);

   // Wait until the command is completed
   	read_count = 0;
	do {
		if(++read_count > 10) {
			TOUCH_INFO_MSG("%s[%d], command = %d\n", __func__, __LINE__, command);
			return 0;
		}
		delayMS(1); //wait 1ms
		readRMI(F54_Command_Base, &command, 1);
	} while (command != 0x00);

	readRMI(F54_Data_Buffer, imageBuffer, 6);

#ifdef F54_Porting
	ret += sprintf(buf+ret, "\n Parameters: ");
#else
	TOUCH_INFO_MSG("Parameters:\t");
#endif
	for(i=0; i<3; i++) {
		resistance[i] = (short)((imageBuffer[i*2+1] << 8) | imageBuffer[i*2]);
#ifdef F54_Porting
		ret += sprintf(buf+ret, "%5d ", (resistance[i]));
#else
		TOUCH_INFO_MSG("%1.3f,\t\t", (float)(resistance[i])/1000);
#endif

#ifdef F54_Porting
		if((resistance[i] >= resistanceLimit[i][0]) && (resistance[i] <= resistanceLimit[i][1]))
			Result++;
#else
		if((resistance[i]/1000 >= resistanceLimit[i][0]) && (resistance[i]/1000 <= resistanceLimit[i][1]))
			Result++;
#endif
	}
#ifdef F54_Porting
	ret += sprintf(buf+ret, "\n\n Limits(+) : ");
#else
	TOUCH_INFO_MSG("\n");

	TOUCH_INFO_MSG("Limits:\t\t");
#endif
	for(i=0; i<3; i++) {
#ifdef F54_Porting
		ret += sprintf(buf+ret, "%5d ", resistanceLimit[i][1]);
#else
		printk("%1.3f,%1.3f\t", resistanceLimit[i][0], resistanceLimit[i][1]);
#endif
	}

	ret += sprintf(buf+ret, "\n Limits(-) : ");

	for(i=0; i<3; i++) {
#ifdef F54_Porting
		ret += sprintf(buf+ret, "%5d ", resistanceLimit[i][0]);
#else
		printk("%1.3f,%1.3f\t", resistanceLimit[i][0], resistanceLimit[i][1]);
#endif
	}

#ifdef F54_Porting
	ret += sprintf(buf+ret, "\n-----------------------------------------------------\n");
#else
	printk("\n");
#endif

	// Set the Force Cal
	command = 0x02;
	writeRMI(F54_Command_Base, &command, 1);

	read_count = 0;
	do {
		if(++read_count > 10) {
			TOUCH_INFO_MSG("%s[%d], command = %d\n", __func__, __LINE__, command);
			return 0;
		}
		delayMS(1); //wait 1ms
		readRMI(F54_Command_Base, &command, 1);
	} while (command != 0x00);

	//enable all the interrupts
	//Reset
	command= 0x01;
	writeRMI(F01_Cmd_Base, &command, 1);
	delayMS(200);
	readRMI(F01_Data_Base+1, &command, 1); //Read Interrupt status register to Interrupt line goes to high

	if(Result == 3) {
#ifdef F54_Porting
		ret += sprintf(buf+ret, "RESULT: Pass\n");
		write_log(buf);
#else
		TOUCH_INFO_MSG("Test Result: Pass\n");
#endif
		return 1; //Pass
	} else {
#ifdef F54_Porting
		ret += sprintf(buf+ret, "RESULT: Fail\n");
		write_log(buf);
#else
		TOUCH_INFO_MSG("Test Result: Fail, Result = %d\n", Result);
#endif
		return 0; //Fail
	}
}
int F54_GetHighResistance(char *buf)
{
	unsigned char imageBuffer[6];
	short resistance[3];
	int i, Result=0;
	unsigned char command;

	int resistanceLimit[3][2] = { {-1000, 450}, {-1000, 450}, {-400, 20} };	//base value * 1000
	int ret = 0;
	int waitcount;

	// Set report mode
	command = 0x04;
	writeRMI(F54_Data_Base, &command, 1);

	// Force update
	command = 0x04;
	writeRMI(F54_Command_Base, &command, 1);

	waitcount = 0;
	do {
		if(++waitcount > 500) {
			TOUCH_INFO_MSG("%s[%d], command = %d\n", __func__, __LINE__, command);
		return ret;
		}
		delayMS(1); //wait 1ms
		readRMI(F54_Command_Base, &command, 1);
	} while (command != 0x00);

	command = 0x02;
	writeRMI(F54_Command_Base, &command, 1);

	waitcount = 0;
	do {
		if(++waitcount > 500) {
			TOUCH_INFO_MSG("%s[%d], command = %d\n", __func__, __LINE__, command);
			return ret;
		}
		delayMS(1); //wait 1ms
		readRMI(F54_Command_Base, &command, 1);
	} while (command != 0x00);

	command = 0x00;
	writeRMI(F54_Data_LowIndex, &command, 1);
	writeRMI(F54_Data_HighIndex, &command, 1);

	// Set the GetReport bit
	command = 0x01;
	writeRMI(F54_Command_Base, &command, 1);

	// Wait until the command is completed
	waitcount = 0;
	do {
		if(++waitcount > 500) {
			TOUCH_INFO_MSG("%s[%d], command = %d\n", __func__, __LINE__, command);
			return ret;
		}
		delayMS(1); //wait 1ms
		readRMI(F54_Command_Base, &command, 1);
	} while (command != 0x00);

	readRMI(F54_Data_Buffer, imageBuffer, 6);
/*
	ret += sprintf(buf+ret, "\n\n=====================================================\n");
	ret += sprintf(buf+ret, "\tHigh Resistance Test\n");
	ret += sprintf(buf+ret, "=====================================================\n");
	ret += sprintf(buf+ret, "\n Parameters: ");
*/
	for(i=0; i<3; i++) {
		resistance[i] = (short)((imageBuffer[i*2+1] << 8) | imageBuffer[i*2]);
		//ret += sprintf(buf+ret, "%5d ", (resistance[i]));
		if((resistance[i] >= resistanceLimit[i][0]) && (resistance[i] <= resistanceLimit[i][1]))
			Result++;
	}
/*	ret += sprintf(buf+ret, "\n\n Limits(+) : ");

	for(i=0; i<3; i++) {
		ret += sprintf(buf+ret, "%5d ", resistanceLimit[i][1]);
	}
	ret += sprintf(buf+ret, "\n Limits(-) : ");
	for(i=0; i<3; i++) {
		ret += sprintf(buf+ret, "%5d ", resistanceLimit[i][0]);
	}
*/
	// Set the Force Cal
	command = 0x02;
	writeRMI(F54_Command_Base, &command, 1);

	waitcount = 0;
	do {
		if(++waitcount > 100) {
			TOUCH_INFO_MSG("%s[%d], command = %d\n", __func__, __LINE__, command);
			break;
		}
		delayMS(1); //wait 1ms
		readRMI(F54_Command_Base, &command, 1);
	} while (command != 0x00);

	if (Result == 3) {
		ret += sprintf(buf+ret, "RESULT: Pass\n\n");
	} else {
		ret += sprintf(buf+ret, "RESULT: Fail\n\n");
	}

	//enable all the interrupts
	//	SetPage(0x00);
	//Reset
	command= 0x01;
	writeRMI(F01_Cmd_Base, &command, 1);
	delayMS(200);
	readRMI(F01_Data_Base+1, &command, 1); //Read Interrupt status register to Interrupt line goes to high

	return ret;
}