public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] usb: typec-mux: broadcast typec state to next mux for ptn36502 & nb7vpq904m retimers
@ 2024-06-06 13:11 Neil Armstrong
  2024-06-06 13:11 ` [PATCH v2 1/4] usb: typec-mux: ptn36502: unregister typec switch on probe error and remove Neil Armstrong
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Neil Armstrong @ 2024-06-06 13:11 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: Bjorn Andersson, Luca Weiss, linux-arm-msm, linux-usb,
	linux-kernel, Neil Armstrong

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 <neil.armstrong@linaro.org>
---
Changes in v2:
- Split out the typec_switch_put() fixes in separates fixes patches
- Link to v1: https://lore.kernel.org/r/20240527-topic-sm8x50-upstream-retimer-broadcast-mode-v1-0-79ec91381aba@linaro.org

---
Neil Armstrong (4):
      usb: typec-mux: ptn36502: unregister typec switch on probe error and remove
      usb: typec-mux: nb7vpq904m: unregister typec switch on probe error and remove
      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: ee78a17615ad0cfdbbc27182b1047cd36c9d4d5f
change-id: 20240527-topic-sm8x50-upstream-retimer-broadcast-mode-76520768ac3f

Best regards,
-- 
Neil Armstrong <neil.armstrong@linaro.org>


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH v2 1/4] usb: typec-mux: ptn36502: unregister typec switch on probe error and remove
  2024-06-06 13:11 [PATCH v2 0/4] usb: typec-mux: broadcast typec state to next mux for ptn36502 & nb7vpq904m retimers Neil Armstrong
@ 2024-06-06 13:11 ` Neil Armstrong
  2024-06-07  5:48   ` Dmitry Baryshkov
  2024-06-10 12:51   ` Heikki Krogerus
  2024-06-06 13:11 ` [PATCH v2 2/4] usb: typec-mux: nb7vpq904m: " Neil Armstrong
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 15+ messages in thread
From: Neil Armstrong @ 2024-06-06 13:11 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: Bjorn Andersson, Luca Weiss, linux-arm-msm, linux-usb,
	linux-kernel, Neil Armstrong

Add the missing call to typec_switch_put() when probe fails and
the ptn36502_remove() call is called.

Fixes: 8e99dc783648 ("usb: typec: add support for PTN36502 redriver")
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 drivers/usb/typec/mux/ptn36502.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/mux/ptn36502.c b/drivers/usb/typec/mux/ptn36502.c
index 0ec86ef32a87..88136a6d6f31 100644
--- a/drivers/usb/typec/mux/ptn36502.c
+++ b/drivers/usb/typec/mux/ptn36502.c
@@ -322,8 +322,10 @@ static int ptn36502_probe(struct i2c_client *client)
 				     "Failed to acquire orientation-switch\n");
 
 	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_switch_put;
+	}
 
 	ret = ptn36502_detect(ptn);
 	if (ret)
@@ -363,6 +365,9 @@ static int ptn36502_probe(struct i2c_client *client)
 err_disable_regulator:
 	regulator_disable(ptn->vdd18_supply);
 
+err_switch_put:
+	typec_switch_put(ptn->typec_switch);
+
 	return ret;
 }
 
@@ -374,6 +379,8 @@ static void ptn36502_remove(struct i2c_client *client)
 	typec_switch_unregister(ptn->sw);
 
 	regulator_disable(ptn->vdd18_supply);
+
+	typec_switch_put(ptn->typec_switch);
 }
 
 static const struct i2c_device_id ptn36502_table[] = {

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 2/4] usb: typec-mux: nb7vpq904m: unregister typec switch on probe error and remove
  2024-06-06 13:11 [PATCH v2 0/4] usb: typec-mux: broadcast typec state to next mux for ptn36502 & nb7vpq904m retimers Neil Armstrong
  2024-06-06 13:11 ` [PATCH v2 1/4] usb: typec-mux: ptn36502: unregister typec switch on probe error and remove Neil Armstrong
