From patchwork Tue Jun 26 23:45:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Li X-Patchwork-Id: 10490347 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 6436960386 for ; Wed, 27 Jun 2018 00:03:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57E6A1FF13 for ; Wed, 27 Jun 2018 00:03:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BF5526E54; Wed, 27 Jun 2018 00:03:32 +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 D69B71FF13 for ; Wed, 27 Jun 2018 00:03:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934339AbeF0ADa (ORCPT ); Tue, 26 Jun 2018 20:03:30 -0400 Received: from mail-eopbgr00061.outbound.protection.outlook.com ([40.107.0.61]:3936 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934331AbeF0AD2 (ORCPT ); Tue, 26 Jun 2018 20:03:28 -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=WFj9kati1UJLM+2ggfmXqSfLi9tIO70c2q35xOmG8j0ReDERslfF2TCEq9nLs+LKfnF3ofWBkPBpt3Ii8J28n0nVqUd/8P9zKA5xONcdQi5H7ohMZ5K8KI10Q+FVi3AdLvmz3LGuJhGnun9M2R0jzHSoYrd7AH+nLeq91eDdgL4= 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 AM0PR0402MB3908.eurprd04.prod.outlook.com (2603:10a6:208:f::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.884.22; Wed, 27 Jun 2018 00:03:21 +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 v8 12/14] staging: typec: tcpci: keep the disconnected cc line open Date: Wed, 27 Jun 2018 07:45:30 +0800 Message-Id: <1530056732-9640-13-git-send-email-jun.li@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530056732-9640-1-git-send-email-jun.li@nxp.com> References: <1530056732-9640-1-git-send-email-jun.li@nxp.com> MIME-Version: 1.0 X-Originating-IP: [92.121.68.129] X-ClientProxiedBy: HK0P153CA0011.APCP153.PROD.OUTLOOK.COM (2603:1096:203:18::23) To AM0PR0402MB3908.eurprd04.prod.outlook.com (2603:10a6:208:f::28) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 765f0f5e-9c80-4488-13a7-08d5dbc16812 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:AM0PR0402MB3908; X-Microsoft-Exchange-Diagnostics: 1; AM0PR0402MB3908; 3:Bp/ixdi/QKAhy2W5SMM9iw57LsXrgAi29SeBrMagw4XmsmJq7uDQ/yXMHn4LW2f3vcNa+yL49HLZax7dvnUlkB9d19Bjyc2oNyg4UkdLmt4DyVnhiYgynaS5jzm0lQ3B59oWng8yGqqpOlIH8ykEhyIK1JTCbItAJ+RGS4M0yEjw7emjc/yiXUfw4DkBwwmXscM1Ds29Mui+c9y5G0aaxfpfKuzXXzQz6tbFABt441PJDCckuKl3JFLRxigTjtcZ; 25:lXWFkrQ8a7sBzkcHiU4do2JuDsIh+55Uv7TAwZfQzBmBOqNDl7lj5Rr682gsLMsuXyWxS5f9FcBp2kz3VDkEi2Ob31WVdk465Nh/KJvC/nyLwdD6g+fuXZolvtF5SOsXKT9Ac+Sk8Qkq/78ZvYIfLXRA/YY2B31cCbg10yneoZGJ0S50cnHWAgBi/oMVfXHcJ4hfBjSB+l4wpY57H0BkJG8oKnn/e4n6RXNh+kGPO7VAyLOvyxYiW3RkGE2x1DMb3VTJTHB2KoQBwdpP5LonHd25nK0D8QM5WJInJyVZXyoEJiX/+/z6urzmMMpOMCMom8EB3RHZftJ78ndp0AeVNg==; 31:/4WrN6797h4T96f16pHflsfhKO6h16KeYpzomY/ZmLZ8j8xP+2juExtEs+90a13qx+t3+YuuZ+3lflGT72GomsGPAUJIFEk9nDQqDoIHuUsl9GUVnO/tCsKlbKdKMAbQFGBM8DpjrRAzBDZv6Vy5TDyu4OfLXRCbJP9nOJBQiBzsa+tV+QzLcJCCX8/e6lUUQBn9oZUUXbTmhyWwQC0U1hm4pJe6TckFIVZhWHL2GG0= X-MS-TrafficTypeDiagnostic: AM0PR0402MB3908: X-Microsoft-Exchange-Diagnostics: 1; AM0PR0402MB3908; 20:TPeLrsy11f2MWawohRFwfeRinEhCRXWAKCrKFfM/mlZMmlRKclsxNYah9Iapei6nCE2Apm1X55XNfiyPHOlKExu3Z1/ayjvA/g+IobPxtU7XoKAmlTTGAgBRJW9BEb82zKK1l2PbyiBFF0QVo2Imq/Js2gbRhsGWQdJCUEoaG11g871nm8bYO58srpKMUkEKLQXdF12Cqq0XIIBp7PhUHSrG/Ou8AOrpRZj+z22M5kkMn0G6Px1KGmG1SDCQVPQlTT9lhUwBrAbdaxurfIwvl3rxAstaa1amJAdxHegZGgdh9WWWkx9R3No/q5xw4YHvh6xS3KYum7e/JtZls9pOMzVR1KT0LWys+NjP9M90cJ1VKg/1zslwIC18AdqlXjL1f0cc0TKsK24IstkOvqB8P4O0df6EkUaPkUJVddIFX79yBjzdC5xNuKUGxzriozKM9rQeU2zNFGTimm3JmDp9ik6FXepqyFkWrvyZm0KCJPX0LjVIA4muCyrpGwnN77lq; 4:G/s1TiyVjItf+6owaeG6i28/V8NPfurEmaz0gz0Yla2qbqdl0ojzQhNa8sIfx5rtauIt0UQH3AX7zdKqBLxRpcwCIZrs0JqQaMzgwQJvaM21LcfF+1X7Cdj7a576wItlHTcp+tA3ZqtdtfZlg/JGckE8xAxfCxf4gej3IlJ6ri85WVd3tJyuHShRkFQv6zHa3mcSVqtSbXwC1tKJRRfkJQbfS1/+rnVugIRjvSKKs+pDHBGB/3zyoeTdVJXadOVk5cCcS2hTxBPExRcxXNuQHFeFWF9E9INJ+ZISe+Y0/3wob5hZqa/S9cVxha961cjUja01Py6iF1rCwmlYih4nslQnU53OLkgQozU9hH5uqZ0= 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:AM0PR0402MB3908; BCL:0; PCL:0; RULEID:; SRVR:AM0PR0402MB3908; X-Forefront-PRVS: 0716E70AB6 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(1496009)(346002)(136003)(376002)(366004)(39860400002)(396003)(189003)(199004)(2906002)(7736002)(26005)(6486002)(305945005)(486006)(575784001)(48376002)(478600001)(86362001)(25786009)(4326008)(16526019)(186003)(36756003)(50466002)(16586007)(68736007)(6512007)(47776003)(51416003)(52116002)(53936002)(3846002)(386003)(6506007)(6116002)(76176011)(316002)(97736004)(50226002)(476003)(2616005)(956004)(6666003)(11346002)(446003)(106356001)(8936002)(81156014)(66066001)(5660300001)(81166006)(8676002)(105586002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR0402MB3908; 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; AM0PR0402MB3908; 23:MsML38IwxQMDlyL7LMuRSskWmcjD8JrClsCyjux?= =?us-ascii?Q?Vg2E5EUfcpI4b+7mOIjrv/9Ly2Ki8HctRRJoy0EXiaqxROBI+YYSAKKKEDrz?= =?us-ascii?Q?2HCDm3/s3X8O2XEWhpZ4Q+Df1PCdRfpIaeRCZ6cl6Sw+TwmpRd8rBCr9pPfR?= =?us-ascii?Q?ZUgbTicG3jFy0SvcmWDcC9i+WhNZPNynYe95MWzp3OSLO/zYc3CBazuZqIxs?= =?us-ascii?Q?78QK1H5HHzuZxrHrtL/FNAH1AMfUddjAAgcInoQ4yhLnnfj1Acx36G34/G/7?= =?us-ascii?Q?0nqAAtr0DUOM+R/6nrPbADHzJl2/ORZum/BHuPyq/fOlk/yoGT40FrhoYRCn?= =?us-ascii?Q?sJ7fyc+WxIa7OTdCfY3DUyGd4ahxn62Ou+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8efBa/wGGzh/X1kf1sFoW9FxNzNYf48fLpe9jCuXEsz2XBlcltmjulIjn29x4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM0PR0402MB3908; 7:wePgxNRiVjQBBPO+VnCB80+UgaT1FuuPESsNAs9zVJrcBGHJyxPpe6s+JOP1YmvByxWYcwvjuLIG1GstS1k8F69uysIRtV1huFixSlVfFDQMurYqCyaDHnVII+SYBmhiKEF4Pp3tmz2O5xhCwNcfkUZyiArUUouFZ8SWays3GFH1E5UTEO7TNu3rvgFOOvqW6EWdv4Aq0g/oKYYH90hGta6MhA6MjMPJXocEVlFHXDJWLdzL4HT5YrBIa7Pxxydv X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jun 2018 00:03:21.9134 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 765f0f5e-9c80-4488-13a7-08d5dbc16812 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3908 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 Reviewed-by: Guenter Roeck --- 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)