usb: pd: Fix sink hard reset timing
The current hard reset handling (most recently fixed with commit 172cec3a ("usb: pd: Improve sink hard reset handling")) is based on a maximum timeout for the longest possible (according to spec) duration that VBUS may turn off and back on again, just under 2s, before re-starting the sink and waiting for capabilities again. However, this method is prone to timing errors, particularly tTypeCSinkWaitCap, which should be based on when VBUS turns on. Fix this by making use of the VBUS presence notification from the charger (PROP_PRESENT). Keep track of this in the psy_changed() callback and use the falling notification to determine when to transition out of PE_SNK_TRANSITION_TO_DEFAULT into PE_SNK_STARTUP. Bring back PE_SNK_DISCOVERY which is now used as a waiting state until the VBUS rising notification comes and transition to PE_SNK_WAIT_FOR_CAPABILITIES. And move setting of PROP_VOLTAGE_MAX to PE_SNK_STARTUP after VBUS has turned off to avoid tripping the charger's overvoltage detection. Also since aforementioned commit, the CC HW is now able to handle VBUS going away and not treating it as a false disconnect, so we can remove the workaround as a disconnect can now be treated as a disconnect. Change-Id: I885f3f4c219e102758fd09c8aae9257d093ebb72 Signed-off-by:Jack Pham <jackp@codeaurora.org>
Loading
Please register or sign in to comment