Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp718272imm; Thu, 13 Sep 2018 06:46:41 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbfuqmpy07ggj/QAQOa8nf3nJwoMCHV/GPg2L4xR2nSqopHD19ffCDibHRQOGEZSLqwuUI5 X-Received: by 2002:a17:902:7009:: with SMTP id y9-v6mr7334884plk.249.1536846401860; Thu, 13 Sep 2018 06:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846401; cv=none; d=google.com; s=arc-20160816; b=O7cM7rOFoEtZOJUApmI7aIXgYxN6IE2Xhx9+Yx6w/bRjm2IXJ0H2URjs2Ajvvwbn15 hDiJXS0dDAAMhgGAz9IkKShrAvAM+CJDMcy8dsUwfNzbcZMrCuFjp8zsAxWx2ug6wWBE 4Sb4S9lj/oEKjtxiB2TGyc+glEqGLiQArqPqumE59uAFM0qhKDxk0QAqAInOFlWSC5Ei MiP6iuYB6FTrZl5nRzQoO+UuBoakxq44fwt+uVQZPVQB9k149Bla4EnZp4vibUN926ES Xtiij+a0lmoSgjrYD8yCHNHQxCPsX3XWFgGotvWNq1SMHnKBgTxeneMtAlfVAU5EzaAv BgvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=E6AI+xLHhLhosh1k8SCPRvDgwR2on1ob9kTQbtPYiHw=; b=yBoSHlYwlBKlADZ8cy8O/6ILNZ1lamoM1CWuRz7o2BnOugPeHjMEDtYpspeioyM15B J5kEND5mQ58RuwPDGSVuiHvIUh8M+sbAbPDUY8k/niLlJ87UB6lx9XNXXHUQZqg+wwWu O4cmaSFz7HZt8FXCGRGjjs2LAdQ3ZvLgV3rQLwvNos/UC4XYvM4klm5Vb7I9sbyyQVyz QX/sbUsFgf0h8ZhfuPtAQx9r2viKrLXEiPNNeLMsB8tAexy+6PuCbQx5zPNzZrVMh0fI oQAYSlr/AqGSnLo8SuL8OYazjm7KC6kyamIzS6HvRIExSDuWiYeL1wVCAJqhw9JQvF4u QBiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lsKDPONs; 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 k10-v6si3845895plt.328.2018.09.13.06.46.26; Thu, 13 Sep 2018 06:46:41 -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=lsKDPONs; 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 S1730077AbeIMSzx (ORCPT + 99 others); Thu, 13 Sep 2018 14:55:53 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:35699 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728479AbeIMSzv (ORCPT ); Thu, 13 Sep 2018 14:55:51 -0400 Received: by mail-oi0-f67.google.com with SMTP id m11-v6so9499041oic.2 for ; Thu, 13 Sep 2018 06:46:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=E6AI+xLHhLhosh1k8SCPRvDgwR2on1ob9kTQbtPYiHw=; b=lsKDPONs78XTqeBkUm1xgyg4ViI6rZUMcfuo8n2nuyzXnvuoN0S3sO5xkxUpIi83il SEAbdxzpKnkHPPj6XT9tIHnnLDZ76WyGTiMCBPM3AGMWaOtD0wjyAVrZyP5VEbdF7yEt fdUK67C7tV+yZzD6F8xK5CLaH09b5VBWahZ2Shtt4Ba7OhqFb31eUGZ7jhWikn6KPh70 7TJUBtWcTaDC2q+KboXCqPjqI4oPVhbc9bgH8JSSm7QbMfhciz1oROKBsWcTaT4RdF+3 USLhOkZSwBfUYyLzlWqWU8W5Ulfg174HsdGtBIIPgDo1UXKJpA0qoRiiku+bkKM8mIYz yBBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=E6AI+xLHhLhosh1k8SCPRvDgwR2on1ob9kTQbtPYiHw=; b=num7kbMs/AAiJyVf+Zj5fBsGO8KFTwcCsswwYrMVdIR5DKVv99ptFwl+VCfA+Fj0nS BWxSb4Zpyteq/CDGIxjp++Cc3rHaqnfS42bbFbxp6yTLicwyViVI0eUUZQYaK8KsaBOW KD7dVvWj4VLtVpNBCblZQO9khK8UDMxBwUmrDKi+5efZZw6yKHMYVRw17+RVLZWXNTo6 m4Tf3b0Xe8dWEA6Zrj9rhtVuU28HKdBD88D2P5oTBederuioc95P70RcR9WNIDhjsIHA GGpzhshtbrvrVh5xEYZtD/CMHjeht7VUm9KaFJ/ucQLA6B0W4f68bajUtBPPVgG/P+C0 fHLA== X-Gm-Message-State: APzg51DlmP4E5DuZpLe8XaHuEc94whQH+N3VxERjB4um7QboHV9K1aha bLE3dpicMyYeoDOhLmnN934pOsQysfeb9rd7Oe4yxA== X-Received: by 2002:aca:f0a:: with SMTP id 10-v6mr6215750oip.183.1536846377954; Thu, 13 Sep 2018 06:46:17 -0700 (PDT) MIME-Version: 1.0 References: <20180913021113.18150-1-badhri@google.com> <20180913021113.18150-2-badhri@google.com> <20180913063943.GA13306@jackp-linux.qualcomm.com> In-Reply-To: From: Badhri Jagan Sridharan Date: Thu, 13 Sep 2018 06:45:41 -0700 Message-ID: Subject: Re: [PATCH 2/2] typec: tcpm: Add option to maintain current limit at Vsafe5V To: jackp@codeaurora.org Cc: Heikki Krogerus , Greg Kroah-Hartman , USB , LKML , Guenter Roeck 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 + Guenter On Thu, Sep 13, 2018 at 6:43 AM Badhri Jagan Sridharan wrote: > > On Wed, Sep 12, 2018 at 11:39 PM Jack Pham wrote: > > > > Hello Badhri, > > > > On Wed, Sep 12, 2018 at 07:11:13PM -0700, Badhri Jagan Sridharan wrote: > > > During hard reset, TCPM turns off the charging path. > > > The spec provides an option for Sink to either drop to vSafe5V or vSafe0V. > > > > This doesn't make sense. By definition the sink isn't sourcing VBUS, so > > how can it control whether to allow the voltage to be 5V or 0V? > > The way I understand it, this is for the current limits that can be > set on the Sink side. > During hard reset, sink has to fallback to VSafe5V or VSafe0V if > higher pd contract was negotiated. > > > > > > > > From USB_PD_R3_0 > > > 2.6.2 Sink Operation > > > .. > > > Serious errors are handled by Hard Reset Signaling issued by either Port > > > Partner. A Hard Reset: > > > resets protocol as for a Soft Reset but also returns the power supply to > > > USB Default Operation (vSafe0V or vSafe5V output) in order to protect the > > > Sink. > > > > I can see how the wording here "vSafe0V *or* vSafe5V" is misleading, as > > I think it actually is both. In later parts of the spec, the source's > > VBUS behavior is well defined in that it must first drop to vSafe0V > > and then return to vSafe5V. Please refer to section 7.1.5. > > > Yeah thats for the source. But for sink, Say if the source isnt PD, then, > sink initiated hard resets happen during the connection. Sink would hard reset > couple of times before deeming that the partner is non PD. When connected > to Type-A ports/non-pd partner, vbus is not going to likely drop so there isnt > a reason to setcharge to false or drop the input current limit. Do you agree ? > > > > > > > > Add a config option to tcpc_dev and let the device specific driver decide > > > what needs to be done. > > > > > > Signed-off-by: Badhri Jagan Sridharan > > > --- > > > drivers/usb/typec/tcpm.c | 7 ++++++- > > > include/linux/usb/tcpm.h | 1 + > > > 2 files changed, 7 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c > > > index a4e0c027a2a9..350d1a7c4543 100644 > > > --- a/drivers/usb/typec/tcpm.c > > > +++ b/drivers/usb/typec/tcpm.c > > > @@ -3269,7 +3269,12 @@ 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->tcpc->config->vsafe_5v_hard_reset) > > > > Therefore I think this config option doesn't make sense. > > > > > + tcpm_set_current_limit(port, > > > + tcpm_get_current_limit(port), > > > + 5000); > > > > But I do think this might still be useful at least in ensuring the sink > > returns to drawing only default power during the transition before > > re-establishing a contract. Given that the sink can't control when > > exactly VBUS will go to 0V, is it ok to call set_current_limit() even if > > VBUS is momentarily 0V, so at least it is in preparation for when VBUS > > turns back on? Or would it be safer to do it during the > > SNK_HARD_RESET_SINK_ON state after we know VBUS is back to vSafe5V? > > IMHO Doing it in SNK_HARD_RESET_SINK_ON makes more sense when > vsafe_5v_hard_reset > is not set. > > > > > > > > + else > > > + tcpm_set_charge(port, false); > > > > Regards, > > Jack > > -- > > The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, > > a Linux Foundation Collaborative Project