Commit 5b832152 authored by Caveh Jalali's avatar Caveh Jalali Committed by chrome-bot
Browse files

anx3429: wait for TCPC restart after FW update



we need to wait for the TCPC to restart and the pd_task() to settle
after a firmware update before proceding.  the AP doesn't really have
a reliable way to to tell if the pd_task() is back in business on the
EC side, so we'll just wait a conservative amount of time before
declaring victory.

BRANCH=none
BUG=b:35586895

TEST=used 2 different firmware blobs and verified it switches between
	them during software sync.

CQ-DEPEND=CL:631976

Change-Id: I983894464cfaa27d5c133c9728c5df11ebb62323
Signed-off-by: default avatarCaveh Jalali <caveh@google.com>
Reviewed-on: https://chromium-review.googlesource.com/631996

Reviewed-by: default avatarJulius Werner <jwerner@chromium.org>
parent eaa0d9c3
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#endif #endif
#define ANX_TIMEOUT_US (1 * USECS_PER_SEC) /* 1s */ #define ANX_TIMEOUT_US (1 * USECS_PER_SEC) /* 1s */
#define ANX_RESTART_MS (1 * MSECS_PER_SEC) /* 1s */
/* OTP memory layout */ /* OTP memory layout */
...@@ -516,20 +517,19 @@ static int __must_check anx3429_enable_mcu(Anx3429 *me) ...@@ -516,20 +517,19 @@ static int __must_check anx3429_enable_mcu(Anx3429 *me)
* capture chip (vendor, product, device, rev) IDs * capture chip (vendor, product, device, rev) IDs
* *
* @param me device context * @param me device context
* @param renew force info to be refreshed from chip
* @return 0 if ok, -1 on error * @return 0 if ok, -1 on error
*/ */
static int __must_check anx3429_capture_device_id(Anx3429 *me, int renew) static int __must_check anx3429_capture_device_id(Anx3429 *me)
{ {
struct ec_params_pd_chip_info p; struct ec_params_pd_chip_info p;
struct ec_response_pd_chip_info r; struct ec_response_pd_chip_info r;
if (me->chip.vendor != 0 && !renew) if (me->chip.vendor != 0)
return 0; return 0;
p.port = me->ec_pd_id; p.port = me->ec_pd_id;
p.renew = renew; p.renew = 0;
int status = ec_command(me->bus->ec, EC_CMD_PD_CHIP_INFO, 0, int status = ec_command(me->bus->ec, EC_CMD_PD_CHIP_INFO, 0,
&p, sizeof(p), &r, sizeof(r)); &p, sizeof(p), &r, sizeof(r));
if (status < 0) { if (status < 0) {
...@@ -559,6 +559,11 @@ static int __must_check anx3429_capture_device_id(Anx3429 *me, int renew) ...@@ -559,6 +559,11 @@ static int __must_check anx3429_capture_device_id(Anx3429 *me, int renew)
return 0; return 0;
} }
static void anx3429_clear_device_id(Anx3429 *me)
{
memset(&me->chip, 0, sizeof(me->chip));
}
/* /*
* update the firmware blob and update the next available header to * update the firmware blob and update the next available header to
* point to it. * point to it.
...@@ -714,7 +719,7 @@ static VbError_t anx3429_check_hash(const VbootAuxFwOps *vbaux, ...@@ -714,7 +719,7 @@ static VbError_t anx3429_check_hash(const VbootAuxFwOps *vbaux,
if (hash_size != sizeof(me->chip.fw_rev)) if (hash_size != sizeof(me->chip.fw_rev))
return VBERROR_INVALID_PARAMETER; return VBERROR_INVALID_PARAMETER;
if (anx3429_capture_device_id(me, 0) == 0) if (anx3429_capture_device_id(me) == 0)
status = VBERROR_SUCCESS; status = VBERROR_SUCCESS;
if (status != VBERROR_SUCCESS) if (status != VBERROR_SUCCESS)
...@@ -973,8 +978,15 @@ pd_resume: ...@@ -973,8 +978,15 @@ pd_resume:
if (anx3429_ec_pd_resume(me) != 0) if (anx3429_ec_pd_resume(me) != 0)
status = VBERROR_UNKNOWN; status = VBERROR_UNKNOWN;
if (anx3429_capture_device_id(me, 1) != 0) /* force re-read */
status = VBERROR_UNKNOWN; anx3429_clear_device_id(me);
/*
* wait for the TCPC and pd_task() to restart
*
* TODO(b/64696543): remove delay when the EC can delay TCPC
* host commands until it can service them.
*/
mdelay(ANX_RESTART_MS);
return status; return status;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment