Message ID | 20240606-topic-sm8x50-upstream-retimer-broadcast-mode-v2-4-c6f6eae479c3@linaro.org (mailing list archive) |
---|---|
State | Accepted |
Commit | 90c478ee37bebe1adaab920e3e06228fef3b9364 |
Headers | show |
Series | usb: typec-mux: broadcast typec state to next mux for ptn36502 & nb7vpq904m retimers | expand |
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>
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
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); }
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(-)