Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #define CREATE_TRACE_POINTS
0003 #include "ucsi.h"
0004 #include "trace.h"
0005 
0006 static const char * const ucsi_cmd_strs[] = {
0007     [0]             = "Unknown command",
0008     [UCSI_PPM_RESET]        = "PPM_RESET",
0009     [UCSI_CANCEL]           = "CANCEL",
0010     [UCSI_CONNECTOR_RESET]      = "CONNECTOR_RESET",
0011     [UCSI_ACK_CC_CI]        = "ACK_CC_CI",
0012     [UCSI_SET_NOTIFICATION_ENABLE]  = "SET_NOTIFICATION_ENABLE",
0013     [UCSI_GET_CAPABILITY]       = "GET_CAPABILITY",
0014     [UCSI_GET_CONNECTOR_CAPABILITY] = "GET_CONNECTOR_CAPABILITY",
0015     [UCSI_SET_UOM]          = "SET_UOM",
0016     [UCSI_SET_UOR]          = "SET_UOR",
0017     [UCSI_SET_PDM]          = "SET_PDM",
0018     [UCSI_SET_PDR]          = "SET_PDR",
0019     [UCSI_GET_ALTERNATE_MODES]  = "GET_ALTERNATE_MODES",
0020     [UCSI_GET_CAM_SUPPORTED]    = "GET_CAM_SUPPORTED",
0021     [UCSI_GET_CURRENT_CAM]      = "GET_CURRENT_CAM",
0022     [UCSI_SET_NEW_CAM]      = "SET_NEW_CAM",
0023     [UCSI_GET_PDOS]         = "GET_PDOS",
0024     [UCSI_GET_CABLE_PROPERTY]   = "GET_CABLE_PROPERTY",
0025     [UCSI_GET_CONNECTOR_STATUS] = "GET_CONNECTOR_STATUS",
0026     [UCSI_GET_ERROR_STATUS]     = "GET_ERROR_STATUS",
0027 };
0028 
0029 const char *ucsi_cmd_str(u64 raw_cmd)
0030 {
0031     u8 cmd = raw_cmd & GENMASK(7, 0);
0032 
0033     return ucsi_cmd_strs[(cmd >= ARRAY_SIZE(ucsi_cmd_strs)) ? 0 : cmd];
0034 }
0035 
0036 const char *ucsi_cci_str(u32 cci)
0037 {
0038     if (UCSI_CCI_CONNECTOR(cci)) {
0039         if (cci & UCSI_CCI_ACK_COMPLETE)
0040             return "Event pending (ACK completed)";
0041         if (cci & UCSI_CCI_COMMAND_COMPLETE)
0042             return "Event pending (command completed)";
0043         return "Connector Change";
0044     }
0045     if (cci & UCSI_CCI_ACK_COMPLETE)
0046         return "ACK completed";
0047     if (cci & UCSI_CCI_COMMAND_COMPLETE)
0048         return "Command completed";
0049 
0050     return "";
0051 }
0052 
0053 static const char * const ucsi_recipient_strs[] = {
0054     [UCSI_RECIPIENT_CON]        = "port",
0055     [UCSI_RECIPIENT_SOP]        = "partner",
0056     [UCSI_RECIPIENT_SOP_P]      = "plug (prime)",
0057     [UCSI_RECIPIENT_SOP_PP]     = "plug (double prime)",
0058 };
0059 
0060 const char *ucsi_recipient_str(u8 recipient)
0061 {
0062     return ucsi_recipient_strs[recipient];
0063 }