summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/console_output.c1
-rw-r--r--common/host_command_pd.c15
-rw-r--r--include/console.h1
3 files changed, 15 insertions, 2 deletions
diff --git a/common/console_output.c b/common/console_output.c
index 99e30cc6ce..3bbad84ad4 100644
--- a/common/console_output.c
+++ b/common/console_output.c
@@ -47,6 +47,7 @@ static const char * const channel_names[] = {
"lightbar",
"lpc",
"motionsense",
+ "pdhostcmd",
"port80",
"pwm",
"spi",
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");
}
/*
diff --git a/include/console.h b/include/console.h
index a7ee2f1b67..8890e7c838 100644
--- a/include/console.h
+++ b/include/console.h
@@ -43,6 +43,7 @@ enum console_channel {
CC_LIGHTBAR,
CC_LPC,
CC_MOTION_SENSE,
+ CC_PD_HOST_CMD,
CC_PORT80,
CC_PWM,
CC_SPI,