summaryrefslogtreecommitdiff
path: root/src/include/device
diff options
context:
space:
mode:
authorDerek Huang <derek.huang@intel.corp-partner.google.com>2021-09-27 14:31:26 +0800
committerTim Wawrzynczak <twawrzynczak@chromium.org>2021-10-06 22:16:48 +0000
commit89d8260e3f64a0aa9117f5d39a92743146048348 (patch)
tree88e50c0693ee712e0769ad0706c071076f838780 /src/include/device
parentd6da4ef69e4ec8decbaee41297c3a96686021567 (diff)
include/device: Generic interface for USB-C mux operations
Create a generic interface to allow any of the EC or other drivers to provide set of USB-C mux operations. Signed-off-by: Derek Huang <derek.huang@intel.corp-partner.google.com> Change-Id: Ic5435f2054d1c9f114b06c3b4643e34713290e0d Reviewed-on: https://review.coreboot.org/c/coreboot/+/58002 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org> Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src/include/device')
-rw-r--r--src/include/device/usbc_mux.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/include/device/usbc_mux.h b/src/include/device/usbc_mux.h
new file mode 100644
index 0000000000..e395d2dd62
--- /dev/null
+++ b/src/include/device/usbc_mux.h
@@ -0,0 +1,69 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+/* 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);