Skip to content

Commit

Permalink
usb: typec: ucsi: Preliminary support for alternate modes
Browse files Browse the repository at this point in the history
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 <ajayg@nvidia.com>
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Heikki Krogerus authored and Greg Kroah-Hartman committed Apr 25, 2019
1 parent 5c9ae5a commit ad74b86
Show file tree
Hide file tree
Showing 4 changed files with 428 additions and 92 deletions.
12 changes: 12 additions & 0 deletions drivers/usb/typec/ucsi/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,15 @@ const char *ucsi_cci_str(u32 cci)

return "";
}

static const char * const ucsi_recipient_strs[] = {
[UCSI_RECIPIENT_CON] = "port",
[UCSI_RECIPIENT_SOP] = "partner",
[UCSI_RECIPIENT_SOP_P] = "plug (prime)",
[UCSI_RECIPIENT_SOP_PP] = "plug (double prime)",
};

const char *ucsi_recipient_str(u8 recipient)
{
return ucsi_recipient_strs[recipient];
}
26 changes: 26 additions & 0 deletions drivers/usb/typec/ucsi/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define __UCSI_TRACE_H

#include <linux/tracepoint.h>
#include <linux/usb/typec_altmode.h>

const char *ucsi_cmd_str(u64 raw_cmd);
const char *ucsi_ack_str(u8 ack);
Expand Down Expand Up @@ -134,6 +135,31 @@ DEFINE_EVENT(ucsi_log_connector_status, ucsi_register_port,
TP_ARGS(port, status)
);

DECLARE_EVENT_CLASS(ucsi_log_register_altmode,
TP_PROTO(u8 recipient, struct typec_altmode *alt),
TP_ARGS(recipient, alt),
TP_STRUCT__entry(
__field(u8, recipient)
__field(u16, svid)
__field(u8, mode)
__field(u32, vdo)
),
TP_fast_assign(
__entry->recipient = recipient;
__entry->svid = alt->svid;
__entry->mode = alt->mode;
__entry->vdo = alt->vdo;
),
TP_printk("%s alt mode: svid %04x, mode %d vdo %x",
ucsi_recipient_str(__entry->recipient), __entry->svid,
__entry->mode, __entry->vdo)
);

DEFINE_EVENT(ucsi_log_register_altmode, ucsi_register_altmode,
TP_PROTO(u8 recipient, struct typec_altmode *alt),
TP_ARGS(recipient, alt)
);

#endif /* __UCSI_TRACE_H */

/* This part must be outside protection */
Expand Down
Loading

0 comments on commit ad74b86

Please sign in to comment.