From: Peng Fan <[email protected]>

After reaching SNK_READY or SRC_READY, the poll loop exits immediately.
However, some PD sources send follow-up messages (e.g., Get_Sink_Cap,
Get_Status) shortly after the explicit contract is established. Since
the TCPCI hardware auto-sends GoodCRC for received messages, the
source expects a timely response. If no response arrives within
SenderResponseTimer (24-30ms), the source sends a Hard Reset,
causing VBUS to drop and resetting VBUS-powered boards.

Add a 500ms settling period after reaching Ready state to process
any follow-up messages from the source before entering low power
mode and disabling PD message reception.

Signed-off-by: Peng Fan <[email protected]>
---
 drivers/usb/tcpm/tcpm.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/tcpm/tcpm.c b/drivers/usb/tcpm/tcpm.c
index 25ff0926cdf..d6af0fae7c1 100644
--- a/drivers/usb/tcpm/tcpm.c
+++ b/drivers/usb/tcpm/tcpm.c
@@ -2252,6 +2252,16 @@ static void tcpm_poll_event(struct udevice *dev)
                tcpm_check_and_run_delayed_work(dev);
        }
 
+       if (port->state == SNK_READY || port->state == SRC_READY) {
+               int settle;
+
+               for (settle = 0; settle < 1000; settle++) {
+                       drvops->poll_event(dev);
+                       udelay(500);
+                       tcpm_check_and_run_delayed_work(dev);
+               }
+       }
+
        if (port->state != SNK_READY && port->state != SRC_READY)
                dev_warn(dev, "TCPM: exit in state %s\n",
                         tcpm_states[port->state]);

-- 
2.51.0

Reply via email to