From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=FROM_WORDY, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3325C43382 for ; Wed, 26 Sep 2018 15:24:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 75583214FF for ; Wed, 26 Sep 2018 15:24:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75583214FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=diasemi.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728365AbeIZVhY (ORCPT ); Wed, 26 Sep 2018 17:37:24 -0400 Received: from mail1.bemta26.messagelabs.com ([85.158.142.113]:49946 "EHLO mail1.bemta26.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727285AbeIZVhW (ORCPT ); Wed, 26 Sep 2018 17:37:22 -0400 Received: from [85.158.142.194] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-2.bemta.az-b.eu-central-1.aws.symcld.net id A2/57-09730-984ABAB5; Wed, 26 Sep 2018 15:23:53 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOIsWRWlGSWpSXmKPExsUSt3OpsW7HktX RBut79S2aF69ns+havZPF4vKuOWwWi5a1Mls8WXiGyYHVY97JQI/9c9ewe+z83sDu8XmTXABL FGtmXlJ+RQJrxrs3FxgL/vNVPPyym6mBcTdPFyMXh5DAekaJ3jebmbsYOYGcCon79xazgdi8A pkSXb+OAtkcHJwC7hJ79hVDlLhJPJ/bBFbCJmAhMfnEAzCbRUBV4v/+J4wgtrBAkMStG/uYQO aLCPQwSmw8soQdJMEskCSx9m0PM8R8QYmTM5+wQMQlJA6+eAF1g4HE6QWNYHEJAXuJ6e+vMoP cICGgL9F4LBYibCjxfdY3qBJzia7pU5knMArOQjJ1FpKpCxiZVjFaJhVlpmeU5CZm5ugaGhjo Ghoa65roGpkY6iVW6SbppZbqJqfmlRQlAmX1EsuL9Yorc5NzUvTyUks2MQIjIKWQ5eMOxu3t6 YcYJTmYlER5FXxWRwvxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4DVcDJQTLEpNT61Iy8wBxiJMWo KDR0mE1wQkzVtckJhbnJkOkTrFqCglzqsCkhAASWSU5sG1weL/EqOslDAvIwMDgxBPQWpRbmY JqvwrRnEORiVhXi+QKTyZeSVw018BLWYCWjyhZwXI4pJEhJRUA2Pb6erDl7OPZE01c1hzLUpu 8W/t6fzlUnLzDrz4/XyxFWf8zS9/XN/NLD7+hec+6yPZWb/+bxKaKVNWW1Z2p7v5WP/ej8Gvr pye67Qh36g187ZbgKKa9WXLxfZrfk77GBM0V8RduTvlt/lHwdi0oNyAmP9qk/9ITIg4zrn0T2 HCJV2fnscJesuUWIozEg21mIuKEwGyXb3z+gIAAA== X-Env-Sender: Adam.Thomson.Opensource@diasemi.com X-Msg-Ref: server-25.tower-239.messagelabs.com!1537975432!279113!1 X-Originating-IP: [94.185.165.51] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.14.24; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6890 invoked from network); 26 Sep 2018 15:23:52 -0000 Received: from mailrelay2.diasemi.com (HELO sw-ex-cashub01.diasemi.com) (94.185.165.51) by server-25.tower-239.messagelabs.com with AES128-SHA encrypted SMTP; 26 Sep 2018 15:23:52 -0000 Received: from swsrvapps-01.diasemi.com (10.20.28.141) by SW-EX-CASHUB01.diasemi.com (10.20.16.140) with Microsoft SMTP Server id 14.3.382.0; Wed, 26 Sep 2018 16:23:52 +0100 Received: by swsrvapps-01.diasemi.com (Postfix, from userid 22379) id 2F1FA3FAF0; Wed, 26 Sep 2018 16:23:52 +0100 (BST) Message-ID: <383410593681e2fed025a4b538ea0840ff370a9a.1537975081.git.Adam.Thomson.Opensource@diasemi.com> In-Reply-To: References: From: Adam Thomson Date: Wed, 26 Sep 2018 16:23:52 +0100 Subject: [PATCH 2/2] usb: typec: fusb302: Resolve fixed power role contract setup To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman CC: , , MIME-Version: 1.0 Content-Type: text/plain X-KSE-AttachmentFiltering-Interceptor-Info: protection disabled X-KSE-ServerInfo: sw-ex-cashub01.diasemi.com, 9 X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 26/09/2018 13:22:00 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the controller is configured for a fixed power role (Source only or Sink only), attach does not proceed within the TCPM state machine as there is no CC event generated by this driver to update the CC line status. To rectify this, when CC is configured as Source or Sink we now make use of the hardware's automatic fixed Source or Sink toggling mechanism, which detects attaches in the same way as for DRP toggling. In this way the result of toggling is handled in the same way by the 'fusb302_handle_togdone()' function, and CC events are generated as expected for TCPM allowing a contract to be established. Signed-off-by: Adam Thomson --- drivers/usb/typec/tcpm/fusb302.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c index fd851d8..43b64d9 100644 --- a/drivers/usb/typec/tcpm/fusb302.c +++ b/drivers/usb/typec/tcpm/fusb302.c @@ -679,6 +679,7 @@ static int tcpm_set_cc(struct tcpc_dev *dev, enum typec_cc_status cc) int ret = 0; bool pull_up, pull_down; u8 rd_mda; + enum toggling_mode mode; mutex_lock(&chip->lock); switch (cc) { @@ -764,6 +765,29 @@ static int tcpm_set_cc(struct tcpc_dev *dev, enum typec_cc_status cc) chip->intr_comp_chng = false; } fusb302_log(chip, "cc := %s", typec_cc_status_name[cc]); + + /* Enable detection for fixed SNK or SRC only roles */ + switch (cc) { + case TYPEC_CC_RD: + mode = TOGGLING_MODE_SNK; + break; + case TYPEC_CC_RP_DEF: + case TYPEC_CC_RP_1_5: + case TYPEC_CC_RP_3_0: + mode = TOGGLING_MODE_SRC; + break; + default: + mode = TOGGLING_MODE_OFF; + break; + } + + if (mode != TOGGLING_MODE_OFF) { + ret = fusb302_set_toggling(chip, mode); + if (ret < 0) + fusb302_log(chip, + "cannot set fixed role toggling mode, ret=%d", + ret); + } done: mutex_unlock(&chip->lock); -- 1.9.1