@ 2024-06-06 13:11 ` Neil Armstrong
  2024-06-07  5:50   ` Dmitry Baryshkov
  2024-06-10 13:02   ` Heikki Krogerus
  2024-06-06 13:11 ` [PATCH v2 3/4] usb: typec-mux: ptn36502: broadcast typec state to next mux Neil Armstrong
  2024-06-06 13:11 ` [PATCH v2 4/4] usb: typec-mux: nb7vpq904m: " Neil Armstrong
  3 siblings, 2 replies; 15+ messages in thread
From: Neil Armstrong @ 2024-06-06 13:11 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: Bjorn Andersson, Luca Weiss, linux-arm-msm, linux-usb,
	linux-kernel, Neil Armstrong

Add the missing call to typec_switch_put() when probe fails and
the nb7vpq904m_remove() call is called.

Fixes: 348359e7c232 ("usb: typec: nb7vpq904m: Add an error handling path in nb7vpq904m_probe()")
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 drivers/usb/typec/mux/nb7vpq904m.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/typec/mux/nb7vpq904m.c b/drivers/usb/typec/mux/nb7vpq904m.c
index ed93194b16cf..569f1162ee2e 100644
--- a/drivers/usb/typec/mux/nb7vpq904m.c
+++ b/drivers/usb/typec/mux/nb7vpq904m.c
@@ -415,7 +415,7 @@ static int nb7vpq904m_probe(struct i2c_client *client)
 
 	ret = nb7vpq904m_parse_data_lanes_mapping(nb7);
 	if (ret)
-		return ret;
+		goto err_switch_put;
 
 	ret = regulator_enable(nb7->vcc_supply);
 	if (ret)
@@ -458,6 +458,9 @@ static int nb7vpq904m_probe(struct i2c_client *client)
 	gpiod_set_value(nb7->enable_gpio, 0);
 	regulator_disable(nb7->vcc_supply);
 
+err_switch_put:
+	typec_switch_put(nb7->typec_switch);
+
 	return ret;
 }
 
@@ -471,6 +474,8 @@ static void nb7vpq904m_remove(struct i2c_client *client)
 	gpiod_set_value(nb7->enable_gpio, 0);
 
 	regulator_disable(nb7->vcc_supply);
+
+	typec_switch_put(nb7->typec_switch);
 }
 
 static const struct i2c_device_id nb7vpq904m_table[] = {

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 3/4] usb: typec-mux: ptn36502: broadcast typec state to next mux
  2024-06-06 13:11 [PATCH v2 0/4] usb: typec-mux: broadcast typec state to next mux for ptn36502 & nb7vpq904m retimers Neil Armstrong
  2024-06-06 13:11 ` [PATCH v2 1/4] usb: typec-mux: ptn36502: unregister typec switch on probe error and remove Neil Armstrong
  2024-06-06 13:11 ` [PATCH v2 2/4] usb: typec-mux: nb7vpq904m: " Neil Armstrong
@ 2024-06-06 13:11 ` Neil Armstrong
  2024-06-07  5:51   ` Dmitry Baryshkov
  2024-06-10 13:04   ` Heikki Krogerus
  2024-06-06 13:11 ` [PATCH v2 4/4] usb: typec-mux: nb7vpq904m: " Neil Armstrong
  3 siblings, 2 replies; 15+ messages in thread
From: Neil Armstrong @ 2024-06-06 13:11 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: Bjorn Andersson, Luca Weiss, linux-arm-msm, linux-usb,
	linux-kernel, Neil Armstrong

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


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH v2 4/4] usb: typec-mux: nb7vpq904m: broadcast typec state to next mux
  2024-06-06 13:11 [PATCH v2 0/4] usb: typec-mux: broadcast typec state to next mux for ptn36502 & nb7vpq904m retimers Neil Armstrong
                   ` (2 preceding siblings ...)
  2024-06-06 13:11 ` [PATCH v2 3/4] usb: typec-mux: ptn36502: broadcast typec state to next mux Neil Armstrong
@ 2024-06-06 13:11 ` Neil Armstrong
  2024-06-07  5:55   ` Dmitry Baryshkov
  2024-06-10 13:06   ` Heikki Krogerus
  3 siblings, 2 replies; 15+ messages in thread
