lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zmb54WG2tcKPD/Zf@kuha.fi.intel.com>
Date: Mon, 10 Jun 2024 16:04:33 +0300
From: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
To: Neil Armstrong <neil.armstrong@...aro.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Bjorn Andersson <andersson@...nel.org>,
	Luca Weiss <luca.weiss@...rphone.com>,
	linux-arm-msm@...r.kernel.org, linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 3/4] usb: typec-mux: ptn36502: broadcast typec state
 to next mux

On Thu, Jun 06, 2024 at 03:11:15PM +0200, Neil Armstrong wrote:
> In the Type-C graph, the ptn36502 retimer is in between the USB-C
> connector and the USB3/DP combo PHY, and this PHY also requires the
> USB-C mode events to properly set-up the SuperSpeed Lanes functions
> to setup USB3-only, USB3 + DP Altmode or DP Altmode only on the 4 lanes.
> 
> Update the ptn36502 retimer to get an optional type-c mux on the next
> endpoint, and broadcast the received mode to it.
> 
> Tested-by: Luca Weiss <luca.weiss@...rphone.com>
> Signed-off-by: Neil Armstrong <neil.armstrong@...aro.org>

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

> ---
> 
> Reported Tested by Luca in [1]
> 
> [1] https://lore.kernel.org/all/D1HOCBW6RG72.1B2RKGKW2Q5VC@fairphone.com/
> ---
>  drivers/usb/typec/mux/ptn36502.c | 24 ++++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/mux/ptn36502.c b/drivers/usb/typec/mux/ptn36502.c
> index 88136a6d6f31..129d9d24b932 100644
> --- a/drivers/usb/typec/mux/ptn36502.c
> +++ b/drivers/usb/typec/mux/ptn36502.c
> @@ -67,6 +67,7 @@ struct ptn36502 {
>  	struct typec_retimer *retimer;
>  
>  	struct typec_switch *typec_switch;
> +	struct typec_mux *typec_mux;
>  
>  	struct mutex lock; /* protect non-concurrent retimer & switch */
>  
> @@ -235,6 +236,7 @@ static int ptn36502_sw_set(struct typec_switch_dev *sw, enum typec_orientation o
>  static int ptn36502_retimer_set(struct typec_retimer *retimer, struct typec_retimer_state *state)
>  {
>  	struct ptn36502 *ptn = typec_retimer_get_drvdata(retimer);
> +	struct typec_mux_state mux_state;
>  	int ret = 0;
>  
>  	mutex_lock(&ptn->lock);
> @@ -252,7 +254,14 @@ static int ptn36502_retimer_set(struct typec_retimer *retimer, struct typec_reti
>  
>  	mutex_unlock(&ptn->lock);
>  
> -	return ret;
> +	if (ret)
> +		return ret;
> +
> +	mux_state.alt = state->alt;
> +	mux_state.data = state->data;
> +	mux_state.mode = state->mode;
> +
> +	return typec_mux_set(ptn->typec_mux, &mux_state);
>  }
>  
>  static int ptn36502_detect(struct ptn36502 *ptn)
> @@ -321,10 +330,17 @@ static int ptn36502_probe(struct i2c_client *client)
>  		return dev_err_probe(dev, PTR_ERR(ptn->typec_switch),
>  				     "Failed to acquire orientation-switch\n");
>  
> +	ptn->typec_mux = fwnode_typec_mux_get(dev->fwnode);
> +	if (IS_ERR(ptn->typec_mux)) {
> +		ret = dev_err_probe(dev, PTR_ERR(ptn->typec_mux),
> +				    "Failed to acquire mode-switch\n");
> +		goto err_switch_put;
> +	}
> +
>  	ret = regulator_enable(ptn->vdd18_supply);
>  	if (ret) {
>  		ret = dev_err_probe(dev, ret, "Failed to enable vdd18\n");
> -		goto err_switch_put;
> +		goto err_mux_put;
>  	}
>  
>  	ret = ptn36502_detect(ptn);
> @@ -365,6 +381,9 @@ static int ptn36502_probe(struct i2c_client *client)
>  err_disable_regulator:
>  	regulator_disable(ptn->vdd18_supply);
>  
> +err_mux_put:
> +	typec_mux_put(ptn->typec_mux);
> +
>  err_switch_put:
>  	typec_switch_put(ptn->typec_switch);
>  
> @@ -380,6 +399,7 @@ static void ptn36502_remove(struct i2c_client *client)
>  
>  	regulator_disable(ptn->vdd18_supply);
>  
> +	typec_mux_put(ptn->typec_mux);
>  	typec_switch_put(ptn->typec_switch);
>  }
>  
> 
> -- 
> 2.34.1

-- 
heikki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