2024-05-27 07:45:49

by Neil Armstrong

[permalink] [raw]
Subject: [PATCH 0/2] usb: typec-mux: broadcast typec state to next mux for ptn36502 & nb7vpq904m retimers

In the Type-C graph, a retimer is usually 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 nb7vpq904m & ptn36502 retimers to get an optional type-c mux
on the next endpoint, and broadcast the received mode to it.

This makes it possible to support 4-lanes DP altmode on Qualcomm platforms.

Signed-off-by: Neil Armstrong <[email protected]>
---
Neil Armstrong (2):
usb: typec-mux: ptn36502: broadcast typec state to next mux
usb: typec-mux: nb7vpq904m: broadcast typec state to next mux

drivers/usb/typec/mux/nb7vpq904m.c | 29 +++++++++++++++++++++++++++--
drivers/usb/typec/mux/ptn36502.c | 33 ++++++++++++++++++++++++++++++---
2 files changed, 57 insertions(+), 5 deletions(-)
---
base-commit: 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0
change-id: 20240527-topic-sm8x50-upstream-retimer-broadcast-mode-76520768ac3f

Best regards,
--
Neil Armstrong <[email protected]>



2024-05-27 07:46:10

by Neil Armstrong

[permalink] [raw]
Subject: [PATCH 1/2] usb: typec-mux: ptn36502: broadcast typec state to next mux

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 <[email protected]>
Signed-off-by: Neil Armstrong <[email protected]>

--

Reported Tested by Luca in [1]

[1] https://lore.kernel.org/all/[email protected]/
---
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);
+
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


2024-05-27 07:46:18

by Neil Armstrong

[permalink] [raw]
Subject: [PATCH 2/2] usb: typec-mux: nb7vpq904m: broadcast typec state to next mux

In the Type-C graph, the nb7vpq904m 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 nb7vpq904m retimer to get an optional type-c mux on the next
endpoint, and broadcast the received mode to it.

