ryu: enable MBKP events for PD events

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

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

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

Change-Id: I21f47884a869987c917e56ed9b3f914815af51e4
Reviewed-on: https://chromium-review.googlesource.com/273620
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: 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 f863bd1b95
commit 4d5f547ef1
3 changed files with 34 additions and 3 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"
@@ -51,6 +52,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.
@@ -180,7 +188,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);
@@ -567,7 +575,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);
}
/**
@@ -645,3 +659,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

@@ -43,6 +43,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

View File

@@ -35,7 +35,7 @@ static int event_is_set(uint8_t event_type)
static void set_host_interrupt(int active)
{
/* interrupt host by using active low EC_INT signal */
gpio_set_level(GPIO_EC_INT, !active);
gpio_set_level(GPIO_EC_INT_L, !active);
}
void mkbp_send_event(uint8_t event_type)