1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
4  */
5 
6 #ifndef _DP_HPD_H_
7 #define _DP_HPD_H_
8 
9 //#include <linux/usb/usbpd.h>
10 
11 #include <linux/types.h>
12 #include <linux/device.h>
13 
14 enum plug_orientation {
15 	ORIENTATION_NONE,
16 	ORIENTATION_CC1,
17 	ORIENTATION_CC2,
18 };
19 
20 /**
21  * struct dp_usbpd - DisplayPort status
22  *
23  * @orientation: plug orientation configuration
24  * @low_pow_st: low power state
25  * @adaptor_dp_en: adaptor functionality enabled
26  * @multi_func: multi-function preferred
27  * @usb_config_req: request to switch to usb
28  * @exit_dp_mode: request exit from displayport mode
29  * @hpd_high: Hot Plug Detect signal is high.
30  * @hpd_irq: Change in the status since last message
31  * @alt_mode_cfg_done: bool to specify alt mode status
32  * @debug_en: bool to specify debug mode
33  * @connect: simulate disconnect or connect for debug mode
34  */
35 struct dp_usbpd {
36 	enum plug_orientation orientation;
37 	bool low_pow_st;
38 	bool adaptor_dp_en;
39 	bool multi_func;
40 	bool usb_config_req;
41 	bool exit_dp_mode;
42 	bool hpd_high;
43 	bool hpd_irq;
44 	bool alt_mode_cfg_done;
45 	bool debug_en;
46 
47 	int (*connect)(struct dp_usbpd *dp_usbpd, bool hpd);
48 };
49 
50 /**
51  * struct dp_usbpd_cb - callback functions provided by the client
52  *
53  * @configure: called by usbpd module when PD communication has
54  * been completed and the usb peripheral has been configured on
55  * dp mode.
56  * @disconnect: notify the cable disconnect issued by usb.
57  * @attention: notify any attention message issued by usb.
58  */
59 struct dp_usbpd_cb {
60 	int (*configure)(struct device *dev);
61 	int (*disconnect)(struct device *dev);
62 	int (*attention)(struct device *dev);
63 };
64 
65 /**
66  * dp_hpd_get() - setup hpd module
67  *
68  * @dev: device instance of the caller
69  * @cb: struct containing callback function pointers.
70  *
71  * This function allows the client to initialize the usbpd
72  * module. The module will communicate with HPD module.
73  */
74 struct dp_usbpd *dp_hpd_get(struct device *dev, struct dp_usbpd_cb *cb);
75 
76 int dp_hpd_register(struct dp_usbpd *dp_usbpd);
77 void dp_hpd_unregister(struct dp_usbpd *dp_usbpd);
78 int dp_hpd_connect(struct dp_usbpd *dp_usbpd, bool hpd);
79 
80 #endif /* _DP_HPD_H_ */
81