From: Neil Armstrong @ 2024-06-06 13:11 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: Bjorn Andersson, Luca Weiss, linux-arm-msm, linux-usb,
	linux-kernel, Neil Armstrong

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 <neil.armstrong@linaro.org>
---
 drivers/usb/typec/mux/nb7vpq904m.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/mux/nb7vpq904m.c b/drivers/usb/typec/mux/nb7vpq904m.c
index 569f1162ee2e..b57b6c9c40fe 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 = {
@@ -413,9 +422,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)
-		goto err_switch_put;
+		goto err_mux_put;
 
 	ret = regulator_enable(nb7->vcc_supply);
 	if (ret)
@@ -458,6 +474,9 @@ 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);
 
@@ -475,6 +494,7 @@ static void nb7vpq904m_remove(struct i2c_client *client)
 
 	regulator_disable(nb7->vcc_supply);
 
+	typec_mux_put(nb7->typec_mux);
 	typec_switch_put(nb7->typec_switch);
 }
 

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 1/4] usb: typec-mux: ptn36502: unregister typec switch on probe error and remove
  2024-06-06 13:11 ` [PATCH v2 1/4] usb: typec-mux: ptn36502: unregister typec switch on probe error and remove Neil Armstrong
@ 2024-06-07  5:48   ` Dmitry Baryshkov
  2024-06-10 12:51   ` Heikki Krogerus
  1 sibling, 0 replies; 15+ messages in thread
From: Dmitry Baryshkov @ 2024-06-07  5:48 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Heikki Krogerus, Greg Kroah-Hartman, Bjorn Andersson, Luca Weiss,
	linux-arm-msm, linux-usb, linux-kernel

On Thu, Jun 06, 2024 at 03:11:13PM +0200, Neil Armstrong wrote:
> Add the missing call to typec_switch_put() when probe fails and
> the ptn36502_remove() call is called.
> 
> Fixes: 8e99dc783648 ("usb: typec: add support for PTN36502 redriver")
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
>  drivers/usb/typec/mux/ptn36502.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 2/4] usb: typec-mux: nb7vpq904m: unregister typec switch on probe error and remove
  2024-06-06 13:11 ` [PATCH v2 2/4] usb: typec-mux: nb7vpq904m: " Neil Armstrong
@ 2024-06-07  5:50   ` Dmitry Baryshkov
  2024-06-07 14:00     ` Neil Armstrong
  2024-06-10 13:02   ` Heikki Krogerus
  1 sibling, 1 reply; 15+ messages in thread
From: Dmitry Baryshkov @ 2024-06-07  5:50 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Heikki Krogerus, Greg Kroah-Hartman, Bjorn Andersson, Luca Weiss,
	linux-arm-msm, linux-usb, linux-kernel

On Thu, Jun 06, 2024 at 03:11:14PM +0200, Neil Armstrong wrote:
> Add the missing call to typec_switch_put() when probe fails and
> the nb7vpq904m_remove() call is called.
> 
> Fixes: 348359e7c232 ("usb: typec: nb7vpq904m: Add an error handling path in nb7vpq904m_probe()")
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
>  drivers/usb/typec/mux/nb7vpq904m.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

I'd say:

Fixes: 88d8f3ac9c67 ("usb: typec: add support for the nb7vpq904m Type-C Linear Redriver")

Nevertheless:

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>



-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 3/4] usb: typec-mux: ptn36502: broadcast typec state to next mux
  2024-06-06 13:11 ` [PATCH v2 3/4] usb: typec-mux: ptn36502: broadcast typec state to next mux Neil Armstrong
@ 2024-06-07  5:51   ` Dmitry Baryshkov
  2024-06-10 13:04   ` Heikki Krogerus
  1 sibling, 0 replies; 15+ messages in thread
