Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
c1b0bc2d HK |
2 | #ifndef __UCSI_DEBUG_H |
3 | #define __UCSI_DEBUG_H | |
4 | ||
5 | #include "ucsi.h" | |
6 | ||
7 | static const char * const ucsi_cmd_strs[] = { | |
8 | [0] = "Unknown command", | |
9 | [UCSI_PPM_RESET] = "PPM_RESET", | |
10 | [UCSI_CANCEL] = "CANCEL", | |
11 | [UCSI_CONNECTOR_RESET] = "CONNECTOR_RESET", | |
12 | [UCSI_ACK_CC_CI] = "ACK_CC_CI", | |
13 | [UCSI_SET_NOTIFICATION_ENABLE] = "SET_NOTIFICATION_ENABLE", | |
14 | [UCSI_GET_CAPABILITY] = "GET_CAPABILITY", | |
15 | [UCSI_GET_CONNECTOR_CAPABILITY] = "GET_CONNECTOR_CAPABILITY", | |
16 | [UCSI_SET_UOM] = "SET_UOM", | |
17 | [UCSI_SET_UOR] = "SET_UOR", | |
18 | [UCSI_SET_PDM] = "SET_PDM", | |
19 | [UCSI_SET_PDR] = "SET_PDR", | |
20 | [UCSI_GET_ALTERNATE_MODES] = "GET_ALTERNATE_MODES", | |
21 | [UCSI_GET_CAM_SUPPORTED] = "GET_CAM_SUPPORTED", | |
22 | [UCSI_GET_CURRENT_CAM] = "GET_CURRENT_CAM", | |
23 | [UCSI_SET_NEW_CAM] = "SET_NEW_CAM", | |
24 | [UCSI_GET_PDOS] = "GET_PDOS", | |
25 | [UCSI_GET_CABLE_PROPERTY] = "GET_CABLE_PROPERTY", | |
26 | [UCSI_GET_CONNECTOR_STATUS] = "GET_CONNECTOR_STATUS", | |
27 | [UCSI_GET_ERROR_STATUS] = "GET_ERROR_STATUS", | |
28 | }; | |
29 | ||
30 | static inline const char *ucsi_cmd_str(u64 raw_cmd) | |
31 | { | |
32 | u8 cmd = raw_cmd & GENMASK(7, 0); | |
33 | ||
34 | return ucsi_cmd_strs[(cmd >= ARRAY_SIZE(ucsi_cmd_strs)) ? 0 : cmd]; | |
35 | } | |
36 | ||
37 | static const char * const ucsi_ack_strs[] = { | |
38 | [0] = "", | |
39 | [UCSI_ACK_EVENT] = "event", | |
40 | [UCSI_ACK_CMD] = "command", | |
41 | }; | |
42 | ||
43 | static inline const char *ucsi_ack_str(u8 ack) | |
44 | { | |
45 | return ucsi_ack_strs[(ack >= ARRAY_SIZE(ucsi_ack_strs)) ? 0 : ack]; | |
46 | } | |
47 | ||
48 | static inline const char *ucsi_cci_str(u32 cci) | |
49 | { | |
50 | if (cci & GENMASK(7, 0)) { | |
51 | if (cci & BIT(29)) | |
52 | return "Event pending (ACK completed)"; | |
53 | if (cci & BIT(31)) | |
54 | return "Event pending (command completed)"; | |
55 | return "Connector Change"; | |
56 | } | |
57 | if (cci & BIT(29)) | |
58 | return "ACK completed"; | |
59 | if (cci & BIT(31)) | |
60 | return "Command completed"; | |
61 | ||
62 | return ""; | |
63 | } | |
64 | ||
65 | #endif /* __UCSI_DEBUG_H */ |