From patchwork Wed Dec 11 10:57:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13903351 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2078.outbound.protection.outlook.com [40.107.22.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63D351EE7A5 for ; Wed, 11 Dec 2024 10:57:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.78 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733914680; cv=fail; b=IJLJnz6iUNHpM/wuH7G9w/quhr7brI4qx8rA/6ezE0dUUIjKOSKOvp8lKFKhPM7oRk1LHGckZAEKN0zmHovkwn7yr/VAXi2Tib3LZQR/nlBDgcj/7RUSTLAiXP0sZ/c3+j7ePJ9913ftc3eQrhLmPRvefcrYXU7NX52mX6dTTB8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733914680; c=relaxed/simple; bh=iKg1SG+5DnLBbNCH/y8RvpyrNl1Y2+J93+RJjlb3Cvg=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=dNLnyRkNlZotubphG3x5GtfIxtA1Ggzi0QP4Xkze4SwqYv+VnsdsUVLVGxTm0e2ixh8zRJFWjhlo5bkacyCcO3qetJrgjv3VxXosAdu7VRe67CFqQTYEtU0aE/kz4yVuV0dLx6/acU2jPFLO26waK/ZopyMI7gXPHX1ERtuDJLg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Fpfknf3i; arc=fail smtp.client-ip=40.107.22.78 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Fpfknf3i" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=h7pUfttncoaN4DIZDQLyC8IEbu3vRVqAj2UbFb78B0vizvA7uq6wO6J86rR6wT0JwAvXouyZlKKxg6P8npZZHuuKb00B4UIkXYV91LbzTuPuJsrEHeO2a+eBVNpl7AlxKyFb43hozdD8wW4YZtQ2PQ6VxfCvXqt5mNHGEUyzxt8tnxthKP7A7LEj4z9uarslts1NOW0ptq4C+O28VToNM9Dwg8kv81ZDye4ZQqZNboSrbTtxVnDgg2D3FPI4uRmnxonDO5OhwNzMna4hPGc1fSpvqWsUa6ANcfbEuWekslVVwM9G5ZguDWMuurB9xd8aHTyjSqIMSqz/ASaFw21CeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uoyH22W8vWWbmV4eWWLEx1W1gprr01qg+yYf9eanoeo=; b=ozRiJ3BJU2FayhmN5ElWtzFqSWVhvm+9iztkBf6BnJrDSbDkFOPZTxN5Z4JuITsqL8BJ1e8fdASKM/IapSh9hTteURIwELEJCDWGji8JzTs1NsI+Xh0FD2RNZ1RfFUt0IEKlpShiOozu9yGm4lNE1W5ravmuqKt4s0eo5qJdLBOqnPju8aMc+wXT68Mb98J4kXadooUD4hbsMFGx7QSDzx4QABnpPltV8UMiJIIKcaX+v+XLStdne0DHVKJIhYjLYTAKh/qJfE31EQTMvCZmgGDNIuiBXouXjoXvMbkSdr0Bv2QVWYKVcRz2iB3iTJ0ewRjwv1PkXtwqAQcZSQrg5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uoyH22W8vWWbmV4eWWLEx1W1gprr01qg+yYf9eanoeo=; b=Fpfknf3ibpqoxVPBmQw7EcvNS0h3UoMXz+FJffzYFNS6OG0h7l5Szwf7KbGYMoBTY/U1A1TAs7KxpFjneeLyKYtG4HYcQzLMzNrZCkqOUM8jjZYxrhtoqdZ+JpYDEaJ5JCLn+9VFYmq3rxwMlMHUmkqscx8ou3X+7mhOP99DG+xFmEeOv3W21juUi7Qc5fMVF35mPaWIiF024lRS/S3bD5UwlMyn0JozJCtFI8qmbXAjAQN0FTfaHX1l70LB1X6ki9Dh9MU82CbM59EbsOd4OlsRUTpFqLTO368BZujH4vPb4ZMIwaeCKhh6aTrGXt/vrf++UlZHYHjcccHDGJObpw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) by GVXPR04MB10151.eurprd04.prod.outlook.com (2603:10a6:150:1b7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.15; Wed, 11 Dec 2024 10:57:52 +0000 Received: from DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::4e24:c2c7:bd58:c5c7]) by DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::4e24:c2c7:bd58:c5c7%6]) with mapi id 15.20.8230.016; Wed, 11 Dec 2024 10:57:51 +0000 From: Xu Yang To: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, andre.draszik@linaro.org, m.felsch@pengutronix.de, rdbabiera@google.com, emanuele.ghidoli@toradex.com Cc: linux-usb@vger.kernel.org, imx@lists.linux.dev, jun.li@nxp.com Subject: [PATCH] usb: typec: tcpci: set local CC to Rd only when cc1/cc2 status is Rp Date: Wed, 11 Dec 2024 18:57:53 +0800 Message-Id: <20241211105753.1205312-1-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: JH0PR01CA0070.apcprd01.prod.exchangelabs.com (2603:1096:990:57::14) To DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8822:EE_|GVXPR04MB10151:EE_ X-MS-Office365-Filtering-Correlation-Id: 2b91455c-bb47-483f-e803-08dd19d2a854 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|366016|376014|38350700014; X-Microsoft-Antispam-Message-Info: 8IwlXS+1aL6gTyK/mViwuFnExUWGm34wund942aqIIBainCR44zt+Gt257YZolK/CwAN9yczwwpjDgtT9p6kJOTagu4EL0stmOLDlNgFQCGiugB71aekdVkJMU4OeSvFzqcYP4LYyQL6fqEZzpokZBLq8pBeYM0IhMvaWLMqy0kIrqi/ZuRZKjSQW0Hi6PGEFkT/MNoeZwWoRlvdxIsz39HJeuvpYWrXGKrgrR11j+CPkbLBQpS6CV7MQZAbC1i5N/zJgavxd2olpG6nYSoMPw+NpUwNi1M7y/FV6/Bj0Kj/0NDVb/0u7drtO8xb/oqdWruaab3whDS3brjZsqf+RoogwZDMzMsNq7QKMJlkMNyQ/AZevqWrUGezTEv9rqfAoNvjgemeRYWzuJeHNAErGHIz4iXg641ss4VbHzsXTwt7Xkj+UI56jC5T5dGj5xswPkcxv/o1bt182JLbMg93A4vA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13230040)(1800799024)(52116014)(366016)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YjBEojvVkQZqufRBnQIq8tt9mVC/yqZsGwUGZpZregEZ1EQ1N4TJIIO3sQBg4+Eh2ZkeTfX99Zdc9grJ9ZopDZFBDOz6cclpWQHLCMikXfDEm1AZ1dgaYjhUOvubWVFiKRiNt51h0bUqMkDu23zwI8xoZpk6XQbhPxOoK2B2fq7NmCY5vSNDB8oAKBJI+K7USdyafuA3MOjqQseFcJ32vFbOsY0gdhYbW+NrjsjSrx4mGSXDtZ3z9T4+8xIT7LfZaJDwWLTo3qapDJHO2cy8ywtYGSFq6qIFTKW4ccjrIwsTgE5QpgqIRGVi+5OAaUwdStkabnvnlxNho5rYAJW1WxQ7P6XcRSBF3yaEieAmkoMl28nZqwKowASr7bX4ESDZT9Yp53ttvC61BHCH3E+DfCOkCJsVJnLNw0C1EvZLYOitnoc3972+owbgpYvni4zwBG66OV2937jrUZ/4dqSIfwIlDDUqidcho1qMLDtL7DkwgXMjvO7aualYnNZZjhcczW5cDAC6bOscRSlkcOyz4ipu+1O0tvWfbv0mMBmBz+pTfssuqTXpwCdfIMrC+GS5VHwCpE8tYwqxtQT2tJYQ8s2fI4b8is5rod8/qZW19NTBhWUX/QmEcn7H9RjDQXA1VLlBbLp6eFw7eb/xXYTZkGEDIVEI2e7cNXkxr42pmljNR6iBUnNNRnTP+6bt6MpHWuNHyegN4Oj/P+Sq26slX+4ruOEsZiVsdSzUXiYZm3pPyyA73M7D+MflHKcpd7+n/Hx9XQAAbs2hg7rXlkUpV1MzGTqNSblwNYjcA2JTAzgJgL7hI5DCPKLUPXW5Ec45AHONsqD/fIYOeNvOaAJYVzDUHw/J4rZ9Vl2l1YP3vixnkYgpKE0zUKC3lzy140P2UcQv8AElC7+Qkf7W/2dTC/ct7btINeak9SV7Ub9dWPkdw9xlSqyXVY1K7c4adXq9JM6IQ9Yr44ohPZ5dqVdGHSehIPVhgs+MlYbEcEeVBU9lhVNQtFyOH2FYrCFZz5Xm2ixfq2j+KFFD3JCBZ8vVygt/+HVf8L4nCR2oqMXaD5fFSJN5lh9ONEuvvdMN9Z/0WDXUFyZerIWUszN4X+oW4d4RYIWIXeDlGuDq9uSsi7gbERYMxc+OtMJAJrAsUCpGdrlMA7nNrP2D/MBkPGX68RoiuJ1H0IlyC4K4IWHuusRhgyMpnHmUiO28uHfDEnOwCLJYpJpSphluzOL1HSw1GkNskqjQoecJV4zPNYw6hII++CbMCKc5U7HtaWrVZurdEdgHlCY+2KMp8YJpF9VvPY/KuAEkoJFEE76Iega0/Uxvah3pb7eWM3owt3nYpzk2RJLzpVJ7fJOvKFLrT1Gl02gC1yRHLomzHO1CVn2oNnIwhUlo+oqj/QxxCy5T5dINSw0VDMnYcYHl34c6o1SAimMldPXmlWo+RjwvtKyg+6OTD1U2ijYwgkIpsEBBi1wL3yfCMBpbbFswuvRF9Fp3t4UsjV3bSfl+4rDyG16yDz3hxB/tTDpGWKmd5jRMGrDIsH2GcxMfkLJngiBSmBxja4wIW5SphuckHrYTQAQJ3tCtAG3OSy5GRtei8uZxDOPJ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2b91455c-bb47-483f-e803-08dd19d2a854 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8822.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 10:57:51.8746 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NEkZzePWcHKCzD7i3tu7QOEFFoUqLCmh/x5zjNINNoFcwHLrZVI/lQAO9G2psHC2Vgbnf9emn2i5EGrudH1bXw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB10151 The cc1 and cc2 status returned by tcpci_get_cc() may be TYPEC_CC_OPEN or TYPEC_CC_RA. So don't assume it's just TYPEC_CC_RD or TYPEC_CC_RP_*. This will let local port present Rd on CC only when cc1/cc2 status is TYPEC_CC_RP_*. Signed-off-by: Xu Yang --- drivers/usb/typec/tcpm/tcpci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c index ed32583829be..2f15734a5043 100644 --- a/drivers/usb/typec/tcpm/tcpci.c +++ b/drivers/usb/typec/tcpm/tcpci.c @@ -282,7 +282,7 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc, if (cc2 == TYPEC_CC_RD) /* Role control would have the Rp setting when DRP was enabled */ reg |= FIELD_PREP(TCPC_ROLE_CTRL_CC2, TCPC_ROLE_CTRL_CC_RP); - else + else if (cc2 >= TYPEC_CC_RP_DEF) reg |= FIELD_PREP(TCPC_ROLE_CTRL_CC2, TCPC_ROLE_CTRL_CC_RD); } else { reg &= ~TCPC_ROLE_CTRL_CC1; @@ -290,7 +290,7 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc, if (cc1 == TYPEC_CC_RD) /* Role control would have the Rp setting when DRP was enabled */ reg |= FIELD_PREP(TCPC_ROLE_CTRL_CC1, TCPC_ROLE_CTRL_CC_RP); - else + else if (cc1 >= TYPEC_CC_RP_DEF) reg |= FIELD_PREP(TCPC_ROLE_CTRL_CC1, TCPC_ROLE_CTRL_CC_RD); } }