summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/samus_pd/usb_pd_policy.c16
-rw-r--r--common/host_command_pd.c4
-rw-r--r--include/ec_commands.h6
3 files changed, 25 insertions, 1 deletions
diff --git a/board/samus_pd/usb_pd_policy.c b/board/samus_pd/usb_pd_policy.c
index 867a020dd6..7b56d12435 100644
--- a/board/samus_pd/usb_pd_policy.c
+++ b/board/samus_pd/usb_pd_policy.c
@@ -3,6 +3,7 @@
* found in the LICENSE file.
*/
+#include "atomic.h"
#include "common.h"
#include "console.h"
#include "gpio.h"
@@ -194,6 +195,18 @@ DECLARE_CONSOLE_COMMAND(ecint, command_ec_int,
"Toggle EC interrupt line",
NULL);
+static int command_pd_host_event(int argc, char **argv)
+{
+ atomic_or(&(pd_status.status), PD_STATUS_HOST_EVENT);
+ pd_send_ec_int();
+
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(pdevent, command_pd_host_event,
+ "",
+ "Send PD host event",
+ NULL);
+
/****************************************************************************/
/* Host commands */
static int ec_status_host_cmd(struct host_cmd_handler_args *args)
@@ -205,6 +218,9 @@ static int ec_status_host_cmd(struct host_cmd_handler_args *args)
*r = pd_status;
+ /* Clear host event */
+ atomic_clear(&(pd_status.status), PD_STATUS_HOST_EVENT);
+
args->response_size = sizeof(*r);
return EC_RES_SUCCESS;
diff --git a/common/host_command_pd.c b/common/host_command_pd.c
index 5f57c83305..467dc07dd7 100644
--- a/common/host_command_pd.c
+++ b/common/host_command_pd.c
@@ -54,6 +54,10 @@ static void pd_exchange_status(void)
CONFIG_CHARGER_INPUT_CURRENT));
if (rv < 0)
CPRINTS("Failed to set input current limit from PD MCU");
+
+ /* If PD is signalling host event, then pass it up to AP */
+ if (pd_status.status | PD_STATUS_HOST_EVENT)
+ host_set_single_event(EC_HOST_EVENT_PD_MCU);
}
void pd_command_task(void)
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 83bca00c84..6b065accdc 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -271,6 +271,9 @@ enum host_event_code {
/* Hang detect logic detected a hang and warm rebooted the AP */
EC_HOST_EVENT_HANG_REBOOT = 21,
+ /* PD MCU triggering host event */
+ EC_HOST_EVENT_PD_MCU = 22,
+
/*
* The high bit of the event mask is not used as a host event code. If
* it reads back as set, then the entire event mask should be
@@ -2497,8 +2500,9 @@ struct ec_params_pd_status {
} __packed;
/* Status of PD being sent back to EC */
+#define PD_STATUS_HOST_EVENT (1 << 0)
struct ec_response_pd_status {
- int8_t status; /* PD MCU status */
+ uint32_t status; /* PD MCU status */
uint32_t curr_lim_ma; /* input current limit */
} __packed;