Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp715377pxj; Wed, 16 Jun 2021 11:52:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFq9lKeW9qirZhC6kKnDVitWBjZRcfooEdWRBakm4JFY0DVLhO0vMrDM0OzKxKHEuToC6T X-Received: by 2002:a05:6638:1202:: with SMTP id n2mr746407jas.57.1623869530889; Wed, 16 Jun 2021 11:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623869530; cv=none; d=google.com; s=arc-20160816; b=EUsP0pvgw2lrlYy2BTzgnL9XYG+/wf9QNuwimvmHP6U/vqT97kqgoCw0XITC7vmLDn de+ATwlimD9lDoN/bE40cc9AinYL+HeC4dBakl5Zx7ZbtPBODbIZR7HN4jbKLtSxaK1D 5OLUy7J0r6Bnx/EDGZzc9fI2o0CV1sW86AxS9l7+6okqfZ4GjSldvIHXToGG8SvzVpIu JpCdh5d4gfnKGvn1g03wn4L+gZqeT86hojzy1XlvRvkyAplXUSZxA0gkbBlJT8jbejWS IiNQUsa6+upB12hlExejXG4T6qra2yKjgjOX/8bsY9ZkEc1HFNH3/I351WiRYzvaxz9A fiPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=ISyNkjhoR3Lva7aU2fMOpeCG2IcTsggM9GLxFT4M8Zc=; b=F1qohBvVhmmKEhyEuo5iOZLrhhxOgmrim6N1DYmTxL5Y8DRnrKi7kmSL5tocZqwV6Q l1elnB1jSJMDNflrEmi4sSuyBtmsPXSWqBaSoq8O07WPXXNXNKyg/bZaWRABv9xPohWp 8LaRQAikNviZGmWOV5tO2Zv04MnjhC8EGf54GqozWq+wfFFqS3JkEkZ5gKW9E+NvE+Zy mJsJLsq7Z5Jq5TvX9M8rW0JTW5mtv/qRQSjZDILIo7K5OyXh3AsKRvXJTncUgiiLY+Ib Oivsi3BLjgfsJntjxhubbguTyJD2Gb72jplz0sNJuWMYezsK4tA3OUUoPyO1xmOBl8em s4Qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y5si3352324ioq.102.2021.06.16.11.51.59; Wed, 16 Jun 2021 11:52:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232732AbhFPNnL (ORCPT + 99 others); Wed, 16 Jun 2021 09:43:11 -0400 Received: from mga11.intel.com ([192.55.52.93]:6739 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233162AbhFPNnI (ORCPT ); Wed, 16 Jun 2021 09:43:08 -0400 IronPort-SDR: cdU14Jz4ghW37p3YToV4VZ6GisTpFme2FHdyaZnZtrUiXn4Wy2093K/aXaJcDV8SkwqQmRREzE EQmp2IvMVgNg== X-IronPort-AV: E=McAfee;i="6200,9189,10016"; a="203154409" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="203154409" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 06:40:42 -0700 IronPort-SDR: Lt07RJrdxe5oOrfZmM+ZpHT4AIw0XB/Z9/g/TyrMb9KXvSXMSRmUpNkEjbqEWfdRgR1Xmgw7lu mCQBv1C0BtBw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="554809828" Received: from kuha.fi.intel.com ([10.237.72.162]) by fmsmga001.fm.intel.com with SMTP; 16 Jun 2021 06:40:39 -0700 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Wed, 16 Jun 2021 16:40:39 +0300 Date: Wed, 16 Jun 2021 16:40:38 +0300 From: Heikki Krogerus To: Badhri Jagan Sridharan Cc: Guenter Roeck , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Tso , stable@vger.kernel.org Subject: Re: [PATCH v1] usb: typec: tcpci: Fix up sink disconnect thresholds for PD Message-ID: References: <20210615174323.1160132-1-badhri@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210615174323.1160132-1-badhri@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 15, 2021 at 10:43:23AM -0700, Badhri Jagan Sridharan wrote: > "Table 4-3 VBUS Sink Characteristics" of "Type-C Cable and Connector > Specification" defines the disconnect voltage thresholds of various > configurations. This change fixes the disconnect threshold voltage > calculation based on vSinkPD_min and vSinkDisconnectPD as defined > by the table. > > Fixes: e1a97bf80a022 ("usb: typec: tcpci: Implement Auto discharge disconnect callbacks") > Signed-off-by: Badhri Jagan Sridharan Acked-by: Heikki Krogerus > --- > drivers/usb/typec/tcpm/tcpci.c | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) > > diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c > index 22862345d1ab..9858716698df 100644 > --- a/drivers/usb/typec/tcpm/tcpci.c > +++ b/drivers/usb/typec/tcpm/tcpci.c > @@ -21,8 +21,12 @@ > #define PD_RETRY_COUNT_DEFAULT 3 > #define PD_RETRY_COUNT_3_0_OR_HIGHER 2 > #define AUTO_DISCHARGE_DEFAULT_THRESHOLD_MV 3500 > -#define AUTO_DISCHARGE_PD_HEADROOM_MV 850 > -#define AUTO_DISCHARGE_PPS_HEADROOM_MV 1250 > +#define VSINKPD_MIN_IR_DROP_MV 750 > +#define VSRC_NEW_MIN_PERCENT 95 > +#define VSRC_VALID_MIN_MV 500 > +#define VPPS_NEW_MIN_PERCENT 95 > +#define VPPS_VALID_MIN_MV 100 > +#define VSINKDISCONNECT_PD_MIN_PERCENT 90 > > #define tcpc_presenting_rd(reg, cc) \ > (!(TCPC_ROLE_CTRL_DRP & (reg)) && \ > @@ -351,11 +355,13 @@ static int tcpci_set_auto_vbus_discharge_threshold(struct tcpc_dev *dev, enum ty > threshold = AUTO_DISCHARGE_DEFAULT_THRESHOLD_MV; > } else if (mode == TYPEC_PWR_MODE_PD) { > if (pps_active) > - threshold = (95 * requested_vbus_voltage_mv / 100) - > - AUTO_DISCHARGE_PD_HEADROOM_MV; > + threshold = ((VPPS_NEW_MIN_PERCENT * requested_vbus_voltage_mv / 100) - > + VSINKPD_MIN_IR_DROP_MV - VPPS_VALID_MIN_MV) * > + VSINKDISCONNECT_PD_MIN_PERCENT / 100; > else > - threshold = (95 * requested_vbus_voltage_mv / 100) - > - AUTO_DISCHARGE_PPS_HEADROOM_MV; > + threshold = ((VSRC_NEW_MIN_PERCENT * requested_vbus_voltage_mv / 100) - > + VSINKPD_MIN_IR_DROP_MV - VSRC_VALID_MIN_MV) * > + VSINKDISCONNECT_PD_MIN_PERCENT / 100; > } else { > /* 3.5V for non-pd sink */ > threshold = AUTO_DISCHARGE_DEFAULT_THRESHOLD_MV; > -- > 2.32.0.272.g935e593368-goog -- heikki