From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 420B4C433F5 for ; Tue, 11 Jan 2022 09:19:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349195AbiAKJTD (ORCPT ); Tue, 11 Jan 2022 04:19:03 -0500 Received: from mga04.intel.com ([192.55.52.120]:1927 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236775AbiAKJTD (ORCPT ); Tue, 11 Jan 2022 04:19:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1641892743; x=1673428743; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=EeoQc6pt57l7P58d0yw85g0sKFKZur/luE+GMJh9eX4=; b=P7/lS1X7u2jRTynK98EOYi2oWJHI+YztSLsUsV6fDSQyBjduj1fewJlK KjjcemfedutU3ocEH9mWXNALrwZO6yJGkrtZiQAOoeg3izw92vaHpy3/+ 5xJMC8lexcwXgHVxrrOMrDSQfyrBQwlKf0LsP1hgpxo0HhG+aE+oT5oUx qyrLtjDruBT9JVKa2xBej6RJ1tPc931LccLUAXMwnRtIeGXHYIqCWepzv 75yAoble/Wa3NoHsGLwUMJtaZtya0rBc87qHSSan9tbZPyJmpgBquYvUl agafbzUQFo/c5yMcsurrK8yciTfANy5vBqw6fgDeGNgimjfDZrWFsPmUq Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10223"; a="242255865" X-IronPort-AV: E=Sophos;i="5.88,279,1635231600"; d="scan'208";a="242255865" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jan 2022 01:19:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,279,1635231600"; d="scan'208";a="669757448" Received: from kuha.fi.intel.com ([10.237.72.185]) by fmsmga001.fm.intel.com with SMTP; 11 Jan 2022 01:19:00 -0800 Received: by kuha.fi.intel.com (sSMTP sendmail emulation); Tue, 11 Jan 2022 11:18:59 +0200 Date: Tue, 11 Jan 2022 11:18:59 +0200 From: Heikki Krogerus To: Xu Yang Cc: "linux@roeck-us.net" , "gregkh@linuxfoundation.org" , "linux-usb@vger.kernel.org" , Jun Li , dl-linux-imx Subject: Re: [EXT] Re: [PATCH] usb: typec: tcpci: don't touch CC line which source Vconn Message-ID: References: <20220106085325.1353591-1-xu.yang_2@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On Tue, Jan 11, 2022 at 04:43:42AM +0000, Xu Yang wrote: > Hi, > > > > > I'm sorry, but I did not understand the subject line? > > > > On Thu, Jan 06, 2022 at 04:53:25PM +0800, Xu Yang wrote: > > > With the AMS and Collision Avoidance, tcpm often needs to change the > > CC's > > > termination. When one CC line is souring Vconn, if we still change its > > > termination, the voltage of the another CC line is likely to be fluctuant > > > and unstable. > > > > > > Therefore, we should verify whether a CC line is soucing Vconn before > > > changing its termination. And only changing the termination that is > > > not a Vconn line. This can be done by reading the VCONN Present bit of > > > POWER_ STATUS register. To determinate the polarity, we can read the > > > Plug Orientation bit of TCPC_CONTROL register. Since only if Plug > > > Orientation is set, Vconn can be sourced. > > > > > > Fixes: 0908c5aca31e ("usb: typec: tcpm: AMS and Collision Avoidance") > > > cc: > > > Signed-off-by: Xu Yang > > > > Okay, the commit message does explain what's this about, but could you > > still change the subject to "..don't touch the CC line if it's VCONN > > source" or something like that? > > Sorry for the puzzling title, I will change it in the next formal patch. > > > > > > --- > > > drivers/usb/typec/tcpm/tcpci.c | 27 +++++++++++++++++++++++++++ > > > drivers/usb/typec/tcpm/tcpci.h | 1 + > > > 2 files changed, 28 insertions(+) > > > > > > diff --git a/drivers/usb/typec/tcpm/tcpci.c > > b/drivers/usb/typec/tcpm/tcpci.c > > > index 35a1307349a2..0bf4cbfaa21c 100644 > > > --- a/drivers/usb/typec/tcpm/tcpci.c > > > +++ b/drivers/usb/typec/tcpm/tcpci.c > > > @@ -75,9 +75,26 @@ static int tcpci_write16(struct tcpci *tcpci, unsigned > > int reg, u16 val) > > > static int tcpci_set_cc(struct tcpc_dev *tcpc, enum typec_cc_status cc) > > > { > > > struct tcpci *tcpci = tcpc_to_tcpci(tcpc); > > > + bool vconn_pres = false; > > > + enum typec_cc_polarity polarity = TYPEC_POLARITY_CC1; > > > unsigned int reg; > > > int ret; > > > > > > + ret = regmap_read(tcpci->regmap, TCPC_POWER_STATUS, ®); > > > + if (ret < 0) > > > + return ret; > > > + > > > + if (reg & TCPC_POWER_STATUS_VCONN_PRES) { > > > > Isn't that bit optional? tcpm.c already knows the vconn status, right? > > If it does, then maybe it would be safer to change the API so that you > > pass also the information about the vconn status to the .set_cc > > callback? So in this case: > > > > static int tcpci_set_cc(struct tpcp_dev *tcpc, enum typec_cc_status cc, enum > > typec_role vconn) > > > > That way the support would also be for all the other drivers too, so > > not just for tcpci.c. > > Yeah, it's better to change the API in the tcpm.c. But from to my observation, > other drivers already have their own implementation to set CC's termination. > > For fusb302: > It use chip->cc_polarity to choose which CC line to be changed. > > For wcove: > It only changes one CC's termination at one time. > > So, there is no such a problem for them with the AMS and Collision Avoidance. > In tcpci, this problem appears because two CC's termination are changed at the > same time even though Vconn enabled. > > Therefore, I'm not sure the API in tcpm should be changed or only tcpci driver > should be changed at this case. Any suggestion for this? Well, if this is only a problem for tcpci.c, then I guess API change would not make much sense. Maybe we can just go with this for now. thanks, -- heikki