bool fw_update_internal(struct i2c_client *ts_client)
{
	not_reset = 1;
	client = ts_client;
	SynaFirmwareData = SynaFirmware;

	FirmwareImage = kzalloc(16000, GFP_KERNEL);
	if (FirmwareImage == NULL) {
		pr_err("tsp fw. : alloc fw. memory failed.\n");
		return false;
	}
	ConfigImage = kzalloc(16000, GFP_KERNEL);
	if (ConfigImage == NULL) {
		pr_err("tsp fw. : alloc fw. memory failed.\n");
		return false;
	}

	SynaInitialize();
	SynaReadConfigInfo();
	SynaReadFirmwareInfo();
	SynaF34_FlashControl = SynaF34DataBase + SynaFirmwareBlockSize + 2;
	SynaEnableFlashing();
	SynaProgramFirmware();
	SynaProgramConfiguration();
	SynaFinalizeReflash();

	kfree(FirmwareImage);
	kfree(ConfigImage);

	not_reset = 0;
	return true;
}
コード例 #2
0
bool synaptics_fw_update(struct i2c_client *ts_client, const u8 *fw_data,
							const int gpio)
{
	client = ts_client;
	SynaFirmwareData = fw_data;
	gpio_irq = gpio;

	FirmwareImage = kzalloc(16000, GFP_KERNEL);
	if (FirmwareImage == NULL) {
		pr_err("tsp fw. : alloc fw. memory failed.\n");
		return false;
	}
	ConfigImage = kzalloc(16000, GFP_KERNEL);
	if (ConfigImage == NULL) {
		pr_err("tsp fw. : alloc fw. memory failed.\n");
		return false;
	}

	SynaInitialize();
	SynaReadConfigInfo();
	SynaReadFirmwareInfo();
	SynaF34_FlashControl = SynaF34DataBase + SynaFirmwareBlockSize + 2;
	SynaEnableFlashing();
	SynaProgramFirmware();
	SynaProgramConfiguration();
	SynaFinalizeReflash();

	kfree(FirmwareImage);
	kfree(ConfigImage);

	pr_info("tsp fw. : fw. update completed.");

	return true;
}
bool fw_update_file(struct i2c_client *ts_client)
{
	int ret = 0;
	long fw_size = 0;
	unsigned char *fw_data;
	struct file *filp;
	loff_t pos;
	mm_segment_t oldfs;

	client = ts_client;

	oldfs = get_fs();
	set_fs(KERNEL_DS);

	filp = filp_open("/sdcard/synaptics_fw.img", O_RDONLY, 0);
	if (IS_ERR(filp)) {
		pr_err("tsp fw. : file open error:%d\n", (s32)filp);
		return false;
	}

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

	fw_data = kzalloc(fw_size, GFP_KERNEL);

	pos = 0;
	ret = vfs_read(filp, (char __user *)fw_data, fw_size, &pos);
	if (ret != fw_size) {
		pr_err("tsp fw. : failed to read file (ret = %d)\n", ret);
		kfree(fw_data);
		filp_close(filp, current->files);
		return false;
	}

	filp_close(filp, current->files);

	set_fs(oldfs);

	FirmwareImage = kzalloc(16000, GFP_KERNEL);
	if (FirmwareImage == NULL) {
		pr_err("tsp fw. : alloc fw. memory failed.\n");
		return false;
	}
	ConfigImage = kzalloc(16000, GFP_KERNEL);
	if (ConfigImage == NULL) {
		pr_err("tsp fw. : alloc fw. memory failed.\n");
		return false;
	}

	SynaFirmwareData = fw_data;
	SynaInitialize();
	SynaReadConfigInfo();
	SynaReadFirmwareInfo();
	SynaF34_FlashControl = SynaF34DataBase + SynaFirmwareBlockSize + 2;
	SynaEnableFlashing();
	SynaProgramFirmware();
	SynaProgramConfiguration();
	SynaFinalizeReflash();

	kfree(FirmwareImage);
	kfree(ConfigImage);
	kfree(fw_data);

	return true;
}