Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75126058 authored by jabashque's avatar jabashque Committed by MajorP93
Browse files

power: oplus_vooc: Skip fw header/footer for vooc_fw_update_newmethod

The vooc charging firmware files that ships in OnePlus sm8250 devices
has an 80 byte header and a 128 byte footer, and when we load the
firwmare, the header and footer is present in the payload to be written.
However, the fw_update functions for the various ICs assume that the
header and footer is already removed from the payload, and on the
OnePlus 8 and OnePlus 8 Pro (which uses an STM8S MCU), trying to write
this payload without removing the header and footer leads to some funny
writes that causes the bus driver to always report a -107 error on any
subsequent writes.

Fix this by lying about the payload size and doing some pointer
arithmetic so that the fw_update functions would end up writing a
payload that excludes the header and footer.

Change-Id: I00fbc2c34df13f34f0a6bd59ef313f99d0edc3fc
parent 7818142c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -1803,8 +1803,8 @@ void fw_update_thread(struct work_struct *work)
		} while((ret < 0) && (--retry > 0));
		chg_debug(" retry times %d, chip->fw_path[%s]\n", 5 - retry, chip->fw_path);
		if(!ret) {
			chip->firmware_data =  fw->data;
			chip->fw_data_count =  fw->size;
			chip->firmware_data =  fw->data + 80 /* header */;
			chip->fw_data_count =  fw->size - 80 /* header */ - 128 /* footer */;
			chip->fw_data_version = chip->firmware_data[chip->fw_data_count - 4];
			chg_debug("count:0x%x, version:0x%x\n",
				chip->fw_data_count,chip->fw_data_version);
@@ -1864,8 +1864,8 @@ void fw_update_thread_fix(struct work_struct *work)
		} while ((ret < 0) && (--retry > 0));
		chg_debug(" retry times %d, chip->fw_path[%s]\n", 5 - retry, chip->fw_path);
		if(!ret) {
			chip->firmware_data =  fw->data;
			chip->fw_data_count =  fw->size;
			chip->firmware_data =  fw->data + 80 /* header */;
			chip->fw_data_count =  fw->size - 80 /* header */ - 128 /* footer */;
			chip->fw_data_version = chip->firmware_data[chip->fw_data_count - 4];
			chg_debug("count:0x%x, version:0x%x\n",
				chip->fw_data_count, chip->fw_data_version);