diff options
author | Derek Huang <derek.huang@intel.corp-partner.google.com> | 2021-09-29 21:59:45 +0800 |
---|---|---|
committer | Tim Wawrzynczak <twawrzynczak@chromium.org> | 2021-10-06 22:19:29 +0000 |
commit | 63ffc1adc0407be878019e33e2ae38e72d00a65e (patch) | |
tree | 9f60656a67851e9dd42e2520b1aeb2d2d6b2116d /src/ec | |
parent | c0bd123408680d3d7b0bb2c64acd103e2f13ec17 (diff) |
ec/google/chromeec: Add new API for USB-C mux handling
Add google_chromeec_get_usbc_mux_info() to obtain USB-C mux
related information.
BUG=b:192947843
Signed-off-by: Derek Huang <derek.huang@intel.corp-partner.google.com>
Change-Id: Idc27f23214c2d5b91334ae3efe248100329964ba
Reviewed-on: https://review.coreboot.org/c/coreboot/+/58059
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Diffstat (limited to 'src/ec')
-rw-r--r-- | src/ec/google/chromeec/ec.c | 36 | ||||
-rw-r--r-- | src/ec/google/chromeec/ec.h | 8 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index 5a8e4f6cd3..e27ad9e938 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -1565,6 +1565,42 @@ int google_chromeec_usb_get_pd_mux_info(int port, uint8_t *flags) return 0; } +/* + * Obtain any USB-C mux data needed for the specified port + * in: physical port number of the type-c port + * out: struct usbc_mux_info mux_info stores USB-C mux data + * Return: 0 on success, -1 on error +*/ +int google_chromeec_get_usbc_mux_info(int port, struct usbc_mux_info *mux_info) +{ + uint8_t mux_flags; + uint8_t dp_pin_mode; + bool ufp, dbg_acc, active_cable; + + if (google_chromeec_usb_get_pd_mux_info(port, &mux_flags) < 0) { + printk(BIOS_ERR, "Port C%d: get_pd_mux_info failed\n", port); + return -1; + } + + if (google_chromeec_usb_pd_get_info(port, &ufp, &dbg_acc, + &active_cable, &dp_pin_mode) < 0) { + printk(BIOS_ERR, "Port C%d: pd_control failed\n", port); + return -1; + } + + mux_info->usb = !!(mux_flags & USB_PD_MUX_USB_ENABLED); + mux_info->dp = !!(mux_flags & USB_PD_MUX_DP_ENABLED); + mux_info->polarity = !!(mux_flags & USB_PD_MUX_POLARITY_INVERTED); + mux_info->hpd_irq = !!(mux_flags & USB_PD_MUX_HPD_IRQ); + mux_info->hpd_lvl = !!(mux_flags & USB_PD_MUX_HPD_LVL); + mux_info->ufp = !!ufp; + mux_info->dbg_acc = !!dbg_acc; + mux_info->cable = !!active_cable; + mux_info->dp_pin_mode = dp_pin_mode; + + return 0; +} + /** * Check if EC/TCPM is in an alternate mode or not. * diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h index a06dfa19c0..f4090fe941 100644 --- a/src/ec/google/chromeec/ec.h +++ b/src/ec/google/chromeec/ec.h @@ -9,6 +9,7 @@ #include <types.h> #include <device/device.h> #include "ec_commands.h" +#include <device/usbc_mux.h> /* Fill in base and size of the IO port resources used. */ void google_chromeec_ioport_range(uint16_t *base, size_t *size); @@ -48,6 +49,13 @@ int google_chromeec_wait_for_dp_hpd(int port, long timeout_ms); * specified port. * Return: 0 on success, -1 on error */ int google_chromeec_typec_control_enter_dp_mode(int port); +/* + * Obtain any USB-C mux data needed for the specified port + * in: int port physical port number of the type-c port + * out: struct usbc_mux_info mux_info stores USB-C mux data + * Return: 0 on success, -1 on error + */ +int google_chromeec_get_usbc_mux_info(int port, struct usbc_mux_info *mux_info); /* Device events */ uint64_t google_chromeec_get_device_enabled_events(void); |