forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/usb/typec/ucsi/trace.c
....@@ -1,3 +1,63 @@
11 // SPDX-License-Identifier: GPL-2.0
22 #define CREATE_TRACE_POINTS
3
+#include "ucsi.h"
34 #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_UOM] = "SET_UOM",
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
+
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
+const char *ucsi_cci_str(u32 cci)
37
+{
38
+ if (UCSI_CCI_CONNECTOR(cci)) {
39
+ if (cci & UCSI_CCI_ACK_COMPLETE)
40
+ return "Event pending (ACK completed)";
41
+ if (cci & UCSI_CCI_COMMAND_COMPLETE)
42
+ return "Event pending (command completed)";
43
+ return "Connector Change";
44
+ }
45
+ if (cci & UCSI_CCI_ACK_COMPLETE)
46
+ return "ACK completed";
47
+ if (cci & UCSI_CCI_COMMAND_COMPLETE)
48
+ return "Command completed";
49
+
50
+ return "";
51
+}
52
+
53
+static const char * const ucsi_recipient_strs[] = {
54
+ [UCSI_RECIPIENT_CON] = "port",
55
+ [UCSI_RECIPIENT_SOP] = "partner",
56
+ [UCSI_RECIPIENT_SOP_P] = "plug (prime)",
57
+ [UCSI_RECIPIENT_SOP_PP] = "plug (double prime)",
58
+};
59
+
60
+const char *ucsi_recipient_str(u8 recipient)
61
+{
62
+ return ucsi_recipient_strs[recipient];
63
+}