summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorMarek Maslanka <mmaslanka@google.com>2026-10-07 05:38:37 +0200
committerTzung-Bi Shih <tzungbi@kernel.org>2026-10-08 02:16:45 +0000
commit2d3ee0bdb321ad84d9cf18d4bfd2b839293a695d (patch)
tree8b57f303817ee9c4243d1e7091f35af5573f6264 /include/linux
parentca75b38b1a3c2eabe81d231dae4ea180cf6287cd (diff)
downloadlinux-next-2d3ee0bdb321ad84d9cf18d4bfd2b839293a695d.tar.gz
linux-next-2d3ee0bdb321ad84d9cf18d4bfd2b839293a695d.zip
platform/chrome: cros_ec_typec: Poll for role swap completion
Depending on the EC USB-C stack (TCPMv2 vs PDC), EC_CMD_USB_PD_CONTROL with a role swap request may either block until the swap completes or queue the request asynchronously for the EC PD task and return the current (pre-swap) role in the immediate response. On platforms where the EC handles the swap asynchronously, checking resp.role right after issuing the swap command sees the old role and fails with -EIO before the USB PD handshake completes. If the immediate response does not yet reflect the target role, poll EC_CMD_USB_PD_CONTROL with USB_PD_CTRL_SWAP_NONE until the target role is reached while connected, or until ROLE_SWAP_TIMEOUT_MS expires. The timeout mirrors PD_ROLE_SWAP_TIMEOUT used by the TCPM port manager, since a PR_Swap may legitimately take seconds when the partner answers with Wait and the initiator retries. While at it, report the failure modes the same way tcpm.c does, so that userspace can tell a rejected swap from a disconnect: -ETIMEDOUT when the partner never completes the swap, and -ENOTCONN when the port goes away while waiting. Decoding of the swapped role is factored out into cros_typec_resp_to_role() instead of being open coded for each swap type, which also keeps an unhandled swap type from being misread as a power role swap. Fixes: ab229c2b72c3 ("platform/chrome: cros_ec_typec: Add role swap ops") Signed-off-by: Marek Maslanka <mmaslanka@google.com> Link: https://lore.kernel.org/r/20261007033837.708119-1-mmaslanka@google.com Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Diffstat (limited to 'include/linux')
0 files changed, 0 insertions, 0 deletions