Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1341385imm; Fri, 28 Sep 2018 16:49:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV60CqJImNhiHz/pmNMD/dewdjD3/69kbSNkMJBuj/wvdtpjf3YNn7Ookas3FsqtlnJrwXqTB X-Received: by 2002:a63:9a42:: with SMTP id e2-v6mr372821pgo.340.1538178564888; Fri, 28 Sep 2018 16:49:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538178564; cv=none; d=google.com; s=arc-20160816; b=TUUGQ2Oucfba2RWVrM2c5Uuf7H4UUdcUyqb5Wqt3zk3XEi6Ij1UdwhzaC72RXPSB6+ NmfsSes1nPe35BhQCplN9+4w6k+NWS49Z4JkHGS/BQqg4UuGrEDYFukYo3qeFgJtg/73 eOK9SQQwws0hZyWqfh8LiI/bacm4W0i3VfLNnpA5crCUc7uyLWGTQvoA60i/3KruaFge lWGH1MenVUnrZIlThMeuZurQ/hNmEsq9mZQdmHCzlK7JBC2bauxkGDxcEzls2DNprtrQ FwfepNeoaPIew0TOl+v/jM0PDauWd8tyqD7YuzTu266Pw00c1DxbFNooHIx5FnewllIH 0iUQ== 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=Bkui6iSebkHx1Pu/R15EYWWA4zHQ+9B38oYC3sD//6o=; b=sS2LlPWVwzy3DUSS63eitqOz+15b67f1rPOlchxPc7i5qVW3JbQJuEyVZPB/j2mKFX xtE39N5Hfs7kdSrW3hdWBTj744FxsV3wAOOKWhOTAQIwyzDq6zmboLkoGsETE/zWlKu8 JOYidIBKbD+8cQk2khFvxEz8h8dEJ4TGUnf39irMDfp0ZLhi7rbC7sp/c6YPAC8a3UH5 XA3A1OSw/W20loHEtt9xpPtVU8avqwwCL7pR2LD9v7UDi7yb9/PrMbfaGaRHAgeIw4QZ /nkHlkwquJTY98aAj0bsc5Z/t2CIioxj/WuEToJiFMimj5FHKBXXEZhPQrpONHdl7iBs DKVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=sE+oeyJY; 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 t23-v6si6068137plr.48.2018.09.28.16.49.10; Fri, 28 Sep 2018 16:49:24 -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=sE+oeyJY; 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 S1727496AbeI2GNa (ORCPT + 99 others); Sat, 29 Sep 2018 02:13:30 -0400 Received: from mail-pf1-f201.google.com ([209.85.210.201]:49915 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727395AbeI2GN3 (ORCPT ); Sat, 29 Sep 2018 02:13:29 -0400 Received: by mail-pf1-f201.google.com with SMTP id a4-v6so8946624pfi.16 for ; Fri, 28 Sep 2018 16:47:23 -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=Bkui6iSebkHx1Pu/R15EYWWA4zHQ+9B38oYC3sD//6o=; b=sE+oeyJY30ic3FHYY+smQoR4/jYzJ2E91PND7YCl1IM8oyvJ4+dt555MSulAOaCSCQ Vpzel0v4GlyCyaaF5iRF18oJjU5VKq1Le5GuocdGXzZB4IWmgvn9JG3pzfRjHT5ElM5u vU+LSVOGdk/fwrDFd7YshAvq68QMH1+h2KFySeIgLoQrwsd6qo7S9Y0FPS1z3ij0u7iK e31bXTezWAaUdDo6r1f1+gaIlYT/SLskoNXzcq/alL8+tFP5yYkceiGjHVAtlNSJCgnU i8YBf9cpDeHT+RsHBTCDY17WfFy4oGs+chVfFYjnTWCVrRRJRwKuVVN5lgyA1Pfb5mgv Wsew== 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=Bkui6iSebkHx1Pu/R15EYWWA4zHQ+9B38oYC3sD//6o=; b=EIMVJ9dyPg+C1LKXdu7SVPr74FKDuGvLn40A0V/bEFvuylT+agl1RKcT7AnDP3ClAB kfwfW/ESZ2XaZ/LwcqoflB0NM19SjoCR7930MJWnaDO58rZ/hs2oXij3+AhoT1Sj2+BJ Lyp8P+9Te7rxxdS/Oeh4fkuKasEFhakMWRV95tABopIm79Fa3pP8jA205rnZSDrfWa+z S+ILMXD+r8kbvn6Khs7E6eO2l71NaxLnu52AokC2f2MA8ax+Ga1l3ZkbbrKlSx5hgSog gL57bKst7l/n8BL0iYnGEcqM/Mme7UDxzqQKqAz82E196HoSq6BKFy/fg6IZdTLK7+hr 1Vmg== X-Gm-Message-State: ABuFfoiLGNiyIHqANvDAg1BmG6R38hAXT6fud2JJvOjOlQ1p1vmfkCVY UTF3ZFh3OFjD/DzWgX9ILINUcZPV/8w= X-Received: by 2002:a65:60cc:: with SMTP id r12-v6mr794209pgv.78.1538178443346; Fri, 28 Sep 2018 16:47:23 -0700 (PDT) Date: Fri, 28 Sep 2018 16:47:03 -0700 In-Reply-To: <20180928234703.15970-1-badhri@google.com> Message-Id: <20180928234703.15970-3-badhri@google.com> Mime-Version: 1.0 References: <20180928234703.15970-1-badhri@google.com> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog Subject: [PATCH 3/3] [PATCH v2 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 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 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.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index c3ac0e46106b4..c25a69922ee6a 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/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