mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
usb: typec: ps883x: Rework ps883x_set()
In preparation to extend it with new alt/USB modes, rework the code a bit by changing the flow into a pair of switch statements. Reviewed-by: Jack Pham <jack.pham@oss.qualcomm.com> Signed-off-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://patch.msgid.link/20251014-topic-ps883x_usb4-v1-2-e6adb1a4296e@oss.qualcomm.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
f83cb615cb
commit
6bebd9b777
|
|
@ -99,44 +99,47 @@ static int ps883x_set(struct ps883x_retimer *retimer, struct typec_retimer_state
|
||||||
int cfg1 = 0x00;
|
int cfg1 = 0x00;
|
||||||
int cfg2 = 0x00;
|
int cfg2 = 0x00;
|
||||||
|
|
||||||
if (retimer->orientation == TYPEC_ORIENTATION_NONE ||
|
|
||||||
state->mode == TYPEC_STATE_SAFE) {
|
|
||||||
return ps883x_configure(retimer, cfg0, cfg1, cfg2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state->alt && state->alt->svid != USB_TYPEC_DP_SID)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (retimer->orientation == TYPEC_ORIENTATION_REVERSE)
|
if (retimer->orientation == TYPEC_ORIENTATION_REVERSE)
|
||||||
cfg0 |= CONN_STATUS_0_ORIENTATION_REVERSED;
|
cfg0 |= CONN_STATUS_0_ORIENTATION_REVERSED;
|
||||||
|
|
||||||
switch (state->mode) {
|
if (state->alt) {
|
||||||
case TYPEC_STATE_USB:
|
switch (state->alt->svid) {
|
||||||
cfg0 |= CONN_STATUS_0_USB_3_1_CONNECTED;
|
case USB_TYPEC_DP_SID:
|
||||||
break;
|
cfg1 |= CONN_STATUS_1_DP_CONNECTED |
|
||||||
|
CONN_STATUS_1_DP_HPD_LEVEL;
|
||||||
|
|
||||||
case TYPEC_DP_STATE_C:
|
switch (state->mode) {
|
||||||
cfg1 = CONN_STATUS_1_DP_CONNECTED |
|
case TYPEC_DP_STATE_C:
|
||||||
CONN_STATUS_1_DP_SINK_REQUESTED |
|
cfg1 |= CONN_STATUS_1_DP_SINK_REQUESTED |
|
||||||
CONN_STATUS_1_DP_PIN_ASSIGNMENT_C_D |
|
CONN_STATUS_1_DP_PIN_ASSIGNMENT_C_D;
|
||||||
CONN_STATUS_1_DP_HPD_LEVEL;
|
fallthrough;
|
||||||
break;
|
case TYPEC_DP_STATE_D:
|
||||||
|
cfg1 |= CONN_STATUS_0_USB_3_1_CONNECTED;
|
||||||
case TYPEC_DP_STATE_D:
|
break;
|
||||||
cfg0 |= CONN_STATUS_0_USB_3_1_CONNECTED;
|
default: /* MODE_E */
|
||||||
cfg1 = CONN_STATUS_1_DP_CONNECTED |
|
break;
|
||||||
CONN_STATUS_1_DP_SINK_REQUESTED |
|
}
|
||||||
CONN_STATUS_1_DP_PIN_ASSIGNMENT_C_D |
|
break;
|
||||||
CONN_STATUS_1_DP_HPD_LEVEL;
|
default:
|
||||||
break;
|
dev_err(&retimer->client->dev, "Got unsupported SID: 0x%x\n",
|
||||||
|
state->alt->svid);
|
||||||
case TYPEC_DP_STATE_E:
|
return -EOPNOTSUPP;
|
||||||
cfg1 = CONN_STATUS_1_DP_CONNECTED |
|
}
|
||||||
CONN_STATUS_1_DP_HPD_LEVEL;
|
} else {
|
||||||
break;
|
switch (state->mode) {
|
||||||
|
case TYPEC_STATE_SAFE:
|
||||||
default:
|
/* USB2 pins don't even go through this chip */
|
||||||
return -EOPNOTSUPP;
|
case TYPEC_MODE_USB2:
|
||||||
|
break;
|
||||||
|
case TYPEC_STATE_USB:
|
||||||
|
case TYPEC_MODE_USB3:
|
||||||
|
cfg0 |= CONN_STATUS_0_USB_3_1_CONNECTED;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
dev_err(&retimer->client->dev, "Got unsupported mode: %lu\n",
|
||||||
|
state->mode);
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ps883x_configure(retimer, cfg0, cfg1, cfg2);
|
return ps883x_configure(retimer, cfg0, cfg1, cfg2);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user