Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp769210ybc; Sat, 16 Nov 2019 08:22:00 -0800 (PST) X-Google-Smtp-Source: APXvYqw0g0x/SlNW/8uulYR9ZMZe1g9h3hlXac/em1WMCHRlbrG1oW2hObsO3UdhnqoFnxtjDwwJ X-Received: by 2002:a17:906:9458:: with SMTP id z24mr10696287ejx.289.1573921320502; Sat, 16 Nov 2019 08:22:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573921320; cv=none; d=google.com; s=arc-20160816; b=z6RFjHjWPWyJDiycwGTsGX+bPlmf+GHag3gIWXUmXSh0EdczvMvY2EAWqKIdYwhh2q B/Vks/yJSyKQk3ByGnA0m7OdZIRY/YNVMvNGMvYsNNop0ThaiN7YWVQ0vDvNOuom33dq zPU/R7SZrtFCAcL+LV1O9tiKV68dNqlGpRf2dG9pjPz/RjjygiRkjj0axQr/jgeq/qKM n58Vth53/JORpd9tvApu/GpPSMFEd5ohCx/s06nS2Uq7S3bAN3x662nEDUB612DnA8Le GKmKs21d45UBh8WqqEe1fATBWvG3g/nLZBMrVHRrJpYARJ7AyUsZBZ5FQNEo7UP9Xmpi bkGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vfVtqHN6nmpZ5Yf8gU7iT1WjsBP3VfxEHCHsi+OFut8=; b=CHkhjB4oDvBGPK+1r1YBtFp+t2ONhNJPpJgVhNOOWmEQloS3nqro36EAR+wwh0s6AO i8kFLN+arnDmniEFJzdHOGzyJSe+dBdbleBMR+EUu6djT7Xy9ECjNEGtEhURfIHacvny lFf3L37Z12re0CRqGmAgAwwbUCKe4xSaAg04oKnp1APnDwBM29gaX2iVJO4mg3FUcYll T9GR0YhyXTDHznO370Y5pMpYFXocAzM+e+nWL+5kKpd2i1Zza0yYG+Lw4bp4OtrkLz9s vb5pjBDhR784zi4yur74vVazdcXxmIYBljHuYLSdjZaEhaKE7H3I/Go97KvTlk3UbI1s 1NxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s68mZhIy; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c9si8651860edy.72.2019.11.16.08.21.35; Sat, 16 Nov 2019 08:22:00 -0800 (PST) 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=@kernel.org header.s=default header.b=s68mZhIy; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731990AbfKPQRQ (ORCPT + 99 others); Sat, 16 Nov 2019 11:17:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:53408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729527AbfKPPqu (ORCPT ); Sat, 16 Nov 2019 10:46:50 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D82F820870; Sat, 16 Nov 2019 15:46:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919210; bh=he1wjEhFAwwWAUwEw1PmINc7L+xpclqFnPx9YRYPgPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s68mZhIyBGM4niSF0zdSmJ4lDz1as6psZNcF/XTTDb7W3B1fgDRgE4OV7iP7a8tgF ha40/RvN8/pCDwc2r8iEOR5d/QNCJjBazKtjIPGJl34EMJ1VcpUjdfcHjJHt/WERPj Yqpwbo9rqhkOj+l/+Veq//BXwv5oD+1hcTbg9/yE= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Badhri Jagan Sridharan , Rob Herring , Heikki Krogerus , Greg Kroah-Hartman , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 215/237] usb: typec: tcpm: charge current handling for sink during hard reset Date: Sat, 16 Nov 2019 10:40:50 -0500 Message-Id: <20191116154113.7417-215-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Badhri Jagan Sridharan [ Upstream commit 157c0f2f641a9938382b092c64548ebdabfe25e0 ] 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 Reviewed-by: Rob Herring Reviewed-by: Heikki Krogerus -------- 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 Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/typec/tcpm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index 819ae3b2bd7e8..39cf190012393 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -3322,7 +3322,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); /* @@ -3354,6 +3355,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.20.1