diff mbox series

[v10,09/15] usb: typec: tcpm: frs sourcing vbus callback

Message ID 20201008061556.1402293-10-badhri@google.com
State Superseded
Headers show
Series TCPM support for FRS and AutoDischarge Disconnect | expand

Commit Message

Badhri Jagan Sridharan Oct. 8, 2020, 6:15 a.m. UTC
During FRS hardware autonomously starts to source vbus. Provide
callback to perform chip specific operations.

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
---
Introduced in v9. No chages since then.
---
 drivers/usb/typec/tcpm/tcpm.c | 9 +++++++++
 include/linux/usb/tcpm.h      | 4 ++++
 2 files changed, 13 insertions(+)

Comments

Heikki Krogerus Oct. 19, 2020, 1:40 p.m. UTC | #1
On Wed, Oct 07, 2020 at 11:15:50PM -0700, Badhri Jagan Sridharan wrote:
> During FRS hardware autonomously starts to source vbus. Provide
> callback to perform chip specific operations.
> 
> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>

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

> ---
> Introduced in v9. No chages since then.
> ---
>  drivers/usb/typec/tcpm/tcpm.c | 9 +++++++++
>  include/linux/usb/tcpm.h      | 4 ++++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
> index 55535c4f66bf..02b7f623f584 100644
> --- a/drivers/usb/typec/tcpm/tcpm.c
> +++ b/drivers/usb/typec/tcpm/tcpm.c
> @@ -4090,7 +4090,16 @@ static void _tcpm_pd_vbus_on(struct tcpm_port *port)
>  	case SRC_TRY_DEBOUNCE:
>  		/* Do nothing, waiting for sink detection */
>  		break;
> +	case FR_SWAP_SEND:
> +	case FR_SWAP_SEND_TIMEOUT:
> +	case FR_SWAP_SNK_SRC_TRANSITION_TO_OFF:
> +	case FR_SWAP_SNK_SRC_SOURCE_VBUS_APPLIED:
> +		if (port->tcpc->frs_sourcing_vbus)
> +			port->tcpc->frs_sourcing_vbus(port->tcpc);
> +		break;
>  	case FR_SWAP_SNK_SRC_NEW_SINK_READY:
> +		if (port->tcpc->frs_sourcing_vbus)
> +			port->tcpc->frs_sourcing_vbus(port->tcpc);
>  		tcpm_set_state(port, FR_SWAP_SNK_SRC_SOURCE_VBUS_APPLIED, 0);
>  		break;
>  
> diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
> index 09762d26fa0c..7303f518ba49 100644
> --- a/include/linux/usb/tcpm.h
> +++ b/include/linux/usb/tcpm.h
> @@ -83,6 +83,9 @@ enum tcpm_transmit_type {
>   *		Optional; Called to enable/disable PD 3.0 fast role swap.
>   *		Enabling frs is accessory dependent as not all PD3.0
>   *		accessories support fast role swap.
> + * @frs_sourcing_vbus:
> + *		Optional; Called to notify that vbus is now being sourced.
> + *		Low level drivers can perform chip specific operations, if any.
>   */
>  struct tcpc_dev {
>  	struct fwnode_handle *fwnode;
> @@ -109,6 +112,7 @@ struct tcpc_dev {
>  			   const struct pd_message *msg);
>  	int (*set_bist_data)(struct tcpc_dev *dev, bool on);
>  	int (*enable_frs)(struct tcpc_dev *dev, bool enable);
> +	void (*frs_sourcing_vbus)(struct tcpc_dev *dev);
>  };
>  
>  struct tcpm_port;
> -- 
> 2.28.0.806.g8561365e88-goog

thanks,
diff mbox series

Patch

diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c
index 55535c4f66bf..02b7f623f584 100644
--- a/drivers/usb/typec/tcpm/tcpm.c
+++ b/drivers/usb/typec/tcpm/tcpm.c
@@ -4090,7 +4090,16 @@  static void _tcpm_pd_vbus_on(struct tcpm_port *port)
 	case SRC_TRY_DEBOUNCE:
 		/* Do nothing, waiting for sink detection */
 		break;
+	case FR_SWAP_SEND:
+	case FR_SWAP_SEND_TIMEOUT:
+	case FR_SWAP_SNK_SRC_TRANSITION_TO_OFF:
+	case FR_SWAP_SNK_SRC_SOURCE_VBUS_APPLIED:
+		if (port->tcpc->frs_sourcing_vbus)
+			port->tcpc->frs_sourcing_vbus(port->tcpc);
+		break;
 	case FR_SWAP_SNK_SRC_NEW_SINK_READY:
+		if (port->tcpc->frs_sourcing_vbus)
+			port->tcpc->frs_sourcing_vbus(port->tcpc);
 		tcpm_set_state(port, FR_SWAP_SNK_SRC_SOURCE_VBUS_APPLIED, 0);
 		break;
 
diff --git a/include/linux/usb/tcpm.h b/include/linux/usb/tcpm.h
index 09762d26fa0c..7303f518ba49 100644
--- a/include/linux/usb/tcpm.h
+++ b/include/linux/usb/tcpm.h
@@ -83,6 +83,9 @@  enum tcpm_transmit_type {
  *		Optional; Called to enable/disable PD 3.0 fast role swap.
  *		Enabling frs is accessory dependent as not all PD3.0
  *		accessories support fast role swap.
+ * @frs_sourcing_vbus:
+ *		Optional; Called to notify that vbus is now being sourced.
+ *		Low level drivers can perform chip specific operations, if any.
  */
 struct tcpc_dev {
 	struct fwnode_handle *fwnode;
@@ -109,6 +112,7 @@  struct tcpc_dev {
 			   const struct pd_message *msg);
 	int (*set_bist_data)(struct tcpc_dev *dev, bool on);
 	int (*enable_frs)(struct tcpc_dev *dev, bool enable);
+	void (*frs_sourcing_vbus)(struct tcpc_dev *dev);
 };
 
 struct tcpm_port;