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>
This commit is contained in:
Derek Huang 2021-09-27 14:31:26 +08:00 committed by Tim Wawrzynczak
parent d6da4ef69e
commit 89d8260e3f
1 changed files with 69 additions and 0 deletions

View File

@ -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);