struct typec_retimer *retimer;
struct typec_switch *typec_switch;
+ struct typec_mux *typec_mux;
struct mutex lock; /* protect non-concurrent retimer & switch */
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);
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)
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);
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);
regulator_disable(ptn->vdd18_supply);
+ typec_mux_put(ptn->typec_mux);
typec_switch_put(ptn->typec_switch);
}