From: Dmitry Baryshkov @ 2024-06-07  5:51 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Heikki Krogerus, Greg Kroah-Hartman, Bjorn Andersson, Luca Weiss,
	linux-arm-msm, linux-usb, linux-kernel

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@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 | 24 ++++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 4/4] usb: typec-mux: nb7vpq904m: broadcast typec state to next mux
  2024-06-06 13:11 ` [PATCH v2 4/4] usb: typec-mux: nb7vpq904m: " Neil Armstrong
@ 2024-06-07  5:55   ` Dmitry Baryshkov
  2024-06-10 13:06   ` Heikki Krogerus
  1 sibling, 0 replies; 15+ messages in thread
From: Dmitry Baryshkov @ 2024-06-07  5:55 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Heikki Krogerus, Greg Kroah-Hartman, Bjorn Andersson, Luca Weiss,
	linux-arm-msm, linux-usb, linux-kernel

On Thu, Jun 06, 2024 at 03:11:16PM +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 <neil.armstrong@linaro.org>
> ---
>  drivers/usb/typec/mux/nb7vpq904m.c | 24 ++++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
> 

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 2/4] usb: typec-mux: nb7vpq904m: unregister typec switch on probe error and remove
  2024-06-07  5:50   ` Dmitry Baryshkov
@ 2024-06-07 14:00     ` Neil Armstrong
  2024-06-07 14:49       ` Dmitry Baryshkov
  0 siblings, 1 reply; 15+ messages in thread
From: Neil Armstrong @ 2024-06-07 14:00 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Heikki Krogerus, Greg Kroah-Hartman, Bjorn Andersson, Luca Weiss,
	linux-arm-msm, linux-usb, linux-kernel

On 07/06/2024 07:50, Dmitry Baryshkov wrote:
> On Thu, Jun 06, 2024 at 03:11:14PM +0200, Neil Armstrong wrote:
>> Add the missing call to typec_switch_put() when probe fails and
>> the nb7vpq904m_remove() call is called.
>>
>> Fixes: 348359e7c232 ("usb: typec: nb7vpq904m: Add an error handling path in nb7vpq904m_probe()")
>> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
>> ---
>>   drivers/usb/typec/mux/nb7vpq904m.c | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> I'd say:
> 
> Fixes: 88d8f3ac9c67 ("usb: typec: add support for the nb7vpq904m Type-C Linear Redriver")

I should add both yes, it won't apply with only 88d8f3ac9c67

> 
> Nevertheless:
> 
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> 
> 
> 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 2/4] usb: typec-mux: nb7vpq904m: unregister typec switch on probe error and remove
  2024-06-07 14:00     ` Neil Armstrong
@ 2024-06-07 14:49       ` Dmitry Baryshkov
  0 siblings, 0 replies; 15+ messages in thread
From: Dmitry Baryshkov @ 2024-06-07 14:49 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Heikki Krogerus, Greg Kroah-Hartman, Bjorn Andersson, Luca Weiss,
	linux-arm-msm, linux-usb, linux-kernel

On Fri, Jun 07, 2024 at 04:00:22PM +0200, Neil Armstrong wrote:
> On 07/06/2024 07:50, Dmitry Baryshkov wrote:
> > On Thu, Jun 06, 2024 at 03:11:14PM +0200, Neil Armstrong wrote:
> > > Add the missing call to typec_switch_put() when probe fails and
> > > the nb7vpq904m_remove() call is called.
> > > 
> > > Fixes: 348359e7c232 ("usb: typec: nb7vpq904m: Add an error handling path in nb7vpq904m_probe()")
> > > Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> > > ---
> > >   drivers/usb/typec/mux/nb7vpq904m.c | 7 ++++++-
> > >   1 file changed, 6 insertions(+), 1 deletion(-)
> > 
> > I'd say:
> > 
> > Fixes: 88d8f3ac9c67 ("usb: typec: add support for the nb7vpq904m Type-C Linear Redriver")
> 
> I should add both yes, it won't apply with only 88d8f3ac9c67

That's fine. The issue is still present in the original commit. In the
worst case you'll get a 'please backport' request.

> 
> > 
> > Nevertheless:
> > 
> > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > 
> > 
> > 
> 

-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 1/4] usb: typec-mux: ptn36502: unregister typec switch on probe error and remove
  2024-06-06 13:11 ` [PATCH v2 1/4] usb: typec-mux: ptn36502: unregister typec switch on probe error and remove Neil Armstrong
  2024-06-07  5:48   ` Dmitry Baryshkov
