summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2021-02-08 02:38:11 -0800
committerCommit Bot <commit-bot@chromium.org>2021-04-02 18:52:18 +0000
commitdc951654138d3f8547765b328308a7fc86c5e7b6 (patch)
tree4b70c5da36181aba278d0ca7a33b7906c76b6b93
parent6917e192ce03e484856ae1d69c7d781c34581241 (diff)
downloadchrome-ec-dc951654138d3f8547765b328308a7fc86c5e7b6.tar.gz
honeybuns: Set lane control gpio when MST is in reset
GPIO_MST_HUB_LANE_SWITCH is used by the EC to signal to the MST hub if the host will be providing 2 or 4 lanes of DP. Some MST hubs will only read this signal coming out of reset. This CL adds a method to set MST_HUB_LANE_SWITCH which includes putting the MST hub in reset. BUG=b:175434634 BRANCH=None TEST=modified the mf preference in CBI and verified that MST_HUB_LANE_SWITCH follows the expected level based on pin config in the DP Configure message: Pin Config C -> 0* MST_HUB_LANE_SWITCH Pin Config D -> 1* MST_HUB_LANE_SWITCH Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I096988567b1e53cf49833359ce053da199f406db Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2682789 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/baseboard.c33
-rw-r--r--baseboard/honeybuns/baseboard.h14
-rw-r--r--baseboard/honeybuns/usb_pd_policy.c8
3 files changed, 54 insertions, 1 deletions
diff --git a/baseboard/honeybuns/baseboard.c b/baseboard/honeybuns/baseboard.c
index cd21c22492..3b6d4ba626 100644
--- a/baseboard/honeybuns/baseboard.c
+++ b/baseboard/honeybuns/baseboard.c
@@ -5,6 +5,7 @@
/* Honeybuns family-specific configuration */
#include "console.h"
+#include "cros_board_info.h"
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
@@ -38,8 +39,29 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+
+void baseboard_set_mst_lane_control(int dock_mf)
+{
+ /* Check if lane swich level is changing */
+ if (dock_mf != gpio_get_level(GPIO_MST_HUB_LANE_SWITCH)) {
+ /* put MST into reset */
+ gpio_set_level(GPIO_MST_RST_L, 0);
+ msleep(1);
+ gpio_set_level(GPIO_MST_HUB_LANE_SWITCH, dock_mf);
+ CPRINTS("MST: lane control = %s", dock_mf ? "high" : "low");
+ msleep(1);
+ /* lane control is set, take MST out of reset */
+ gpio_set_level(GPIO_MST_RST_L, 1);
+ }
+}
+
static void baseboard_init(void)
{
+#ifdef SECTION_IS_RW
+ int rv;
+ uint32_t fw_config;
+#endif
+
/* Turn on power rails */
board_power_sequence();
CPRINTS("board: Power rails enabled");
@@ -49,11 +71,20 @@ static void baseboard_init(void)
system_clear_reset_flags(EC_RESET_FLAG_POWER_ON);
/* Make certain SN5S330 PPC does full initialization */
system_set_reset_flags(EC_RESET_FLAG_EFS);
+
+ /*
+ * Dock multi function (mf) preference is stored in bit 0 of fw_config
+ * field of the CBI. If this value is programmed, then make sure the
+ * MST_LANE_CONTROL gpio matches the mf bit.
+ */
+ rv = cbi_get_fw_config(&fw_config);
+ if (!rv)
+ baseboard_set_mst_lane_control(fw_config & 1);
#else
/* Set up host port usbc to present Rd on CC lines */
if(baseboard_usbc_init(USB_PD_PORT_HOST))
CPRINTS("usbc: Failed to set up sink path");
-#endif
+#endif /* SECTION_IS_RW */
}
/*
* Power sequencing must run before any other chip init is attempted, so run
diff --git a/baseboard/honeybuns/baseboard.h b/baseboard/honeybuns/baseboard.h
index 85a877d80c..0faf727ab8 100644
--- a/baseboard/honeybuns/baseboard.h
+++ b/baseboard/honeybuns/baseboard.h
@@ -229,8 +229,22 @@ enum adc_channel {
extern const struct power_seq board_power_seq[];
extern const size_t board_power_seq_count;
+/*
+ * Configure the host port to present Rd on both CC lines. This function is
+ * called in RO which does not otherwise have usbc/usb-pd support.
+ *
+ * @return true - initialized. false - not.
+ */
int baseboard_usbc_init(int port);
+/*
+ * Set MST_LANE_CONTROL gpio to match the DP pin configuration selected
+ * by the host in the DP Configure SVDM message.
+ *
+ * @param dock_mf 1 -> 2 lanes DP, 0 -> 4 lanes DP
+ */
+void baseboard_set_mst_lane_control(int dock_mf);
+
#endif /* !__ASSEMBLER__ */
#endif /* __CROS_EC_BASEBOARD_H */
diff --git a/baseboard/honeybuns/usb_pd_policy.c b/baseboard/honeybuns/usb_pd_policy.c
index 5257753204..a3b43d2402 100644
--- a/baseboard/honeybuns/usb_pd_policy.c
+++ b/baseboard/honeybuns/usb_pd_policy.c
@@ -325,6 +325,14 @@ static void svdm_configure_demux(int port, int enable, int mf)
/* 4 lane mode if MF is not preferred */
if (!mf)
demux &= ~USB_PD_MUX_USB_ENABLED;
+ /*
+ * Make sure the MST_LANE_CONTROL gpio is set to match the DP
+ * pin configuration selected by the host. Note that the mf
+ * passed into this function reflects the pin configuration
+ * selected by the host and not the user mf preference which is
+ * stored in bit 0 of CBI fw_config.
+ */
+ baseboard_set_mst_lane_control(mf);
} else {
demux &= ~USB_PD_MUX_DP_ENABLED;
demux |= USB_PD_MUX_USB_ENABLED;