summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2021-06-09 09:47:46 -0700
committerCommit Bot <commit-bot@chromium.org>2021-06-16 06:56:59 +0000
commitd73bb872f1278ef741d85203c42969aa3a7b2c75 (patch)
treec705d426026a5d25dbeb11c4e91a6f6727a71d21
parentb1af8c3689ecc265092f034d6ce8ee715d2614d8 (diff)
downloadchrome-ec-d73bb872f1278ef741d85203c42969aa3a7b2c75.tar.gz
gingerbread: Use CONFIG_USB_PD_VBUS_DETECT_TCPC for C1
This CL changes the stm32gx TCPM driver to allow CONFIG_USB_PD_VBUS_DETECT_TCPC to still be defined on boards that also use the stm32gx TCPM driver. This is required for gingerbread which has a PPC on C0 for VBUS detection, but relies on the TCPC to detect VBUS on port C1. BUG=b:159330563 BRANCH=quiche TEST=validated that can attach as SRC/DFP on C1 > pd 1 state Port C1 CC2, Enable - Role: SRC-DFP-VC TC State: Attached.SRC, [10.435540 C1: PE_SRC_Ready] [10.436511 pin_mode: 4, mf: 0, mux: 2] [10.442645 C1: PE_VDM_Request_DPM] [10.470346 C1: Entered DP mode] [10.470480 C1: PE_SRC_Ready] Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I986d504b1306c02132869abe7cbd630a966e0acd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2949954 Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r--baseboard/honeybuns/usb_pd_policy.c8
-rw-r--r--board/gingerbread/board.h1
-rw-r--r--driver/tcpm/stm32gx.c22
3 files changed, 29 insertions, 2 deletions
diff --git a/baseboard/honeybuns/usb_pd_policy.c b/baseboard/honeybuns/usb_pd_policy.c
index 07a284a1af..975210940f 100644
--- a/baseboard/honeybuns/usb_pd_policy.c
+++ b/baseboard/honeybuns/usb_pd_policy.c
@@ -304,6 +304,14 @@ int pd_snk_is_vbus_provided(int port)
return ppc_is_vbus_present(port);
}
+__override bool pd_check_vbus_level(int port, enum vbus_level level)
+{
+ if (level == VBUS_PRESENT)
+ return pd_snk_is_vbus_provided(port);
+ else
+ return !pd_snk_is_vbus_provided(port);
+}
+
int board_vbus_source_enabled(int port)
{
if (IS_ENABLED(BOARD_C1_NO_PPC) && port)
diff --git a/board/gingerbread/board.h b/board/gingerbread/board.h
index f631429cdb..eb2eb934cb 100644
--- a/board/gingerbread/board.h
+++ b/board/gingerbread/board.h
@@ -34,6 +34,7 @@
#define CONFIG_USB_PD_PORT_MAX_COUNT 2
#define CONFIG_USB_MUX_TUSB1064
+#define CONFIG_USB_PD_VBUS_DETECT_TCPC
#define BOARD_C1_NO_PPC
#define CONFIG_USB_PID 0x5049
diff --git a/driver/tcpm/stm32gx.c b/driver/tcpm/stm32gx.c
index 61bffacd53..654bf73652 100644
--- a/driver/tcpm/stm32gx.c
+++ b/driver/tcpm/stm32gx.c
@@ -20,8 +20,13 @@
#include "usb_pd_tcpm.h"
#include "hooks.h"
-#if defined(CONFIG_USB_PD_VBUS_DETECT_TCPC) || \
- defined(CONFIG_USB_PD_TCPC_LOW_POWER)
+/*
+ * STM32G4 UCPD peripheral does not have the ability to detect VBUS, but
+ * CONFIG_USB_PD_VBUS_DETECT_TCPC maybe still be defined for another port on the
+ * same board which uses a TCPC that does have this feature. Therefore, this
+ * config option is not considered an error.
+ */
+#if defined(CONFIG_USB_PD_TCPC_LOW_POWER)
#error "Unsupported config options of Stm32gx PD driver"
#endif
@@ -147,10 +152,23 @@ enum ec_error_list stm32gx_tcpm_set_bist_test_mode(const int port,
return stm32gx_ucpd_set_bist_test_mode(port, enable);
}
+bool stm32gx_tcpm_check_vbus_level(int port, enum vbus_level level)
+{
+ /*
+ * UCPD peripheral can't detect VBUS, so always return 0. Any port which
+ * uses the stm32g4 UCPD peripheral for its TCPC would also have a PPC
+ * that will handle VBUS detection. However, there may be products which
+ * don't have a PPC on some ports that will rely on a TCPC to do VBUS
+ * detection.
+ */
+ return 0;
+}
+
const struct tcpm_drv stm32gx_tcpm_drv = {
.init = &stm32gx_tcpm_init,
.release = &stm32gx_tcpm_release,
.get_cc = &stm32gx_tcpm_get_cc,
+ .check_vbus_level = &stm32gx_tcpm_check_vbus_level,
.select_rp_value = &stm32gx_tcpm_select_rp_value,
.set_cc = &stm32gx_tcpm_set_cc,
.set_polarity = &stm32gx_tcpm_set_polarity,