mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] usb: typec: tcpm: Handle vbus shutoff when in source mode
@ 2021-02-01 10:02 Badhri Jagan Sridharan
  2021-02-01 14:38 ` Guenter Roeck
  2021-02-02  8:21 ` Heikki Krogerus
  0 siblings, 2 replies; 3+ messages in thread
From: Badhri Jagan Sridharan @ 2021-02-01 10:02 UTC (permalink / raw)
  To: Guenter Roeck, Heikki Krogerus, Greg Kroah-Hartman, Kyle Tso
  Cc: linux-usb, linux-kernel, Badhri Jagan Sridharan

While in source mode, vbus could be shutoff by protections
circuits. TCPM does not move back to toggling state to
re-initiate connection. Fix this by moving to SRC_UNATTACHED
state when vbus shuts off while in source mode.

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
---
 drivers/usb/typec/tcpm/tcpm.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 0afd8ef692e8..ff0732c12b8a 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -4897,6 +4897,17 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port)
 		/* Do nothing, waiting for sink detection */
 		break;
 
+	case SRC_STARTUP:
+	case SRC_SEND_CAPABILITIES:
+	case SRC_SEND_CAPABILITIES_TIMEOUT:
+	case SRC_NEGOTIATE_CAPABILITIES:
+	case SRC_TRANSITION_SUPPLY:
+	case SRC_READY:
+	case SRC_WAIT_NEW_CAPABILITIES:
+		/* Force to unattached state to re-initiate connection */
+		tcpm_set_state(port, SRC_UNATTACHED, 0);
+		break;
+
 	case PORT_RESET:
 		/*
 		 * State set back to default mode once the timer completes.
-- 
2.30.0.365.g02bc693789-goog


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

* Re: [PATCH v1] usb: typec: tcpm: Handle vbus shutoff when in source mode
  2021-02-01 10:02 [PATCH v1] usb: typec: tcpm: Handle vbus shutoff when in source mode Badhri Jagan Sridharan
@ 2021-02-01 14:38 ` Guenter Roeck
  2021-02-02  8:21 ` Heikki Krogerus
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2021-02-01 14:38 UTC (permalink / raw)
  To: Badhri Jagan Sridharan, Heikki Krogerus, Greg Kroah-Hartman, Kyle Tso
  Cc: linux-usb, linux-kernel

On 2/1/21 2:02 AM, Badhri Jagan Sridharan wrote:
> While in source mode, vbus could be shutoff by protections
> circuits. TCPM does not move back to toggling state to
> re-initiate connection. Fix this by moving to SRC_UNATTACHED
> state when vbus shuts off while in source mode.
> 
> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>

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

> ---
>  drivers/usb/typec/tcpm/tcpm.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 0afd8ef692e8..ff0732c12b8a 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4897,6 +4897,17 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port)
>  		/* Do nothing, waiting for sink detection */
>  		break;
>  
> +	case SRC_STARTUP:
> +	case SRC_SEND_CAPABILITIES:
> +	case SRC_SEND_CAPABILITIES_TIMEOUT:
> +	case SRC_NEGOTIATE_CAPABILITIES:
> +	case SRC_TRANSITION_SUPPLY:
> +	case SRC_READY:
> +	case SRC_WAIT_NEW_CAPABILITIES:
> +		/* Force to unattached state to re-initiate connection */
> +		tcpm_set_state(port, SRC_UNATTACHED, 0);
> +		break;
> +
>  	case PORT_RESET:
>  		/*
>  		 * State set back to default mode once the timer completes.
> 


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

* Re: [PATCH v1] usb: typec: tcpm: Handle vbus shutoff when in source mode
  2021-02-01 10:02 [PATCH v1] usb: typec: tcpm: Handle vbus shutoff when in source mode Badhri Jagan Sridharan
  2021-02-01 14:38 ` Guenter Roeck
@ 2021-02-02  8:21 ` Heikki Krogerus
  1 sibling, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2021-02-02  8:21 UTC (permalink / raw)
  To: Badhri Jagan Sridharan
  Cc: Guenter Roeck, Greg Kroah-Hartman, Kyle Tso, linux-usb, linux-kernel

On Mon, Feb 01, 2021 at 02:02:12AM -0800, Badhri Jagan Sridharan wrote:
> While in source mode, vbus could be shutoff by protections
> circuits. TCPM does not move back to toggling state to
> re-initiate connection. Fix this by moving to SRC_UNATTACHED
> state when vbus shuts off while in source mode.
> 
> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>

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

> ---
>  drivers/usb/typec/tcpm/tcpm.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 0afd8ef692e8..ff0732c12b8a 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4897,6 +4897,17 @@ static void _tcpm_pd_vbus_off(struct tcpm_port *port)
>  		/* Do nothing, waiting for sink detection */
>  		break;
>  
> +	case SRC_STARTUP:
> +	case SRC_SEND_CAPABILITIES:
> +	case SRC_SEND_CAPABILITIES_TIMEOUT:
> +	case SRC_NEGOTIATE_CAPABILITIES:
> +	case SRC_TRANSITION_SUPPLY:
> +	case SRC_READY:
> +	case SRC_WAIT_NEW_CAPABILITIES:
> +		/* Force to unattached state to re-initiate connection */
> +		tcpm_set_state(port, SRC_UNATTACHED, 0);
> +		break;
> +
>  	case PORT_RESET:
>  		/*
>  		 * State set back to default mode once the timer completes.
> -- 
> 2.30.0.365.g02bc693789-goog

thanks,

-- 
heikki

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

end of thread, other threads:[~2021-02-02  8:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01 10:02 [PATCH v1] usb: typec: tcpm: Handle vbus shutoff when in source mode Badhri Jagan Sridharan
2021-02-01 14:38 ` Guenter Roeck
2021-02-02  8:21 ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®