Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp460033imm; Mon, 1 Oct 2018 12:45:39 -0700 (PDT) X-Google-Smtp-Source: ACcGV61+G1y0oY9Zz1U69hQMWQjz1RncjoJmIvzQHVYtLzafVhVIzwKvXQwJ1VNADjHLE4UbUreO X-Received: by 2002:a17:902:8502:: with SMTP id bj2-v6mr13173629plb.295.1538423139758; Mon, 01 Oct 2018 12:45:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538423139; cv=none; d=google.com; s=arc-20160816; b=yKzZ3dS5x0slQsrH2FlEcnZnN2WvdjtfEq3Qh1au1CCJGyPUq4Ie+bGa2TLAi6bD9E 3AQn/Dr0M9lSKvdOVRfgMDyYJJ7WzMHJ99xs/7w9aqv5DaguiVAJczekiWX9wKsIBBVN Y7LxagD/WPC9RZtlcVgRiS/tpVHnZysqYBaIZ5gThlm8ziL+8AKa9qJ56piv+uB1aKOQ KyOaO5N+T8lBJrJp3869Eh3noDypoJWipjbhWIxkGcptEw1T8yEWtzzh1BEOZZjDLOgl z6MaA3xArVOo2KWWaTLyUBzMSAuJHmncP+kaPaP6pO5aPIObbxo3tEkfNUia0CzQjVhZ wuNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=QnL/wTVd8g+QQeeekaKssRaFgYtQTuUuTzrOIXl9vSk=; b=cF/XSVLnoff8Tpyy9SalliHsgrWACk9Rty9JjeL2i2zfsAPFYvTOnxoFkrXVzLEYIf nRNWp6lrFvHNJsZ0WrXS8VxB7vI+88puvzqqCDV8LFc8ZgL+Omc5JpLgsTnjHRzak4Oi JIpmC+nhdE8f1fhmDJeLxvLvpJUDa1ElJ+O9Q6Pzg5LzHvPyYcUmPfqqUjVl9nDk470P ntYw7A9+F8SVuS+oXtpbF8FiiwKhJdpXXBDmMyEVF22pJ+uRnPJwSDXYiKPm//xLyd7D 7ep7tvb+Cp5TG9DG4AjioSJFk1rBE1I3JBupAwI8XJEch8Y4NjqbivW96Hd6xva3dIKF Py2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dpqKwe5J; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1-v6si6007528plo.165.2018.10.01.12.45.25; Mon, 01 Oct 2018 12:45:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dpqKwe5J; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726461AbeJBCYf (ORCPT + 99 others); Mon, 1 Oct 2018 22:24:35 -0400 Received: from mail-pg1-f202.google.com ([209.85.215.202]:44087 "EHLO mail-pg1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726204AbeJBCYe (ORCPT ); Mon, 1 Oct 2018 22:24:34 -0400 Received: by mail-pg1-f202.google.com with SMTP id h9-v6so7567627pgs.11 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=qf8K2UmJHtc6BWG8Z6awdkx2ADNhYh5/OnvxgaX9HB1+AecTkL4y5DqpkFuRcmHsni ROuWGHvRyInGSGb1YyKczJNAkL5WM1am2JP7PKUgM/nf1H46HZUCDpoVZTPu5KqZaVLl cHKdbRPjINlT57IgLxbsXPlwR4VFtJNq6UGbAqtxK7ME9MNwBCtT2xEfUMucDOhvIwbd lCut7vVh64IPpUd+l+NZH10m0CJnnoYwTCNU5ufthrCa0hkSnfLLzpcKnsxGqenI+qgK xhHyvZ75sHCYjw2BcshzBziWjZYyKzx88Jt/iBQFkAp30Rp0M46ERGF6hCbdTW1RH/ST wDYA== X-Gm-Message-State: ABuFfogM/GC8JEpklqqRef+m4MA8+sq0VA6CPhZ4vTwMBqfWOdOLtvSx iiVyKQRRBzkETbUcxQ9NlKgGSE4kMKk= 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; -- 2.19.0.605.g01d371f741-goog