diff mbox series

[1/8] usb: typec: Handle retimers in typec_set_mode()

Message ID 20240416-ucsi-glink-altmode-v1-1-890db00877ac@linaro.org (mailing list archive)
State Not Applicable
Headers show
Series usb: typec: ucsi: glink: merge in altmode support | expand

Commit Message

Dmitry Baryshkov April 16, 2024, 2:20 a.m. UTC
Make typec_set_mode() also handle retimers in addition to muxes. Setting
the USB mode requires retimers to be configured in addition to just
switching the mux configuration.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/usb/typec/class.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

Konrad Dybcio April 16, 2024, 2:30 p.m. UTC | #1
On 4/16/24 04:20, Dmitry Baryshkov wrote:
> Make typec_set_mode() also handle retimers in addition to muxes. Setting
> the USB mode requires retimers to be configured in addition to just
> switching the mux configuration.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---

Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>

Konrad
Neil Armstrong April 16, 2024, 5:26 p.m. UTC | #2
On 16/04/2024 04:20, Dmitry Baryshkov wrote:
> Make typec_set_mode() also handle retimers in addition to muxes. Setting
> the USB mode requires retimers to be configured in addition to just
> switching the mux configuration.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
>   drivers/usb/typec/class.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 9610e647a8d4..28d395535bd1 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -2095,14 +2095,21 @@ EXPORT_SYMBOL_GPL(typec_get_orientation);
>    * @mode: Accessory Mode, USB Operation or Safe State
>    *
>    * Configure @port for Accessory Mode @mode. This function will configure the
> - * muxes needed for @mode.
> + * muxes and retimeres needed for @mode.
>    */
>   int typec_set_mode(struct typec_port *port, int mode)
>   {
> +	struct typec_retimer_state retimer_state = { };
>   	struct typec_mux_state state = { };
> +	int ret;
>   
> +	retimer_state.mode = mode;
>   	state.mode = mode;
>   
> +	ret = typec_retimer_set(port->retimer, &retimer_state);
> +	if (ret)
> +		return ret;
> +
>   	return typec_mux_set(port->mux, &state);
>   }
>   EXPORT_SYMBOL_GPL(typec_set_mode);
> 

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Heikki Krogerus April 22, 2024, 8 a.m. UTC | #3
On Tue, Apr 16, 2024 at 05:20:50AM +0300, Dmitry Baryshkov wrote:
> Make typec_set_mode() also handle retimers in addition to muxes. Setting
> the USB mode requires retimers to be configured in addition to just
> switching the mux configuration.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

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

> ---
>  drivers/usb/typec/class.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 9610e647a8d4..28d395535bd1 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -2095,14 +2095,21 @@ EXPORT_SYMBOL_GPL(typec_get_orientation);
>   * @mode: Accessory Mode, USB Operation or Safe State
>   *
>   * Configure @port for Accessory Mode @mode. This function will configure the
> - * muxes needed for @mode.
> + * muxes and retimeres needed for @mode.
>   */
>  int typec_set_mode(struct typec_port *port, int mode)
>  {
> +	struct typec_retimer_state retimer_state = { };
>  	struct typec_mux_state state = { };
> +	int ret;
>  
> +	retimer_state.mode = mode;
>  	state.mode = mode;
>  
> +	ret = typec_retimer_set(port->retimer, &retimer_state);
> +	if (ret)
> +		return ret;
> +
>  	return typec_mux_set(port->mux, &state);
>  }
>  EXPORT_SYMBOL_GPL(typec_set_mode);
> 
> -- 
> 2.39.2
diff mbox series

Patch

diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index 9610e647a8d4..28d395535bd1 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -2095,14 +2095,21 @@  EXPORT_SYMBOL_GPL(typec_get_orientation);
  * @mode: Accessory Mode, USB Operation or Safe State
  *
  * Configure @port for Accessory Mode @mode. This function will configure the
- * muxes needed for @mode.
+ * muxes and retimeres needed for @mode.
  */
 int typec_set_mode(struct typec_port *port, int mode)
 {
+	struct typec_retimer_state retimer_state = { };
 	struct typec_mux_state state = { };
+	int ret;
 
+	retimer_state.mode = mode;
 	state.mode = mode;
 
+	ret = typec_retimer_set(port->retimer, &retimer_state);
+	if (ret)
+		return ret;
+
 	return typec_mux_set(port->mux, &state);
 }
 EXPORT_SYMBOL_GPL(typec_set_mode);