From patchwork Thu May 3 00:24:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 10376843 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2785D6038F for ; Thu, 3 May 2018 00:42:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1807E29137 for ; Thu, 3 May 2018 00:42:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0BF0629153; Thu, 3 May 2018 00:42:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AF4029137 for ; Thu, 3 May 2018 00:42:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751829AbeECAmV (ORCPT ); Wed, 2 May 2018 20:42:21 -0400 Received: from mail-eopbgr10079.outbound.protection.outlook.com ([40.107.1.79]:55664 "EHLO EUR02-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751755AbeECAmU (ORCPT ); Wed, 2 May 2018 20:42:20 -0400 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; bh=31N0wV7GSdS42Kdk2ADIo6J1Lfucpg4oEJUqJNSv7A4=; b=vrCmZ6zrPWYj0dqHAQhp7bl8WS1RnhAZ4quop4bpbdjxrl0FB6uXE8DjbcRPW8/7AbqUlQQNPwkFSAt0YhDeU9cv7Jw9L9vr53vGZML4dWkUzS2r1gnqK73WKslmlKkwUlSeEn9G9Arr9zqZhCDRRn5bOo2DJl9olWPR2cYRVj0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jun.li@nxp.com; Received: from b47624-OptiPlex-7040.ap.freescale.net (92.121.68.129) by DB3PR0402MB3914.eurprd04.prod.outlook.com (2603:10a6:8:f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.715.24; Thu, 3 May 2018 00:42:11 +0000 From: Li Jun To: robh+dt@kernel.org, gregkh@linuxfoundation.org, heikki.krogerus@linux.intel.com, linux@roeck-us.net Cc: jun.li@nxp.com, a.hajda@samsung.com, cw00.choi@samsung.com, shufan_lee@richtek.com, peter.chen@nxp.com, gsomlo@gmail.com, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH v5 11/14] usb: typec: tcpm: set cc for drp toggling attach Date: Thu, 3 May 2018 08:24:51 +0800 Message-Id: <1525307094-27402-12-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525307094-27402-1-git-send-email-jun.li@nxp.com> References: <1525307094-27402-1-git-send-email-jun.li@nxp.com> MIME-Version: 1.0 X-Originating-IP: [92.121.68.129] X-ClientProxiedBy: OSAPR01CA0012.jpnprd01.prod.outlook.com (2603:1096:603:2a::24) To DB3PR0402MB3914.eurprd04.prod.outlook.com (2603:10a6:8:f::29) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DB3PR0402MB3914; X-Microsoft-Exchange-Diagnostics: 1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5r/SvhJB+f18CDNZMg2TgNN2eerUsrk62XpZ+L/e0xDfzMpwOXpM5FOoDs4Nxsnry3aiz9+hdTefRtZqhD0WbEpRzE3V94mBC1RTJ2Ok8CRYkuyFUxYnG1eozxPEf8zGDHWGKT9Y59XYL+2kDkC0NulPB8KdXlDCKab/yi5544zLYd5skHxDsV3rFbvgx4TQZmr94nBYyfGi59qkSHB5Gs1ZTdqiF1MkHlhwntD3orBMByAIL3TBzC0ellALAi1Io8d3zU4dkm0sPZSbWgY2uW5vX5HA7Pe4Yde8QUicUUjdOH64+SV0xyuzW8y+zCZB9JGI19yRRTkTaWa06wVlO6x9LtYWop2N20SoERTq/; 4:v1EWn3HvXKm+6Vh46ZC1NU/TnfQIJEgyFZdcrc7ovPnOhzYrtrYSzt5HH91/g6IN3P6Z2B4BNgdL9cm06yeNaRqWFU++2SbF4zm84hIWES37Qw4JgIJsBWRue4fbhQFNpF/olxWWuAn1nUXijORpk420JGSdtWXnIR1uSCm7lB+8OX3UuPL1pfKsQdPwK2uvR3m08EMS3TzXNNGA3ASXM0h8hjbYV+ezUeeMifaNXR2wexG5SplTWYIzIToNxXeS0kNXqsgXf6I0I5HyPwozid+kcUrKRYluQ0I/kNB2mCBOSQDBGwz8kljtq7TgorOE X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(10201501046)(3231254)(944501410)(52105095)(6055026)(6041310)(20161123562045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011); SRVR:DB3PR0402MB3914; BCL:0; PCL:0; RULEID:; SRVR:DB3PR0402MB3914; X-Forefront-PRVS: 066153096A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39380400002)(376002)(39860400002)(346002)(366004)(189003)(199004)(7416002)(47776003)(7736002)(8936002)(66066001)(305945005)(106356001)(2906002)(5660300001)(6486002)(105586002)(6116002)(3846002)(6666003)(81166006)(8676002)(50226002)(68736007)(81156014)(36756003)(956004)(2616005)(386003)(16586007)(476003)(50466002)(6506007)(59450400001)(6512007)(97736004)(316002)(446003)(39060400002)(52116002)(26005)(76176011)(48376002)(4326008)(5890100001)(11346002)(486006)(16526019)(86362001)(51416003)(53936002)(186003)(478600001)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR0402MB3914; H:b47624-OptiPlex-7040.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB3PR0402MB3914; 23:4JFW2V3HNb0KugrTCtpDwyqa3cjPZ6v66PZrb9b?= =?us-ascii?Q?oJti8KMBRCdIiAT28DPcBqKLHFN9ymhGNbZGepDXkLxCLqwFUEUiT0hZcFRq?= =?us-ascii?Q?xHWr35ViO/DF1EagqwBuI6J9qoG6KTsuaFv3Ukp4cwQN9wry1L7VFe6NQGn8?= =?us-ascii?Q?u5cwA0hehcXYYGpV7x23bhCmnqxn4rF6UIq53b0VQaByRnlNQealUQAmb4RF?= =?us-ascii?Q?lv9FsduAbVIEhKpDb8h9f5L8P0birSwCS234T/UNoaelfgME+7w3VO1SDqsZ?= =?us-ascii?Q?TUqoVfL2FfZEKdotk1hJh0L7i3WTL+jd1P5sZ+FcDOHtuRrV3HTg71xeKtGG?= =?us-ascii?Q?PN0xn3yoeIotoNlwa1aJsPjLhYR9NOI9y9sHkBiKa/boPu8Z2LonWIjWtRH1?= =?us-ascii?Q?IInGzhBvoQqnNEqiobC3Hjs4ItE67isKsHquHYi4as0w170whwfk4YSRp8PR?= =?us-ascii?Q?vgxf1lOqs3/RE5WZrX76JlH0x0XwFqY8658P4uT7ZA+OCIg+vQu5ogoHM74+?= =?us-ascii?Q?q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P3CkpmSYXk91YAU9v+qrjFnXMJNUbaxCx+gGpV13Dif93hH6mes1XF8mAgnSkwMbfeNDY1tqEiwAm28TX3FPXv9oV2PpOFlU9uPbzun/Hb6Q08WpIzYbF0NnH9H X-MS-Office365-Filtering-Correlation-Id: 082850e4-a111-48d1-4cc9-08d5b08eb8a4 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2018 00:42:11.6631 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 082850e4-a111-48d1-4cc9-08d5b08eb8a4 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR0402MB3914 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case of drp toggling, we may need set correct cc value for role control after attach as it may never been set. Signed-off-by: Li Jun --- drivers/usb/typec/tcpm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index 0c7fa14..7e7eaca 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -2599,6 +2599,7 @@ static void tcpm_reset_port(struct tcpm_port *port) tcpm_set_attached_state(port, false); port->try_src_count = 0; port->try_snk_count = 0; + port->cc_req = TYPEC_CC_OPEN; port->supply_voltage = 0; port->current_limit = 0; port->usb_type = POWER_SUPPLY_USB_TYPE_C; @@ -2831,6 +2832,8 @@ static void run_state_machine(struct tcpm_port *port) break; case SRC_ATTACHED: + if (port->cc_req == TYPEC_CC_OPEN) + tcpm_set_cc(port, tcpm_rp_cc(port)); ret = tcpm_src_attach(port); tcpm_set_state(port, SRC_UNATTACHED, ret < 0 ? 0 : PD_T_PS_SOURCE_ON); @@ -3004,6 +3007,8 @@ static void run_state_machine(struct tcpm_port *port) tcpm_set_state(port, SNK_UNATTACHED, PD_T_PD_DEBOUNCE); break; case SNK_ATTACHED: + if (port->cc_req == TYPEC_CC_OPEN) + tcpm_set_cc(port, TYPEC_CC_RD); ret = tcpm_snk_attach(port); if (ret < 0) tcpm_set_state(port, SNK_UNATTACHED, 0);