From patchwork Mon May 28 02:52:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 10429725 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 7D626601C7 for ; Mon, 28 May 2018 03:10:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EAD428AF4 for ; Mon, 28 May 2018 03:10:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6376C28AF7; Mon, 28 May 2018 03:10:26 +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 AD05728AF4 for ; Mon, 28 May 2018 03:10:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753169AbeE1DKY (ORCPT ); Sun, 27 May 2018 23:10:24 -0400 Received: from mail-eopbgr00069.outbound.protection.outlook.com ([40.107.0.69]:47392 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753149AbeE1DKW (ORCPT ); Sun, 27 May 2018 23:10:22 -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:X-MS-Exchange-SenderADCheck; bh=uqH7hMYIGdcg5Q0ueFmA03qFJbqCd7q2zc8R1AZqftQ=; b=Z8Sv221gG+HL/I354voqnJwzXuIpv93szQRmaXBdddnx6I8CVttc4kjlO6856WwitG4XMN6OeN07HYKpf2+rBrqGs7o1FGhRwt9CPzNlp1BdP+hLQO2ohDuBN+Wbcfj3T/kbNUR8mUGVVlfgG6blLisZZyPKDEtdkbULI4HqKgA= Received: from b47624-OptiPlex-7040.ap.freescale.net (92.121.68.129) by VI1PR0402MB3919.eurprd04.prod.outlook.com (2603:10a6:803:22::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.797.11; Mon, 28 May 2018 03:10:15 +0000 From: Li Jun To: robh+dt@kernel.org, gregkh@linuxfoundation.org, heikki.krogerus@linux.intel.com, linux@roeck-us.net Cc: cw00.choi@samsung.com, a.hajda@samsung.com, shufan_lee@richtek.com, peter.chen@nxp.com, garsilva@embeddedor.com, gsomlo@gmail.com, jun.li@nxp.com, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH v6 12/15] usb: typec: tcpm: set cc for drp toggling attach Date: Mon, 28 May 2018 10:52:44 +0800 Message-Id: <1527475967-15201-13-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1527475967-15201-1-git-send-email-jun.li@nxp.com> References: <1527475967-15201-1-git-send-email-jun.li@nxp.com> MIME-Version: 1.0 X-Originating-IP: [92.121.68.129] X-ClientProxiedBy: HK2PR0302CA0015.apcprd03.prod.outlook.com (2603:1096:202::25) To VI1PR0402MB3919.eurprd04.prod.outlook.com (2603:10a6:803:22::32) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(5600026)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:VI1PR0402MB3919; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0402MB3919; 3:fNGidUd4gSVNX9rd7nMlRwkSlNux5uSOeOdVfnLLHnjEk1JyGzRfnFqCU6bAqLoXMzM11BeA9Vn8VrC1P8AUvmYJNfWaYlujMStNNH39VW3Ul/XT9k5DnbLeo9IUe2HtbicqwmR6N84Nh5yCvul3SBHsC73yPqlgjZu0RheZKpjkD4IbrHNJJJbVZA69o9AtJOYbEMGFSem9JIoelSVokQ62t2wO9TchVZv9ZBW5O4KJWmkVRwnWxUA1tr6bwxiQ; 25:8fy4XRRHfqwJrKluVfwl8pcnYWnFwL7uFuCifNhaO5qZ2lFM3WVLLQgAuaWlb2Nd5FU0dl5zzRJ98ZNMjHbBt34oFiNJQPZ4dO8D4Hyi/75YDK+d9wrHQCvjhS3oGpcizYeOCoz3wLpQjiEOOcnqty7RpCydhYX3KJiDFBo2E0VLjCVCFvyVrHke/BGGiBmBcTcori0+JCGiTsDMghdl2ZFJDGztSAvzQl9Z+Fr51yAsZgCGXRRsUnOEGLojC4hHTnN73PRro5CjHinUJaedpM445iEbyCWjDgx1jpn2WBR8MEgsX1vTcYFL5TQdkBN53+GP2SmaF8NbX7SjI8HQvA==; 31:tYsnj3hzcEI+rRF6g4D/KShTJ04FA1F6FHSY5TdoKVSVSvMBaAgJ0fWhc8m0+L/x+/yRgvG2ZV6csLpA4qpDr4bUTagKVchi87R3iE8B3lS3aG3uqhp0/CLhHAzfYvleWkx9h0GewfWP0+jKdUqCE+NCjxrUvKVqJsu3VqrQG6SKOI/j9MbcDKKgfWSWh2vWQmbpz1um7/ITHV0lzAYxu2ghVD1l2Z9xwDEHBj6Wzj8= X-MS-TrafficTypeDiagnostic: VI1PR0402MB3919: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jun.li@nxp.com; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0402MB3919; 20:JvahsePKKjfjuDznPpFc2/pIhtSxJ1bO6X0HjF5U2p0t4ku7Yn6MaKYVWbq0LhXQZh5YgNev02/vX7bne+O5rB5FsV5xGAqgQr0erwhusKek5G1FvynI8yh2GjTLWwd3WOVwbO7OU3KyD2trMAp6GveGZuuNjGpa6ElrdICbWHNFwbeaRnnaiHxlPpfuI5lRU/0vfxGPzR17O3597Vhqutrz/RUZ5yK888AR4Q9KGu1enmnEHFr46oIHsFtn9u1oX6mnahuIk2Cync1TEdMmjLHkNYxE3RIX5oWY6oaXP8W0Lm4SKOo0Wuq2pzth32HCnfz0TpbvbLBn5v5zDrAjNjE/j2HJ4cKoYKIjhkB17bQKHHFLGCf5CXLlZnDMzW+xibXKqyMKp8QpKT3XcIa2mwR3sJ40HD2fKlug/ovUbkMy74C3C1VkXqxORW+MKoXldEZzGkV75MGmjD4UY6Gsj6P3NB8n48pdX+3gRysJjXaOMK42Hp/15PimXr6KLdnr; 4:H0pdi3yKEQ9EOQMmWuiIJv7n6B9UdHpmQd3UlFzlaGUjtfJOijNsmByjuWjTAXVfuR1brOgVav7sdht/9UUqNlgRvKJAB4NMdVwMeS9YgFiHwImYX1AAnI7Yw74g4t5kCglNUqIllu00hn6fanQ5G5r+N+ZilwKL4dXuuD9A/N4J/YZP1+/prJmIxdv89taw7HfnnKkrrcZcu/7JIowmtvrms+nXVIksm1dZrAjJTN0rh5BdQ9EYIJS/2qJ0VjupXXa5YiOL89VQwKAYNIuUc3Xj819wGHDbpVtI3pYwKr/5eOKNxrJZ3NPsIglWHxW6 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231254)(944501410)(52105095)(10201501046)(93006095)(93001095)(3002001)(6055026)(149027)(150027)(6041310)(20161123560045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(6072148)(201708071742011)(7699016); SRVR:VI1PR0402MB3919; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0402MB3919; X-Forefront-PRVS: 06860EDC7B X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(1496009)(39380400002)(396003)(39860400002)(366004)(346002)(376002)(199004)(189003)(6506007)(8676002)(16526019)(305945005)(26005)(7736002)(386003)(486006)(446003)(48376002)(11346002)(956004)(2616005)(2906002)(66066001)(81156014)(186003)(3846002)(81166006)(478600001)(8936002)(50466002)(6486002)(5660300001)(6116002)(6666003)(7416002)(36756003)(50226002)(47776003)(39060400002)(476003)(86362001)(106356001)(68736007)(5890100001)(53936002)(51416003)(105586002)(59450400001)(16586007)(316002)(4326008)(6512007)(76176011)(97736004)(25786009)(52116002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB3919; H:b47624-OptiPlex-7040.ap.freescale.net; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0402MB3919; 23:0jrqRCgcwNkDkiahzD3z/gWguzTstkuTtq7+xLE?= =?us-ascii?Q?uaggJl8sQ55BZzDvDWjmOzK3lGvUpR8OBSR5TgjH/hL/IHYCoGtWBapF6v56?= =?us-ascii?Q?U/ddXhcDurCFXN8fXUwXRO3HMWSqsqChi2g/COGEjRCtPfd6digqII5cSMQQ?= =?us-ascii?Q?nr30MHGTsMXdYVYL9Mof7WjK1gpmB7EOTr7+g+hp+gSVR2Z3EOxIW9vkAFDB?= =?us-ascii?Q?8v1uVfoV0qdeGPrAzpJZAxxFoIrfgKICC/VVivRL/zjmF3DQHaecR2i6lhUl?= =?us-ascii?Q?NZ/uyRSbyUuItPWYHb47NZaSw9+2yWRerC/nsPCXk9urLm+K899UdTqDKhr4?= =?us-ascii?Q?1I4xquDpwdsR+/RpL01g5GOsq3pM4greh9jnaAuF3/c/dCIky3IG5X++DFxT?= =?us-ascii?Q?3ehnFibHmaD44L8KGUSMSnUOML+aX0u1fuMFuvg+obvJBqPvqw47PPsI6i8y?= =?us-ascii?Q?lmAFOjytsG/bs9XHR9YFWA30sg08geBOWkZsi3zfDWNaRpoOcAzEixTAElQ9?= =?us-ascii?Q?adzttQeBJFOnjt8ZhS9vJyf7fo9wM34a3dRaQ2HYGynrOJeoE5BQ/Nk8QjlU?= =?us-ascii?Q?7jCZDzhjM3kO8FExtW7AtB1p6JI4R7QMBS8fQu+LYaAdlxwf4QAjT9a/xpGO?= =?us-ascii?Q?n6gHNNETqc8g+oylPvfDms55CUd8BsDK9iWIdXLMj1csKqZiAK1UKDj2tQ/C?= =?us-ascii?Q?Zh7LFGZDCbqJFg9JQ4lVjoCxYv4++7745npT+B3B7mNRfj9bFI5TM7UamuQf?= =?us-ascii?Q?tqPysiuPwaSnxNIO8ylH4Bzit3OjL7jteS50GNdDmVo5iTPABTR4nH/TltZz?= =?us-ascii?Q?BzvDiazylnJORdQBrIYicBuEguKojE3V+LAv4b5zK19teA1SrE+07nJPE6u0?= =?us-ascii?Q?Zs19AbW38dd21+RCe6SBBi2Xc5Q5ug3U+ddqQrq2KFoaK0tRp3dbKDyJdN5m?= =?us-ascii?Q?kwd99kjXy3eCZMRJ9to1prvfGJM4yCwMHEWbM4jfn/xHEwnF1a6cvlvAIa0X?= =?us-ascii?Q?hcBxpFdEp8GvMKXQZp7C1xCiCeuzoskYeMQ8PHkulPfzRkTDM6k24sUW6Uw0?= =?us-ascii?Q?0UUSzbSqi3Iu1j3fvLdtjlzbLrnqxvOnTwXgYGgeySvRWjengLqekokm82he?= =?us-ascii?Q?BBihvRTbVscPOGEZcO156mE1EXpXas2cKwhe/J1ttun55KfUUDhGY3KexuJg?= =?us-ascii?Q?c7qqJlWBzpyuqYJE2gLGO7mWyzKJgovoPCveDBWcO+fB3XrdV2clrASHnvYd?= =?us-ascii?Q?ZNvCHoFrl+JcDA1dqNXpqh1XQpTc3iRAHwmhkVl6b?= X-Microsoft-Antispam-Message-Info: v1P99FeGSIpu7sSckLCaMRrszkMxTozMIBdfCSFo2jqS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kieIWOkRvCLkzZ8lPr3KD2ijVw4e46EAVlRZ5Q/+4DiS7kbWNG2tZBna6inxYhXLWQG81r8YXdYFj7dX5UyqPZl5oFt+Ll/fJJr8N/USNwxB6G1+LXZeCzZPYrhEA6+bUUJG4kGudpsqSjuWVzc0RYKssFs2DdLgf6TIxuAot26BP6NfZUebllox+Xz8R5AR8CyfrrircpfaUT9AXjjN X-MS-Office365-Filtering-Correlation-Id: 7f335398-6461-47f4-1309-08d5c4488bce X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2018 03:10:15.0801 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7f335398-6461-47f4-1309-08d5c4488bce X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3919 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 d885bff..98ea916 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);