@ 2024-06-10 12:51   ` Heikki Krogerus
  1 sibling, 0 replies; 15+ messages in thread
From: Heikki Krogerus @ 2024-06-10 12:51 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Greg Kroah-Hartman, Bjorn Andersson, Luca Weiss, linux-arm-msm,
	linux-usb, linux-kernel

On Thu, Jun 06, 2024 at 03:11:13PM +0200, Neil Armstrong wrote:
> Add the missing call to typec_switch_put() when probe fails and
> the ptn36502_remove() call is called.
> 
> Fixes: 8e99dc783648 ("usb: typec: add support for PTN36502 redriver")
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>

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

> ---
>  drivers/usb/typec/mux/ptn36502.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/mux/ptn36502.c b/drivers/usb/typec/mux/ptn36502.c
> index 0ec86ef32a87..88136a6d6f31 100644
> --- a/drivers/usb/typec/mux/ptn36502.c
> +++ b/drivers/usb/typec/mux/ptn36502.c
> @@ -322,8 +322,10 @@ static int ptn36502_probe(struct i2c_client *client)
>  				     "Failed to acquire orientation-switch\n");
>  
>  	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_switch_put;
> +	}
>  
>  	ret = ptn36502_detect(ptn);
>  	if (ret)
> @@ -363,6 +365,9 @@ static int ptn36502_probe(struct i2c_client *client)
>  err_disable_regulator:
>  	regulator_disable(ptn->vdd18_supply);
>  
> +err_switch_put:
> +	typec_switch_put(ptn->typec_switch);
> +
>  	return ret;
>  }
>  
> @@ -374,6 +379,8 @@ static void ptn36502_remove(struct i2c_client *client)
>  	typec_switch_unregister(ptn->sw);
>  
>  	regulator_disable(ptn->vdd18_supply);
> +
> +	typec_switch_put(ptn->typec_switch);
>  }
>  
>  static const struct i2c_device_id ptn36502_table[] = {
> 
> -- 
> 2.34.1

-- 
heikki

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 2/4] usb: typec-mux: nb7vpq904m: unregister typec switch on probe error and remove
  2024-06-06 13:11 ` [PATCH v2 2/4] usb: typec-mux: nb7vpq904m: " Neil Armstrong
  2024-06-07  5:50   ` Dmitry Baryshkov
@ 2024-06-10 13:02   ` Heikki Krogerus
  1 sibling, 0 replies; 15+ messages in thread
From: Heikki Krogerus @ 2024-06-10 13:02 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Greg Kroah-Hartman, Bjorn Andersson, Luca Weiss, linux-arm-msm,
	linux-usb, linux-kernel

On Thu, Jun 06, 2024 at 03:11:14PM +0200, Neil Armstrong wrote:
> Add the missing call to typec_switch_put() when probe fails and
> the nb7vpq904m_remove() call is called.
> 
> Fixes: 348359e7c232 ("usb: typec: nb7vpq904m: Add an error handling path in nb7vpq904m_probe()")
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>

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

> ---
>  drivers/usb/typec/mux/nb7vpq904m.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/mux/nb7vpq904m.c b/drivers/usb/typec/mux/nb7vpq904m.c
> index ed93194b16cf..569f1162ee2e 100644
> --- a/drivers/usb/typec/mux/nb7vpq904m.c
> +++ b/drivers/usb/typec/mux/nb7vpq904m.c
> @@ -415,7 +415,7 @@ static int nb7vpq904m_probe(struct i2c_client *client)
>  
>  	ret = nb7vpq904m_parse_data_lanes_mapping(nb7);
>  	if (ret)
> -		return ret;
> +		goto err_switch_put;
>  
>  	ret = regulator_enable(nb7->vcc_supply);
>  	if (ret)
> @@ -458,6 +458,9 @@ static int nb7vpq904m_probe(struct i2c_client *client)
>  	gpiod_set_value(nb7->enable_gpio, 0);
>  	regulator_disable(nb7->vcc_supply);
>  
> +err_switch_put:
> +	typec_switch_put(nb7->typec_switch);
> +
>  	return ret;
>  }
>  
> @@ -471,6 +474,8 @@ static void nb7vpq904m_remove(struct i2c_client *client)
>  	gpiod_set_value(nb7->enable_gpio, 0);
>  
>  	regulator_disable(nb7->vcc_supply);
> +
> +	typec_switch_put(nb7->typec_switch);
>  }
>  
>  static const struct i2c_device_id nb7vpq904m_table[] = {
> 
> -- 
> 2.34.1

-- 
heikki

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 3/4] usb: typec-mux: ptn36502: broadcast typec state to next mux
  2024-06-06 13:11 ` [PATCH v2 3/4] usb: typec-mux: ptn36502: broadcast typec state to next mux Neil Armstrong
  2024-06-07  5:51   ` Dmitry Baryshkov