Signed-off-by: Neil Armstrong <[email protected]>
---
drivers/usb/typec/mux/nb7vpq904m.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/mux/nb7vpq904m.c b/drivers/usb/typec/mux/nb7vpq904m.c
index b17826713753..efb10f890fed 100644
--- a/drivers/usb/typec/mux/nb7vpq904m.c
+++ b/drivers/usb/typec/mux/nb7vpq904m.c
@@ -69,6 +69,7 @@ struct nb7vpq904m {

bool swap_data_lanes;
struct typec_switch *typec_switch;
+ struct typec_mux *typec_mux;

struct mutex lock; /* protect non-concurrent retimer & switch */

@@ -275,6 +276,7 @@ static int nb7vpq904m_sw_set(struct typec_switch_dev *sw, enum typec_orientation
static int nb7vpq904m_retimer_set(struct typec_retimer *retimer, struct typec_retimer_state *state)
{
struct nb7vpq904m *nb7 = typec_retimer_get_drvdata(retimer);
+ struct typec_mux_state mux_state;
int ret = 0;

mutex_lock(&nb7->lock);
@@ -292,7 +294,14 @@ static int nb7vpq904m_retimer_set(struct typec_retimer *retimer, struct typec_re

mutex_unlock(&nb7->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(nb7->typec_mux, &mux_state);
}

static const struct regmap_config nb7_regmap = {
@@ -411,9 +420,16 @@ static int nb7vpq904m_probe(struct i2c_client *client)
return dev_err_probe(dev, PTR_ERR(nb7->typec_switch),
"failed to acquire orientation-switch\n");

+ nb7->typec_mux = fwnode_typec_mux_get(dev->fwnode);
+ if (IS_ERR(nb7->typec_mux)) {
+ ret = dev_err_probe(dev, PTR_ERR(nb7->typec_mux),
+ "Failed to acquire mode-switch\n");
+ goto err_switch_put;
+ }
+
ret = nb7vpq904m_parse_data_lanes_mapping(nb7);
if (ret)
- return ret;
+ goto err_mux_put;

ret = regulator_enable(nb7->vcc_supply);
if (ret)
@@ -456,6 +472,12 @@ static int nb7vpq904m_probe(struct i2c_client *client)
gpiod_set_value(nb7->enable_gpio, 0);
regulator_disable(nb7->vcc_supply);

+err_mux_put:
+ typec_mux_put(nb7->typec_mux);
+
+err_switch_put:
+ typec_switch_put(nb7->typec_switch);
+
return ret;
}

@@ -469,6 +491,9 @@ static void nb7vpq904m_remove(struct i2c_client *client)
gpiod_set_value(nb7->enable_gpio, 0);

regulator_disable(nb7->vcc_supply);
+
+ typec_mux_put(nb7->typec_mux);
+ typec_switch_put(nb7->typec_switch);
}

static const struct i2c_device_id nb7vpq904m_table[] = {

--
2.34.1


2024-05-27 09:16:41

by Dmitry Baryshkov

[permalink] [raw]
Subject: Re: [PATCH 1/2] usb: typec-mux: ptn36502: broadcast typec state to next mux

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 <[email protected]>
> Signed-off-by: Neil Armstrong <[email protected]>
>
> --
>
> Reported Tested by Luca in [1]
>
> [1] https://lore.kernel.org/all/[email protected]/
> ---
> 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.

> +
> 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
>

--
With best wishes
Dmitry

2024-05-27 09:18:49

by Dmitry Baryshkov

[permalink] [raw]
Subject: Re: [PATCH 2/2] usb: typec-mux: nb7vpq904m: broadcast typec state to next mux

On Mon, May 27, 2024 at 09:45:30AM +0200, Neil Armstrong wrote:
> In the Type-C graph, the nb7vpq904m 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 nb7vpq904m retimer to get an optional type-c mux on the next
> endpoint, and broadcast the received mode to it.
>
> Signed-off-by: Neil Armstrong <[email protected]>
> ---
> drivers/usb/typec/mux/nb7vpq904m.c | 29 +++++++++++++++++++++++++++--
> 1 file changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/mux/nb7vpq904m.c b/drivers/usb/typec/mux/nb7vpq904m.c
> index b17826713753..efb10f890fed 100644
> --- a/drivers/usb/typec/mux/nb7vpq904m.c
> +++ b/drivers/usb/typec/mux/nb7vpq904m.c
> @@ -69,6 +69,7 @@ struct nb7vpq904m {
>
> bool swap_data_lanes;
> struct typec_switch *typec_switch;
> + struct typec_mux *typec_mux;
>
> struct mutex lock; /* protect non-concurrent retimer & switch */
>
> @@ -275,6 +276,7 @@ static int nb7vpq904m_sw_set(struct typec_switch_dev *sw, enum typec_orientation
> static int nb7vpq904m_retimer_set(struct typec_retimer *retimer, struct typec_retimer_state *state)
> {
> struct nb7vpq904m *nb7 = typec_retimer_get_drvdata(retimer);
> + struct typec_mux_state mux_state;
> int ret = 0;
>
> mutex_lock(&nb7->lock);
> @@ -292,7 +294,14 @@ static int nb7vpq904m_retimer_set(struct typec_retimer *retimer, struct typec_re
>
> mutex_unlock(&nb7->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(nb7->typec_mux, &mux_state);
> }
>
> static const struct regmap_config nb7_regmap = {
> @@ -411,9 +420,16 @@ static int nb7vpq904m_probe(struct i2c_client *client)
> return dev_err_probe(dev, PTR_ERR(nb7->typec_switch),
> "failed to acquire orientation-switch\n");
>
> + nb7->typec_mux = fwnode_typec_mux_get(dev->fwnode);
> + if (IS_ERR(nb7->typec_mux)) {
> + ret = dev_err_probe(dev, PTR_ERR(nb7->typec_mux),
> + "Failed to acquire mode-switch\n");
> + goto err_switch_put;
> + }
> +
> ret = nb7vpq904m_parse_data_lanes_mapping(nb7);
> if (ret)
> - return ret;
> + goto err_mux_put;
>
> ret = regulator_enable(nb7->vcc_supply);
> if (ret)
> @@ -456,6 +472,12 @@ static int nb7vpq904m_probe(struct i2c_client *client)
> gpiod_set_value(nb7->enable_gpio, 0);
> regulator_disable(nb7->vcc_supply);
>
> +err_mux_put:
> + typec_mux_put(nb7->typec_mux);
> +
> +err_switch_put:
> + typec_switch_put(nb7->typec_switch);

Same comment, typec_switch_put should go to a separate commit. IMHO it
almost begs us to have devm_fwnode_typec_mux_get() and
devm_fwnode_typec_switch_get().

> +
> return ret;
> }
>
> @@ -469,6 +491,9 @@ static void nb7vpq904m_remove(struct i2c_client *client)
> gpiod_set_value(nb7->enable_gpio, 0);
>
> regulator_disable(nb7->vcc_supply);
> +
> + typec_mux_put(nb7->typec_mux);
> + typec_switch_put(nb7->typec_switch);
> }
>
> static const struct i2c_device_id nb7vpq904m_table[] = {
>
> --
> 2.34.1
>

--
With best wishes
Dmitry

2024-06-06 12:53:32

by Neil Armstrong

[permalink] [raw]
Subject: Re: [PATCH 1/2] usb: typec-mux: ptn36502: broadcast typec state to next mux

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 <[email protected]>
>> Signed-off-by: Neil Armstrong <[email protected]>
>>
>> --
>>
>> Reported Tested by Luca in [1]
>>
>> [1] https://lore.kernel.org/all/[email protected]/
>> ---
>> 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
>>
>


2024-06-06 12:53:53

by Neil Armstrong

[permalink] [raw]
Subject: Re: [PATCH 2/2] usb: typec-mux: nb7vpq904m: broadcast typec state to next mux

On 27/05/2024 11:18, Dmitry Baryshkov wrote:
> On Mon, May 27, 2024 at 09:45:30AM +0200, Neil Armstrong wrote:
>> In the Type-C graph, the nb7vpq904m 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 nb7vpq904m retimer to get an optional type-c mux on the next
>> endpoint, and broadcast the received mode to it.
>>
>> Signed-off-by: Neil Armstrong <[email protected]>
>> ---
>> drivers/usb/typec/mux/nb7vpq904m.c | 29 +++++++++++++++++++++++++++--
>> 1 file changed, 27 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/usb/typec/mux/nb7vpq904m.c b/drivers/usb/typec/mux/nb7vpq904m.c
>> index b17826713753..efb10f890fed 100644
>> --- a/drivers/usb/typec/mux/nb7vpq904m.c
>> +++ b/drivers/usb/typec/mux/nb7vpq904m.c
>> @@ -69,6 +69,7 @@ struct nb7vpq904m {
>>
>> bool swap_data_lanes;
>> struct typec_switch *typec_switch;
>> + struct typec_mux *typec_mux;
>>
>> struct mutex lock; /* protect non-concurrent retimer & switch */
>>
>> @@ -275,6 +276,7 @@ static int nb7vpq904m_sw_set(struct typec_switch_dev *sw, enum typec_orientation
>> static int nb7vpq904m_retimer_set(struct typec_retimer *retimer, struct typec_retimer_state *state)
>> {
>> struct nb7vpq904m *nb7 = typec_retimer_get_drvdata(retimer);
>> + struct typec_mux_state mux_state;
>> int ret = 0;
>>
>> mutex_lock(&nb7->lock);
>> @@ -292,7 +294,14 @@ static int nb7vpq904m_retimer_set(struct typec_retimer *retimer, struct typec_re
>>
>> mutex_unlock(&nb7->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(nb7->typec_mux, &mux_state);
>> }
>>
>> static const struct regmap_config nb7_regmap = {
>> @@ -411,9 +420,16 @@ static int nb7vpq904m_probe(struct i2c_client *client)
>> return dev_err_probe(dev, PTR_ERR(nb7->typec_switch),
>> "failed to acquire orientation-switch\n");
>>
>> + nb7->typec_mux = fwnode_typec_mux_get(dev->fwnode);
>> + if (IS_ERR(nb7->typec_mux)) {
>> + ret = dev_err_probe(dev, PTR_ERR(nb7->typec_mux),
>> + "Failed to acquire mode-switch\n");
>> + goto err_switch_put;
>> + }
>> +
>> ret = nb7vpq904m_parse_data_lanes_mapping(nb7);
>> if (ret)
>> - return ret;
>> + goto err_mux_put;
>>
>> ret = regulator_enable(nb7->vcc_supply);
>> if (ret)
>> @@ -456,6 +472,12 @@ static int nb7vpq904m_probe(struct i2c_client *client)
>> gpiod_set_value(nb7->enable_gpio, 0);
>> regulator_disable(nb7->vcc_supply);
>>
>> +err_mux_put:
>> + typec_mux_put(nb7->typec_mux);
>> +
>> +err_switch_put:
>> + typec_switch_put(nb7->typec_switch);
>
> Same comment, typec_switch_put should go to a separate commit. IMHO it
> almost begs us to have devm_fwnode_typec_mux_get() and
> devm_fwnode_typec_switch_get().

Yep

Thx,
Neil

>
>> +
>> return ret;
>> }
>>
>> @@ -469,6 +491,9 @@ static void nb7vpq904m_remove(struct i2c_client *client)
>> gpiod_set_value(nb7->enable_gpio, 0);
>>
>> regulator_disable(nb7->vcc_supply);
>> +
>> + typec_mux_put(nb7->typec_mux);
>> + typec_switch_put(nb7->typec_switch);
>> }
>>
>> static const struct i2c_device_id nb7vpq904m_table[] = {
>>
>> --
>> 2.34.1
>>
>