Skip to content

Commit 25a2bc2

Browse files
superna9999gregkh
authored andcommitted
usb: typec: ucsi: call typec_set_mode on non-altmode partner change
Add support for calling typec_set_mode() for the DEBUG, AUDIO accessory modes. Let's also call typec_set_mode() for USB as default and SAFE when partner is disconnected. The USB state is only called when ALT mode is specifically not specified by the partner status flags in order to leave the altmode handlers setup the proper mode to switches, muxes and retimers. Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> Tested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20230614-topic-sm8550-upstream-type-c-audio-v1-1-15a92565146b@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent aed1a2a commit 25a2bc2

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

drivers/usb/typec/ucsi/ucsi.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,23 @@ static void ucsi_partner_change(struct ucsi_connector *con)
809809
break;
810810
}
811811

812+
if (con->status.flags & UCSI_CONSTAT_CONNECTED) {
813+
switch (UCSI_CONSTAT_PARTNER_TYPE(con->status.flags)) {
814+
case UCSI_CONSTAT_PARTNER_TYPE_DEBUG:
815+
typec_set_mode(con->port, TYPEC_MODE_DEBUG);
816+
break;
817+
case UCSI_CONSTAT_PARTNER_TYPE_AUDIO:
818+
typec_set_mode(con->port, TYPEC_MODE_AUDIO);
819+
break;
820+
default:
821+
if (UCSI_CONSTAT_PARTNER_FLAGS(con->status.flags) ==
822+
UCSI_CONSTAT_PARTNER_FLAG_USB)
823+
typec_set_mode(con->port, TYPEC_STATE_USB);
824+
}
825+
} else {
826+
typec_set_mode(con->port, TYPEC_STATE_SAFE);
827+
}
828+
812829
/* Only notify USB controller if partner supports USB data */
813830
if (!(UCSI_CONSTAT_PARTNER_FLAGS(con->status.flags) & UCSI_CONSTAT_PARTNER_FLAG_USB))
814831
u_role = USB_ROLE_NONE;

0 commit comments

Comments
 (0)