Linux Audio

Check our new training course

Linux BSP development engineering services

Need help to port Linux and bootloaders to your hardware?
Loading...
Note: File does not exist in v6.8.
  1
  2#include <linux/types.h>
  3
  4/* -------------------------------------------------------------------------- */
  5
  6/* Command Status and Connector Change Indication (CCI) data structure */
  7struct ucsi_cci {
  8	unsigned int RESERVED1:1;
  9	unsigned int connector_change:7;
 10	u8 data_length;
 11	unsigned int RESERVED9:9;
 12	unsigned int not_supported:1;
 13	unsigned int cancel_complete:1;
 14	unsigned int reset_complete:1;
 15	unsigned int busy:1;
 16	unsigned int ack_complete:1;
 17	unsigned int error:1;
 18	unsigned int cmd_complete:1;
 19} __packed;
 20
 21/* Default fields in CONTROL data structure */
 22struct ucsi_command {
 23	u8 cmd;
 24	u8 length;
 25	u64 data:48;
 26} __packed;
 27
 28/* Set USB Operation Mode Command structure */
 29struct ucsi_uor_cmd {
 30	u8 cmd;
 31	u8 length;
 32	u64 con_num:7;
 33	u64 role:3;
 34#define UCSI_UOR_ROLE_DFP			BIT(0)
 35#define UCSI_UOR_ROLE_UFP			BIT(1)
 36#define UCSI_UOR_ROLE_DRP			BIT(2)
 37	u64 data:38;
 38} __packed;
 39
 40struct ucsi_control {
 41	union {
 42		u64 raw_cmd;
 43		struct ucsi_command cmd;
 44		struct ucsi_uor_cmd uor;
 45	};
 46};
 47
 48struct ucsi_data {
 49	u16 version;
 50	u16 RESERVED;
 51	union {
 52		u32 raw_cci;
 53		struct ucsi_cci cci;
 54	};
 55	struct ucsi_control ctrl;
 56	u32 message_in[4];
 57	u32 message_out[4];
 58} __packed;
 59
 60/* Commands */
 61#define UCSI_PPM_RESET			0x01
 62#define UCSI_CANCEL			0x02
 63#define UCSI_CONNECTOR_RESET		0x03
 64#define UCSI_ACK_CC_CI			0x04
 65#define UCSI_SET_NOTIFICATION_ENABLE	0x05
 66#define UCSI_GET_CAPABILITY		0x06
 67#define UCSI_GET_CONNECTOR_CAPABILITY	0x07
 68#define UCSI_SET_UOM			0x08
 69#define UCSI_SET_UOR			0x09
 70#define UCSI_SET_PDM			0x0A
 71#define UCSI_SET_PDR			0x0B
 72#define UCSI_GET_ALTERNATE_MODES	0x0C
 73#define UCSI_GET_CAM_SUPPORTED		0x0D
 74#define UCSI_GET_CURRENT_CAM		0x0E
 75#define UCSI_SET_NEW_CAM		0x0F
 76#define UCSI_GET_PDOS			0x10
 77#define UCSI_GET_CABLE_PROPERTY		0x11
 78#define UCSI_GET_CONNECTOR_STATUS	0x12
 79#define UCSI_GET_ERROR_STATUS		0x13
 80
 81/* ACK_CC_CI commands */
 82#define UCSI_ACK_EVENT			1
 83#define UCSI_ACK_CMD			2
 84
 85/* Bits for SET_NOTIFICATION_ENABLE command */
 86#define UCSI_ENABLE_NTFY_CMD_COMPLETE		BIT(0)
 87#define UCSI_ENABLE_NTFY_EXT_PWR_SRC_CHANGE	BIT(1)
 88#define UCSI_ENABLE_NTFY_PWR_OPMODE_CHANGE	BIT(2)
 89#define UCSI_ENABLE_NTFY_CAP_CHANGE		BIT(5)
 90#define UCSI_ENABLE_NTFY_PWR_LEVEL_CHANGE	BIT(6)
 91#define UCSI_ENABLE_NTFY_PD_RESET_COMPLETE	BIT(7)
 92#define UCSI_ENABLE_NTFY_CAM_CHANGE		BIT(8)
 93#define UCSI_ENABLE_NTFY_BAT_STATUS_CHANGE	BIT(9)
 94#define UCSI_ENABLE_NTFY_PARTNER_CHANGE		BIT(11)
 95#define UCSI_ENABLE_NTFY_PWR_DIR_CHANGE		BIT(12)
 96#define UCSI_ENABLE_NTFY_CONNECTOR_CHANGE	BIT(14)
 97#define UCSI_ENABLE_NTFY_ERROR			BIT(15)
 98#define UCSI_ENABLE_NTFY_ALL			0xdbe7
 99
