1 // SPDX-License-Identifier: GPL-2.0
2 #define CREATE_TRACE_POINTS
3 #include "ucsi.h"
4 #include "trace.h"
5
6 static const char * const ucsi_cmd_strs[] = {
7 [0] = "Unknown command",
8 [UCSI_PPM_RESET] = "PPM_RESET",
9 [UCSI_CANCEL] = "CANCEL",
10 [UCSI_CONNECTOR_RESET] = "CONNECTOR_RESET",
11 [UCSI_ACK_CC_CI] = "ACK_CC_CI",
12 [UCSI_SET_NOTIFICATION_ENABLE] = "SET_NOTIFICATION_ENABLE",
13 [UCSI_GET_CAPABILITY] = "GET_CAPABILITY",
14 [UCSI_GET_CONNECTOR_CAPABILITY] = "GET_CONNECTOR_CAPABILITY",
15 [UCSI_SET_CCOM] = "SET_CCOM",
16 [UCSI_SET_UOR] = "SET_UOR",
17 [UCSI_SET_PDM] = "SET_PDM",
18 [UCSI_SET_PDR] = "SET_PDR",
19 [UCSI_GET_ALTERNATE_MODES] = "GET_ALTERNATE_MODES",
20 [UCSI_GET_CAM_SUPPORTED] = "GET_CAM_SUPPORTED",
21 [UCSI_GET_CURRENT_CAM] = "GET_CURRENT_CAM",
22 [UCSI_SET_NEW_CAM] = "SET_NEW_CAM",
23 [UCSI_GET_PDOS] = "GET_PDOS",
24 [UCSI_GET_CABLE_PROPERTY] = "GET_CABLE_PROPERTY",
25 [UCSI_GET_CONNECTOR_STATUS] = "GET_CONNECTOR_STATUS",
26 [UCSI_GET_ERROR_STATUS] = "GET_ERROR_STATUS",
27 };
28
ucsi_cmd_str(u64 raw_cmd)29 const char *ucsi_cmd_str(u64 raw_cmd)
30 {
31 u8 cmd = raw_cmd & GENMASK(7, 0);
32
33 return ucsi_cmd_strs[(cmd >= ARRAY_SIZE(ucsi_cmd_strs)) ? 0 : cmd];
34 }
35
36 static const char * const ucsi_recipient_strs[] = {
37 [UCSI_RECIPIENT_CON] = "port",
38 [UCSI_RECIPIENT_SOP] = "partner",
39 [UCSI_RECIPIENT_SOP_P] = "plug (prime)",
40 [UCSI_RECIPIENT_SOP_PP] = "plug (double prime)",
41 };
42
ucsi_recipient_str(u8 recipient)43 const char *ucsi_recipient_str(u8 recipient)
44 {
45 return ucsi_recipient_strs[recipient];
46 }
47