diff options
author | Alec Berg <alecaberg@chromium.org> | 2014-06-21 04:00:57 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-06-28 00:55:35 +0000 |
commit | d7c19b023687b33eebe5fe429961a13305c71566 (patch) | |
tree | 51e81822645d7b9aace74b8868a5553faeb1e620 /common/host_command_pd.c | |
parent | f8171d72f30392807af3b69450b7153ef0b1082f (diff) | |
download | chrome-ec-d7c19b023687b33eebe5fe429961a13305c71566.tar.gz |
samus: add retry mechanism for EC to PD host commands
Add a retry mechanism for EC to PD host commands to make the
communication channel more robust.
BUG=none
BRANCH=none
TEST=run on system to verify that we don't drop host commands
to PD MCU.
Change-Id: Ida6f02a149e4dd9e85a5aac21790928b16864104
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/205148
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'common/host_command_pd.c')
-rw-r--r-- | common/host_command_pd.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/common/host_command_pd.c b/common/host_command_pd.c index a6f6d54720..27bc8265fa 100644 --- a/common/host_command_pd.c +++ b/common/host_command_pd.c @@ -7,11 +7,14 @@ #include "charge_state.h" #include "common.h" +#include "console.h" #include "host_command.h" #include "task.h" #include "timer.h" #include "util.h" +#define CPRINTS(format, args...) cprints(CC_PD_HOST_CMD, format, ## args) + #define TASK_EVENT_EXCHANGE_PD_STATUS TASK_EVENT_CUSTOM(1) static int pd_charger_connected; @@ -25,7 +28,7 @@ static void pd_exchange_status(void) { struct ec_params_pd_status ec_status; struct ec_response_pd_status pd_status; - int rv; + int rv = 0, tries = 0; /* * TODO(crosbug.com/p/29499): Change sending state of charge to @@ -37,13 +40,21 @@ static void pd_exchange_status(void) else ec_status.batt_soc = -1; - rv = pd_host_command(EC_CMD_PD_EXCHANGE_STATUS, 0, &ec_status, + /* Try 3 times to get the PD MCU status. */ + while (tries++ < 3) { + rv = pd_host_command(EC_CMD_PD_EXCHANGE_STATUS, 0, &ec_status, sizeof(struct ec_params_pd_status), &pd_status, sizeof(struct ec_response_pd_status)); + if (rv >= 0) + break; + task_wait_event(500*MSEC); + } if (rv >= 0) pd_charger_connected = pd_status.status & EC_CMD_PD_STATUS_FLAG_CHARGER_CONN; + else + CPRINTS("Host command to PD MCU failed"); } /* |