diff options
-rw-r--r-- | baseboard/guybrush/baseboard.c | 4 | ||||
-rw-r--r-- | driver/usb_mux/anx7451.c | 47 | ||||
-rw-r--r-- | driver/usb_mux/anx7451.h | 2 |
3 files changed, 25 insertions, 28 deletions
diff --git a/baseboard/guybrush/baseboard.c b/baseboard/guybrush/baseboard.c index 0492bc5ae1..4a7c2cbbd8 100644 --- a/baseboard/guybrush/baseboard.c +++ b/baseboard/guybrush/baseboard.c @@ -448,7 +448,7 @@ __overridable int board_c1_anx7451_mux_set(const struct usb_mux *me, struct usb_mux usbc1_anx7451 = { .usb_port = USBC_PORT_C1, .i2c_port = I2C_PORT_TCPC1, - .i2c_addr_flags = ANX7491_I2C_ADDR0_FLAGS, + .i2c_addr_flags = ANX7491_I2C_ADDR3_FLAGS, .driver = &anx7451_usb_mux_driver, .board_set = &board_c1_anx7451_mux_set, }; @@ -921,7 +921,7 @@ static void baseboard_a1_anx7491_retimer_setup(void) CPRINTSUSB("A1: ANX7491 retimer not detected!"); return; } - CPRINTSUSB("A1: ANX7451 retimer detected"); + CPRINTSUSB("A1: ANX7491 retimer detected"); board_a1_anx7491_retimer_setup(); } diff --git a/driver/usb_mux/anx7451.c b/driver/usb_mux/anx7451.c index 8af46f6388..38d56e8fcb 100644 --- a/driver/usb_mux/anx7451.c +++ b/driver/usb_mux/anx7451.c @@ -7,6 +7,7 @@ */ #include "anx7451.h" +#include "chipset.h" #include "common.h" #include "console.h" #include "i2c.h" @@ -33,6 +34,23 @@ static int anx7451_set_mux(const struct usb_mux *me, mux_state_t mux_state) { int reg; + /* Mux is not powered in Z1 */ + if (chipset_in_state(CHIPSET_STATE_HARD_OFF)) + return (mux_state == USB_PD_MUX_NONE) ? EC_SUCCESS + : EC_ERROR_NOT_POWERED; + + /* ULTRA_LOW_POWER must always be disabled (Fig 2-2) */ + RETURN_ERROR(anx7451_write(me, ANX7451_REG_ULTRA_LOW_POWER, + ANX7451_ULTRA_LOW_POWER_DIS)); + + + /* b/184907521: If both DP and USB disabled, mux will fail */ + if (!(mux_state & (USB_PD_MUX_USB_ENABLED | USB_PD_MUX_DP_ENABLED))) { + CPRINTS("ANX7451 requires USB or DP to be set, " + "forcing USB enabled"); + mux_state |= USB_PD_MUX_USB_ENABLED; + } + /* ULP_CFG_MODE_EN overrides pin control. Always set it */ reg = ANX7451_ULP_CFG_MODE_EN; if (mux_state & USB_PD_MUX_USB_ENABLED) @@ -49,6 +67,10 @@ static int anx7451_get_mux(const struct usb_mux *me, mux_state_t *mux_state) { int reg; + /* Mux is not powered in Z1 */ + if (chipset_in_state(CHIPSET_STATE_HARD_OFF)) + return USB_PD_MUX_NONE; + *mux_state = 0; RETURN_ERROR(anx7451_read(me, ANX7451_REG_ULP_CFG_MODE, ®)); @@ -62,31 +84,8 @@ static int anx7451_get_mux(const struct usb_mux *me, mux_state_t *mux_state) return EC_SUCCESS; } -static int anx7451_init(const struct usb_mux *me) -{ - uint64_t now; - - /* - * ANX7451 requires 30ms to power on. EC and ANX7451 are on the same - * power rail, so just wait 30ms since EC boot. - */ - now = get_time().val; - if (now < ANX7451_I2C_READY_DELAY_MS*MSEC) - usleep(ANX7451_I2C_READY_DELAY_MS*MSEC - now); - - /* ULTRA_LOW_POWER must always be disabled (Fig 2-2) */ - RETURN_ERROR(anx7451_write(me, ANX7451_REG_ULTRA_LOW_POWER, - ANX7451_ULTRA_LOW_POWER_DIS)); - - /* Start mux in safe mode */ - RETURN_ERROR(anx7451_set_mux(me, USB_PD_MUX_NONE)); - - return EC_SUCCESS; -} - const struct usb_mux_driver anx7451_usb_mux_driver = { - .init = anx7451_init, .set = anx7451_set_mux, - .get = anx7451_get_mux + .get = anx7451_get_mux, /* Low power mode is not supported on ANX7451 */ }; diff --git a/driver/usb_mux/anx7451.h b/driver/usb_mux/anx7451.h index 102738aa7c..c8d302f5c9 100644 --- a/driver/usb_mux/anx7451.h +++ b/driver/usb_mux/anx7451.h @@ -9,8 +9,6 @@ #ifndef __CROS_EC_USB_MUX_ANX7451_H #define __CROS_EC_USB_MUX_ANX7451_H -#define ANX7451_I2C_READY_DELAY_MS 30 - /* I2C interface addresses */ #define ANX7451_I2C_ADDR0_FLAGS 0x10 #define ANX7451_I2C_ADDR1_FLAGS 0x14 |