[9610] usbpd Rp Defenderault to Contract.
[GitHub/moto-9609/android_kernel_motorola_exynos9610.git] / include / linux / ccic / usbpd.h
1 #ifndef __USBPD_H__
2 #define __USBPD_H__
3
4 #include <linux/ccic/usbpd_msg.h>
5 #include <linux/muic/muic.h>
6
7 #ifdef CONFIG_IFCONN_NOTIFIER
8 #include <linux/ifconn/ifconn_notifier.h>
9 #endif
10
11 #include <linux/time.h>
12 #include <linux/kernel.h>
13 #include <linux/module.h>
14 #include <linux/ktime.h>
15
16 #define MAX_CHARGING_VOLT 12000 /* 12V */
17 #define USBPD_VOLT_UNIT 50 /* 50mV */
18 #define USBPD_CURRENT_UNIT 10 /* 10mA */
19
20 #define USBPD_MAX_COUNT_MSG_OBJECT (8) /* 0..7 */
21
22 /* Counter */
23 #define USBPD_nMessageIDCount (7)
24 #define USBPD_nRetryCount (3)
25 #define USBPD_nHardResetCount (4)
26 #define USBPD_nCapsCount (16)
27 #define USBPD_nDiscoverIdentityCount (20)
28
29 /* Timer */
30 #define tSrcTransition (25) /* 25~35 ms */
31 #define tPSSourceOn (420) /* 390~480 ms */
32 #define tPSSourceOff (750) /* 750~960 ms */
33 #define tSenderResponse (25) /* 24~30ms */
34 #define tSenderResponseSRC (300) /* 1000 ms */
35 #define tSendSourceCap (10) /* 1~2 s */
36 #define tPSHardReset (17) /* 25~35 ms */
37 #define tSinkWaitCap (2500) /* 2.1~2.5 s */
38 #define tPSTransition (450) /* 450~550 ms */
39 #define tVCONNSourceOn (100) /* 24~30 ms */
40 #define tVDMSenderResponse (50) /* 24~30 ms */
41 #define tVDMWaitModeEntry (50) /* 40~50 ms */
42 #define tVDMWaitModeExit (50) /* 40~50 ms */
43 #define tDiscoverIdentity (50) /* 40~50 ms */
44 #define tSwapSourceStart (30) /* 30 ms */
45 #define tTypeCSinkWaitCap (310) /* 310~620 ms */
46 #define tTypeCSendSourceCap (100) /* 100~200ms */
47 #define tSrcRecover (880) /* 660~1000ms */
48 #define tNoResponse (5500) /* 660~1000ms */
49
50 /* Protocol States */
51 typedef enum {
52 /* Rx */
53 PRL_Rx_Layer_Reset_for_Receive = 0x11,
54 PRL_Rx_Wait_for_PHY_Message = 0x12,
55 PRL_Rx_Send_GoodCRC = 0x13,
56 PRL_Rx_Store_MessageID = 0x14,
57 PRL_Rx_Check_MessageID = 0x15,
58
59 /* Tx */
60 PRL_Tx_PHY_Layer_Reset = 0x21,
61 PRL_Tx_Wait_for_Message_Request = 0x22,
62 PRL_Tx_Layer_Reset_for_Transmit = 0x23,
63 PRL_Tx_Construct_Message = 0x24,
64 PRL_Tx_Wait_for_PHY_Response = 0x25,
65 PRL_Tx_Match_MessageID = 0x26,
66 PRL_Tx_Message_Sent = 0x27,
67 PRL_Tx_Check_RetryCounter = 0x28,
68 PRL_Tx_Transmission_Error = 0x29,
69 PRL_Tx_Discard_Message = 0x2A,
70 } protocol_state;
71
72 /* Policy Engine States */
73 typedef enum {
74 /* Source */
75 PE_SRC_Startup = 0x30,
76 PE_SRC_Discovery = 0x31,
77 PE_SRC_Send_Capabilities = 0x32,
78 PE_SRC_Negotiate_Capability = 0x33,
79 PE_SRC_Transition_Supply = 0x34,
80 PE_SRC_Ready = 0x35,
81 PE_SRC_Disabled = 0x36,
82 PE_SRC_Capability_Response = 0x37,
83 PE_SRC_Hard_Reset = 0x38,
84 PE_SRC_Hard_Reset_Received = 0x39,
85 PE_SRC_Transition_to_default = 0x3A,
86 PE_SRC_Give_Source_Cap = 0x3B,
87 PE_SRC_Get_Sink_Cap = 0x3C,
88 PE_SRC_Wait_New_Capabilities = 0x3D,
89
90 /* Sink */
91 PE_SNK_Startup = 0x40,
92 PE_SNK_Discovery = 0x41,
93 PE_SNK_Wait_for_Capabilities = 0x42,
94 PE_SNK_Evaluate_Capability = 0x43,
95 PE_SNK_Select_Capability = 0x44,
96 PE_SNK_Transition_Sink = 0x45,
97 PE_SNK_Ready = 0x46,
98 PE_SNK_Hard_Reset = 0x47,
99 PE_SNK_Transition_to_default = 0x48,
100 PE_SNK_Give_Sink_Cap = 0x49,
101 PE_SNK_Get_Source_Cap = 0x4A,
102
103 /* Source Soft Reset */
104 PE_SRC_Send_Soft_Reset = 0x50,
105 PE_SRC_Soft_Reset = 0x51,
106
107 /* Sink Soft Reset */
108 PE_SNK_Send_Soft_Reset = 0x60,
109 PE_SNK_Soft_Reset = 0x61,
110
111 /* UFP VDM */
112 PE_UFP_VDM_Get_Identity = 0x70,
113 PE_UFP_VDM_Send_Identity = 0x71,
114 PE_UFP_VDM_Get_Identity_NAK = 0x72,
115 PE_UFP_VDM_Get_SVIDs = 0x73,
116 PE_UFP_VDM_Send_SVIDs = 0x74,
117 PE_UFP_VDM_Get_SVIDs_NAK = 0x75,
118 PE_UFP_VDM_Get_Modes = 0x76,
119 PE_UFP_VDM_Send_Modes = 0x77,
120 PE_UFP_VDM_Get_Modes_NAK = 0x78,
121 PE_UFP_VDM_Evaluate_Mode_Entry = 0x79,
122 PE_UFP_VDM_Mode_Entry_ACK = 0x7A,
123 PE_UFP_VDM_Mode_Entry_NAK = 0x7B,
124 PE_UFP_VDM_Mode_Exit = 0x7C,
125 PE_UFP_VDM_Mode_Exit_ACK = 0x7D,
126 PE_UFP_VDM_Mode_Exit_NAK = 0x7E,
127 PE_UFP_VDM_Attention_Request = 0x7F,
128 PE_UFP_VDM_Evaluate_Status = 0x80,
129 PE_UFP_VDM_Status_ACK = 0x81,
130 PE_UFP_VDM_Status_NAK = 0x82,
131 PE_UFP_VDM_Evaluate_Configure = 0x83,
132 PE_UFP_VDM_Configure_ACK = 0x84,
133 PE_UFP_VDM_Configure_NAK = 0x85,
134
135 /* DFP VDM */
136 PE_DFP_VDM_Identity_Request = 0x8A,
137 PE_DFP_VDM_Identity_ACKed = 0x8B,
138 PE_DFP_VDM_Identity_NAKed = 0x8C,
139 PE_DFP_VDM_SVIDs_Request = 0x8D,
140 PE_DFP_VDM_SVIDs_ACKed = 0x8E,
141 PE_DFP_VDM_SVIDs_NAKed = 0x8F,
142 PE_DFP_VDM_Modes_Request = 0x90,
143 PE_DFP_VDM_Modes_ACKed = 0x91,
144 PE_DFP_VDM_Modes_NAKed = 0x92,
145 PE_DFP_VDM_Mode_Entry_Request = 0x93,
146 PE_DFP_VDM_Mode_Entry_ACKed = 0x94,
147 PE_DFP_VDM_Mode_Entry_NAKed = 0x95,
148 PE_DFP_VDM_Mode_Exit_Request = 0x96,
149 PE_DFP_VDM_Mode_Exit_ACKed = 0x97,
150 PE_DFP_VDM_Mode_Exit_NAKed = 0x98,
151 PE_DFP_VDM_Status_Update = 0x99,
152 PE_DFP_VDM_Status_Update_ACKed = 0x9A,
153 PE_DFP_VDM_Status_Update_NAKed = 0x9B,
154 PE_DFP_VDM_DisplayPort_Configure = 0x9C,
155 PE_DFP_VDM_DisplayPort_Configure_ACKed = 0x9D,
156 PE_DFP_VDM_DisplayPort_Configure_NAKed = 0x9E,
157 PE_DFP_VDM_Attention_Request = 0x9F,
158
159 /* Power Role Swap */
160 PE_PRS_SRC_SNK_Reject_PR_Swap = 0xA0,
161 PE_PRS_SRC_SNK_Evaluate_Swap = 0xA1,
162 PE_PRS_SRC_SNK_Send_Swap = 0xA2,
163 PE_PRS_SRC_SNK_Accept_Swap = 0xA3,
164 PE_PRS_SRC_SNK_Transition_off = 0xA4,
165 PE_PRS_SRC_SNK_Assert_Rd = 0xA5,
166 PE_PRS_SRC_SNK_Wait_Source_on = 0xA6,
167 PE_PRS_SNK_SRC_Reject_Swap = 0xA7,
168 PE_PRS_SNK_SRC_Evaluate_Swap = 0xA8,
169 PE_PRS_SNK_SRC_Send_Swap = 0xA9,
170 PE_PRS_SNK_SRC_Accept_Swap = 0xAA,
171 PE_PRS_SNK_SRC_Transition_off = 0xAB,
172 PE_PRS_SNK_SRC_Assert_Rp = 0xAC,
173 PE_PRS_SNK_SRC_Source_on = 0xAD,
174
175 /* Data Role Swap */
176 PE_DRS_DFP_UFP_Evaluate_DR_Swap = 0xAE,
177 PE_DRS_DFP_UFP_Accept_DR_Swap = 0xAF,
178 PE_DRS_DFP_UFP_Change_to_UFP = 0xB0,
179 PE_DRS_DFP_UFP_Send_DR_Swap = 0xB1,
180 PE_DRS_DFP_UFP_Reject_DR_Swap = 0xB2,
181 PE_DRS_UFP_DFP_Evaluate_DR_Swap = 0xB3,
182 PE_DRS_UFP_DFP_Accept_DR_Swap = 0xB4,
183 PE_DRS_UFP_DFP_Change_to_DFP = 0xB5,
184 PE_DRS_UFP_DFP_Send_DR_Swap = 0xB6,
185 PE_DRS_UFP_DFP_Reject_DR_Swap = 0xB7,
186 PE_DRS_Evaluate_Port = 0xB8,
187 PE_DRS_Evaluate_Send_Port = 0xB9,
188
189 /* Vconn Source Swap */
190 PE_VCS_Evaluate_Swap = 0xC0,
191 PE_VCS_Accept_Swap = 0xC1,
192 PE_VCS_Wait_for_VCONN = 0xC2,
193 PE_VCS_Turn_Off_VCONN = 0xC3,
194 PE_VCS_Turn_On_VCONN = 0xC4,
195 PE_VCS_Send_PS_RDY = 0xC5,
196 PE_VCS_Send_Swap = 0xC6,
197 PE_VCS_Reject_VCONN_Swap = 0xC7,
198
199 /* UVDM Message */
200 PE_DFP_UVDM_Send_Message = 0xD0,
201 PE_DFP_UVDM_Receive_Message = 0xD1,
202
203 /* Dual Role */
204 PE_DR_SRC_Get_Source_Cap = 0xE0,
205 PE_DR_SRC_Give_Sink_Cap = 0xE1,
206 PE_DR_SNK_Get_Sink_Cap = 0xE2,
207 PE_DR_SNK_Give_Source_Cap = 0xE3,
208
209 /* Bist Mode */
210 PE_BIST_Receive_Mode = 0xE4,
211 PE_BIST_Frame_Received = 0xE5,
212
213 Error_Recovery = 0xFF
214 } policy_state;
215
216 typedef enum usbpd_manager_command {
217 MANAGER_REQ_GET_SNKCAP = 1,
218 MANAGER_REQ_GOTOMIN = 1 << 2,
219 MANAGER_REQ_SRCCAP_CHANGE = 1 << 3,
220 MANAGER_REQ_PR_SWAP = 1 << 4,
221 MANAGER_REQ_DR_SWAP = 1 << 5,
222 MANAGER_REQ_VCONN_SWAP = 1 << 6,
223 MANAGER_REQ_VDM_DISCOVER_IDENTITY = 1 << 7,
224 MANAGER_REQ_VDM_DISCOVER_SVID = 1 << 8,
225 MANAGER_REQ_VDM_DISCOVER_MODE = 1 << 9,
226 MANAGER_REQ_VDM_ENTER_MODE = 1 << 10,
227 MANAGER_REQ_VDM_EXIT_MODE = 1 << 11,
228 MANAGER_REQ_VDM_ATTENTION = 1 << 12,
229 MANAGER_REQ_VDM_STATUS_UPDATE = 1 << 13,
230 MANAGER_REQ_VDM_DisplayPort_Configure = 1 << 14,
231 MANAGER_REQ_NEW_POWER_SRC = 1 << 15,
232 MANAGER_REQ_UVDM_SEND_MESSAGE = 1 << 16,
233 MANAGER_REQ_UVDM_RECEIVE_MESSAGE = 1 << 17,
234 } usbpd_manager_command_type;
235
236 typedef enum usbpd_manager_event {
237 MANAGER_DISCOVER_IDENTITY_ACKED = 0,
238 MANAGER_DISCOVER_IDENTITY_NAKED = 1,
239 MANAGER_DISCOVER_SVID_ACKED = 2,
240 MANAGER_DISCOVER_SVID_NAKED = 3,
241 MANAGER_DISCOVER_MODE_ACKED = 4,
242 MANAGER_DISCOVER_MODE_NAKED = 5,
243 MANAGER_ENTER_MODE_ACKED = 6,
244 MANAGER_ENTER_MODE_NAKED = 7,
245 MANAGER_EXIT_MODE_ACKED = 8,
246 MANAGER_EXIT_MODE_NAKED = 9,
247 MANAGER_ATTENTION_REQUEST = 10,
248 MANAGER_STATUS_UPDATE_ACKED = 11,
249 MANAGER_STATUS_UPDATE_NAKED = 12,
250 MANAGER_DisplayPort_Configure_ACKED = 13,
251 MANAGER_DisplayPort_Configure_NACKED = 14,
252 MANAGER_NEW_POWER_SRC = 15,
253 MANAGER_UVDM_SEND_MESSAGE = 16,
254 MANAGER_UVDM_RECEIVE_MESSAGE = 17,
255 MANAGER_START_DISCOVER_IDENTITY = 18,
256 MANAGER_SEND_PR_SWAP = 19,
257 MANAGER_SEND_DR_SWAP = 20,
258 } usbpd_manager_event_type;
259
260 enum usbpd_msg_status {
261 MSG_GOODCRC = 1<<0,
262 MSG_ACCEPT = 1<<1,
263 MSG_PSRDY = 1<<2,
264 MSG_REQUEST = 1<<3,
265 MSG_REJECT = 1<<4,
266 MSG_WAIT = 1<<5,
267 MSG_ERROR = 1<<6,
268 MSG_PING = 1<<7,
269 MSG_GET_SNK_CAP = 1<<8,
270 MSG_GET_SRC_CAP = 1<<9,
271 MSG_SNK_CAP = 1<<10,
272 MSG_SRC_CAP = 1<<11,
273 MSG_PR_SWAP = 1<<12,
274 MSG_DR_SWAP = 1<<13,
275 MSG_VCONN_SWAP = 1<<14,
276 VDM_DISCOVER_IDENTITY = 1<<15,
277 VDM_DISCOVER_SVID = 1<<16,
278 VDM_DISCOVER_MODE = 1<<17,
279 VDM_ENTER_MODE = 1<<18,
280 VDM_EXIT_MODE = 1<<19,
281 VDM_ATTENTION = 1<<20,
282 VDM_DP_STATUS_UPDATE = 1<<21,
283 VDM_DP_CONFIGURE = 1<<22,
284 MSG_SOFTRESET = 1<<23,
285 PLUG_DETACH = 1<<24,
286 PLUG_ATTACH = 1<<25,
287 MSG_HARDRESET = 1<<26,
288 CC_DETECT = 1<<27,
289 UVDM_MSG = 1<<28,
290 MSG_PASS = 1<<29,
291 MSG_RID = 1<<30,
292 MSG_BIST = 1<<31,
293 };
294
295 /* Timer */
296 enum usbpd_timer_id {
297 DISCOVER_IDENTITY_TIMER = 1,
298 HARD_RESET_COMPLETE_TIMER = 2,
299 NO_RESPONSE_TIMER = 3,
300 PS_HARD_RESET_TIMER = 4,
301 PS_SOURCE_OFF_TIMER = 5,
302 PS_SOURCE_ON_TIMER = 6,
303 PS_TRANSITION_TIMER = 7,
304 SENDER_RESPONSE_TIMER = 8,
305 SINK_ACTIVITY_TIMER = 9,
306 SINK_REQUEST_TIMER = 10,
307 SINK_WAIT_CAP_TIMER = 11,
308 SOURCE_ACTIVITY_TIMER = 12,
309 SOURCE_CAPABILITY_TIMER = 13,
310 SWAP_RECOVERY_TIMER = 14,
311 SWAP_SOURCE_START_TIMER = 15,
312 VCONN_ON_TIMER = 16,
313 VDM_MODE_ENTRY_TIMER = 17,
314 VDM_MODE_EXIT_TIMER = 18,
315 VDM_RESPONSE_TIMER = 19,
316 USBPD_TIMER_MAX_COUNT
317 };
318
319 enum usbpd_protocol_status {
320 DEFAULT_PROTOCOL_NONE = 0,
321 MESSAGE_SENT = 1,
322 TRANSMISSION_ERROR = 2
323 };
324
325 enum usbpd_policy_informed {
326 DEFAULT_POLICY_NONE = 0,
327 HARDRESET_RECEIVED = 1,
328 SOFTRESET_RECEIVED = 2,
329 PLUG_EVENT = 3,
330 PLUG_ATTACHED = 4,
331 PLUG_DETACHED = 5,
332 };
333
334 typedef struct usbpd_phy_ops {
335 /* 1st param should be 'usbpd_data *' */
336 int (*tx_msg)(void *, msg_header_type *, data_obj_type *);
337 int (*rx_msg)(void *, msg_header_type *, data_obj_type *);
338 int (*hard_reset)(void *);
339 void (*soft_reset)(void *);
340 int (*set_power_role)(void *, int);
341 int (*get_power_role)(void *, int *);
342 int (*set_data_role)(void *, int);
343 int (*get_data_role)(void *, int *);
344 int (*set_vconn_source)(void *, int);
345 int (*get_vconn_source)(void *, int *);
346 int (*set_check_msg_pass)(void *, int);
347 unsigned (*get_status)(void *, unsigned);
348 bool (*poll_status)(void *);
349 void (*driver_reset)(void *);
350 int (*set_otg_control)(void *, int);
351 int (*set_cc_control)(void *, int);
352 void (*pr_swap)(void *, int);
353 int (*vbus_on_check)(void *);
354 int (*set_rp_control)(void *, int);
355 int (*get_side_check)(void *_data);
356 void (*set_pwr_opmode)(void *_data, int mode);
357 } usbpd_phy_ops_type;
358
359 struct policy_data {
360 policy_state state;
361 msg_header_type tx_msg_header;
362 msg_header_type rx_msg_header;
363 data_obj_type tx_data_obj[USBPD_MAX_COUNT_MSG_OBJECT];
364 data_obj_type rx_data_obj[USBPD_MAX_COUNT_MSG_OBJECT];
365 bool rx_hardreset;
366 bool rx_softreset;
367 bool plug;
368 bool plug_valid;
369 bool modal_operation;
370 bool abnormal_state;
371 bool sink_cap_received;
372 bool send_sink_cap;
373 bool txhardresetflag;
374 bool pd_support;
375 };
376
377 struct protocol_data {
378 protocol_state state;
379 unsigned stored_message_id;
380 msg_header_type msg_header;
381 data_obj_type data_obj[USBPD_MAX_COUNT_MSG_OBJECT];
382 unsigned status;
383 };
384
385 struct usbpd_counter {
386 unsigned retry_counter;
387 unsigned message_id_counter;
388 unsigned caps_counter;
389 unsigned hard_reset_counter;
390 unsigned discover_identity_counter;
391 unsigned swap_hard_reset_counter;
392 };
393
394 struct usbpd_manager_data {
395 usbpd_manager_command_type cmd; /* request to policy engine */
396 usbpd_manager_event_type event; /* policy engine infromed */
397 #if defined(CONFIG_IFCONN_NOTIFIER)
398 struct ifconn_notifier_template template;
399 #endif
400
401 msg_header_type uvdm_msg_header;
402 data_obj_type uvdm_data_obj[USBPD_MAX_COUNT_MSG_OBJECT];
403
404 int alt_sended;
405 int vdm_en;
406 /* request */
407 int max_power;
408 int op_power;
409 int max_current;
410 int op_current;
411 int min_current;
412 bool giveback;
413 bool usb_com_capable;
414 bool no_usb_suspend;
415
416 /* source */
417 int source_max_volt;
418 int source_min_volt;
419 int source_max_power;
420
421 /* sink */
422 int sink_max_volt;
423 int sink_min_volt;
424 int sink_max_power;
425
426 /* sink cap */
427 int sink_cap_max_volt;
428
429 /* power role swap*/
430 bool power_role_swap;
431 /* data role swap*/
432 bool data_role_swap;
433 bool vconn_source_swap;
434 bool vbus_short;
435
436 bool is_samsung_accessory_enter_mode;
437 bool uvdm_first_req;
438 bool uvdm_dir;
439 struct completion uvdm_out_wait;
440 struct completion uvdm_in_wait;
441
442 uint16_t Vendor_ID;
443 uint16_t Product_ID;
444 uint16_t Device_Version;
445 int acc_type;
446 uint16_t SVID_0;
447 uint16_t SVID_1;
448 uint16_t Standard_Vendor_ID;
449
450 /* dp */
451 int dp_selected_pin;
452 int hpd;
453 int hpdirq;
454 int dp_is_connect;
455 int dp_hs_connect;
456 int pin_assignment;
457 int is_sent_pin_configuration;
458
459 struct mutex vdm_mutex;
460
461 struct usbpd_data *pd_data;
462 struct delayed_work acc_detach_handler;
463 struct delayed_work select_pdo_handler;
464 struct delayed_work start_discover_msg_handler;
465 muic_attached_dev_t attached_dev;
466
467 int pd_attached;
468 };
469
470 struct usbpd_data {
471 struct device *dev;
472 struct device *ccic_dev;
473 void *phy_driver_data;
474 struct usbpd_counter counter;
475 struct hrtimer timers[USBPD_TIMER_MAX_COUNT];
476 unsigned expired_timers;
477 usbpd_phy_ops_type phy_ops;
478 struct protocol_data protocol_tx;
479 struct protocol_data protocol_rx;
480 struct policy_data policy;
481 msg_header_type source_msg_header;
482 data_obj_type source_data_obj;
483 msg_header_type sink_msg_header;
484 data_obj_type sink_data_obj[2];
485 data_obj_type source_request_obj;
486 struct usbpd_manager_data manager;
487 struct workqueue_struct *policy_wqueue;
488 struct work_struct worker;
489 struct completion msg_arrived;
490 unsigned wait_for_msg_arrived;
491 int lc_test;
492 int id_matched;
493 bool msg_received;
494 int msg_id;
495 struct mutex accept_mutex;
496
497 struct timeval time1;
498 struct timeval time2;
499
500 int pd_support;
501 };
502
503 static inline struct usbpd_data *protocol_rx_to_usbpd(struct protocol_data *rx)
504 {
505 return container_of(rx, struct usbpd_data, protocol_rx);
506 }
507
508 static inline struct usbpd_data *protocol_tx_to_usbpd(struct protocol_data *tx)
509 {
510 return container_of(tx, struct usbpd_data, protocol_tx);
511 }
512
513 static inline struct usbpd_data *policy_to_usbpd(struct policy_data *policy)
514 {
515 return container_of(policy, struct usbpd_data, policy);
516 }
517
518 static inline struct usbpd_data *manager_to_usbpd(struct usbpd_manager_data *manager)
519 {
520 return container_of(manager, struct usbpd_data, manager);
521 }
522
523 extern int usbpd_init(struct device *dev, void *phy_driver_data);
524 extern void usbpd_init_policy(struct usbpd_data *);
525
526 extern void usbpd_init_manager_val(struct usbpd_data *);
527 extern int usbpd_init_manager(struct usbpd_data *);
528 extern void usbpd_manager_plug_attach(struct device *);
529 extern void usbpd_manager_plug_detach(struct device *dev, bool notify);
530 extern void usbpd_manager_acc_detach(struct device *dev);
531 extern int usbpd_manager_match_request(struct usbpd_data *);
532 extern bool usbpd_manager_power_role_swap(struct usbpd_data *);
533 extern bool usbpd_manager_vconn_source_swap(struct usbpd_data *);
534 extern void usbpd_manager_turn_on_source(struct usbpd_data *);
535 extern void usbpd_manager_turn_off_power_supply(struct usbpd_data *);
536 extern void usbpd_manager_turn_off_power_sink(struct usbpd_data *);
537 extern void usbpd_manager_turn_off_vconn(struct usbpd_data *);
538 extern bool usbpd_manager_data_role_swap(struct usbpd_data *);
539 extern int usbpd_manager_get_identity(struct usbpd_data *);
540 extern int usbpd_manager_get_svids(struct usbpd_data *);
541 extern int usbpd_manager_get_modes(struct usbpd_data *);
542 extern int usbpd_manager_enter_mode(struct usbpd_data *);
543 extern int usbpd_manager_exit_mode(struct usbpd_data *, unsigned mode);
544 extern int usbpd_manager_get_status(struct usbpd_data *pd_data);
545 extern int usbpd_manager_get_configure(struct usbpd_data *pd_data);
546 extern int usbpd_manager_get_attention(struct usbpd_data *pd_data);
547 extern void usbpd_dp_detach(struct usbpd_data *pd_data);
548 extern void usbpd_manager_inform_event(struct usbpd_data *,
549 usbpd_manager_event_type);
550 extern int usbpd_manager_evaluate_capability(struct usbpd_data *);
551 extern data_obj_type usbpd_manager_select_capability(struct usbpd_data *);
552 extern bool usbpd_manager_vdm_request_enabled(struct usbpd_data *);
553 extern void usbpd_manager_acc_handler_cancel(struct device *);
554 extern void usbpd_manager_acc_detach_handler(struct work_struct *);
555 extern void usbpd_manager_send_pr_swap(struct device *);
556 extern void usbpd_manager_send_dr_swap(struct device *);
557 extern void usbpd_policy_work(struct work_struct *);
558 extern void usbpd_protocol_tx(struct usbpd_data *);
559 extern void usbpd_protocol_rx(struct usbpd_data *);
560 extern void usbpd_kick_policy_work(struct device *);
561 extern void usbpd_cancel_policy_work(struct device *);
562 extern void usbpd_rx_hard_reset(struct device *);
563 extern void usbpd_rx_soft_reset(struct usbpd_data *);
564 extern void usbpd_policy_reset(struct usbpd_data *, unsigned flag);
565
566 extern void usbpd_set_ops(struct device *, usbpd_phy_ops_type *);
567 extern void usbpd_read_msg(struct usbpd_data *);
568 extern bool usbpd_send_msg(struct usbpd_data *, msg_header_type *,
569 data_obj_type *);
570 extern bool usbpd_send_ctrl_msg(struct usbpd_data *d, msg_header_type *h,
571 unsigned msg, unsigned dr, unsigned pr);
572 extern unsigned usbpd_wait_msg(struct usbpd_data *pd_data, unsigned msg_status,
573 unsigned ms);
574 extern void usbpd_reinit(struct device *);
575 extern void usbpd_init_protocol(struct usbpd_data *);
576
577 /* for usbpd certification polling */
578 void usbpd_timer1_start(struct usbpd_data *pd_data);
579 int usbpd_check_time1(struct usbpd_data *pd_data);
580 void usbpd_timer2_start(struct usbpd_data *pd_data);
581 int usbpd_check_time2(struct usbpd_data *pd_data);
582
583 #endif