[touch][focaltech] Reset the touch controller when starting
Follow the reset sequence specified in the datasheet. There are some
rare cases where the controller never responds to any I2C transfers;
putting it in a known state may fix that.
Bug: 80106
Test: fx test focaltech-test
Test: Touch works on Focaltech Astro
Change-Id: I15c47ba3ec4ffadd2f4639df26af875f2850f483
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/560371
Reviewed-by: Andres Oportus <andresoportus@google.com>
Commit-Queue: Braden Kell <bradenkell@google.com>
diff --git a/src/ui/input/drivers/focaltech/ft_device.cc b/src/ui/input/drivers/focaltech/ft_device.cc
index 81e6995..45dfbbb 100644
--- a/src/ui/input/drivers/focaltech/ft_device.cc
+++ b/src/ui/input/drivers/focaltech/ft_device.cc
@@ -124,6 +124,13 @@
return ZX_ERR_INTERNAL;
}
+ // Reset the chip -- should be low for at least 1ms, and the chip should take at most 200ms to
+ // initialize.
+ reset_gpio_.ConfigOut(0);
+ zx::nanosleep(zx::deadline_after(zx::msec(5)));
+ reset_gpio_.Write(1);
+ zx::nanosleep(zx::deadline_after(zx::msec(200)));
+
status = UpdateFirmwareIfNeeded(device_info);
if (status != ZX_OK) {
return status;
diff --git a/src/ui/input/drivers/focaltech/ft_device_test.cc b/src/ui/input/drivers/focaltech/ft_device_test.cc
index c2c0d2b..06466cd 100644
--- a/src/ui/input/drivers/focaltech/ft_device_test.cc
+++ b/src/ui/input/drivers/focaltech/ft_device_test.cc
@@ -106,6 +106,7 @@
interrupt_gpio_.ExpectConfigIn(ZX_OK, GPIO_NO_PULL)
.ExpectGetInterrupt(ZX_OK, ZX_INTERRUPT_MODE_EDGE_LOW, std::move(interrupt));
+ reset_gpio_.ExpectConfigOut(ZX_OK, 0).ExpectWrite(ZX_OK, 1);
}
protected: