Curtis Chen has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/57402 )
Change subject: mb/google/volteer: Modify APIs for USB-C DP alternate mode support src/ec/google/chromeec: Modify APIs for USB-C DP ALT mode ......................................................................
mb/google/volteer: Modify APIs for USB-C DP alternate mode support src/ec/google/chromeec: Modify APIs for USB-C DP ALT mode
1. The API now would delay N seconds if N ports are connected with non-DP mode device. Let them wait in parrlel in 1 second. 2. Get the DP mode port directly. 3. Keep the original API format, no need to modify old project.
BUG=b:192947843 TEST=select ENABLE_TCSS_DISPLAY_DETECTION in Kconfig.name. Build coreboot and update your system. Boot the system, external display connected on USB-C port should show screen in developer mode or recovery mode
Change-Id: If2a49336754648ecb2f62d26e68ce04a367adc39 Signed-off-by: Curtis Chen curtis.chen@intel.com --- M src/ec/google/chromeec/ec.c M src/ec/google/chromeec/ec.h M src/mainboard/google/fizz/mainboard.c M src/mainboard/google/hatch/variants/baseboard/mainboard.c M src/mainboard/google/volteer/mainboard.c M src/soc/intel/common/block/tcss/tcss.c 6 files changed, 38 insertions(+), 27 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/02/57402/1
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index ce6d559..91c9692 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -1564,10 +1564,9 @@ * Check if EC/TCPM is in an alternate mode or not. * * @param svid SVID of the alternate mode to check - * @param port port number to check, -1 means check all port * @return 0: Not in the mode. -1: Error. 1: Yes. */ -int google_chromeec_pd_get_amode(uint16_t svid, int port) +int google_chromeec_pd_get_amode(uint16_t svid) { struct ec_response_usb_pd_ports resp; struct chromeec_command cmd = { @@ -1589,8 +1588,6 @@ struct ec_params_usb_pd_get_mode_response resp2; int svid_idx = 0;
- if (port >= 0 && i != port) - continue; do { /* Reset cmd in each iteration in case google_chromeec_command changes it. */ @@ -1607,7 +1604,7 @@ if (google_chromeec_command(&cmd) < 0) return -1; if (resp2.svid == svid) - return 1; + return (1 << i); svid_idx++; } while (resp2.svid); } @@ -1621,16 +1618,20 @@ * Wait for DisplayPort to be ready * * @param timeout Wait aborts after <timeout> ms. - * @param port Wait for the specific port, -1 means wait for all ports * @return 1: Success or 0: Timeout. */ -int google_chromeec_wait_for_displayport(long timeout, int port) +int google_chromeec_wait_for_displayport(long timeout) { struct stopwatch sw; + int ret = 0;
printk(BIOS_INFO, "Waiting for DisplayPort\n"); stopwatch_init_msecs_expire(&sw, timeout); - while (google_chromeec_pd_get_amode(USB_SID_DISPLAYPORT, port) != 1) { + while (1) { + ret = google_chromeec_pd_get_amode(USB_SID_DISPLAYPORT); + if (ret > 0) + break; + if (stopwatch_expired(&sw)) { printk(BIOS_WARNING, "DisplayPort not ready after %ldms. Abort.\n", @@ -1642,7 +1643,7 @@ printk(BIOS_INFO, "DisplayPort ready after %lu ms\n", stopwatch_duration_msecs(&sw));
- return 1; + return ret; }
int google_chromeec_get_keybd_config(struct ec_response_keybd_config *keybd) diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h index 6170810..e4b8234 100644 --- a/src/ec/google/chromeec/ec.h +++ b/src/ec/google/chromeec/ec.h @@ -26,7 +26,7 @@ int google_ec_running_ro(void); enum ec_image google_chromeec_get_current_image(void); void google_chromeec_init(void); -int google_chromeec_pd_get_amode(uint16_t svid, int port); +int google_chromeec_pd_get_amode(uint16_t svid); /* Check for the current mux state in EC * in: int port physical port number of the type-c port * out: uint8_t flags representing the status of the mux such as @@ -36,7 +36,7 @@ /* Returns data role and type of device connected */ int google_chromeec_usb_pd_control(int port, bool *ufp, bool *dbg_acc, uint8_t *dp_mode); -int google_chromeec_wait_for_displayport(long timeout, int port); +int google_chromeec_wait_for_displayport(long timeout); int google_chromeec_typec_control_enter_dp_mode(int port);
/* Device events */ diff --git a/src/mainboard/google/fizz/mainboard.c b/src/mainboard/google/fizz/mainboard.c index 74bca2b..0945b9c 100644 --- a/src/mainboard/google/fizz/mainboard.c +++ b/src/mainboard/google/fizz/mainboard.c @@ -259,7 +259,7 @@ gpio_input(GPIO_HDMI_HPD); if (display_init_required() && !gpio_get(GPIO_HDMI_HPD)) { /* This has to be done before FSP-S runs. */ - if (google_chromeec_wait_for_displayport(display_timeout_ms, -1)) + if (google_chromeec_wait_for_displayport(display_timeout_ms)) wait_for_hpd(GPIO_DP_HPD, display_timeout_ms); } } diff --git a/src/mainboard/google/hatch/variants/baseboard/mainboard.c b/src/mainboard/google/hatch/variants/baseboard/mainboard.c index eaf34b7..d641405 100644 --- a/src/mainboard/google/hatch/variants/baseboard/mainboard.c +++ b/src/mainboard/google/hatch/variants/baseboard/mainboard.c @@ -161,7 +161,7 @@ && !gpio_get(GPIO_HDMI_HPD) && !gpio_get(GPIO_DP_HPD)) { /* This has to be done before FSP-S runs. */ - if (google_chromeec_wait_for_displayport(display_timeout_ms, -1)) + if (google_chromeec_wait_for_displayport(display_timeout_ms)) wait_for_hpd(GPIO_DP_HPD, display_timeout_ms); } /* Psys_pmax needs to be setup before FSP-S */ diff --git a/src/mainboard/google/volteer/mainboard.c b/src/mainboard/google/volteer/mainboard.c index 4192da3..d8285f8 100644 --- a/src/mainboard/google/volteer/mainboard.c +++ b/src/mainboard/google/volteer/mainboard.c @@ -147,24 +147,30 @@ } }
-const int mainboard_tcss_wait_for_displayport(int port, long timeout) +const int mainboard_tcss_wait_for_displayport(int num_ports, long timeout) { - int ret; + int ret = 0, i; uint8_t mux_flags;
- if ((ret = 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 ret; + for (i = 0; i < num_ports; i++) { + if ((ret = google_chromeec_usb_get_pd_mux_info(i, &mux_flags)) < 0) { + printk(BIOS_ERR, "port C%d: get_pd_mux_info failed\n", i); + continue; + } + + if (mux_flags) /* If port is connected */ + break; }
- ret = 0; - if (mux_flags) /* If port is connected */ - if ((ret = google_chromeec_wait_for_displayport(timeout, port))) - printk(BIOS_INFO, "port C%d: DispalyPort detected\n", port); + + if (i != num_ports) {/* If port is connected */ + ret = google_chromeec_wait_for_displayport(timeout); + if (ret < 1) + printk(BIOS_INFO, "No DisplayPort detected\n"); else - printk(BIOS_INFO, "port C%d: No DisplayPort detected\n", port); - else - printk(BIOS_INFO, "port C%d: Nothing is connected\n", port); + printk(BIOS_INFO, "port index 0x%x: DispalyPort detected\n", ret); + } else + printk(BIOS_INFO, "Nothing is connected\n");
return ret; } diff --git a/src/soc/intel/common/block/tcss/tcss.c b/src/soc/intel/common/block/tcss/tcss.c index 40ab418..ab73265 100644 --- a/src/soc/intel/common/block/tcss/tcss.c +++ b/src/soc/intel/common/block/tcss/tcss.c @@ -284,7 +284,7 @@
static void tcss_configure_dp_mode(const struct tcss_port_map *port_map, size_t num_ports) { - int ret; + int ret, alt_ret; size_t i; const struct tcss_mux_info *mux_info; const struct tcss_port_map *port_info; @@ -292,8 +292,12 @@ if (!display_init_required()) return;
+ alt_ret = mainboard_tcss_wait_for_displayport(num_ports, WAIT_FOR_DISPLAYPORT_TIMEOUT); + if (!alt_ret) + return; + for (i = 0; i < num_ports; i++) { - if (mainboard_tcss_wait_for_displayport(i, WAIT_FOR_DISPLAYPORT_TIMEOUT) == 0) + if (!(alt_ret & 1 << i)) continue; mainboard_tcss_enter_dp_mode(i); if (mainboard_tcss_wait_for_hpd(i, WAIT_FOR_HPD_TIMEOUT) == 0)