summaryrefslogtreecommitdiff
path: root/src/ec
diff options
context:
space:
mode:
authorDerek Huang <derek.huang@intel.corp-partner.google.com>2021-08-25 17:19:39 +0800
committerTim Wawrzynczak <twawrzynczak@chromium.org>2021-10-06 22:19:00 +0000
commitc0bd123408680d3d7b0bb2c64acd103e2f13ec17 (patch)
tree54eb07cf005a10de6b8e2bf8cbe8575fe5e039d7 /src/ec
parentc0f005a5d6e26c29bd1379163b890331ba8b38d0 (diff)
ec/google/chromeec: Add APIs for USB-C DP ALT mode
Add API to allow AP to send the command to EC to enter DP ALT mode and API to wait for DP HPD event. BUG=b:192947843 TEST=select ENABLE_TCSS_DISPLAY_DETECTION in Kconfig.name. Build coreboot and update your system. Boot the system you will find below message in the coreboot log with or without USB-C display connected: 'HPD ready after %lu ms' or 'HPD not ready after %ldms. Abort.'. Signed-off-by: Derek Huang <derek.huang@intel.corp-partner.google.com> Change-Id: Id11510c1ff58579ae2cddfe5a4d69646fd84f5c3 Reviewed-on: https://review.coreboot.org/c/coreboot/+/57138 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/ec')
-rw-r--r--src/ec/google/chromeec/ec.c46
-rw-r--r--src/ec/google/chromeec/ec.h8
2 files changed, 54 insertions, 0 deletions
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c
index 9086693770..5a8e4f6cd3 100644
--- a/src/ec/google/chromeec/ec.c
+++ b/src/ec/google/chromeec/ec.c
@@ -1508,6 +1508,33 @@ int google_chromeec_usb_pd_get_info(int port, bool *ufp, bool *dbg_acc,
return 0;
}
+int google_chromeec_typec_control_enter_dp_mode(int port)
+{
+ if (!google_chromeec_check_feature(EC_FEATURE_TYPEC_REQUIRE_AP_MODE_ENTRY))
+ return 0;
+
+ struct ec_params_typec_control typec_control = {
+ .port = port,
+ .command = TYPEC_CONTROL_COMMAND_ENTER_MODE,
+ .mode_to_enter = TYPEC_MODE_DP,
+ };
+
+ struct chromeec_command cmd = {
+ .cmd_code = EC_CMD_TYPEC_CONTROL,
+ .cmd_version = 0,
+ .cmd_data_in = &typec_control,
+ .cmd_size_in = sizeof(typec_control),
+ .cmd_data_out = NULL,
+ .cmd_size_out = 0,
+ .cmd_dev_index = 0,
+ };
+
+ if (google_chromeec_command(&cmd) < 0)
+ return -1;
+
+ return 0;
+}
+
/**
* Check for the current mux state in EC. Flags representing the mux state found
* in ec_commands.h
@@ -1632,6 +1659,25 @@ int google_chromeec_wait_for_displayport(long timeout_ms)
return ret;
}
+int google_chromeec_wait_for_dp_hpd(int port, long timeout_ms)
+{
+ uint8_t mux_flags;
+ struct stopwatch sw;
+
+ stopwatch_init_msecs_expire(&sw, timeout_ms);
+ do {
+ google_chromeec_usb_get_pd_mux_info(port, &mux_flags);
+ if (stopwatch_expired(&sw)) {
+ printk(BIOS_WARNING, "HPD not ready after %ldms. Abort.\n", timeout_ms);
+ return -1;
+ }
+ mdelay(100);
+ } while (!(mux_flags & USB_PD_MUX_HPD_LVL) || !(mux_flags & USB_PD_MUX_DP_ENABLED));
+ printk(BIOS_INFO, "HPD ready after %lu ms\n", stopwatch_duration_msecs(&sw));
+
+ return 0;
+}
+
int google_chromeec_get_keybd_config(struct ec_response_keybd_config *keybd)
{
struct chromeec_command cmd = {
diff --git a/src/ec/google/chromeec/ec.h b/src/ec/google/chromeec/ec.h
index 6fa58a9a1e..a06dfa19c0 100644
--- a/src/ec/google/chromeec/ec.h
+++ b/src/ec/google/chromeec/ec.h
@@ -40,6 +40,14 @@ int google_chromeec_usb_pd_get_info(int port, bool *ufp, bool *dbg_acc,
* >=1: Bitmask of the ports that DP device is connected
*/
int google_chromeec_wait_for_displayport(long timeout_ms);
+/* Poll (up to `timeout_ms` ms) for a Hot-Plug Detect (HPD)
+ * event on the specified port.
+ * Return: 0 on HPD ready, -1 on timeout */
+int google_chromeec_wait_for_dp_hpd(int port, long timeout_ms);
+/* Send command to EC to request to enter DisplayPort ALT mode on the
+ * specified port.
+ * Return: 0 on success, -1 on error */
+int google_chromeec_typec_control_enter_dp_mode(int port);
/* Device events */
uint64_t google_chromeec_get_device_enabled_events(void);