Paradetech: fix product id to avoid touch firmware lost

Early-shipped TC3406 panels might report an unexpected report ID
when the firmware is wiped. This CL adds a workaround to force
the PID to the expected one, allowing the firmware to be recovered.

BUG=b:458507155
TEST=1. Deploy touch updater to obiwan device \
     2. Erase touch firmware \
     3. ssh ${DUT} reboot \
     4. Review logs to validate firmware updater

Change-Id: I7b6a9dd56d42476217154f0727bb17381d765bdb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/touch_updater/+/7130362
Tested-by: Daniel Duan <daniel.duan@paradetech.corp-partner.google.com>
Reviewed-by: Henry Barnor <hbarnor@chromium.org>
Commit-Queue: Daniel Duan <daniel.duan@paradetech.corp-partner.google.com>
Reviewed-by: Kenneth Albanowski <kenalba@google.com>
diff --git a/scripts/chromeos-paradetech-touch-firmware-update-legacy.sh b/scripts/chromeos-paradetech-touch-firmware-update-legacy.sh
index a186673..926215a 100644
--- a/scripts/chromeos-paradetech-touch-firmware-update-legacy.sh
+++ b/scripts/chromeos-paradetech-touch-firmware-update-legacy.sh
@@ -20,6 +20,7 @@
 FLAGS "$@" || exit 1
 eval set -- "${FLAGS_ARGV}"
 
+PARADETECH_VENDOR_ID="1DA0"
 PARADE_FW_UPDATE_USER="fwupdate-hidraw"
 PARADE_FW_UPDATE_GROUP="fwupdate-hidraw"
 PARADE_FIRMWARE_NAME="paradetech.bin"
@@ -113,6 +114,7 @@
 main() {
   local preferred_search_path="${FLAGS_i2c_path}"
   local touch_device_name="${FLAGS_device_name}"
+  local i2c_dev_name=""
   local hidraw_path=""
   local active_pid=""
   local target_pid=""
@@ -146,6 +148,21 @@
 
   active_pid="${touch_device_name##*_}"
 
+  # For the legacy module (PID 3001), it may report a default PID (3406)
+  # when the touch firmware is wiped. It was initially assumed that the
+  # bootloader would only respond with basic ACKs, which led to the adoption
+  # of a default PID (3406). While the issue has been resolved, earlier
+  # shipped products retain the default setting. Additionally, touch device
+  # will recover its finger report function after system reboot again.
+  if [ "${active_pid}" = "3406" ]; then
+    log_msg "Correct PID from 3406 to 3001"
+    log_msg "You may need to reboot the computer to reload touch driver."
+    active_pid="3001"
+    i2c_dev_name="$(cat "${FLAGS_i2c_path}/name")"
+    report_updater_run "${FLAGS_i2c_path}" "Paradetech" \
+      "${i2c_dev_name}" "${PARADETECH_VENDOR_ID}" "${active_pid}"
+  fi
+
   # Make sure the product ID is what the updater expects.
   log_msg "Active product ID: ${active_pid}"