Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1709063 > unrolled thread

[PATCH] staging: typec: tcpm: Consider port_type while determining unattached_state

Started byBadhri Jagan Sridharan <badhri@google.com>
First post2017-08-11 00:10 +0200
Last post2017-08-11 00:20 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] staging: typec: tcpm: Consider port_type while determining unattached_state Badhri Jagan Sridharan <badhri@google.com> - 2017-08-11 00:10 +0200
    Re: [PATCH] staging: typec: tcpm: Consider port_type while  determining unattached_state Badhri Jagan Sridharan <badhri@google.com> - 2017-08-11 00:20 +0200

#1709063 — [PATCH] staging: typec: tcpm: Consider port_type while determining unattached_state

FromBadhri Jagan Sridharan <badhri@google.com>
Date2017-08-11 00:10 +0200
Subject[PATCH] staging: typec: tcpm: Consider port_type while determining unattached_state
Message-ID<ud3Oq-3qn-19@gated-at.bofh.it>
While performing PORT_RESET, upon receiving the cc disconnect
signal from the underlaying tcpc device, TCPM transitions into
unattached state. Consider, the current type of port while determining
the unattached state.

In the below logs, although the port_type was set to sink, TCPM
transitioned into SRC_UNATTACHED.

[  762.290654] state change SRC_READY -> PORT_RESET
[  762.324531] Setting voltage/current limit 0 mV 0 mA
[  762.327912] polarity 0
[  762.334864] cc:=0
[  762.347193] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms
[  762.347200] VBUS off
[  762.347203] CC1: 2 -> 0, CC2: 0 -> 0 [state PORT_RESET, polarity 0, disconnected]
[  762.347206] state change PORT_RESET -> SRC_UNATTACHED

Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
---
 drivers/staging/typec/tcpm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index 20eb4ebcf8c3..4c526341d850 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm.c
@@ -2099,10 +2099,16 @@ static inline enum tcpm_state ready_state(struct tcpm_port *port)
 
 static inline enum tcpm_state unattached_state(struct tcpm_port *port)
 {
-	if (port->pwr_role == TYPEC_SOURCE)
+	if (port->port_type == TYPEC_PORT_DRP) {
+		if (port->pwr_role == TYPEC_SOURCE)
+			return SRC_UNATTACHED;
+		else
+			return SNK_UNATTACHED;
+	} else if (port->port_type == TYPEC_PORT_DFP) {
 		return SRC_UNATTACHED;
-	else
+	} else {
 		return SNK_UNATTACHED;
+	}
 }
 
 static void tcpm_check_send_discover(struct tcpm_port *port)
-- 
2.14.0.434.g98096fd7a8-goog

[toc] | [next] | [standalone]


#1709072 — Re: [PATCH] staging: typec: tcpm: Consider port_type while determining unattached_state

FromBadhri Jagan Sridharan <badhri@google.com>
Date2017-08-11 00:20 +0200
SubjectRe: [PATCH] staging: typec: tcpm: Consider port_type while determining unattached_state
Message-ID<ud3Y5-3tF-17@gated-at.bofh.it>
In reply to#1709063
Please hold off on reviewing this patch.
Patch went wrong while rebasing.

Thanks,
Badhri

On Thu, Aug 10, 2017 at 3:06 PM, Badhri Jagan Sridharan
<badhri@google.com> wrote:
> While performing PORT_RESET, upon receiving the cc disconnect
> signal from the underlaying tcpc device, TCPM transitions into
> unattached state. Consider, the current type of port while determining
> the unattached state.
>
> In the below logs, although the port_type was set to sink, TCPM
> transitioned into SRC_UNATTACHED.
>
> [  762.290654] state change SRC_READY -> PORT_RESET
> [  762.324531] Setting voltage/current limit 0 mV 0 mA
> [  762.327912] polarity 0
> [  762.334864] cc:=0
> [  762.347193] pending state change PORT_RESET -> PORT_RESET_WAIT_OFF @ 100 ms
> [  762.347200] VBUS off
> [  762.347203] CC1: 2 -> 0, CC2: 0 -> 0 [state PORT_RESET, polarity 0, disconnected]
> [  762.347206] state change PORT_RESET -> SRC_UNATTACHED
>
> Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com>
> ---
>  drivers/staging/typec/tcpm.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
> index 20eb4ebcf8c3..4c526341d850 100644
> --- a/drivers/staging/typec/tcpm.c
> +++ b/drivers/staging/typec/tcpm.c
> @@ -2099,10 +2099,16 @@ static inline enum tcpm_state ready_state(struct tcpm_port *port)
>
>  static inline enum tcpm_state unattached_state(struct tcpm_port *port)
>  {
> -       if (port->pwr_role == TYPEC_SOURCE)
> +       if (port->port_type == TYPEC_PORT_DRP) {
> +               if (port->pwr_role == TYPEC_SOURCE)
> +                       return SRC_UNATTACHED;
> +               else
> +                       return SNK_UNATTACHED;
> +       } else if (port->port_type == TYPEC_PORT_DFP) {
>                 return SRC_UNATTACHED;
> -       else
> +       } else {
>                 return SNK_UNATTACHED;
> +       }
>  }
>
>  static void tcpm_check_send_discover(struct tcpm_port *port)
> --
> 2.14.0.434.g98096fd7a8-goog
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web