blob: 0648a74f667c12f04a2e24cdae62a0f79ed3a006 [file] [log] [blame]
Derek Huang89d8260e2021-09-27 14:31:26 +08001/* SPDX-License-Identifier: GPL-2.0-only */
2
Alan Huang5826c592021-11-02 10:26:02 +08003#ifndef __USBC_MUX_H__
4#define __USBC_MUX_H__
5
Derek Huang89d8260e2021-09-27 14:31:26 +08006/* struct to hold all USB-C mux related variables */
7struct usbc_mux_info {
8 bool dp; /* DP connected */
9 bool usb; /* USB connected */
10 bool cable; /* 0 = Passive cable, 1 = Active cable */
11 bool polarity; /* Polarity of connected device. 0 = Normal, 1 = Flipped */
12 bool hpd_lvl; /* HPD Level assert */
13 bool hpd_irq; /* HPD IRQ assert */
14 bool ufp; /* 0 = DFP, 1 = UFP */
15 bool dbg_acc; /* Debug Accessory. 0 = Disable, 1 = Enable */
16 uint8_t dp_pin_mode; /* DP pin assignments
17 0h: Reserved.
18 1h: Pin Assignment A.
19 2h: Pin Assignment B.
20 3h: Pin Assignment C.
21 4h: Pin Assignment D.
22 5h: Pin Assignment E.
23 6h: Pin Assignment F.
24 7-Fh: Reserved. */
25};
26struct usbc_mux_ops {
27 /*
28 * Get mux information on a given port.
29 *
30 * Return value:
31 * -1 = error
32 * 0 = success
33 */
34 int (*get_mux_info)(int port, struct usbc_mux_info *info);
35};
36
37struct usbc_dp_ops {
38 /*
39 * Wait up to `timeout_ms` for DP connection to be ready on any available port.
40 *
41 * Return value:
42 * -1 = error
43 * 0 = no DP connection
44 * <bit mask> = mask for ports that are ready in DP mode.
45 */
46 int (*wait_for_connection)(long timeout_ms);
47
48 /*
49 * Enter DP mode on a given `port`.
50 *
51 * Return value:
52 * -1 = error
53 * 0 = success
54 */
55 int (*enter_dp_mode)(int port);
56
57 /*
58 * Wait up to `timeout_ms` for HPD on a given port.
59 *
60 * Return value:
61 * -1 = timeout
62 * 0 = success
63 */
64 int (*wait_for_hpd)(int port, long timeout_ms);
65};
66
67struct usbc_ops {
68 struct usbc_mux_ops mux_ops;
69 struct usbc_dp_ops dp_ops;
70};
71
72const struct usbc_ops *usbc_get_ops(void);
Alan Huang5826c592021-11-02 10:26:02 +080073
74#endif /* __USBC_MUX_H__ */