Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Neil Armstrong <neil.armstrong@linaro.org>
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Luca Weiss <luca.weiss@fairphone.com>,
	linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] usb: typec-mux: ptn36502: broadcast typec state to next mux
Date: Thu, 6 Jun 2024 14:53:04 +0200	[thread overview]
Message-ID: <5fcfa552-7b1e-4329-8ffa-dbe7cf34695a@linaro.org> (raw)
In-Reply-To: <llt5o2btdlz5ckvhd3a73kxxkrm544wi3b2xhnytwg62ekcm3l@ck6wqglx35d6>

On 27/05/2024 11:16, Dmitry Baryshkov wrote:
> On Mon, May 27, 2024 at 09:45:29AM +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@fairphone.com>
>> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
>>
>> --
>>
>> Reported Tested by Luca in [1]
>>
>> [1] https://lore.kernel.org/all/D1HOCBW6RG72.1B2RKGKW2Q5VC@fairphone.com/
>> ---
>>   drivers/usb/typec/mux/ptn36502.c | 33 ++++++++++++++++++++++++++++++---
>>   1 file changed, 30 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/usb/typec/mux/ptn36502.c b/drivers/usb/typec/mux/ptn36502.c
>> index 0ec86ef32a87..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,9 +330,18 @@ 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)
>> -		return dev_err_probe(dev, ret, "Failed to enable vdd18\n");
>> +	if (ret) {
>> +		ret = dev_err_probe(dev, ret, "Failed to enable vdd18\n");
>> +		goto err_mux_put;
>> +	}
>>   
>>   	ret = ptn36502_detect(ptn);
>>   	if (ret)
>> @@ -363,6 +381,12 @@ 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);
> 
> Please split typec_switch_put() to a separate patch, it's a fix.

I was lazy, I'll do that,

Thanks

> 
>> +
>>   	return ret;
>>   }
>>   
>> @@ -374,6 +398,9 @@ static void ptn36502_remove(struct i2c_client *client)
>>   	typec_switch_unregister(ptn->sw);
>>   
>>   	regulator_disable(ptn->vdd18_supply);
>> +
>> +	typec_mux_put(ptn->typec_mux);
>> +	typec_switch_put(ptn->typec_switch);
>>   }
>>   
>>   static const struct i2c_device_id ptn36502_table[] = {
>>
>> -- 
>> 2.34.1
>>
> 


  reply	other threads:[~2024-06-06 12:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-27  7:45 [PATCH 0/2] usb: typec-mux: broadcast typec state to next mux for ptn36502 & nb7vpq904m retimers Neil Armstrong
2024-05-27  7:45 ` [PATCH 1/2] usb: typec-mux: ptn36502: broadcast typec state to next mux Neil Armstrong
2024-05-27  9:16   ` Dmitry Baryshkov
2024-06-06 12:53     ` Neil Armstrong [this message]
2024-05-27  7:45 ` [PATCH 2/2] usb: typec-mux: nb7vpq904m: " Neil Armstrong
2024-05-27  9:18   ` Dmitry Baryshkov
2024-06-06 12:53     ` Neil Armstrong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5fcfa552-7b1e-4329-8ffa-dbe7cf34695a@linaro.org \
    --to=neil.armstrong@linaro.org \
    --cc=andersson@kernel.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=luca.weiss@fairphone.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox