summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Marheine <pmarheine@chromium.org>2020-08-20 15:18:35 +1000
committerCommit Bot <commit-bot@chromium.org>2020-08-21 04:38:54 +0000
commitd44d6b29eb5ff59c1afd47135ec626ed907b174a (patch)
treef170e2f7ca5c0a3004a7db289edd088a09a41ba7
parentace8af086a9f8110ec0086cd6f81720e4bc6e7a1 (diff)
downloadchrome-ec-d44d6b29eb5ff59c1afd47135ec626ed907b174a.tar.gz
trembyle: correctly pass USB-C1 HPD to the MST hub
The RTD2141 MST hub on some daughterboard options requires the EC to drive its HPD input because HPD comes over USB-PD, but the MST hub then drives the AP's HPD input. The EC was incorrectly driving nothing, causing DP outputs on port C1 to not be detected. Because the MST's HPD input is connected to an IO expander on current hardware, configure the USB-C and Trembyle-specific HPD twiddling code to support regular or expander GPIOs. Experience says IO expanders tend to be too slow for reliable HPD, but this should allow some (possibly flaky) HPD support until hardware changes are completed to put the output directly on an EC GPIO. BUG=b:159051013,b:165622386 TEST=still builds (I have no v3 hardware to test against) BRANCH=None Signed-off-by: Peter Marheine <pmarheine@chromium.org> Change-Id: I9e041ab7c222927a11b8972920b7e978ab30d751 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2366456 Reviewed-by: Edward Hill <ecgh@chromium.org>
-rw-r--r--baseboard/zork/baseboard.h7
-rw-r--r--baseboard/zork/variant_trembyle.c27
-rw-r--r--board/morphius/board.c6
-rw-r--r--board/woomax/board.h5
4 files changed, 38 insertions, 7 deletions
diff --git a/baseboard/zork/baseboard.h b/baseboard/zork/baseboard.h
index 13e33ca007..d8ea0e8201 100644
--- a/baseboard/zork/baseboard.h
+++ b/baseboard/zork/baseboard.h
@@ -143,6 +143,13 @@
#define CONFIG_USB_PD_COMM_LOCKED
#define CONFIG_USB_PD_DISCHARGE_TCPC
#define CONFIG_USB_PD_DP_HPD_GPIO
+#ifdef VARIANT_ZORK_TREMBYLE
+/*
+ * Use a custom HPD function that supports HPD on IO expander.
+ * TODO(b/165622386) remove this when HPD is on EC GPIO.
+ */
+# define CONFIG_USB_PD_DP_HPD_GPIO_CUSTOM
+#endif
#define CONFIG_USB_PD_DUAL_ROLE
#define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
#define CONFIG_USB_PD_LOGGING
diff --git a/baseboard/zork/variant_trembyle.c b/baseboard/zork/variant_trembyle.c
index 2f1f11fd61..669ed5f6b7 100644
--- a/baseboard/zork/variant_trembyle.c
+++ b/baseboard/zork/variant_trembyle.c
@@ -486,10 +486,10 @@ static int board_ps8818_mux_set(const struct usb_mux *me,
return rv;
/* Enable IN_HPD on the DB */
- ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1);
+ gpio_or_ioex_set_level(PORT_TO_HPD(1), 1);
} else {
/* Disable IN_HPD on the DB */
- ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0);
+ gpio_or_ioex_set_level(PORT_TO_HPD(1), 0);
}
return rv;
@@ -515,3 +515,26 @@ struct usb_mux usbc1_amd_fp5_usb_mux = {
.i2c_addr_flags = AMD_FP5_MUX_I2C_ADDR_FLAGS,
.driver = &amd_fp5_usb_mux_driver,
};
+
+/*
+ * USB-C1 HPD may go through an IO expander, so we must use a custom HPD GPIO
+ * control function with CONFIG_USB_PD_DP_HPD_GPIO_CUSTOM.
+ *
+ * TODO(b/165622386) revert to non-custom GPIO control when HPD is no longer on
+ * the IO expander in any variants.
+ */
+void svdm_set_hpd_gpio(int port, int en)
+{
+ gpio_or_ioex_set_level(PORT_TO_HPD(port), en);
+}
+
+int svdm_get_hpd_gpio(int port)
+{
+ int out;
+
+ if (gpio_or_ioex_get_level(PORT_TO_HPD(port), &out) != EC_SUCCESS) {
+ ccprints("Failed to read current HPD for port C%d", port);
+ return 0;
+ }
+ return out;
+}
diff --git a/board/morphius/board.c b/board/morphius/board.c
index ffb4529662..ab47596e0f 100644
--- a/board/morphius/board.c
+++ b/board/morphius/board.c
@@ -281,8 +281,8 @@ enum gpio_signal board_usbc_port_to_hpd_gpio(int port)
/*
* USB-C1 OPT3 DB
* version_2 uses EC_DP1_HPD
- * version_3 uses DP1_HPD via RTD2141B MST hub, EC does
- * not drive HPD.
+ * version_3 uses DP1_HPD via RTD2141B MST hub to drive AP
+ * HPD, EC drives MST hub HPD input from USB-PD messages.
*
* This would have been ec_config_has_usbc1_retimer_ps8802
* on version_2 hardware but the result is the same and
@@ -290,7 +290,7 @@ enum gpio_signal board_usbc_port_to_hpd_gpio(int port)
*/
else if (ec_config_has_mst_hub_rtd2141b())
return (board_ver >= 3)
- ? GPIO_NO_HPD
+ ? IOEX_USB_C1_HPD_IN_DB
: GPIO_EC_DP1_HPD;
/* USB-C1 OPT1 DB uses DP2_HPD. */
diff --git a/board/woomax/board.h b/board/woomax/board.h
index 9aaf73c65d..0acfa7f3a7 100644
--- a/board/woomax/board.h
+++ b/board/woomax/board.h
@@ -185,13 +185,14 @@ static inline bool ec_config_has_mst_hub_rtd2141b(void)
/*
* USB-C0 always uses USB_C0_HPD (= DP3_HPD).
* USB-C1 OPT1 DB uses DP2_HPD.
- * USB-C1 OPT3 DB uses DP1_HPD via RTD2141B MST hub, EC does not drive HPD.
+ * USB-C1 OPT3 DB uses DP1_HPD via RTD2141B MST hub to drive AP
+ * HPD, EC drives MST hub HPD input from USB-PD messages.
*/
#define PORT_TO_HPD(port) ((port == 0) \
? GPIO_USB_C0_HPD \
: (ec_config_has_mst_hub_rtd2141b()) \
- ? GPIO_NO_HPD \
+ ? IOEX_USB_C1_HPD_IN_DB \
: GPIO_DP2_HPD)
extern const struct usb_mux usbc0_pi3dpx1207_usb_retimer;