summaryrefslogtreecommitdiffstats
path: root/src/include/device/usbc_mux.h
blob: 0648a74f667c12f04a2e24cdae62a0f79ed3a006 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* SPDX-License-Identifier: GPL-2.0-only */

#ifndef __USBC_MUX_H__
#define __USBC_MUX_H__

/* struct to hold all USB-C mux related variables */
struct usbc_mux_info {
	bool dp; /* DP connected */
	bool usb; /* USB connected */
	bool cable; /* 0 = Passive cable, 1 = Active cable */
	bool polarity; /* Polarity of connected device. 0 = Normal, 1 = Flipped */
	bool hpd_lvl; /* HPD Level assert */
	bool hpd_irq; /* HPD IRQ assert */
	bool ufp; /* 0 = DFP, 1 = UFP */
	bool dbg_acc; /* Debug Accessory. 0 = Disable, 1 = Enable */
	uint8_t dp_pin_mode; /* DP pin assignments
				0h: Reserved.
				1h: Pin Assignment A.
				2h: Pin Assignment B.
				3h: Pin Assignment C.
				4h: Pin Assignment D.
				5h: Pin Assignment E.
				6h: Pin Assignment F.
				7-Fh: Reserved. */
};
struct usbc_mux_ops {
	/*
	 * Get mux information on a given port.
	 *
	 * Return value:
	 * -1 = error
	 *  0 = success
	 */
	 int (*get_mux_info)(int port, struct usbc_mux_info *info);
};

struct usbc_dp_ops {
	/*
	 * Wait up to `timeout_ms` for DP connection to be ready on any available port.
	 *
	 * Return value:
	 * -1 = error
	 *  0 = no DP connection
	 * <bit mask> = mask for ports that are ready in DP mode.
	 */
	int (*wait_for_connection)(long timeout_ms);

	/*
	 * Enter DP mode on a given `port`.
	 *
	 * Return value:
	 * -1 = error
	 *  0 = success
	 */
	int (*enter_dp_mode)(int port);

	/*
	 * Wait up to `timeout_ms` for HPD on a given port.
	 *
	 * Return value:
	 * -1 = timeout
	 *  0 = success
	 */
	int (*wait_for_hpd)(int port, long timeout_ms);
};

struct usbc_ops {
	struct usbc_mux_ops mux_ops;
	struct usbc_dp_ops dp_ops;
};

const struct usbc_ops *usbc_get_ops(void);

#endif /* __USBC_MUX_H__ */