static void module_on_master(void *device_data)
{
	struct mms_info *info = (struct mms_info *)device_data;
	struct mms_fac_data *fac_data = info->fac_data;
	struct i2c_client *client = info->client;
	int ret;

	set_default_result(fac_data);

	ret = mms_onoff_power(info, true);
	if (ret) {
		dev_err(&client->dev, "Failed to %s(%d)\n", __func__, ret);
		goto out;
	}

	fac_data->cmd_state = CMD_STATUS_OK;
	sprintf(fac_data->cmd_buff, "OK");
	set_cmd_result(fac_data, fac_data->cmd_buff, strlen(fac_data->cmd_buff));

	dev_info(&client->dev, "%s : %s\n", __func__, fac_data->cmd_buff);

out:
	fac_data->cmd_state = CMD_STATUS_FAIL;
	sprintf(fac_data->cmd_buff, "NG");
	set_cmd_result(fac_data, fac_data->cmd_buff, strlen(fac_data->cmd_buff));

	return;
}
示例#2
0
static void get_delta(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_data_sysfs *sysfs_data = data->sysfs_data;
	char buff[16] = {0};
	int node;

	set_default_result(sysfs_data);
	/* add read function */

	node = mxt_xy_to_node(data);
	if (node < 0) {
		sysfs_data->cmd_state = CMD_STATUS_FAIL;
		return;
	} else {
		snprintf(buff, sizeof(buff), "%d",
			sysfs_data->delta[node]);
		set_cmd_result(sysfs_data,
			buff, strnlen(buff, sizeof(buff)));

		sysfs_data->cmd_state = CMD_STATUS_OK;
	}
	dev_info(&client->dev, "%s: %s(%d)\n", __func__, buff,
			strnlen(buff, sizeof(buff)));
}
示例#3
0
static void module_on_master(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_data_sysfs *sysfs_data = data->sysfs_data;

	char buff[3] = {0};

	mutex_lock(&data->lock);
	if (!data->mxt_enabled) {
		if (data->pdata->power_on())
			snprintf(buff, sizeof(buff), "%s", "NG");
		else
			snprintf(buff, sizeof(buff), "%s", "OK");

		enable_irq(client->irq);
		data->mxt_enabled = true;
	} else {
		snprintf(buff, sizeof(buff), "%s", "OK");
	}
	mutex_unlock(&data->lock);

	set_default_result(sysfs_data);
	set_cmd_result(sysfs_data, buff, strnlen(buff, sizeof(buff)));

	if (strncmp(buff, "OK", 2) == 0)
		sysfs_data->cmd_state = CMD_STATUS_OK;
	else
		sysfs_data->cmd_state = CMD_STATUS_FAIL;

	dev_info(&client->dev, "%s: %s\n", __func__, buff);

}
static void get_y_num(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_fac_data *fdata = data->fdata;

	char buff[16] = {0};
	int val;

	set_default_result(fdata);
	val = fdata->num_ynode;
	if (val < 0) {
		snprintf(buff, sizeof(buff), "%s", "NG");
		set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));
		fdata->cmd_state = CMD_STATUS_FAIL;

		dev_info(&client->dev, "%s: fail to read num of y (%d).\n",
			__func__, val);

		return;
	}
	snprintf(buff, sizeof(buff), "%u", val);
	set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));
	fdata->cmd_state = CMD_STATUS_OK;

	dev_info(&client->dev, "%s: %s(%d)\n",
		__func__, buff, strnlen(buff, sizeof(buff)));
}
static void get_fw_ver_bin(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct device *dev = &data->client->dev;
	struct mxt_fac_data *fdata = data->fdata;

	char buff[40] = {0};

	set_default_result(fdata);

	if (!fdata->fw_ver && !fdata->build_ver) {
		snprintf(buff, sizeof(buff), "NG");
		set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));
		fdata->cmd_state = CMD_STATUS_FAIL;
	} else {
		/* Format : IC vendor + H/W verion of IC + F/W version
		 * ex) Atmel : AT00201B
		 */
			snprintf(buff, sizeof(buff), "AT00%02x%02x",
			fdata->fw_ver, fdata->build_ver);
		set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));
		fdata->cmd_state = CMD_STATUS_OK;
	}
	dev_info(dev, "%s: %s(%d)\n",
		__func__, buff, strnlen(buff, sizeof(buff)));
}
static void run_reference_read(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct mxt_fac_data *fdata = data->fdata;
	int ret;
	char buff[16] = {0};

	set_default_result(fdata);

#if TSP_PATCH
	if(data->patch.event_cnt)
		mxt_patch_test_event(data, 2);
#endif

	ret = mxt_read_all_diagnostic_data(data,
			MXT_DIAG_REFERENCE_MODE);
	if (ret)
		fdata->cmd_state = CMD_STATUS_FAIL;
	else {
		snprintf(buff, sizeof(buff), "%d,%d",
			fdata->ref_min_data, fdata->ref_max_data);
		set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));

		fdata->cmd_state = CMD_STATUS_OK;
	}
}
static void module_on_master(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_fac_data *fdata = data->fdata;

	char buff[3] = {0};

	mutex_lock(&data->input_dev->mutex);

	if (mxt_start(data))
		snprintf(buff, sizeof(buff), "%s", "NG");
	else
		snprintf(buff, sizeof(buff), "%s", "OK");

	mutex_unlock(&data->input_dev->mutex);

	set_default_result(fdata);
	set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));

	if (strncmp(buff, "OK", 2) == 0)
		fdata->cmd_state = CMD_STATUS_OK;
	else
		fdata->cmd_state = CMD_STATUS_FAIL;

	dev_info(&client->dev, "%s: %s\n", __func__, buff);

}
static void get_threshold(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_fac_data *fdata = data->fdata;
	int error;

	char buff[16] = {0};
	u8 threshold = 0;

	set_default_result(fdata);

	if (data->pdata->revision == MXT_REVISION_I)
		error = mxt_read_object(data, MXT_TOUCH_MULTITOUCHSCREEN_T100,
			 30, &threshold);
	else
		error = mxt_read_object(data, MXT_TOUCH_MULTITOUCHSCREEN_T9,
			 7, &threshold);

	if (error) {
		dev_err(&client->dev, "Failed get the threshold\n");
		snprintf(buff, sizeof(buff), "%s", "NG");
		set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));
		fdata->cmd_state = CMD_STATUS_FAIL;
		return;
	}

	snprintf(buff, sizeof(buff), "%d", threshold);

	set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));
	fdata->cmd_state = CMD_STATUS_OK;
	dev_info(&client->dev, "%s: %s(%d)\n",
		__func__, buff, strnlen(buff, sizeof(buff)));
}
示例#9
0
static void get_threshold(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_data_sysfs *sysfs_data = data->sysfs_data;

	char buff[16] = {0};
	u8 threshold;

	set_default_result(sysfs_data);

	mxt_read_object(data,
		TOUCH_MULTITOUCHSCREEN_T9, 7, &threshold);
	if (threshold < 0) {
		snprintf(buff, sizeof(buff), "%s", "NG");
		set_cmd_result(sysfs_data, buff, strnlen(buff, sizeof(buff)));
		sysfs_data->cmd_state = CMD_STATUS_FAIL;
		return;
	}
	snprintf(buff, sizeof(buff), "%d", threshold);

	set_cmd_result(sysfs_data, buff, strnlen(buff, sizeof(buff)));
	sysfs_data->cmd_state = CMD_STATUS_OK;
	dev_info(&client->dev, "%s: %s(%d)\n", __func__,
			buff, strnlen(buff, sizeof(buff)));
}
static void get_threshold(void *device_data)
{
	struct mms_info *info = (struct mms_info *)device_data;
	struct mms_fac_data *fac_data = info->fac_data;
	struct i2c_client *client = info->client;
	s32 buff;

	set_default_result(fac_data);

	buff = i2c_smbus_read_byte_data(info->client, MMS_THRESHOLD);
	if (buff < 0) {
		dev_err(&client->dev, "Failed to read threshold (%d)\n", buff);
		goto out;
	}

	fac_data->cmd_state = CMD_STATUS_OK;
	sprintf(fac_data->cmd_buff, "%d", buff);
	set_cmd_result(fac_data, fac_data->cmd_buff, strlen(fac_data->cmd_buff));

	dev_info(&client->dev, "%s : %s\n", __func__, fac_data->cmd_buff);

	return;

out:
	fac_data->cmd_state = CMD_STATUS_FAIL;
	sprintf(fac_data->cmd_buff, "NG");
	set_cmd_result(fac_data, fac_data->cmd_buff, strlen(fac_data->cmd_buff));

	return ;
}
示例#11
0
static void get_y_num(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_data_sysfs *sysfs_data = data->sysfs_data;

	char buff[16] = {0};
	u8 val;

	set_default_result(sysfs_data);
	val = data->y_num;
	if (val < 0) {
		snprintf(buff, sizeof(buff), "%s", "NG");
		set_cmd_result(sysfs_data, buff, strnlen(buff, sizeof(buff)));
		sysfs_data->cmd_state = CMD_STATUS_FAIL;

		dev_err(&client->dev,
			 "%s: fail to read num of y (%d).\n", __func__, val);

		return;
	}
	snprintf(buff, sizeof(buff), "%u", val);
	set_cmd_result(sysfs_data, buff, strnlen(buff, sizeof(buff)));
	sysfs_data->cmd_state = CMD_STATUS_OK;

	dev_dbg(&client->dev, "%s: %s(%d)\n", __func__, buff,
			strnlen(buff, sizeof(buff)));
}
static void fw_update(void *device_data)
{
	struct mms_info *info = (struct mms_info *)device_data;
	struct mms_fac_data *fac_data = info->fac_data;
	struct i2c_client *client = info->client;
	int fw_type = fac_data->cmd_param[0];
	int ret;

	set_default_result(fac_data);

	if (!info->enabled) {
		dev_err(&client->dev, "%s : TSP is disabled\n");
		goto out;
	}

	mutex_lock(&info->input_dev->mutex);
	disable_irq(info->irq);

	switch (fw_type) {
	case FW_FROM_BUILT_IN:
		ret = update_from_req_fw(info);
	break;
	case FW_FROM_UMS:
		ret = update_from_ums(info);
	break;
	default:
		dev_err(&client->dev,
					"%s : Invalid update type(%d)\n", __func__, fw_type);
		goto err_update;
	break;
	}

	if (ret) {
		dev_err(&client->dev, "%s : Failed fw update(%d)\n", __func__, ret);
		goto err_update;
	}

	enable_irq(info->irq);
	mutex_unlock(&info->input_dev->mutex);

	fac_data->cmd_state = CMD_STATUS_OK;
	sprintf(fac_data->cmd_buff, "OK");
	set_cmd_result(fac_data, fac_data->cmd_buff, strlen(fac_data->cmd_buff));

	dev_info(&client->dev, "%s : %s\n", __func__, fac_data->cmd_buff);

	return;

err_update:
	enable_irq(info->irq);
	mutex_unlock(&info->input_dev->mutex);
out:
	fac_data->cmd_state = CMD_STATUS_FAIL;
	sprintf(fac_data->cmd_buff, "NG");
	set_cmd_result(fac_data, fac_data->cmd_buff, strlen(fac_data->cmd_buff));

	return;
}
示例#13
0
static void not_support_cmd(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_data_sysfs *sysfs_data = data->sysfs_data;

	char buff[16] = {0};

	set_default_result(sysfs_data);
	sprintf(buff, "%s", "NA");
	set_cmd_result(sysfs_data, buff, strnlen(buff, sizeof(buff)));
	sysfs_data->cmd_state = CMD_STATUS_NOT_APPLICABLE;
	dev_info(&client->dev, "%s: \"%s(%d)\"\n", __func__,
				buff, strnlen(buff, sizeof(buff)));
}
示例#14
0
static void run_delta_read(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct mxt_data_sysfs *sysfs_data = data->sysfs_data;
	int ret;

	set_default_result(sysfs_data);

	ret = mxt_read_all_diagnostic_data(data,
			MXT_DIAG_DELTA_MODE);
	if (ret)
		sysfs_data->cmd_state = CMD_STATUS_FAIL;
	else
		sysfs_data->cmd_state = CMD_STATUS_OK;
}
示例#15
0
static void get_config_ver(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_data_sysfs *sysfs_data = data->sysfs_data;
	char buff[40] = {0};

	set_default_result(sysfs_data);
	snprintf(buff, sizeof(buff), "%s", data->config_version);

	set_cmd_result(sysfs_data, buff, strnlen(buff, sizeof(buff)));
	sysfs_data->cmd_state = CMD_STATUS_OK;
	dev_info(&client->dev, "%s: %s(%d)\n", __func__,
			buff, strnlen(buff, sizeof(buff)));
}
static void get_y_num(void *device_data)
{
	struct mms_info *info = (struct mms_info *)device_data;
	struct mms_fac_data *fac_data = info->fac_data;
	struct i2c_client *client = info->client;

	set_default_result(fac_data);

	fac_data->cmd_state = CMD_STATUS_OK;
	sprintf(fac_data->cmd_buff, "%d", fac_data->rx_num);
	set_cmd_result(fac_data, fac_data->cmd_buff, strlen(fac_data->cmd_buff));

	dev_info(&client->dev, "%s : %s\n", __func__, fac_data->cmd_buff);

	return;
}
示例#17
0
static void get_chip_name(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_data_sysfs *sysfs_data = data->sysfs_data;

	char buff[16] = {0};

	set_default_result(sysfs_data);

	snprintf(buff, sizeof(buff), "%s", "MXT1664S");
	set_cmd_result(sysfs_data, buff, strnlen(buff, sizeof(buff)));
	sysfs_data->cmd_state = CMD_STATUS_OK;
	dev_dbg(&client->dev, "%s: %s(%d)\n", __func__,
			buff, strnlen(buff, sizeof(buff)));
}
示例#18
0
static void get_chip_vendor(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_fac_data *fdata = data->fdata;

	char buff[16] = {0};

	set_default_result(fdata);

	snprintf(buff, sizeof(buff), "%s", "ATMEL");
	set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));
	fdata->cmd_state = CMD_STATUS_OK;
	dev_info(&client->dev, "%s: %s(%d)\n",
		__func__, buff, strnlen(buff, sizeof(buff)));
}
static void get_fw_ver_ic(void *device_data)
{
	struct mms_info *info = (struct mms_info *)device_data;
	struct mms_fac_data *fac_data = info->fac_data;
	struct i2c_client *client = info->client;
	char buff[TSP_CMD_FULL_VER_LEN] = {0,};
	int ret;

	set_default_result(fac_data);

	ret = i2c_smbus_read_i2c_block_data(client, MMS_VENDOR_ID, 2, buff);
	if (ret < 0) {
		dev_err(&client->dev, "Failed to read vendor ID(%d)\n", ret);
		goto out;
	}

	ret = i2c_smbus_read_byte_data(client, MMS_HW_ID);
	if (ret < 0) {
		dev_err(&client->dev, "Failed to read HW ID(%d)\n", ret);
		goto out;
	}

	sprintf(buff + 2, "%02X", ret);

	ret = i2c_smbus_read_byte_data(client, MMS_CONFIG_VERSION);
	if (ret < 0) {
		dev_err(&client->dev, "Failed to read FW ver (%d)\n", ret);
		goto out;
	}

	sprintf(buff + 4, "%04X", ret);

	fac_data->cmd_state = CMD_STATUS_OK;
	sprintf(fac_data->cmd_buff, "%s", buff);
	set_cmd_result(fac_data, fac_data->cmd_buff, strlen(fac_data->cmd_buff));

	dev_info(&client->dev, "%s : %s\n", __func__, fac_data->cmd_buff);

	return;

out:
	fac_data->cmd_state = CMD_STATUS_FAIL;
	sprintf(fac_data->cmd_buff, "NG");
	set_cmd_result(fac_data, fac_data->cmd_buff, strlen(fac_data->cmd_buff));

	return ;
}
示例#20
0
static void get_config_ver(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_fac_data *fdata = data->fdata;
	struct mxt_object *user_object;

	char buff[50] = {0};
	char date[10] = {0};
	int error = 0;
	u32 current_crc = 0;

	set_default_result(fdata);

	/* Get the config version from userdata */
	user_object = mxt_get_object(data, MXT_SPT_USERDATA_T38);
	if (!user_object) {
		dev_err(&client->dev, "fail to get object_info\n");
		snprintf(buff, sizeof(buff), "%s", "NG");
		set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));
		fdata->cmd_state = CMD_STATUS_FAIL;
		return;
	}

	mxt_read_mem(data, user_object->start_address,
			MXT_CONFIG_VERSION_LENGTH, date);

	disable_irq(data->client->irq);
	/* Get config CRC from device */
	error = mxt_read_config_crc(data, &current_crc);
	if (error)
		dev_err(&client->dev, "%s Error getting configuration CRC:%d\n",
			__func__, error);
	enable_irq(data->client->irq);

	/* Model number_vendor_date_CRC value */
	/* Need to be removed hard cording in date */
	snprintf(buff, sizeof(buff), "%s_AT_%s_0x%06X",
		data->pdata->project_name, date, current_crc);

	set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));
	fdata->cmd_state = CMD_STATUS_OK;
	dev_info(&client->dev, "%s: %s(%d)\n",
		__func__, buff, strnlen(buff, sizeof(buff)));
}
示例#21
0
static void mxt_run_factory_cal(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_fac_data *fdata = data->fdata;
	struct mxt_message message;
	int error = 0;

	set_default_result(fdata);

	/* To ensure that previous touchs are released */
	msleep(500);

	/* CTRL : enable RPTEN and ENABLE */
	error = mxt_write_object(data, MXT_SPT_GOLDENREFERENCES_T66,
				0, MXT_FCALCMD(MXT_FCALCMD_PRIME) | 0x03);

	if (error) {
		dev_err(&client->dev, "Failed to write FCALCMD_PRIME\n");
		fdata->cmd_state = CMD_STATUS_FAIL;
		return;
	}

	disable_irq(client->irq);

	do {
		error = mxt_read_message_on_fcal(data, &message);

		if (!error)
			msleep(1000);
	} while (!error);

	enable_irq(client->irq);

	if (error == FCALSEQDONE_MAGIC) {
		dev_info(&client->dev, "Sucessed Factory Calibration\n");
		fdata->cmd_state = CMD_STATUS_OK;
	} else {
		dev_err(&client->dev, "Failed Factory Calibration [%d]", error);
		fdata->cmd_state = CMD_STATUS_FAIL;
	}
}
示例#22
0
static void patch_update(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct device *dev = &data->client->dev;
	struct mxt_fac_data *fdata = data->fdata;
	u8 *patch_data = NULL;
	int ret = 0;
	char buff[16] = {0};

	set_default_result(fdata);
	switch (fdata->cmd_param[0]) {

	case 1:
		ret = mxt_load_patch_from_ums(data, patch_data);
		if (ret)
			goto out;
	break;

	default:
		dev_err(dev, "invalid patch file type!!\n");
		ret = -EINVAL;
		goto out;
	}
	dev_info(&data->client->dev, "%s ppatch:%p %p\n", __func__,
		patch_data, data->patch.patch);
	ret = mxt_patch_init(data, data->patch.patch);

out:
	kfree(patch_data);

	if (ret) {
		snprintf(buff, sizeof(buff), "FAIL");
		set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));
		fdata->cmd_state = CMD_STATUS_FAIL;
	} else {
		snprintf(buff, sizeof(buff), "OK");
		set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));
		fdata->cmd_state = CMD_STATUS_OK;
	}
	return;
}
static void get_fw_ver_bin(void *device_data)
{
	struct mms_info *info = (struct mms_info *)device_data;
	struct mms_fac_data *fac_data = info->fac_data;
	struct i2c_client *client = info->client;
	char buff[TSP_CMD_FULL_VER_LEN] = {0,};

	set_default_result(fac_data);

	snprintf(buff, 3, "%s", &info->fw->data[0x452]);
	sprintf(buff + 2, "%02X", info->fw->data[0x454]);
	sprintf(buff + 4, "%04X", info->fw->data[0x32]);

	fac_data->cmd_state = CMD_STATUS_OK;
	sprintf(fac_data->cmd_buff, "%s", buff);
	set_cmd_result(fac_data, fac_data->cmd_buff, strlen(fac_data->cmd_buff));

	dev_info(&client->dev, "%s : %s\n", __func__, fac_data->cmd_buff);

	return;
}
示例#24
0
static void run_reference_read(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct mxt_data_sysfs *sysfs_data = data->sysfs_data;
	int ret;
	char buff[16] = {0};

	set_default_result(sysfs_data);

	ret = mxt_read_all_diagnostic_data(data,
			MXT_DIAG_REFERENCE_MODE);
	if (ret)
		sysfs_data->cmd_state = CMD_STATUS_FAIL;
	else {
		snprintf(buff, sizeof(buff), "%d,%d",
			sysfs_data->ref_min_data, sysfs_data->ref_max_data);
		set_cmd_result(sysfs_data, buff, strnlen(buff, sizeof(buff)));

		sysfs_data->cmd_state = CMD_STATUS_OK;
	}
}
示例#25
0
static void get_fw_ver_ic(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_data_sysfs *sysfs_data = data->sysfs_data;

	char buff[40] = {0};
	int ver = data->info.version;

	set_default_result(sysfs_data);
#if defined(CONFIG_TARGET_LOCALE_USA)
	snprintf(buff, sizeof(buff), "AT00%04x", ver);
#else
	snprintf(buff, sizeof(buff), "%02x", ver);
#endif

	set_cmd_result(sysfs_data, buff, strnlen(buff, sizeof(buff)));
	sysfs_data->cmd_state = CMD_STATUS_OK;
	dev_info(&client->dev, "%s: %s(%d)\n", __func__,
			buff, strnlen(buff, sizeof(buff)));
}
示例#26
0
static void get_reference(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_fac_data *fdata = data->fdata;
	char buff[16] = {0};
	int node;

	set_default_result(fdata);
	/* add read function */

	node = mxt_xy_to_node(data);
	if (node < 0) {
		fdata->cmd_state = CMD_STATUS_FAIL;
		return;
	}
	snprintf(buff, sizeof(buff), "%u", fdata->reference[node]);
	set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));
	fdata->cmd_state = CMD_STATUS_OK;

	dev_info(&client->dev, "%s: %s(%d)\n",
		__func__, buff, strnlen(buff, sizeof(buff)));
}
示例#27
0
/*
* find the x,y position to use maximum delta.
* it is diffult to map the orientation and caculate the node number
* because layout is always different according to device
*/
static void find_delta_node(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct mxt_data_sysfs *sysfs_data = data->sysfs_data;
	char buff[16] = {0};
	u16 x, y;
	int ret;

	set_default_result(sysfs_data);

	/* read all delta to get the maximum delta value */
	ret = mxt_read_all_diagnostic_data(data,
			MXT_DIAG_DELTA_MODE);
	if (ret) {
		sysfs_data->cmd_state = CMD_STATUS_FAIL;
	} else {
		mxt_node_to_xy(data, &x, &y);
		snprintf(buff, sizeof(buff), "%d,%d", x, y);
		set_cmd_result(sysfs_data, buff, strnlen(buff, sizeof(buff)));

		sysfs_data->cmd_state = CMD_STATUS_OK;
	}
}
示例#28
0
static void get_fw_ver_ic(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_fac_data *fdata = data->fdata;

	char buff[40] = {0};
	int ver, build;

	set_default_result(fdata);

	ver = data->info.version;
	build = data->info.build;

	/* Format : IC vendor + H/W verion of IC + F/W version
	 * ex) Atmel : AT00201B
	 */
	snprintf(buff, sizeof(buff), "AT00%02x%02x", ver, build);

	set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));
	fdata->cmd_state = CMD_STATUS_OK;
	dev_info(&client->dev, "%s: %s(%d)\n",
		__func__, buff, strnlen(buff, sizeof(buff)));
}
示例#29
0
static void fw_update(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct device *dev = &data->client->dev;
	struct mxt_fac_data *fdata = data->fdata;
	struct mxt_fw_info fw_info;
	const u8 *fw_data = NULL;
	const struct firmware *fw = NULL;
	int ret = 0;
	char buff[16] = {0};

	memset(&fw_info, 0, sizeof(struct mxt_fw_info));
	fw_info.data = data;

	set_default_result(fdata);
	switch (fdata->cmd_param[0]) {

	case MXT_FW_FROM_UMS:
		ret = mxt_load_fw_from_ums(&fw_info, fw_data);
		if (ret)
			goto out;
	break;

	case MXT_FW_FROM_BUILT_IN:
	case MXT_FW_FROM_REQ_FW:
		ret = mxt_load_fw_from_req_fw(&fw_info, fw);
		if (ret)
			goto out;
	break;

	default:
		dev_err(dev, "invalid fw file type!!\n");
		ret = -EINVAL;
		goto out;
	}
/*
	ret = wait_for_completion_interruptible_timeout(&data->init_done,
			msecs_to_jiffies(90 * MSEC_PER_SEC));

	if (ret <= 0) {
		dev_err(dev, "error while waiting for device to init (%d)\n",
			ret);
		ret = -EBUSY;
		goto out;
	}
*/
	mutex_lock(&data->input_dev->mutex);
	disable_irq(data->client->irq);

	/* Change to the bootloader mode */
	ret = mxt_command_reset(data, MXT_BOOT_VALUE);
	if (ret)
		goto irq_enable;

	ret = mxt_flash_fw(&fw_info);
	if (ret) {
		dev_err(dev, "The firmware update failed(%d)\n", ret);
	} else {
		dev_info(dev, "The firmware update succeeded\n");
		kfree(data->objects);
		data->objects = NULL;

		ret = mxt_initialize(data);
		if (ret) {
			dev_err(dev, "Failed to initialize\n");
			goto irq_enable;
		}

		ret = mxt_rest_initialize(&fw_info);
		if (ret) {
			dev_err(dev, "Failed to rest init\n");
			goto irq_enable;
		}
	}
	ret = mxt_make_highchg(data);

irq_enable:
	enable_irq(data->client->irq);
	mutex_unlock(&data->input_dev->mutex);
out:
	release_firmware(fw);
	vfree(fw_data);

	if (ret) {
		snprintf(buff, sizeof(buff), "FAIL");
		set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));
		fdata->cmd_state = CMD_STATUS_FAIL;
	} else {
		snprintf(buff, sizeof(buff), "OK");
		set_cmd_result(fdata, buff, strnlen(buff, sizeof(buff)));
		fdata->cmd_state = CMD_STATUS_OK;
	}

	return;
}
示例#30
0
/* + function realted samsung factory test */
static void fw_update(void *device_data)
{
	struct mxt_data *data = (struct mxt_data *)device_data;
	struct i2c_client *client = data->client;
	struct mxt_data_sysfs *sysfs_data = data->sysfs_data;
	struct file *filp = NULL;
	const struct firmware *fw = NULL;
	const u8 *fw_data = NULL;
	long fw_size = 0;
	mm_segment_t old_fs = {0};
	char *fw_path;
	int ret;

	set_default_result(sysfs_data);

	fw_path = kzalloc(MXT_MAX_FW_PATH, GFP_KERNEL);
	if (fw_path == NULL) {
		dev_err(&client->dev, "failed to allocate firmware path.\n");
		goto out;
	}

	switch (sysfs_data->cmd_param[0]) {
	case MXT_FW_FROM_UMS:
		snprintf(fw_path, MXT_MAX_FW_PATH, "/sdcard/%s", MXT_FW_NAME);

		old_fs = get_fs();
		set_fs(get_ds());

		filp = filp_open(fw_path, O_RDONLY, 0);
		if (IS_ERR(filp)) {
			dev_err(&client->dev, "could not open firmware: %s,%d\n",
				fw_path, (s32)filp);
			goto err_open;
		}

		fw_size = filp->f_path.dentry->d_inode->i_size;

		fw_data = kzalloc((size_t)fw_size, GFP_KERNEL);
		if (!fw_data) {
			dev_err(&client->dev, "fail to alloc buffer for fw\n");
			goto err_alloc;
		}
		ret = vfs_read(filp, (char __user *)fw_data,
				fw_size, &filp->f_pos);
		if (ret != fw_size) {
			dev_err(&client->dev, "fail to read file %s (ret = %d)\n",
					fw_path, ret);
			goto err_read;
		}
		filp_close(filp, current->files);
		set_fs(old_fs);
	break;

	case MXT_FW_FROM_BUILT_IN:
	case MXT_FW_FROM_REQ_FW:
		snprintf(fw_path, MXT_MAX_FW_PATH, "tsp_atmel/%s", MXT_FW_NAME);

		ret = request_firmware(&fw, fw_path, &client->dev);
		if (ret) {
			dev_err(&client->dev,
				"could not request firmware %s\n", fw_path);
			goto err_open;
		}

		fw_size = fw->size;
		fw_data = kzalloc(fw_size, GFP_KERNEL);
		if (!fw_data) {
			dev_err(&client->dev, "fail to alloc buffer for fw\n");
			goto err_alloc;
		}
		memcpy((void *)fw_data, fw->data, fw_size);
		release_firmware(fw);
	break;

	default:
		dev_err(&client->dev, "invalid fw file type!!\n");
		goto not_support;
	}

	kfree(fw_path);
	disable_irq(data->client->irq);

	ret = mxt_flash_fw_from_sysfs(data, fw_data, fw_size);

	enable_irq(data->client->irq);
	kfree(fw_data);

	if (ret)
		sysfs_data->cmd_state = CMD_STATUS_FAIL;
	else
		sysfs_data->cmd_state = CMD_STATUS_OK;

	return;

err_read:
	kfree(fw_data);
err_alloc:
	if (!filp)
		filp_close(filp, current->files);
	release_firmware(fw);
err_open:
	if (!filp)
		set_fs(old_fs);
not_support:
	kfree(fw_path);
out:
	sysfs_data->cmd_state = CMD_STATUS_FAIL;
	return;
}