Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1980804rwd; Thu, 15 Jun 2023 19:39:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7PwNofZz/zYkS140jHz8Ev2Li0c23aApVtp2kf/FznUwUTm6+t5iPUnbcdskqzVslcYxKz X-Received: by 2002:a05:6358:17:b0:12b:db1d:f606 with SMTP id 23-20020a056358001700b0012bdb1df606mr397656rww.12.1686883168424; Thu, 15 Jun 2023 19:39:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686883168; cv=none; d=google.com; s=arc-20160816; b=vSId1fMZ6kJvGwyEDgLYrwBL/nDgZsRbH9+GFnFBcrvVIaiRSpTot/ASTmJwHmPgjK TjtQw87S4GNvnBGcXLnCAX04mgScRcT9CaDt8WGbGUS1t0rfhy8gP05klReIsYI2VV3c H6AtOY8NeabdZa5fQSQqxMV2cYXklWaXmxN58oavHUq47ITiK4sq5PXxSEt25qjDnL6d QsFiuOgMJx/b57isdxEb2GiKWPKvtt9egApBs4/oYJb0yakF6Amuq6n2bHBe75EcEdyc 0V1IRcXwXns/anSyVRgEvGU0NncMy44iXf0drxNh/tmnb45zPfbpykyadj5FctWcPMmo 3v8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=tL/5ZzohXylVHs3rA5S/DKxBGwleCng15aPbEXAJpUI=; b=Uk3wLCH5dkRM9pCCCIPWuzd3jrbMkIaQZCM4uloW+819r5zoMWvUeqUnGVnrv8VLOB oQfD4ri13s6FhvBFpG8Cy+2pb+LHMWVQUBReBYk5YeeGDP2GrhbpsMiKScjN7Q+Lgh8z s+YGnh7Wj0RHBHeuea8LGofc7cxvXZiFNV7X1DdFizgwjLsaluY65n5UI1Ak8hV/hnpK EHcNYmx5AmWRDWAycdQG2g/QdsgIVW0Z+RcoibFKREGX1NoBTMHYJRwqGzf89jAVrJr8 bcX9dOvdZ/NZqI5o+n6zzr7NSRuhKsK10Xqcgk4f1Q4pp/OLIDu0ifz1ayq2v0MaTEng m/RQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=rock-chips.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m28-20020a638c1c000000b0054fe3b225bcsi3605899pgd.706.2023.06.15.19.39.14; Thu, 15 Jun 2023 19:39:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=rock-chips.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240557AbjFPCUR (ORCPT + 99 others); Thu, 15 Jun 2023 22:20:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240527AbjFPCUO (ORCPT ); Thu, 15 Jun 2023 22:20:14 -0400 Received: from mail-m11876.qiye.163.com (mail-m11876.qiye.163.com [115.236.118.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D137A296E; Thu, 15 Jun 2023 19:20:12 -0700 (PDT) Received: from localhost.localdomain (unknown [58.22.7.114]) by mail-m11876.qiye.163.com (Hmail) with ESMTPA id DC4B73C038F; Fri, 16 Jun 2023 10:20:02 +0800 (CST) From: Frank Wang To: linux@roeck-us.net, heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, sebastian.reichel@collabora.com, heiko@sntech.de Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, huangtao@rock-chips.com, william.wu@rock-chips.com, jianwei.zheng@rock-chips.com, yubing.zhang@rock-chips.com, wmc@rock-chips.com, Frank Wang Subject: usb: typec: tcpm: fix cc role at port reset Date: Fri, 16 Jun 2023 10:20:01 +0800 Message-Id: <20230616022001.25819-1-frank.wang@rock-chips.com> X-Mailer: git-send-email 2.17.1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFDSUNOT01LS0k3V1ktWUFJV1kPCRoVCBIfWUFZQxofTlYaHh8YTh4fHx5PQkNVEwETFh oSFyQUDg9ZV1kYEgtZQVlOQ1VJSVVMVUpKT1lXWRYaDxIVHRRZQVlPS0hVSk5MSUpJVUpLS1VKQl kG X-HM-Tid: 0a88c200a91b2eb2kusndc4b73c038f X-HM-MType: 1 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PE06HRw4DT1LDBAxFiotIUo* OhMKCTFVSlVKTUNNQ0NJS0tIQ0xDVTMWGhIXVR0JGhUQVQwaFRw7CRQYEFYYExILCFUYFBZFWVdZ EgtZQVlOQ1VJSVVMVUpKT1lXWQgBWUFJSUlCNwY+ X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_WEB,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the current implementation, the tcpm set CC1/CC2 role to open when it do port reset would cause the VBUS removed by the Type-C partner. This sets CC1/CC2 according to the default state of port to fix it. Comments are suggested by Guenter Roeck. Signed-off-by: Frank Wang --- drivers/usb/typec/tcpm/tcpm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 3c6b0c8e2d3ae..9f6aaa3e70ca8 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -4885,7 +4885,8 @@ static void run_state_machine(struct tcpm_port *port) break; case PORT_RESET: tcpm_reset_port(port); - tcpm_set_cc(port, TYPEC_CC_OPEN); + tcpm_set_cc(port, tcpm_default_state(port) == SNK_UNATTACHED ? + TYPEC_CC_RD : tcpm_rp_cc(port)); tcpm_set_state(port, PORT_RESET_WAIT_OFF, PD_T_ERROR_RECOVERY); break; -- 2.17.1