100/* Error information returned by PPM in response to GET_ERROR_STATUS command. */
101#define UCSI_ERROR_UNREGONIZED_CMD		BIT(0)
102#define UCSI_ERROR_INVALID_CON_NUM		BIT(1)
103#define UCSI_ERROR_INVALID_CMD_ARGUMENT		BIT(2)
104#define UCSI_ERROR_INCOMPATIBLE_PARTNER		BIT(3)
105#define UCSI_ERROR_CC_COMMUNICATION_ERR		BIT(4)
106#define UCSI_ERROR_DEAD_BATTERY			BIT(5)
107#define UCSI_ERROR_CONTRACT_NEGOTIATION_FAIL	BIT(6)
108
109/* Data structure filled by PPM in response to GET_CAPABILITY command. */
110struct ucsi_capability {
111	u32 attributes;
112#define UCSI_CAP_ATTR_DISABLE_STATE		BIT(0)
113#define UCSI_CAP_ATTR_BATTERY_CHARGING		BIT(1)
114#define UCSI_CAP_ATTR_USB_PD			BIT(2)
115#define UCSI_CAP_ATTR_TYPEC_CURRENT		BIT(6)
116#define UCSI_CAP_ATTR_POWER_AC_SUPPLY		BIT(8)
117#define UCSI_CAP_ATTR_POWER_OTHER		BIT(10)
118#define UCSI_CAP_ATTR_POWER_VBUS		BIT(14)
119	u8 num_connectors;
120	u32 features:24;
121#define UCSI_CAP_SET_UOM			BIT(0)
122#define UCSI_CAP_SET_PDM			BIT(1)
123#define UCSI_CAP_ALT_MODE_DETAILS		BIT(2)
124#define UCSI_CAP_ALT_MODE_OVERRIDE		BIT(3)
125#define UCSI_CAP_PDO_DETAILS			BIT(4)
126#define UCSI_CAP_CABLE_DETAILS			BIT(5)
127#define UCSI_CAP_EXT_SUPPLY_NOTIFICATIONS	BIT(6)
128#define UCSI_CAP_PD_RESET			BIT(7)
129	u8 num_alt_modes;
130	u8 RESERVED;
131	u16 bc_version;
132	u16 pd_version;
133	u16 typec_version;
134} __packed;
135
136/* Data structure filled by PPM in response to GET_CONNECTOR_CAPABILITY cmd. */
137struct ucsi_connector_capability {
138	u8 op_mode;
139#define UCSI_CONCAP_OPMODE_DFP			BIT(0)
140#define UCSI_CONCAP_OPMODE_UFP			BIT(1)
141#define UCSI_CONCAP_OPMODE_DRP			BIT(2)
142#define UCSI_CONCAP_OPMODE_AUDIO_ACCESSORY	BIT(3)
143#define UCSI_CONCAP_OPMODE_DEBUG_ACCESSORY	BIT(4)
144#define UCSI_CONCAP_OPMODE_USB2			BIT(5)
145#define UCSI_CONCAP_OPMODE_USB3			BIT(6)
146#define UCSI_CONCAP_OPMODE_ALT_MODE		BIT(7)
147	u8 provider:1;
148	u8 consumer:1;
149} __packed;
150
151/* Data structure filled by PPM in response to GET_CABLE_PROPERTY command. */
152struct ucsi_cable_property {
153	u16 speed_supported;
154	u8 current_capability;
155	u8 vbus_in_cable:1;
156	u8 active_cable:1;
157	u8 directionality:1;
158	u8 plug_type:2;
159#define UCSI_CABLE_PROPERTY_PLUG_TYPE_A		0
160#define UCSI_CABLE_PROPERTY_PLUG_TYPE_B		1
161#define UCSI_CABLE_PROPERTY_PLUG_TYPE_C		2
162#define UCSI_CABLE_PROPERTY_PLUG_OTHER		3
163	u8 mode_support:1;
164	u8 RESERVED_2:2;
165	u8 latency:4;
166	u8 RESERVED_4:4;
167} __packed;
168
169/* Data structure filled by PPM in response to GET_CONNECTOR_STATUS command. */
170struct ucsi_connector_status {
171	u16 change;
172#define UCSI_CONSTAT_EXT_SUPPLY_CHANGE		BIT(1)
173#define UCSI_CONSTAT_POWER_OPMODE_CHANGE	BIT(2)
174#define UCSI_CONSTAT_PDOS_CHANGE		BIT(5)
175#define UCSI_CONSTAT_POWER_LEVEL_CHANGE		BIT(6)
176#define UCSI_CONSTAT_PD_RESET_COMPLETE		BIT(7)
177#define UCSI_CONSTAT_CAM_CHANGE			BIT(8)
178#define UCSI_CONSTAT_BC_CHANGE			BIT(9)
179#define UCSI_CONSTAT_PARTNER_CHANGE		BIT(11)
180#define UCSI_CONSTAT_POWER_DIR_CHANGE		BIT(12)
181#define UCSI_CONSTAT_CONNECT_CHANGE		BIT(14)
182#define UCSI_CONSTAT_ERROR			BIT(15)
183	u16 pwr_op_mode:3;
184#define UCSI_CONSTAT_PWR_OPMODE_NONE		0
185#define UCSI_CONSTAT_PWR_OPMODE_DEFAULT		1
186#define UCSI_CONSTAT_PWR_OPMODE_BC		2
187#define UCSI_CONSTAT_PWR_OPMODE_PD		3
188#define UCSI_CONSTAT_PWR_OPMODE_TYPEC1_3	4
189#define UCSI_CONSTAT_PWR_OPMODE_TYPEC3_0	5
190	u16 connected:1;
191	u16 pwr_dir:1;
192	u16 partner_flags:8;
193#define UCSI_CONSTAT_PARTNER_FLAG_USB		BIT(0)
194#define UCSI_CONSTAT_PARTNER_FLAG_ALT_MODE	BIT(1)
195	u16 partner_type:3;
196#define UCSI_CONSTAT_PARTNER_TYPE_DFP		1
197#define UCSI_CONSTAT_PARTNER_TYPE_UFP		2
198#define UCSI_CONSTAT_PARTNER_TYPE_CABLE_NO_UFP	3 /* Powered Cable */
199#define UCSI_CONSTAT_PARTNER_TYPE_CABLE_AND_UFP	4 /* Powered Cable */
200#define UCSI_CONSTAT_PARTNER_TYPE_DEBUG		5
201#define UCSI_CONSTAT_PARTNER_TYPE_AUDIO		6
202	u32 request_data_obj;
203	u8 bc_status:2;
204#define UCSI_CONSTAT_BC_NOT_CHARGING		0
205#define UCSI_CONSTAT_BC_NOMINAL_CHARGING	1
206#define UCSI_CONSTAT_BC_SLOW_CHARGING		2
207#define UCSI_CONSTAT_BC_TRICKLE_CHARGING	3
208	u8 provider_cap_limit_reason:4;
209#define UCSI_CONSTAT_CAP_PWR_LOWERED		0
210#define UCSI_CONSTAT_CAP_PWR_BUDGET_LIMIT	1
211	u8 RESERVED:2;
212} __packed;
213
214/* -------------------------------------------------------------------------- */
215