Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp716645imm; Thu, 13 Sep 2018 06:45:18 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbiStJ6v1z0e9gHBuonxoaJ8nw73WHG7FuBW7gNiKoIhS1ymVWf7O00wel1bDMRtqgBW70d X-Received: by 2002:a62:1c7:: with SMTP id 190-v6mr7566805pfb.1.1536846318709; Thu, 13 Sep 2018 06:45:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846318; cv=none; d=google.com; s=arc-20160816; b=pI+ts452Po7ckWMclRNNUqROuguxyEit+oaeTRe8b4AAT9ACc8yyx+H4JxXDvjrLel fh615QiU6P0UzUGMf6+9JN5fYRxm3HmfvLiGZHhbEVsXACJk1ZOgbDhFIFH/Dbcsnx0v F08gftjs+yhHvJ+18ECBv8pWqSjkUY+zNGhLOXIQLhopc5D2DQtYsCvV3Ml4o9C4m70I qKOuG+5DxjcNxNdD6TcMeptTmN9DKafSt/cp47PV81B61S57Mujdv4WU1CyuhLsvrDky Cr+XIzwbh+HAydAqys6KEbDm2eVpYzugQneTK6ivoR77ib3JO0ARrdCsH66dgLOUqI7q gUvw== 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=6YWxzqETBOQqt9hsvagVoYUtnYSuf068RtdNyNkt+Is=; b=W+bc1KczRVCSnWjrnUxZxwh1YAWQbC7/CLNnY/E9Tt/dB1l+/ggrxqy2dGfg/rawe1 vFVIuHpn8Y4hamrXWR09FiD7Z3WqgmcUlZjxPK+U34gMNtl2n2rydycoQ2IQFsk1nvxe 06SgEgkIt9iX/kxlFqUb9Lvl827UYtg5bReUo754LiD4TQHAASz6+GPvJ9OsZ6b/+KXs fDd4s2mRq8Pm66r4Y7xaqt8Smp7ptvUXIjREXLoKnz8Nb3fjCQwgPd6Iz5BqSyFiCYfP m2b9HFMnBrhXOoNvUT4uH7TfgJz1xMtjqEbXzg9939ZMBU7/g/WQbmlNm+ECZBw3e9Xy GGWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GRgs1S3J; 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 j9-v6si4281931pgm.428.2018.09.13.06.45.03; Thu, 13 Sep 2018 06:45:18 -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=GRgs1S3J; 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 S1729903AbeIMSxS (ORCPT + 99 others); Thu, 13 Sep 2018 14:53:18 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:46379 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728932AbeIMSxR (ORCPT ); Thu, 13 Sep 2018 14:53:17 -0400 Received: by mail-oi0-f66.google.com with SMTP id y207-v6so9394433oie.13 for ; Thu, 13 Sep 2018 06:43:46 -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=6YWxzqETBOQqt9hsvagVoYUtnYSuf068RtdNyNkt+Is=; b=GRgs1S3J1AMD0yDzkKBNj3ajz/sBNblOCzXZMvhGo5bvGvzGv6mESjsH3SqIm+Uicg lvbOW6oxX6XRHZtVfDQJ/+/fMsFDmeVEBLeRAL46KEXwqL8x8QYtDfoov/n3cxtKvHCL 1JiGSp388n5lar8b15J6WFs2veLOj4sqvMOP1880HBqv0WnhhpGOvU59Owo4CzTMr1Wl EO2W+DCjBkgPeDc0DqlwGTz3O9eXinak8UURdexQWFRXlg4N7i0sj2WRy1bXWJ7U90YJ 2LNvR32xIcEjfJ0QGshCTR6uMcMxxjfuBqzEdMoIwqAjhANPmeQt6JEIQhYBFxo1pLdX 96cw== 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=6YWxzqETBOQqt9hsvagVoYUtnYSuf068RtdNyNkt+Is=; b=o4MTRQYnaKyb4vYHdDbFM39BsNV9sPXqlC2lANXo6CPkjmQWjRGi8kPj6HFA3ZhG4f OZ99SaNguF9DELtUryrPkbfhSnbd1F0gyShLc+ToES2RQadwGeY4yde6bdkWrTz6NTKm 8/OLYoj01Ej/1kpHb6va6FXrELi0J/3Pwwn+jPsOqgKupw0R9fMF07eSchwWBiSEkbqU 6f1OETd1sekB7QOO8DF5wuxJ1W/zzSmEZMVViIBzVbGXzdVzR50SLCgDLpkEiO5RZiMN YE4ZLKK7EGrtd13riMX+4Uy6r0bxhv3eG4sDByyGh1jc4MAmZD08/AY+87DLR1MOVDTo hgfQ== X-Gm-Message-State: APzg51CGJNSdOlJZNi+7immF3n8T6uoUB/B3Yg1BYm+oQhNOGeglczUc rJ3NwmWa9hU8mKaVhbR8z1UQj2lTBBGkSp0p32mb9A== X-Received: by 2002:aca:f0a:: with SMTP id 10-v6mr6209348oip.183.1536846225191; Thu, 13 Sep 2018 06:43:45 -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: <20180913063943.GA13306@jackp-linux.qualcomm.com> From: Badhri Jagan Sridharan Date: Thu, 13 Sep 2018 06:43:09 -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 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 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