Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3693256pxb; Mon, 1 Feb 2021 02:04:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlAT8cSblHVtVY1664amA4bApqgBjYxoPZdnGmp37M1yiXQ9DwsduSKmT38kylShDDJA2I X-Received: by 2002:adf:f749:: with SMTP id z9mr16830016wrp.327.1612173882429; Mon, 01 Feb 2021 02:04:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612173882; cv=none; d=google.com; s=arc-20160816; b=kgfzOYXtLE3nYHlTkqLUin65OmZSbrFoVQrOypmMBwqb24GW4k1/lJqspH0AGvks5a JufRpjUgjt5Mgi9ZDFIwAkmgKvfd/JZgkT13R/JeYiR0Qp4IRW02rNnVskohlQUIRNgJ YsgKk5qlPUzYPRaa3CIyJXFS9tyld6q1v6Byk6eFd+Ksyv12iTFY+4YvdGc24WwrmK5W nY0jJY/dPRN3AWnpHyB93eSw86uv0pWUl82oFfnsv/+Ue51aliS/DmPaNa9JTfDGLLVo KRh3kvrdYjSsAqKLZYj+Spx5ro0bywsWRO+vIoDwp8fiWNCqQRIqEUlIBZycPVOVS2Ui Y/vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :sender:dkim-signature; bh=Og/c9ZLdNwsrZjaKOb5Rw1KYlib1KDQj+P2JjTzCuz0=; b=dLq3g2UpbQWyO3lReVN7D5BDpYRCx3HlmsMmSQEhhmF7TcJmFk3jtfJyYlSPzgALEY pzfqn6mncQ7giusO6ApXtaoS8tKR/pKSXTgK7W/FAKpW++pWveo9f/UPwbN11T5AuaYZ H+ThmuHJFE9/jfDbdehhjr/skU3AIwSaO8SCBDVwZz/ul4MIWEGpQznXx+id/V/U6Q2B HGdhvEiR7P889SWY8IKSO3JhEuPgEXS/5UrICBw+jkyCUeXgtz7mMjbE3beRsLP0pExH njxr1FbFrRXLqM5uHBUNsAYHN3esrTDK7L907udfMUPWQIIij24AL3EzoDj54r3rTb+v tPTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DmWfY39W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qq23si9187235ejb.140.2021.02.01.02.04.17; Mon, 01 Feb 2021 02:04:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DmWfY39W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232994AbhBAKDc (ORCPT + 99 others); Mon, 1 Feb 2021 05:03:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232893AbhBAKDb (ORCPT ); Mon, 1 Feb 2021 05:03:31 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD952C061786 for ; Mon, 1 Feb 2021 02:02:16 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id u14so8234121plf.4 for ; Mon, 01 Feb 2021 02:02:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=Og/c9ZLdNwsrZjaKOb5Rw1KYlib1KDQj+P2JjTzCuz0=; b=DmWfY39Wj7fxUx8ibl+Z+al1uxv6KEvvJsECeAKzMQwk0gXAQ/qhPSzhoOXv/sXLIK 8H9oT3lTTOlpfoEpIZOsNxCe2A2HMY4dpzwWeAnk5vF03qnv6cOG+gBUBYsCVanFmNxT HdQVFG8EmIEZSo4W4nrOkXpz/36FHTzoDZMMVxoNjuFl3rwmsQ8WwqADYRhD8mOTubIA g2NgHZdjmKLO/9O9QHMcQJNl6JjqrDo7tL1N8B0WD2c2csh4VkRlxUxP9EcNlQgcOpJS Mm8tkLY6ah6k7mBQoYFbRObRud4wqTyg6N/rhUokphC6LUccEjIAdV/R5Dke5GBgFueu iX+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=Og/c9ZLdNwsrZjaKOb5Rw1KYlib1KDQj+P2JjTzCuz0=; b=jKNXIUhAtCzGF9KwtgFZd4vi4vGOBJZoBBVAkFSvlXXbHjol2DqqQI9voaAAo0ZW0l zo8onlX3K027rnmYD7kBPWs8mtQv+QkHG3GuVSI558PCJgP5aCvZen3HhgN0yd5p30IZ md+8h5NYw4ooXzmwwvyo+r434OqUaPkNqWCiG8jqdIzzce6LZupRHSImUNB/EWqdEjpV Pi2Q20Ahj4tTHfA6G93cMSNO0vH0j9g+qv2fuHGQ6ofZ67wKmP21pj618iH4GgYTxLM3 fK3Z+iWVcyOf7j7frXeM+C1i4Gcbe/QN9vGGTwAoDTsyL60wX4iwJVaWqohWWQfjv6H2 +AmA== X-Gm-Message-State: AOAM5308o17bIznFh0J0k2XISBehI+/CrBu+bUKi07iqe6/Yigd8UIas eITqrNeaXgsQEZwAJWQfdkgVBHL04BY= Sender: "badhri via sendgmr" X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:f292:1cff:fee0:66cf]) (user=badhri job=sendgmr) by 2002:a17:902:429:b029:de:2bee:150d with SMTP id 38-20020a1709020429b02900de2bee150dmr11263515ple.18.1612173736228; Mon, 01 Feb 2021 02:02:16 -0800 (PST) Date: Mon, 1 Feb 2021 02:02:12 -0800 Message-Id: <20210201100212.49863-1-badhri@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog Subject: [PATCH v1] usb: typec: tcpm: Handle vbus shutoff when in source mode From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman , Kyle Tso Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Badhri Jagan Sridharan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org While in source mode, vbus could be shutoff by protections circuits. TCPM does not move back to toggling state to re-initiate connection. Fix this by moving to SRC_UNATTACHED state when vbus shuts off while in source mode. Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/typec/tcpm/tcpm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 0afd8ef692e8..ff0732c12b8a 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -4897,6 +4897,17 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port) /* Do nothing, waiting for sink detection */ break; + case SRC_STARTUP: + case SRC_SEND_CAPABILITIES: + case SRC_SEND_CAPABILITIES_TIMEOUT: + case SRC_NEGOTIATE_CAPABILITIES: + case SRC_TRANSITION_SUPPLY: + case SRC_READY: + case SRC_WAIT_NEW_CAPABILITIES: + /* Force to unattached state to re-initiate connection */ + tcpm_set_state(port, SRC_UNATTACHED, 0); + break; + case PORT_RESET: /* * State set back to default mode once the timer completes. -- 2.30.0.365.g02bc693789-goog