From patchwork Mon Oct 1 19:45:01 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: 10622685 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 52EE36CB for ; Mon, 1 Oct 2018 19:45:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4079428390 for ; Mon, 1 Oct 2018 19:45:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34815283C5; Mon, 1 Oct 2018 19:45:19 +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 CCF4C28390 for ; Mon, 1 Oct 2018 19:45:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726462AbeJBCYf (ORCPT ); Mon, 1 Oct 2018 22:24:35 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:47264 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726445AbeJBCYe (ORCPT ); Mon, 1 Oct 2018 22:24:34 -0400 Received: by mail-pf1-f202.google.com with SMTP id i76-v6so3727136pfk.14 for ; Mon, 01 Oct 2018 12:45:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=QnL/wTVd8g+QQeeekaKssRaFgYtQTuUuTzrOIXl9vSk=; b=dpqKwe5Jx6HO0cUzvwv0H7tzvpV3wpkeNtz/Ke092GpEnNuuOikG2YlGK0AHPileSq lXd1DzNXvtw/eJItv146cxyedGJxyOkan/mUQiiHNdBN/zfHG+PI1i3vCTgM0rxscIX+ Odj5CK5qqOI0YdMP7xmRWpRzJGJjpQZX8C0G1yB4ysJgcJ7JKz5IS8HOQvGrxSZV+7nT 7e4ztgfS5x9SHICPTqgIQpXfp22QixU8mI9uwhsNxtLcB20byNYUExTIUXCxwK1lphu+ NrkLwJr+CDpBrr+opME9s2rOdSCCl/n/7SuXJl4LMbPRYxqicfaamUGw+7UJUu9ImuC2 ofKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=QnL/wTVd8g+QQeeekaKssRaFgYtQTuUuTzrOIXl9vSk=; b=LT+ud8iwwdfw10eNb+Km20NzD6MR/DecHYNpJCCFnrNYWSKU/wODDJMk/i/S1TBE0h ElyfgKblun7KZU85ppsZF/26hgB5rAwIEqTGQqWAa9WyL1A+gmZgOh6kqST5yYt2pGwr J0RjTl2p216x56QYvzA3gCt7qjMHgPPmi8kM8YzOU9v/lTmZrGdPFooRjPWyuSVxi7Xh mukSev1lbnAPT7VHOt4tbxu+MJTdfGbILMMtQIdwtojIzVrGIeriNScYTVd0GO7XQK1d FtKuFuMojcgzG0GiOx+3n/Z29R/e3xpUwAX9kKvz3hDRhfYS4wGrqvRVlAPmEO+oPMz2 Lm9Q== X-Gm-Message-State: ABuFfog/h/5BCp/qVuaTctffoeBkqAlcU2yVrAao0owJ4D4RAfvfGOp3 25w+5N1DLMAQXKcEP9YGTquWxpN5C1Y= X-Google-Smtp-Source: ACcGV60qsdXK9rO3A9sY2pXzzAk/S0SH0TV+mpPlUa2AYv0/Arbuk5qof6QLcwgxy129G1i2UOIikyd1XsY= X-Received: by 2002:a62:9c8d:: with SMTP id u13-v6mr2959384pfk.41.1538423113792; Mon, 01 Oct 2018 12:45:13 -0700 (PDT) Date: Mon, 1 Oct 2018 12:45:01 -0700 In-Reply-To: <20181001194501.58338-1-badhri@google.com> Message-Id: <20181001194501.58338-3-badhri@google.com> Mime-Version: 1.0 References: <20181001194501.58338-1-badhri@google.com> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog Subject: [PATCH v3 3/3] usb: typec: tcpm: charge current handling for sink during hard reset From: Badhri Jagan Sridharan To: Rob Herring , Mark Rutland , Heikki Krogerus , Greg Kroah-Hartman , Chanwoo Choi , Andrzej Hajda , Li Jun , linux@roeck-us.net, jackp@codeaurora.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, 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 the initial connect to a non-pd port, sink would hard reset twice before deeming that the port partner is non-pd. TCPM sets the the charge path to false during the hard reset. This causes unnecessary connects/disconnects of charge path and makes port take longer to charge from the non-pd ports. Avoid this by not setting the charge path to false unless the partner has already identified to be pd capable. When partner is a pd port, set the charge path to false in SNK_HARD_RESET_SINK_OFF. Set the current limits to default value based of CC pull up and resume the charge path when port enters SNK_HARD_RESET_SINK_ON. Signed-off-by: Badhri Jagan Sridharan -------- Changes in V3: Rebase on top of usb-next Changes in V2: Based on feedback of jackp@codeaurora.org - vsafe_5v_hard_reset flag from tcpc_config is removed - Patch only differentiates between pd port partner and non-pd port partner V1 version of the patch is here: https://lkml.org/lkml/2018/9/14/11 Reviewed-by: Rob Herring Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tcpm/tcpm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index c3ac0e46106b..c25a69922ee6 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -3273,7 +3273,8 @@ static void run_state_machine(struct tcpm_port *port) case SNK_HARD_RESET_SINK_OFF: memset(&port->pps_data, 0, sizeof(port->pps_data)); tcpm_set_vconn(port, false); - tcpm_set_charge(port, false); + if (port->pd_capable) + tcpm_set_charge(port, false); tcpm_set_roles(port, port->self_powered, TYPEC_SINK, TYPEC_DEVICE); /* @@ -3305,6 +3306,12 @@ static void run_state_machine(struct tcpm_port *port) * Similar, dual-mode ports in source mode should transition * to PE_SNK_Transition_to_default. */ + if (port->pd_capable) { + tcpm_set_current_limit(port, + tcpm_get_current_limit(port), + 5000); + tcpm_set_charge(port, true); + } tcpm_set_attached_state(port, true); tcpm_set_state(port, SNK_STARTUP, 0); break;