Merge "libese-hw: tweak pn80t reset" am: 0d9ac3ef58
am: 582d23462e
Change-Id: I4da5d33468aad76b2925be1d21cd4c37b94d4f83
diff --git a/libese-hw/nxp/pn80t/common.c b/libese-hw/nxp/pn80t/common.c
index b2b4abd..823c92b 100644
--- a/libese-hw/nxp/pn80t/common.c
+++ b/libese-hw/nxp/pn80t/common.c
@@ -97,10 +97,16 @@
const struct Pn80tPlatform *platform = ese->ops->opts;
struct NxpState *ns = NXP_PN80T_STATE(ese);
- /* Attempt a soft reset, but if it fails, then do a hard reset. */
+ /* If there is no error, perform a soft reset.
+ * If there is no cooldown time associated, go ahead and do a real
+ * reset as there is no other interface to trigger a hard reset.
+ *
+ * This avoids pulling the power when a cooldown is in progress
+ * if it is at all possible to avoid.
+ */
if (!ese_error(ese)) {
const uint32_t cooldownSec = nxp_pn80t_send_cooldown(ese, false);
- if (!ese_error(ese)) {
+ if (!ese_error(ese) && cooldownSec > 0) {
return 0;
}
}
@@ -113,6 +119,9 @@
ese_set_error(ese, kNxpPn80tErrorResetToggle);
return -1;
}
+
+ /* Start fresh with the reset. */
+ ese->error.is_err = false;
return 0;
}
@@ -255,6 +264,8 @@
switch (buf[1]) {
case kResetCommand:
ALOGI("interface command received: reset");
+ /* Force a hard reset by setting an error on the hw. */
+ ese_set_error(ese, 0);
if (nxp_pn80t_reset(ese) < 0) {
/* Warning, state unchanged error. */
ok[0] = 0x62;