From mboxrd@z Thu Jan 1 00:00:00 1970 From: Guenter Roeck Subject: Re: [PATCH v4 10/13] usb: typec: tcpm: set cc for drp toggling attach Date: Thu, 29 Mar 2018 15:49:00 -0700 Message-ID: <20180329224900.GA6701@roeck-us.net> References: <1522253178-32414-1-git-send-email-jun.li@nxp.com> <1522253178-32414-11-git-send-email-jun.li@nxp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1522253178-32414-11-git-send-email-jun.li@nxp.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" To: Li Jun Cc: devel@driverdev.osuosl.org, peter.chen@nxp.com, heikki.krogerus@linux.intel.com, devicetree@vger.kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, a.hajda@samsung.com, robh+dt@kernel.org, linux-imx@nxp.com, shufan_lee@richtek.com List-Id: devicetree@vger.kernel.org On Thu, Mar 29, 2018 at 12:06:15AM +0800, Li Jun wrote: > In case of drp toggling, we may need set correct cc value for role control > after attach as it may never been set. > Isn't CC set by the lower level driver in this case ? In other words, is it ever necessary to call back into the low level driver to set CC again ? Doing that in attached state seems a bit late. It may make more sense to update port->cc_req when the state machine leaves DRP_TOGGLING state, ie in _tcpm_cc_change(), and to do it without callback into the low level driver (it should not be necessary). Guenter > Signed-off-by: Li Jun > --- > drivers/usb/typec/tcpm.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c > index 218c230..72d4232 100644 > --- a/drivers/usb/typec/tcpm.c > +++ b/drivers/usb/typec/tcpm.c > @@ -2126,6 +2126,7 @@ static void tcpm_reset_port(struct tcpm_port *port) > tcpm_set_attached_state(port, false); > port->try_src_count = 0; > port->try_snk_count = 0; > + port->cc_req = 0; > } > > static void tcpm_detach(struct tcpm_port *port) > @@ -2361,6 +2362,8 @@ static void run_state_machine(struct tcpm_port *port) > break; > > case SRC_ATTACHED: > + if (!port->cc_req) > + tcpm_set_cc(port, tcpm_rp_cc(port)); > ret = tcpm_src_attach(port); > tcpm_set_state(port, SRC_UNATTACHED, > ret < 0 ? 0 : PD_T_PS_SOURCE_ON); > @@ -2531,6 +2534,8 @@ static void run_state_machine(struct tcpm_port *port) > tcpm_set_state(port, SNK_UNATTACHED, PD_T_PD_DEBOUNCE); > break; > case SNK_ATTACHED: > + if (!port->cc_req) > + tcpm_set_cc(port, TYPEC_CC_RD); > ret = tcpm_snk_attach(port); > if (ret < 0) > tcpm_set_state(port, SNK_UNATTACHED, 0); > -- > 2.7.4 >