summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Yilun Lin <yllin@chromium.org>2021-08-25 12:50:22 +0800
committerCommit Bot <commit-bot@chromium.org>2021-11-19 04:24:49 +0000
commitb644f9dc42009bb5e3cacce5c6060607179be8a1 (patch)
treeda370a62f7ebc4ed2219b5288f050086860d2f63
parent1f2cc27c26d5b21993f68565d57b94cc2da08e12 (diff)
downloadchrome-ec-b644f9dc42009bb5e3cacce5c6060607179be8a1.tar.gz
goroh: configure USB mux.
Goroh rev0 C0 CC1/CC2 and SBU1/SBU2 are connected inversely. The workaround is EC reports the inversed polarity state to the SoC and SoC would reverse the SBU accordingly. BUG=b:188376636 b:185846337 TEST=typec 0|1, and obererve the CC result is inversed at C0 port. BRANCH=main Change-Id: I39af46cfdfa723c9c61f379e4591234048791522 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3115082 Reviewed-by: Rong Chang <rongchang@chromium.org> Reviewed-by: Ting Shen <phoenixshen@chromium.org> Commit-Queue: Eric Yilun Lin <yllin@google.com> Tested-by: Eric Yilun Lin <yllin@google.com>
-rw-r--r--baseboard/goroh/baseboard.c14
-rw-r--r--baseboard/goroh/baseboard.h1
-rw-r--r--baseboard/goroh/usbc_config.c59
3 files changed, 55 insertions, 19 deletions
diff --git a/baseboard/goroh/baseboard.c b/baseboard/goroh/baseboard.c
index ee88d1e713..047ba652a8 100644
--- a/baseboard/goroh/baseboard.c
+++ b/baseboard/goroh/baseboard.c
@@ -243,3 +243,17 @@ void lid_angle_peripheral_enable(int enable)
}
}
#endif
+
+/* Called on AP S5 -> S3 transition */
+static void board_chipset_startup(void)
+{
+ gpio_set_level(GPIO_EN_USB_C1_MUX_PWR, 1);
+}
+DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT);
+
+/* Called on AP S3 -> S5 transition */
+static void board_chipset_shutdown(void)
+{
+ gpio_set_level(GPIO_EN_USB_C1_MUX_PWR, 0);
+}
+DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT);
diff --git a/baseboard/goroh/baseboard.h b/baseboard/goroh/baseboard.h
index 812d102d74..bb6a05418d 100644
--- a/baseboard/goroh/baseboard.h
+++ b/baseboard/goroh/baseboard.h
@@ -104,7 +104,6 @@
#define CONFIG_USBC_VCONN
#define CONFIG_USBC_VCONN_SWAP
#define CONFIG_USB_DRP_ACC_TRYSRC
-#define CONFIG_USB_MUX_IT5205 /* C0 */
#define CONFIG_USBC_RETIMER_PS8818 /* C1 */
#define CONFIG_USB_PD_ALT_MODE
#define CONFIG_USB_PD_ALT_MODE_DFP
diff --git a/baseboard/goroh/usbc_config.c b/baseboard/goroh/usbc_config.c
index 4c02528285..5a49d2ee2d 100644
--- a/baseboard/goroh/usbc_config.c
+++ b/baseboard/goroh/usbc_config.c
@@ -45,34 +45,57 @@ struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_MAX_COUNT] = {
unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
/* USB Mux */
-
-__overridable int board_c1_ps8818_mux_init(const struct usb_mux *me)
+static int goroh_usb_c0_init_mux(const struct usb_mux *me)
{
- /* enable C1 mux power */
- GPIO_SET_LEVEL(GPIO_EN_USB_C1_MUX_PWR, 1);
- return 0;
+ return virtual_usb_mux_driver.init(me);
}
-__overridable int board_c1_ps8818_mux_set(const struct usb_mux *me,
- mux_state_t mux_state)
+static int goroh_usb_c0_set_mux(const struct usb_mux *me, mux_state_t mux_state,
+ bool *ack_required)
{
- if (mux_state == USB_PD_MUX_NONE)
- GPIO_SET_LEVEL(GPIO_EN_USB_C1_MUX_PWR, 0);
+ /*
+ * b/188376636: Inverse C0 polarity.
+ * Goroh rev0 CC1/CC2 SBU1/SBU2 are reversed.
+ * We report inversed polarity to the SoC and SoC we reverse the SBU
+ * accordingly.
+ */
+ mux_state = mux_state ^ USB_PD_MUX_POLARITY_INVERTED;
- return 0;
+ return virtual_usb_mux_driver.set(me, mux_state, ack_required);
+
+}
+
+static int goroh_usb_c0_get_mux(const struct usb_mux *me,
+ mux_state_t *mux_state)
+{
+ return virtual_usb_mux_driver.get(me, mux_state);
}
+static struct usb_mux_driver goroh_usb_c0_mux_driver = {
+ .init = goroh_usb_c0_init_mux,
+ .set = goroh_usb_c0_set_mux,
+ .get = goroh_usb_c0_get_mux,
+};
+
+static const struct usb_mux goroh_usb_c1_ps8818_retimer = {
+ .usb_port = USBC_PORT_C1,
+ .i2c_port = I2C_PORT_USB_C1,
+ .i2c_addr_flags = PS8818_I2C_ADDR_FLAGS,
+ .driver = &ps8818_usb_retimer_driver,
+ .next_mux = NULL,
+};
+
const struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {
- /* C0 no mux */
+ [USBC_PORT_C0] = {
+ .usb_port = USBC_PORT_C0,
+ .driver = &goroh_usb_c0_mux_driver,
+ .hpd_update = &virtual_hpd_update,
},
- {
+ [USBC_PORT_C1] = {
.usb_port = USBC_PORT_C1,
- .i2c_port = I2C_PORT_USB_C1,
- .i2c_addr_flags = PS8818_I2C_ADDR_FLAGS,
- .driver = &ps8818_usb_retimer_driver,
- .board_init = &board_c1_ps8818_mux_init,
- .board_set = &board_c1_ps8818_mux_set,
+ .driver = &virtual_usb_mux_driver,
+ .hpd_update = &virtual_hpd_update,
+ .next_mux = &goroh_usb_c1_ps8818_retimer,
},
};
BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT);