summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorRob Barnes <robbarnes@google.com>2021-04-08 22:51:48 -0600
committerCommit Bot <commit-bot@chromium.org>2021-04-12 18:42:54 +0000
commit9e7040a62bcff60081c4bd18dfae1af000a4bfad (patch)
treed3ec82ff43dfdde68695e6d9f833c0fa54f78fbc /driver
parent99115990760d4a8bf984bdc4298ee9168990bed8 (diff)
downloadchrome-ec-9e7040a62bcff60081c4bd18dfae1af000a4bfad.tar.gz
guybrush: Fix ANX7451 driver
Correct i2c address of ANX7451 on guybrush. Do not attempt to read or write mux in Z1 since mux is not powered. The only required init step is to disable ultra low power. So init can be removed if ultra low power is always set inside set. Prevent disabling both DP and USB at the same time since this causes mux to fail. BUG=b:184907521, b:184908498 TEST=Display port works on Guybrush B2 BRANCH=None Signed-off-by: Rob Barnes <robbarnes@google.com> Change-Id: Icdcc2df6034680844635c8b8675402d0825f34a8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2816306 Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r--driver/usb_mux/anx7451.c47
-rw-r--r--driver/usb_mux/anx7451.h2
2 files changed, 23 insertions, 26 deletions
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, &reg));
@@ -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