summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2014-08-20 18:07:33 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-08-27 01:29:58 +0000
commit1933fb8ff70ec725cbb4d960de5cc23d682acb78 (patch)
tree3c23f0f3e85194bdb5b156b4da911d799e6bf85b
parente913bc15b8a631757b362da09fc1385a7f509def (diff)
downloadchrome-ec-1933fb8ff70ec725cbb4d960de5cc23d682acb78.tar.gz
samus: add ability for PD MCU to send host event to AP
Add host event for PD up to AP. The PD toggles a gpio line to EC causing an interrupt on EC. The EC then sends host command down to PD MCU to get its status. There is a new status bit for PD host event, so when EC see's the PD host event status bit, it sends a PD host event to the AP. There is currently only one host event for PD to AP. BUG=chrome-os-partner:31361 BRANCH=none TEST=added PD console command pdevent, which initiates the host event. when sent, verified on EC that it sets the correct host event bit using hostevent console command Change-Id: If1a59a3232e2f9a49f272c6dee5319254d87b9a9 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/213371 Reviewed-by: Randall Spangler <rspangler@chromium.org>
-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;