Add 0x7900 as a fixup region for firmware backup bins
A binary diff of the output of cyapa_fw_update -c <iic>
and cyapa_fw_update -b shows that a region that corresponds
to firmware address 0x7900 to 0x797F is different in the
backed up binary. In the converted binary, it is always filled
with 0x08.
BUG=chromium-os:24494
TEST=cyapa_fw_update -b -o /lib/firmware/cyapa.bin
echo -n 1 > /sys/bus/i2c/devices/15-0067/update_fw
Ensure that the fw update succeeds. Check dmesg after
this command is finished, check to see that cyapa device
shows up as an input device.
Change-Id: I5c27bd80323d75cb461a16849c5799edb0f63007
Signed-off-by: Benson Leung <bleung@chromium.org>
diff --git a/cyapa_fw_update.c b/cyapa_fw_update.c
index aca9bcf..4d1c5b5 100644
--- a/cyapa_fw_update.c
+++ b/cyapa_fw_update.c
@@ -112,6 +112,11 @@
#define CYAPA_FW_TO_BIN(x) ((x) - CYAPA_FW_OFFSET_START)
#define CYAPA_BIN_TO_FW(x) ((x) + CYAPA_FW_OFFSET_START)
+#define CYAPA_IDAC_0_START 0x7900
+#define CYAPA_IDAC_0_END 0x797F
+#define CYAPA_IDAC_0_SIZE (CYAPA_IDAC_0_END - CYAPA_IDAC_0_START + 1)
+#define CYAPA_IDAC_0_DEF 0x08
+
#define CYAPA_IDAC_1_START 0x7A00
#define CYAPA_IDAC_1_END 0x7A7F
#define CYAPA_IDAC_1_SIZE (CYAPA_IDAC_1_END - CYAPA_IDAC_1_START + 1)
@@ -923,10 +928,14 @@
void cyapa_fixup_fw_buffer(unsigned char* buf)
{
/*
- * reset IDAC values blocks read from trackpad device,
- * because IDAC values are dynamic generated in running time,
- * and will be restored in flash, so we do not want this values.
+ * Set IDAC regions in the image to a default pattern.
+ * The values read from the device are dynamically generated at runtime
+ * during calibration, and should be ignored. Setting these regions
+ * to the pattern will ensure the resulting fw backup image has the
+ * correct checksum.
*/
+ memset(&buf[CYAPA_FW_TO_BIN(CYAPA_IDAC_0_START)], CYAPA_IDAC_0_DEF,
+ CYAPA_IDAC_0_SIZE);
memset(&buf[CYAPA_FW_TO_BIN(CYAPA_IDAC_1_START)], CYAPA_IDAC_1_DEF,
CYAPA_IDAC_1_SIZE);
memset(&buf[CYAPA_FW_TO_BIN(CYAPA_IDAC_2_START)], CYAPA_IDAC_2_DEF,