• Badhri Jagan Sridharan's avatar
    usb: typec: tcpm: Add support for Sink Fast Role SWAP(FRS) · 8dc4bd07
    Badhri Jagan Sridharan authored
    PD 3.0 spec defines a new mechanism for power role swap called
    Fast role swap. This change enables TCPM to support FRS when
    acting as sink.
    
    Once the explicit contract is negotiated, sink port is
    expected to query the source port for sink caps to
    determine whether the source is FRS capable.
    Bits 23 & 24 of fixed pdo of the sink caps from the source, when
    set, indicates the current needed by the source when fast role
    swap is in progress(Implicit contract phasae). 0 indicates that
    the source does not support Fast Role Swap.
    
    Upon receiving the FRS signal from the source,
    TCPC(TCPM_FRS_EVENT) informs TCPM to start the Fast role swap sequence.
    
    1. TCPM sends FRS PD message: FR_SWAP_SEND
    2. If response is not received within the expiry of
       SenderResponseTimer, Error recovery is triggered.:
       FR_SWAP_SEND_TIMEOUT
    3. Upon receipt of the accept message, TCPM waits for
       PSSourceOffTimer for PS_READY message from the partner:
       FR_SWAP_SNK_SRC_NEW_SINK_READY.
    
    TCPC is expected to autonomously turn on vbus once the FRS
    signal is received and vbus voltage falls below vsafe5v within
    tSrcFrSwap. This is different from traditional power role swap
    where the vbus sourcing is turned on by TCPM.
    
    4. By this time, TCPC most likely would have started to
       source vbus, TCPM waits for tSrcFrSwap to see  if the
       lower level TCPC driver signals TCPM_SOURCING_VBUS event:
       FR_SWAP_SNK_SRC_SOURCE_VBUS_APPLIED.
    5. When TCPC signals sourcing vbus, TCPM sends PS_READY msg and
       changes the CC pin from Rd to Rp. This is the end of fast
       role swap sequence and TCPM initiates the sequnce to negotiate
       explicit contract by transitioning into SRC_STARTUP after
       SwapSrcStart.
    
    The code is written based on the sequence described in "Figure 8-107:
    Dual-role Port in Sink to Source Fast Role Swap State Diagram" of
    USB Power Delivery Specification Revision 3.0, Version 1.2.
    Signed-off-by: default avatarBadhri Jagan Sridharan <badhri@google.com>
    Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
    Link: https://lore.kernel.org/r/20201008061556.1402293-7-badhri@google.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    8dc4bd07
tcpm.h 4.3 KB