summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2017-08-22 10:42:20 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-08-23 21:17:23 -0700
commit8eea86766b02055a615b261739e2272ba1531b10 (patch)
tree63f41b22913ccb770d36656028b9b3ec3cc11073
parent0aa4bfe9a3d906a210e27ee40c22e30b3658533a (diff)
downloadchrome-ec-8eea86766b02055a615b261739e2272ba1531b10.tar.gz
coral: Enable TCPC init to happen in pd_task init
This CL enables the config option CONFIG_USB_PD_TCPC_BOARD_INIT and modifies the board level tcpc init function to wait up to 2 seconds to ensure that the battery is out of its disconnected state. This change was put into Eve to ensure the PD chips are not reset until the battery is out of disconnect and delay start of the pd_task (and PD negotiation) until the battery is out of disconnect state. This is part of a change was initially done on Eve https://chromium-review.googlesource.com/c/592716. For Coral the delay of tcpc init relative to the PD task also addresses an issue where VBUS would be dropped by the external charger when attempting to boot with no battery connected. When no battery is connected there is a timing issue between the Analogix TCPC and the EC related to when the TCPC sends its auto GOODCRC. This results in a hard reset which causes the drop of VBUS. BUG=b:64375688 BRANCH=none TEST=Tested by Bitland using 500 iterations and showed no occurrence of the hard reset causing VBUS to drop. Prior to this CL, the failure rate was 1 out 300 attempts. Change-Id: I28fe3266eb1c0a2940e1bdacee65cf4e642d3483 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/627115 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r--board/coral/board.c11
-rw-r--r--board/coral/board.h2
2 files changed, 12 insertions, 1 deletions
diff --git a/board/coral/board.c b/board/coral/board.c
index 319252040d..9ec589aea3 100644
--- a/board/coral/board.c
+++ b/board/coral/board.c
@@ -364,6 +364,16 @@ void board_reset_pd_mcu(void)
void board_tcpc_init(void)
{
int port, reg;
+ int count = 0;
+
+ /* Wait for disconnected battery to wake up */
+ while (battery_hw_present() == BP_YES &&
+ battery_is_present() == BP_NO) {
+ usleep(100 * MSEC);
+ /* Give up waiting after 2 seconds */
+ if (++count > 20)
+ break;
+ }
/* Only reset TCPC if not sysjump */
if (!system_jumped_to_this_image())
@@ -400,7 +410,6 @@ void board_tcpc_init(void)
mux->hpd_update(port, 0, 0);
}
}
-DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C+1);
/*
* Data derived from Seinhart-Hart equation in a resistor divider circuit with
diff --git a/board/coral/board.h b/board/coral/board.h
index c3f06eda65..6523cc2ff1 100644
--- a/board/coral/board.h
+++ b/board/coral/board.h
@@ -87,6 +87,7 @@
#define CONFIG_USB_PD_PORT_COUNT 2
#define CONFIG_USB_PD_QUIRK_SLOW_CC_STATUS
#define CONFIG_USB_PD_VBUS_DETECT_CHARGER
+#define CONFIG_USB_PD_TCPC_BOARD_INIT
#define CONFIG_USB_PD_TCPC_LOW_POWER
#define CONFIG_USB_PD_TCPM_MUX /* for both PS8751 and ANX3429 */
#define CONFIG_USB_PD_TCPM_ANX74XX
@@ -326,6 +327,7 @@ void board_reset_pd_mcu(void);
int board_get_version(void);
void board_set_tcpc_power_mode(int port, int mode);
+void board_tcpc_init(void);
/* Sensors without hardware FIFO are in forced mode */
#define CONFIG_ACCEL_FORCE_MODE_MASK \