@ 2024-06-10 13:04   ` Heikki Krogerus
  1 sibling, 0 replies; 15+ messages in thread
From: Heikki Krogerus @ 2024-06-10 13:04 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Greg Kroah-Hartman, Bjorn Andersson, Luca Weiss, linux-arm-msm,
	linux-usb, linux-kernel

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@fairphone.com>
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH v2 4/4] usb: typec-mux: nb7vpq904m: broadcast typec state to next mux
  2024-06-06 13:11 ` [PATCH v2 4/4] usb: typec-mux: nb7vpq904m: " Neil Armstrong
  2024-06-07  5:55   ` Dmitry Baryshkov
@ 2024-06-10 13:06   ` Heikki Krogerus
  1 sibling, 0 replies; 15+ messages in thread
From: Heikki Krogerus @ 2024-06-10 13:06 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Greg Kroah-Hartman, Bjorn Andersson, Luca Weiss, linux-arm-msm,
	linux-usb, linux-kernel

On Thu, Jun 06, 2024 at 03:11:16PM +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 <neil.armstrong@linaro.org>

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

> ---
>  drivers/usb/typec/mux/nb7vpq904m.c | 24 ++++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/mux/nb7vpq904m.c b/drivers/usb/typec/mux/nb7vpq904m.c
> index 569f1162ee2e..b57b6c9c40fe 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 = {
> @@ -413,9 +422,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)
> -		goto err_switch_put;
> +		goto err_mux_put;
>  
>  	ret = regulator_enable(nb7->vcc_supply);
>  	if (ret)
> @@ -458,6 +474,9 @@ 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);
>  
> @@ -475,6 +494,7 @@ static void nb7vpq904m_remove(struct i2c_client *client)
>  
>  	regulator_disable(nb7->vcc_supply);
>  
> +	typec_mux_put(nb7->typec_mux);
>  	typec_switch_put(nb7->typec_switch);
>  }
>  
> 
> -- 
> 2.34.1

-- 
heikki

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-06-10 13:06 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-06 13:11 [PATCH v2 0/4] usb: typec-mux: broadcast typec state to next mux for ptn36502 & nb7vpq904m retimers Neil Armstrong
2024-06-06 13:11 ` [PATCH v2 1/4] usb: typec-mux: ptn36502: unregister typec switch on probe error and remove Neil Armstrong
2024-06-07  5:48   ` Dmitry Baryshkov
2024-06-10 12:51   ` Heikki Krogerus
2024-06-06 13:11 ` [PATCH v2 2/4] usb: typec-mux: nb7vpq904m: " Neil Armstrong
2024-06-07  5:50   ` Dmitry Baryshkov
2024-06-07 14:00     ` Neil Armstrong
2024-06-07 14:49       ` Dmitry Baryshkov
2024-06-10 13:02   ` Heikki Krogerus
2024-06-06 13:11 ` [PATCH v2 3/4] usb: typec-mux: ptn36502: broadcast typec state to next mux Neil Armstrong
2024-06-07  5:51   ` Dmitry Baryshkov
2024-06-10 13:04   ` Heikki Krogerus
2024-06-06 13:11 ` [PATCH v2 4/4] usb: typec-mux: nb7vpq904m: " Neil Armstrong
2024-06-07  5:55   ` Dmitry Baryshkov
2024-06-10 13:06   ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox