diff options
author | Diana Z <dzigterman@chromium.org> | 2021-05-26 11:30:51 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-06-01 22:40:33 +0000 |
commit | 551793f1b29a0a37a56d57f68d00838d7667b620 (patch) | |
tree | c696e14dc3b7e6c5b87bc9c675400f8e79fb97b9 /driver | |
parent | 109a73f002eb266b0f1b611badb8c2a3ee523d0b (diff) | |
download | chrome-ec-551793f1b29a0a37a56d57f68d00838d7667b620.tar.gz |
NCT38xx: Set debug accessory control conditionally
If we've booted in dead battery mode with a debug accessory connected,
then changing the TCPC_CONTROL.DebugAccessoryControl bit will result in
a significant delay to detecting the CC line state. Track our boot type
and use it plus the presence of a debug accesssory to determine if we'll
change this bit.
BRANCH=None
BUG=b:186799392
TEST=on mancomb, boot and reboot with servo_v4 power only and ensure we
detect the CC lines correctly with no dealy. Also plug in servo_v4 with
BJ power attached first to ensure we set the debug accessory control bit
correctly and verify we can PR swap back and forth.
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I5bcdee1de61ed198cab82bae1ab6ac5996b9e80b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2919942
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'driver')
-rw-r--r-- | driver/tcpm/nct38xx.c | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/driver/tcpm/nct38xx.c b/driver/tcpm/nct38xx.c index 7ec5174bbb..f5527af3a5 100644 --- a/driver/tcpm/nct38xx.c +++ b/driver/tcpm/nct38xx.c @@ -22,18 +22,49 @@ #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) #define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) +enum nct38xx_boot_type { + BOOT_UNKNOWN, + BOOT_DEAD_BATTERY, + BOOT_NORMAL, +}; + +static enum nct38xx_boot_type boot_type[CONFIG_USB_PD_PORT_MAX_COUNT]; + static int nct38xx_init(int port) { int rv; int reg; /* + * Detect dead battery boot by the default role control value of 0x0A + * once per EC run + */ + if (boot_type[port] == BOOT_UNKNOWN) { + RETURN_ERROR(tcpc_read(port, TCPC_REG_ROLE_CTRL, ®)); + + if (reg == 0x0A) + boot_type[port] = BOOT_DEAD_BATTERY; + else + boot_type[port] = BOOT_NORMAL; + } + + RETURN_ERROR(tcpc_read(port, TCPC_REG_POWER_STATUS, ®)); + + /* * Set TCPC_CONTROL.DebugAccessoryControl = 1 to control by TCPM, - * not TCPC. + * not TCPC in most cases. This must be left alone if we're on a + * dead battery boot with a debug accessory. CC line detection will + * be delayed if we have booted from a dead battery with a debug + * accessory and change this bit (see b/186799392). */ - RETURN_ERROR(tcpc_update8(port, TCPC_REG_TCPC_CTRL, - TCPC_REG_TCPC_CTRL_DEBUG_ACC_CONTROL, - MASK_SET)); + if ((boot_type[port] == BOOT_DEAD_BATTERY) && + (reg & TCPC_REG_POWER_STATUS_DEBUG_ACC_CON)) + CPRINTS("C%d: Booted in dead battery mode, not changing debug" + " control", port); + else + RETURN_ERROR(tcpc_update8(port, TCPC_REG_TCPC_CTRL, + TCPC_REG_TCPC_CTRL_DEBUG_ACC_CONTROL, + MASK_SET)); /* * Write to the CONTROL_OUT_EN register to enable: |