From patchwork Mon Jun 25 08:08: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: 10485261 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 25EE4601D5 for ; Mon, 25 Jun 2018 08:26:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 113512889E for ; Mon, 25 Jun 2018 08:26:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 047A9288EF; Mon, 25 Jun 2018 08:26:59 +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 903E32889E for ; Mon, 25 Jun 2018 08:26:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751930AbeFYI04 (ORCPT ); Mon, 25 Jun 2018 04:26:56 -0400 Received: from mail-db5eur01on0088.outbound.protection.outlook.com ([104.47.2.88]:4509 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753288AbeFYI0u (ORCPT ); Mon, 25 Jun 2018 04:26:50 -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=TCbba0kDY+kjNIZKEaFqVByFV7lX/KucAvhHrN/t9vI=; b=rAp733e0EETIjZlrgIPST/UqzgexZCk+7HfIiJ98vWyzf+uS3Zh1jV346wxycamSSQTYRzCGt0kQrsqW3plbWIek7kdrrZzBdt1OnEg0rD1IU8VkirHUoc3RlFgA81DOatS5bL2jc60rkd2VWxWowE35AC+qZ9ykAroDMHCxYpU= 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 VI1PR0402MB3920.eurprd04.prod.outlook.com (2603:10a6:803:23::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.884.24; Mon, 25 Jun 2018 08:26:42 +0000 From: Li Jun To: robh+dt@kernel.org, gregkh@linuxfoundation.org, heikki.krogerus@linux.intel.com, linux@roeck-us.net Cc: a.hajda@samsung.com, jun.li@nxp.com, cw00.choi@samsung.com, shufan_lee@richtek.com, peter.chen@nxp.com, devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH v7 12/14] staging: typec: tcpci: keep the disconnected cc line open Date: Mon, 25 Jun 2018 16:08:44 +0800 Message-Id: <1529914126-22550-13-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1529914126-22550-1-git-send-email-jun.li@nxp.com> References: <1529914126-22550-1-git-send-email-jun.li@nxp.com> MIME-Version: 1.0 X-Originating-IP: [92.121.68.129] X-ClientProxiedBy: HK0PR04CA0004.apcprd04.prod.outlook.com (2603:1096:203:36::16) To VI1PR0402MB3920.eurprd04.prod.outlook.com (2603:10a6:803:23::12) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8c4eada1-9261-4fa5-53ed-08d5da756405 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600026)(711020)(48565401081)(2017052603328)(7153060)(7193020); SRVR:VI1PR0402MB3920; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0402MB3920; 3:MCeb0NeSgW/OAJS9cfajiqsB+wIhqqCHb2X37HAUHqUCcx4EsL/AXlz8NOUDHeMKor+v79K89nb5lpovEsZxGJYF2humpE7ihYGEKKGfsSWLz6dUQtJ7flGzTdy9293EbajxQSZs6vDmL2/JBZtHQJUKCgF5M3UYd5/fZjEVkd2nEiuUjmhM/YmpFUNLduNmnrec1AvlZENI/SngF+w6mhgWx/zP+6Xynuv228A7kXRzloXlqGC1KS7K8u35RcBk; 25:iYcZfP4tJx5ZNfvqzZLcy3IuEHovYrUYOP69JMuq3ADhgcsBWcdmqx0pj40gAMoM8viEx7Pf/hUN0iZsefEwaLvwOROV5iGW7Q2fDVwgOx4sdjMAHxZKq49taNY71S7KfRLtn/km35Ha22IMp6JtkmktHEJqDeEhq0TnGQx/HV6xvcov88p7o82j+oNXUPP7Nc5SSVbhBAL14yY+E8UjM0MdttQSlORU1GPiI5k2kSMVc3XVIKbwzOVRso8hyZqpb11Nt2ZeqQscK5wtRoDBXivSbmTTRiJmGItP4yAFx6WA8u8DMOOW9VysytXVMZwZS1CX22cb7wgH/vM67FVTQQ==; 31:aGg7G2gzfiG5TqTFC8TL95VCfgkNC5kbrEaxIrW4AU3ZcL59G5zcwSX/H1+9hU46fzbZN8ErVayny0rijoh0/Mu0z0pSbLr/hfavkI/6qeMf48XNMNZy986cTXnDQqrT7BIZJ33Nq7oWkG1Bdd2oLK7qp27UVSKw7SpbbR9DyXP8KUdqMJ7t0kebxSvkh1fjr+aEWF/ZRs0vIitFMw8qly3C9NyOnghKsLrOLTsS/QQ= X-MS-TrafficTypeDiagnostic: VI1PR0402MB3920: X-Microsoft-Exchange-Diagnostics: 1; VI1PR0402MB3920; 20:1QM+CtefjneMTFGVRKpUFyxt5gJe0xDgsAPXwk1jRvcGn8/YD9T+7VlH/yi6JpI7LWwBciThI9chG6mLZF2hedjC1TjZhKyLvzuLbeCCZgYU3J2s2Looz8mRAJQHYyDq5abKxu2uRk2COvOvccOUNUpWc3YUSjoURsPY2hmWm69ffTdAxGNocllfFmoFV3noVlO8eDX2u2j9sD5Rtl2aPX+oP3ASoGegttxosTZiIA5rR1K+nKurs9/MraVmKAbfq191b5LZak8/nEeLmKOxCSm6laAtmBgjt2QB1nUkvR812i+8c+upvdR84ErYzziJEN9Y6NS+eeuBuCXKa/yR+AYN9JuHDBA93D9l4FVzzbqa8+bYwGlUmKphmrfZKN1V9o1yhL42EqcuIowm906XojVW/eJGsUCwSc+IQgUkNBwpE+WPehGDF0WDW00lRvuTeRsf6860x8ik4uy5ytqyC0EW1YR1mtWqdRzU4+h5zaFwPn9dyzVjEW6dNihqZP6y; 4:xP6V/YDHBSO3o6FjHVaPIXbKMTKj0uWxQkL8DT4uWxn5icDNvHaUZMEht2rVVLSVHrsDK1zG9XSYHik7ta0LLgOjlGHYGS7u/XPVnYll9wZaEENF9iaWNoR45CQN8t12TmJreXBffq3c8WBRYmX0cU82alAwpNcsybvVwOJIoEwqfHMpwjoQhE83YhMtkAhCRtBZJ4klnOCFN0H5tepXnqg29gOMAMvhzv8NQdNMN6o6HJYW7mu52CsiNHvOYSs4lxCC71npjwMpUONd52L11C5HM4LAN1gyGcKqB6Md89hH19noEPrejzJSGfaJGN26D4Y7pxvjfPcfhcd4JCzhevhETBTu3UC1Vc339P4Jzmo= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(10201501046)(3002001)(3231254)(944501410)(52105095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(6072148)(201708071742011)(7699016); SRVR:VI1PR0402MB3920; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0402MB3920; X-Forefront-PRVS: 0714841678 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(346002)(39380400002)(39860400002)(396003)(376002)(199004)(189003)(53936002)(25786009)(47776003)(316002)(2906002)(16586007)(6486002)(36756003)(4326008)(386003)(6506007)(186003)(6512007)(478600001)(26005)(16526019)(97736004)(8936002)(86362001)(50226002)(52116002)(575784001)(476003)(81166006)(81156014)(486006)(76176011)(305945005)(51416003)(8676002)(2616005)(105586002)(68736007)(446003)(11346002)(66066001)(5660300001)(7736002)(50466002)(3846002)(106356001)(48376002)(6116002)(956004); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0402MB3920; 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; VI1PR0402MB3920; 23:+GUT+yL9P0A7NrtgHG235/8ve4/B44j1FJcp8Gc?= =?us-ascii?Q?l19kwFuLhZRgog0SOkJlROM39lPv3gIk3hPIvCBzDU7R15rMi0DFtWxGEgiQ?= =?us-ascii?Q?d0LMKwNcXTlyxu2aT4N9U3MLn+wiFpplTMI25WSzZhnz1DeknyVPrdjsEldw?= =?us-ascii?Q?g+WGlEksseYiz+JmrltsCDJqPkHe9LC9KBuEV+whErBcjY7nmOwbcajYcmlX?= =?us-ascii?Q?5Or6+N/7z21yi5QJYZR6A/wwJr9QV0tI1LLLTrl1JAcJorpSCDUpfz9+GdWe?= =?us-ascii?Q?sLyRNf3tc9OpZ2DKOshBrsGKgXQH6ubiFDlZ7f7WTpDNGzODbCEvLsOLuIVB?= =?us-ascii?Q?hJvyQTwdlE3lVhFrl8CJqOX2i8nrBfnpWU8G3qr2+7Bkow38ljmYSt4qRIjJ?= =?us-ascii?Q?+jXehZAGyGvmbq1wDO0YUKh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ticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0402MB3920; 7:KHSMKm5Ajtyi5pqm6QPdRwLaLtr+tC9LZiZ1nfps96qfnqU1cQaaB9dtvnv7TsO/SlV3c2UwIFTlXT9pC7PlY3WJ67CibJMzg4Ddq2Tox+YObs3clOGWrcDjmXbiERKwvBrigU+n7Uxm3Ni6S86lkjf9XK4puy3Vz/EkWge8fZOKScu1ZIbn9OkcsJuzXAsI/9zBUXLp1VPVauSerjTtOMIh4qbyChPPcaz5+0NtCX3kmpuu7sidwNpq1Q5yKEnt X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2018 08:26:42.1111 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c4eada1-9261-4fa5-53ed-08d5da756405 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3920 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 While set polarity, we should keep the disconnected cc line to be open. Reviewed-by: Heikki Krogerus Signed-off-by: Li Jun --- drivers/staging/typec/tcpci.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c index 4d3b0ae..11c2d37 100644 --- a/drivers/staging/typec/tcpci.c +++ b/drivers/staging/typec/tcpci.c @@ -185,15 +185,25 @@ static int tcpci_set_polarity(struct tcpc_dev *tcpc, enum typec_cc_polarity polarity) { struct tcpci *tcpci = tcpc_to_tcpci(tcpc); + unsigned int reg; int ret; - ret = regmap_write(tcpci->regmap, TCPC_TCPC_CTRL, - (polarity == TYPEC_POLARITY_CC2) ? - TCPC_TCPC_CTRL_ORIENTATION : 0); + /* Keep the disconnect cc line open */ + ret = regmap_read(tcpci->regmap, TCPC_ROLE_CTRL, ®); if (ret < 0) return ret; - return 0; + if (polarity == TYPEC_POLARITY_CC2) + reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC1_SHIFT; + else + reg |= TCPC_ROLE_CTRL_CC_OPEN << TCPC_ROLE_CTRL_CC2_SHIFT; + ret = regmap_write(tcpci->regmap, TCPC_ROLE_CTRL, reg); + if (ret < 0) + return ret; + + return regmap_write(tcpci->regmap, TCPC_TCPC_CTRL, + (polarity == TYPEC_POLARITY_CC2) ? + TCPC_TCPC_CTRL_ORIENTATION : 0); } static int tcpci_set_vconn(struct tcpc_dev *tcpc, bool enable)