Skip to content

Commit ad74b86

Browse files
Heikki Krogerusgregkh
authored andcommitted
usb: typec: ucsi: Preliminary support for alternate modes
With UCSI the alternate modes, just like everything else related to USB Type-C connectors, are handled in firmware. The operating system can see the status and is allowed to request certain things, for example entering and exiting the modes, but the support for alternate modes is very limited in UCSI. The feature is also optional, which means that even when the platform supports alternate modes, the operating system may not be even made aware of them. UCSI does not support direct VDM reading or writing. Instead, alternate modes can be entered and exited using a single custom command which takes also an optional SVID specific configuration value as parameter. That means every supported alternate mode has to be handled separately in UCSI driver. This commit does not include support for any specific alternate mode. The discovered alternate modes are now registered, but binding a driver to an alternate mode will not be possible until support for that alternate mode is added to the UCSI driver. Tested-by: Ajay Gupta <[email protected]> Signed-off-by: Heikki Krogerus <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5c9ae5a commit ad74b86

File tree

4 files changed

+428
-92
lines changed

4 files changed

+428
-92
lines changed

drivers/usb/typec/ucsi/trace.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,15 @@ const char *ucsi_cci_str(u32 cci)
6060

6161
return "";
6262
}
63+
64+
static const char * const ucsi_recipient_strs[] = {
65+
[UCSI_RECIPIENT_CON] = "port",
66+
[UCSI_RECIPIENT_SOP] = "partner",
67+
[UCSI_RECIPIENT_SOP_P] = "plug (prime)",
68+
[UCSI_RECIPIENT_SOP_PP] = "plug (double prime)",
69+
};
70+
71+
const char *ucsi_recipient_str(u8 recipient)
72+
{
73+
return ucsi_recipient_strs[recipient];
74+
}

drivers/usb/typec/ucsi/trace.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#define __UCSI_TRACE_H
88

99
#include <linux/tracepoint.h>
10+
#include <linux/usb/typec_altmode.h>
1011

1112
const char *ucsi_cmd_str(u64 raw_cmd);
1213
const char *ucsi_ack_str(u8 ack);
@@ -134,6 +135,31 @@ DEFINE_EVENT(ucsi_log_connector_status, ucsi_register_port,
134135
TP_ARGS(port, status)
135136
);
136137

138+
DECLARE_EVENT_CLASS(ucsi_log_register_altmode,
139+
TP_PROTO(u8 recipient, struct typec_altmode *alt),
140+
TP_ARGS(recipient, alt),
141+
TP_STRUCT__entry(
142+
__field(u8, recipient)
143+
__field(u16, svid)
144+
__field(u8, mode)
145+
__field(u32, vdo)
146+
),
147+
TP_fast_assign(
148+
__entry->recipient = recipient;
149+
__entry->svid = alt->svid;
150+
__entry->mode = alt->mode;
151+
__entry->vdo = alt->vdo;
152+
),
153+
TP_printk("%s alt mode: svid %04x, mode %d vdo %x",
154+
ucsi_recipient_str(__entry->recipient), __entry->svid,
155+
__entry->mode, __entry->vdo)
156+
);
157+
158+
DEFINE_EVENT(ucsi_log_register_altmode, ucsi_register_altmode,
159+
TP_PROTO(u8 recipient, struct typec_altmode *alt),
160+
TP_ARGS(recipient, alt)
161+
);
162+
137163
#endif /* __UCSI_TRACE_H */
138164

139165
/* This part must be outside protection */

0 commit comments

Comments
 (0)