ryu_p4p5: enable MBKP events for PD events

enable the MKBP event feature to send host event
and wire up the PD specific events.

This is the P5 version of the following Ryu CL:
https://chromium-review.googlesource.com/273620

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=chrome-os-partner:33194
TEST=On Ryu P5, plug/unplug USB devices and add kernel trace to see the
PD events happening.

Change-Id: Ibe3a3e75919419bd97610c69303c43bca6107210
Reviewed-on: https://chromium-review.googlesource.com/274144
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Vincent Palatin
2015-05-27 14:10:44 -07:00
committed by ChromeOS Commit Bot
parent 52cbad1062
commit f58eff6700
2 changed files with 33 additions and 2 deletions

View File

@@ -6,6 +6,7 @@
#include "adc.h"
#include "adc_chip.h"
#include "atomic.h"
#include "battery.h"
#include "case_closed_debug.h"
#include "charge_manager.h"
@@ -49,6 +50,13 @@
static int charge_current_limit;
/*
* PD host event status for host command
* Note: this variable must be aligned on 4-byte boundary because we pass the
* address to atomic_ functions which use assembly to access them.
*/
static struct ec_response_host_event_status host_event_status __aligned(4);
/*
* Store the state of our USB data switches so that they can be restored
* after pericom reset.
@@ -178,7 +186,7 @@ void usb_charger_task(void)
}
/* notify host of power info change */
/* pd_send_host_event(PD_EVENT_POWER_CHANGE); */
pd_send_host_event(PD_EVENT_POWER_CHANGE);
/* Wait for interrupt */
task_wait_event(-1);
@@ -581,7 +589,13 @@ void board_set_charge_limit(int charge_ma)
/* Send host event up to AP */
void pd_send_host_event(int mask)
{
/* TODO(crosbug.com/p/33194): implement host events */
/* mask must be set */
if (!mask)
return;
atomic_or(&(host_event_status.status), mask);
/* interrupt the AP */
host_set_single_event(EC_HOST_EVENT_PD_MCU);
}
/**
@@ -705,3 +719,19 @@ int board_get_version(void)
return ver;
}
/****************************************************************************/
/* Host commands */
static int host_event_status_host_cmd(struct host_cmd_handler_args *args)
{
struct ec_response_host_event_status *r = args->response;
/* Read and clear the host event status to return to AP */
r->status = atomic_read_clear(&(host_event_status.status));
args->response_size = sizeof(*r);
return EC_RES_SUCCESS;
}
DECLARE_HOST_COMMAND(EC_CMD_PD_HOST_EVENT_STATUS, host_event_status_host_cmd,
EC_VER_MASK(0));

View File

@@ -42,6 +42,7 @@
#define CONFIG_I2C
#define CONFIG_LID_SWITCH
#define CONFIG_LOW_POWER_IDLE
#define CONFIG_MKBP_EVENT
#define CONFIG_VBOOT_HASH
#define CONFIG_WATCHDOG_HELP
#undef CONFIG_TASK_PROFILING