linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: typec: tcpm: move to SNK_UNATTACHED if sink removed for DRP
@ 2020-02-19 16:05 jun.li
  2020-02-19 17:15 ` Guenter Roeck
  2020-02-24 13:55 ` Heikki Krogerus
  0 siblings, 2 replies; 3+ messages in thread
From: jun.li @ 2020-02-19 16:05 UTC (permalink / raw)
  To: linux, heikki.krogerus; +Cc: gregkh, jun.li, linux-imx, linux-usb

From: Li Jun <jun.li@nxp.com>

Per typec spec:
Figure 4-15 Connection State Diagram: DRP
Figure 4-16 Connection State Diagram: DRP with Accessory and Try.SRC
	    Support
Figure 4-17 Connection State Diagram: DRP with Accessory and Try.SNK
	    Support
DRP port should move to Unattached.SNK instead of Unattached.SRC if
sink removed.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
 drivers/usb/typec/tcpm/tcpm.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 78077c2..3174180 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -3680,8 +3680,12 @@ static void _tcpm_cc_change(struct tcpm_port *port, enum typec_cc_status cc1,
 	case SRC_SEND_CAPABILITIES:
 	case SRC_READY:
 		if (tcpm_port_is_disconnected(port) ||
-		    !tcpm_port_is_source(port))
-			tcpm_set_state(port, SRC_UNATTACHED, 0);
+		    !tcpm_port_is_source(port)) {
+			if (port->port_type == TYPEC_PORT_SRC)
+				tcpm_set_state(port, SRC_UNATTACHED, 0);
+			else
+				tcpm_set_state(port, SNK_UNATTACHED, 0);
+		}
 		break;
 	case SNK_UNATTACHED:
 		if (tcpm_port_is_sink(port))
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: typec: tcpm: move to SNK_UNATTACHED if sink removed for DRP
  2020-02-19 16:05 [PATCH] usb: typec: tcpm: move to SNK_UNATTACHED if sink removed for DRP jun.li
@ 2020-02-19 17:15 ` Guenter Roeck
  2020-02-24 13:55 ` Heikki Krogerus
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2020-02-19 17:15 UTC (permalink / raw)
  To: jun.li; +Cc: heikki.krogerus, gregkh, linux-imx, linux-usb

On Thu, Feb 20, 2020 at 12:05:43AM +0800, jun.li@nxp.com wrote:
> From: Li Jun <jun.li@nxp.com>
> 
> Per typec spec:
> Figure 4-15 Connection State Diagram: DRP
> Figure 4-16 Connection State Diagram: DRP with Accessory and Try.SRC
> 	    Support
> Figure 4-17 Connection State Diagram: DRP with Accessory and Try.SNK
> 	    Support
> DRP port should move to Unattached.SNK instead of Unattached.SRC if
> sink removed.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/usb/typec/tcpm/tcpm.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 78077c2..3174180 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -3680,8 +3680,12 @@ static void _tcpm_cc_change(struct tcpm_port *port, enum typec_cc_status cc1,
>  	case SRC_SEND_CAPABILITIES:
>  	case SRC_READY:
>  		if (tcpm_port_is_disconnected(port) ||
> -		    !tcpm_port_is_source(port))
> -			tcpm_set_state(port, SRC_UNATTACHED, 0);
> +		    !tcpm_port_is_source(port)) {
> +			if (port->port_type == TYPEC_PORT_SRC)
> +				tcpm_set_state(port, SRC_UNATTACHED, 0);
> +			else
> +				tcpm_set_state(port, SNK_UNATTACHED, 0);
> +		}
>  		break;
>  	case SNK_UNATTACHED:
>  		if (tcpm_port_is_sink(port))
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: typec: tcpm: move to SNK_UNATTACHED if sink removed for DRP
  2020-02-19 16:05 [PATCH] usb: typec: tcpm: move to SNK_UNATTACHED if sink removed for DRP jun.li
  2020-02-19 17:15 ` Guenter Roeck
@ 2020-02-24 13:55 ` Heikki Krogerus
  1 sibling, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2020-02-24 13:55 UTC (permalink / raw)
  To: jun.li; +Cc: linux, gregkh, linux-imx, linux-usb

On Thu, Feb 20, 2020 at 12:05:43AM +0800, jun.li@nxp.com wrote:
> From: Li Jun <jun.li@nxp.com>
> 
> Per typec spec:
> Figure 4-15 Connection State Diagram: DRP
> Figure 4-16 Connection State Diagram: DRP with Accessory and Try.SRC
> 	    Support
> Figure 4-17 Connection State Diagram: DRP with Accessory and Try.SNK
> 	    Support
> DRP port should move to Unattached.SNK instead of Unattached.SRC if
> sink removed.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/tcpm/tcpm.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 78077c2..3174180 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -3680,8 +3680,12 @@ static void _tcpm_cc_change(struct tcpm_port *port, enum typec_cc_status cc1,
>  	case SRC_SEND_CAPABILITIES:
>  	case SRC_READY:
>  		if (tcpm_port_is_disconnected(port) ||
> -		    !tcpm_port_is_source(port))
> -			tcpm_set_state(port, SRC_UNATTACHED, 0);
> +		    !tcpm_port_is_source(port)) {
> +			if (port->port_type == TYPEC_PORT_SRC)
> +				tcpm_set_state(port, SRC_UNATTACHED, 0);
> +			else
> +				tcpm_set_state(port, SNK_UNATTACHED, 0);
> +		}
>  		break;
>  	case SNK_UNATTACHED:
>  		if (tcpm_port_is_sink(port))
> -- 
> 2.7.4

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-24 13:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-19 16:05 [PATCH] usb: typec: tcpm: move to SNK_UNATTACHED if sink removed for DRP jun.li
2020-02-19 17:15 ` Guenter Roeck
2020-02-24 13:55 ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).