From patchwork Thu Sep 13 02:11:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Badhri Jagan Sridharan X-Patchwork-Id: 10598635 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F21514E5 for ; Thu, 13 Sep 2018 02:11:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62ACF2ADDA for ; Thu, 13 Sep 2018 02:11:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5359E2ADDC; Thu, 13 Sep 2018 02:11: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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL 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 EA6462ADDA for ; Thu, 13 Sep 2018 02:11:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726521AbeIMHSh (ORCPT ); Thu, 13 Sep 2018 03:18:37 -0400 Received: from mail-io1-f73.google.com ([209.85.166.73]:44617 "EHLO mail-io1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726261AbeIMHSf (ORCPT ); Thu, 13 Sep 2018 03:18:35 -0400 Received: by mail-io1-f73.google.com with SMTP id s15-v6so2739709iob.11 for ; Wed, 12 Sep 2018 19:11:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=a7z2/GVC0GewoLAOj0ejoiGO7k0hgtIwfj4eCBu18w4=; b=jGrLBZQii+9GPVTGTz9sJJOGeoMtb8ANE4IY1JLudPEZQeUkKprISz1XND9ujd8HEd xVUszgnKIARu6qtDhF1nwj1AXunoZuNAnrDUunTAq0/jCPb/iXtBpXSlmcL6UcaCvkhZ jjw0UzJl5ar/pIvLbvjHzJ4bu4ECwYKlpL3rtvhXAsQe1W3ulSqLEvqGIojiFk2Bz8aG VD9aatOuKNhNm7PRBkVkPor+yo7drmkA4ijfiEoZ7eskiKrTRxMDDxHWuKcAK/FNZGOn 0VPQyozGSHe8h3YHNFspVBMYAY98Q6EwKzc85r2iHhuXI08b9eRPZCXR8ZsqDQ51sr+r V8Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=a7z2/GVC0GewoLAOj0ejoiGO7k0hgtIwfj4eCBu18w4=; b=rSeoYr5GJx6/Cvl97Yz2XJgjsrMlJjg1SHQKuCeOatpF+HWjcJBS8BlXoUb0gQqTES I2LajRYJM58VR61BheiICSWJSYkSqZApx8en6KrfgmyfniQRQhkfcoc/nVmoACW7ETYq GWmls2W9WgT4/4wfSVh8PGlOMGjD/VEFka/s9qXb/7uo0rkwtS1gxK/sOaAKIJPegnEq dAIHDSt9RMYMQMDQSepEafCvvySXddGi2ZJunhiQ7DkTLA31uvgse9semBUY2UoJs/jI tleY54fccCgFjSvR7xyTxbBKFs2oroUfYwQA/6sj/POmfByiS7Qoi1YvQrWHTaPR7zuL Lt9Q== X-Gm-Message-State: APzg51AhLZIJk6jlYdUAYQwLEoDno8jxPzsc0xjO7+eM2H2jJrihMD2y vNg006BOQcAyMZN2AiL9XhiASmV9/ew= X-Google-Smtp-Source: ANB0VdYv0PyMNckBneXsSawlFTyQAyu0/pgn3LyNjVO6SIS12h0m895hTI8+fHEcr74Xs3XDFpB3QE5HfQk= X-Received: by 2002:a24:9d43:: with SMTP id f64-v6mr4180845itd.17.1536804678091; Wed, 12 Sep 2018 19:11:18 -0700 (PDT) Date: Wed, 12 Sep 2018 19:11:12 -0700 Message-Id: <20180913021113.18150-1-badhri@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog Subject: [PATCH 1/2] typec: tcpm: Do not disconnect link for self powered devices From: Badhri Jagan Sridharan To: Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Badhri Jagan Sridharan , Badhri Jagan Sridharan 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 During HARD_RESET the data link is disconnected. For self powered device, the spec is advising against doing that. From USB_PD_R3_0 7.1.5 Response to Hard Resets Device operation during and after a Hard Reset is defined as follows: Self-powered devices Should Not disconnect from USB during a Hard Reset (see Section 9.1.2). Bus powered devices will disconnect from USB during a Hard Reset due to the loss of their power source. Tackle this by letting TCPM know whether the device is self or bus powered. This overcomes unnecessary port disconnections from hard reset. Also, speeds up the enumeration time when connected to Type-A ports. Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/typec/tcpm.c | 6 +++++- include/linux/usb/tcpm.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index 4f1f4215f3d6..a4e0c027a2a9 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -3270,7 +3270,11 @@ static void run_state_machine(struct tcpm_port *port) memset(&port->pps_data, 0, sizeof(port->pps_data)); tcpm_set_vconn(port, false); tcpm_set_charge(port, false); - tcpm_set_roles(port, false, TYPEC_SINK, TYPEC_DEVICE); + + if (port->tcpc->config->self_powered) + tcpm_set_roles(port, true, TYPEC_SINK, TYPEC_DEVICE); + else + tcpm_set_roles(port, false, TYPEC_SINK, TYPEC_DEVICE); /* * VBUS may or may not toggle, depending on the adapter. * If it doesn't toggle, transition to SNK_HARD_RESET_SINK_ON diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h index 7e7fbfb84e8e..50c74a77db55 100644 --- a/include/linux/usb/tcpm.h +++ b/include/linux/usb/tcpm.h @@ -89,6 +89,7 @@ struct tcpc_config { enum typec_port_data data; enum typec_role default_role; bool try_role_hw; /* try.{src,snk} implemented in hardware */ + bool self_powered; /* port belongs to a self powered device */ const struct typec_altmode_desc *alt_modes; };