]> www.infradead.org Git - users/willy/xarray.git/commitdiff
usb: typec: ucsi: Wait 20ms before reading CCI after a reset
authorPavan Holla <pholla@chromium.org>
Tue, 9 Apr 2024 01:58:57 +0000 (01:58 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 9 Apr 2024 15:38:29 +0000 (17:38 +0200)
The PPM might take time to process a reset. Allow 20ms for the reset to
be processed before reading the CCI.

This should not slow down existing implementations because they would
not set any bits in the CCI after a reset, and would take a 20ms delay
to read the CCI anyway. This change makes the delay explicit, and
reduces a CCI read. Based on the spec, the PPM has 10ms to set busy, so,
20ms seems like a reasonable delay before we read the CCI.

Signed-off-by: Pavan Holla <pholla@chromium.org>
Reviewed-by: Prashant Malani <pmalani@chromium.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20240409-ucsi-reset-delay-v3-1-8440710b012b@chromium.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/typec/ucsi/ucsi.c

index 0e37404d309a2a94247f570b75ccce90bdea46c8..36e1b191f87dce848b97e708a525d875de2f7151 100644 (file)
@@ -1337,6 +1337,9 @@ static int ucsi_reset_ppm(struct ucsi *ucsi)
                        goto out;
                }
 
+               /* Give the PPM time to process a reset before reading CCI */
+               msleep(20);
+
                ret = ucsi->ops->read(ucsi, UCSI_CCI, &cci, sizeof(cci));
                if (ret)
                        goto out;
@@ -1350,7 +1353,6 @@ static int ucsi_reset_ppm(struct ucsi *ucsi)
                                goto out;
                }
 
-               msleep(20);
        } while (!(cci & UCSI_CCI_RESET_COMPLETE));
 
 out: