[PATCH] usb: typec: ucsi: Wait 20ms before retrying reset

From: Pavan Holla
Date: Mon Mar 25 2024 - 17:20:37 EST


The PPM might take time to process reset. Allow 20ms for the reset to
complete before issuing another reset.

Signed-off-by: Pavan Holla <pholla@xxxxxxxxxxxx>
---
There is a 20ms delay for a reset retry to complete. However, the first
reset attempt is expected to complete immediately after an async write
of the reset command. This patch adds 20ms between the async write and
the CCI read that expects the reset to be complete. The additional delay
also allows the PPM to settle after the first reset, which seems to be
the intention behind the original 20ms delay ( kernel v4.14 has a comment
regarding the same )
---
drivers/usb/typec/ucsi/ucsi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
index cf52cb34d285..6b642c4c58b7 100644
--- a/drivers/usb/typec/ucsi/ucsi.c
+++ b/drivers/usb/typec/ucsi/ucsi.c
@@ -1280,6 +1280,9 @@ static int ucsi_reset_ppm(struct ucsi *ucsi)
goto out;
}

+ /* Give the PPM time to reset and stabilize */
+ msleep(20);
+
ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci));
if (ret)
goto out;
@@ -1293,7 +1296,6 @@ static int ucsi_reset_ppm(struct ucsi *ucsi)
goto out;
}

- msleep(20);
} while (!(cci & UCSI_CCI_RESET_COMPLETE));

out:

---
base-commit: 4cece764965020c22cff7665b18a012006359095
change-id: 20240325-ucsi-reset-delay-bdf6712455fd

Best regards,
--
Pavan Holla <pholla@xxxxxxxxxxxx>