All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Li Jun <jun.li@nxp.com>
Cc: robh+dt@kernel.org, gregkh@linuxfoundation.org,
	heikki.krogerus@linux.intel.com, a.hajda@samsung.com,
	shufan_lee@richtek.com, peter.chen@nxp.com,
	devicetree@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-imx@nxp.com, devel@driverdev.osuosl.org
Subject: [v4,10/13] usb: typec: tcpm: set cc for drp toggling attach
Date: Thu, 29 Mar 2018 15:49:00 -0700	[thread overview]
Message-ID: <20180329224900.GA6701@roeck-us.net> (raw)

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 <jun.li@nxp.com>
> ---
>  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
>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Guenter Roeck <linux@roeck-us.net>
To: Li Jun <jun.li@nxp.com>
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
Subject: Re: [PATCH v4 10/13] usb: typec: tcpm: set cc for drp toggling attach
Date: Thu, 29 Mar 2018 15:49:00 -0700	[thread overview]
Message-ID: <20180329224900.GA6701@roeck-us.net> (raw)
In-Reply-To: <1522253178-32414-11-git-send-email-jun.li@nxp.com>

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 <jun.li@nxp.com>
> ---
>  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
> 

             reply	other threads:[~2018-03-29 22:49 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-29 22:49 Guenter Roeck [this message]
2018-03-29 22:49 ` [PATCH v4 10/13] usb: typec: tcpm: set cc for drp toggling attach Guenter Roeck
  -- strict thread matches above, loose matches on Subject: below --
2018-05-01  7:57 [v4,01/13] dt-bindings: connector: add properties for typec Jun Li
2018-05-01  7:57 ` [PATCH v4 01/13] " Jun Li
2018-05-01  7:54 [v4,02/13] dt-bindings: usb: add documentation for typec port controller(TCPCI) Jun Li
2018-05-01  7:54 ` [PATCH v4 02/13] " Jun Li
2018-04-30 11:23 [v4,01/13] dt-bindings: connector: add properties for typec Heikki Krogerus
2018-04-30 11:23 ` [PATCH v4 01/13] " Heikki Krogerus
2018-04-30  7:41 [v4,02/13] dt-bindings: usb: add documentation for typec port controller(TCPCI) Mats Karrman
2018-04-30  7:41 ` [PATCH v4 02/13] " Mats Karrman
2018-04-19 14:47 [v4,02/13] " Jun Li
2018-04-19 14:47 ` [PATCH v4 02/13] " Jun Li
2018-04-16 14:28 [v4,02/13] " Rob Herring
2018-04-16 14:28 ` [PATCH v4 02/13] " Rob Herring
2018-04-16 11:54 [v4,02/13] " Jun Li
2018-04-16 11:54 ` [PATCH v4 02/13] " Jun Li
2018-04-13 11:51 [v4,01/13] dt-bindings: connector: add properties for typec Jun Li
2018-04-13 11:51 ` [PATCH v4 01/13] " Jun Li
2018-04-09 20:04 [v4,02/13] dt-bindings: usb: add documentation for typec port controller(TCPCI) Rob Herring
2018-04-09 20:04 ` [PATCH v4 02/13] " Rob Herring
2018-04-03  8:29 [v4,01/13] dt-bindings: connector: add properties for typec Andrzej Hajda
2018-04-03  8:29 ` [PATCH v4 01/13] " Andrzej Hajda
2018-03-31  8:01 [v4,07/13] staging: typec: tcpci: register port before request irq Dan Carpenter
2018-03-31  8:01 ` [PATCH v4 07/13] " Dan Carpenter
2018-03-31  4:49 [v4,11/13] staging: typec: tcpci: keep the not connecting cc line open Jun Li
2018-03-31  4:49 ` [PATCH v4 11/13] " Jun Li
2018-03-31  4:38 [v4,10/13] usb: typec: tcpm: set cc for drp toggling attach Jun Li
2018-03-31  4:38 ` [PATCH v4 10/13] " Jun Li
2018-03-31  3:37 [v4,10/13] " Jun Li
2018-03-31  3:37 ` [PATCH v4 10/13] " Jun Li
2018-03-31  3:34 [v4,01/13] dt-bindings: connector: add properties for typec Jun Li
2018-03-31  3:34 ` [PATCH v4 01/13] " Jun Li
2018-03-31  3:17 [v4,04/13] usb: typec: add fwnode to tcpc Jun Li
2018-03-31  3:17 ` [PATCH v4 04/13] " Jun Li
2018-03-31  3:09 [v4,07/13] staging: typec: tcpci: register port before request irq Jun Li
2018-03-31  3:09 ` [PATCH v4 07/13] " Jun Li
2018-03-30 15:15 [v4,11/13] staging: typec: tcpci: keep the not connecting cc line open Guenter Roeck
2018-03-30 15:15 ` [PATCH v4 11/13] " Guenter Roeck
2018-03-29 21:18 [v4,10/13] usb: typec: tcpm: set cc for drp toggling attach Mats Karrman
2018-03-29 21:18 ` [PATCH v4 10/13] " Mats Karrman
2018-03-29 19:54 [v4,01/13] dt-bindings: connector: add properties for typec Mats Karrman
2018-03-29 19:54 ` [PATCH v4 01/13] " Mats Karrman
2018-03-29 12:57 [v4,04/13] usb: typec: add fwnode to tcpc Heikki Krogerus
2018-03-29 12:57 ` [PATCH v4 04/13] " Heikki Krogerus
2018-03-29 10:52 [v4,07/13] staging: typec: tcpci: register port before request irq Dan Carpenter
2018-03-29 10:52 ` [PATCH v4 07/13] " Dan Carpenter
2018-03-28 16:06 [v4,13/13] staging: typec: tcpci: move tcpci driver out of staging Jun Li
2018-03-28 16:06 ` [PATCH v4 13/13] " Li Jun
2018-03-28 16:06 [v4,12/13] staging: typec: tcpci: Only touch target bit when enable vconn Jun Li
2018-03-28 16:06 ` [PATCH v4 12/13] " Li Jun
2018-03-28 16:06 [v4,11/13] staging: typec: tcpci: keep the not connecting cc line open Jun Li
2018-03-28 16:06 ` [PATCH v4 11/13] " Li Jun
2018-03-28 16:06 [v4,10/13] usb: typec: tcpm: set cc for drp toggling attach Jun Li
2018-03-28 16:06 ` [PATCH v4 10/13] " Li Jun
2018-03-28 16:06 [v4,09/13] typec: tcpm: add starting value for drp toggling Jun Li
2018-03-28 16:06 ` [PATCH v4 09/13] " Li Jun
2018-03-28 16:06 [v4,08/13] staging: typec: tcpci: enable vbus detection Jun Li
2018-03-28 16:06 ` [PATCH v4 08/13] " Li Jun
2018-03-28 16:06 [v4,07/13] staging: typec: tcpci: register port before request irq Jun Li
2018-03-28 16:06 ` [PATCH v4 07/13] " Li Jun
2018-03-28 16:06 [v4,06/13] usb: typec: tcpm: support get typec and pd config from device properties Jun Li
2018-03-28 16:06 ` [PATCH v4 06/13] " Li Jun
2018-03-28 16:06 [v4,05/13] usb: typec: add API to get typec basic port power and data config Jun Li
2018-03-28 16:06 ` [PATCH v4 05/13] " Li Jun
2018-03-28 16:06 [v4,04/13] usb: typec: add fwnode to tcpc Jun Li
2018-03-28 16:06 ` [PATCH v4 04/13] " Li Jun
2018-03-28 16:06 [v4,03/13] staging: typec: tcpci: add compatible string for nxp ptn5110 Jun Li
2018-03-28 16:06 ` [PATCH v4 03/13] " Li Jun
2018-03-28 16:06 [v4,02/13] dt-bindings: usb: add documentation for typec port controller(TCPCI) Jun Li
2018-03-28 16:06 ` [PATCH v4 02/13] " Li Jun
2018-03-28 16:06 [v4,01/13] dt-bindings: connector: add properties for typec Jun Li
2018-03-28 16:06 ` [PATCH v4 01/13] " Li Jun
2018-03-28 16:06 [PATCH v4 00/13] staging: typec: tcpci: move out of staging Li Jun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180329224900.GA6701@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=a.hajda@samsung.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jun.li@nxp.com \
    --cc=linux-imx@nxp.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=peter.chen@nxp.com \
    --cc=robh+dt@kernel.org \
    --cc=shufan_lee@richtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.