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>
This commit is contained in:
Alec Berg
2014-08-20 18:07:33 -07:00
committed by chrome-internal-fetch
parent e913bc15b8
commit 1933fb8ff7
3 changed files with 25 additions and 1 deletions

View File

@@ -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;

View File

@@ -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)

View File

@@ -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;