summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2015-05-27 14:10:44 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-05-28 23:02:18 +0000
commit4d5f547ef16f947b28aa88a26bc4ce82abb4d2c8 (patch)
tree4580ba1a4491e5813fbec77e082f4b1ca02f9439
parentf863bd1b953696ed4b1629a84d1b0b99e37c294d (diff)
downloadchrome-ec-4d5f547ef16f947b28aa88a26bc4ce82abb4d2c8.tar.gz
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>
-rw-r--r--board/ryu/board.c34
-rw-r--r--board/ryu/board.h1
-rw-r--r--common/mkbp_event.c2
3 files changed, 34 insertions, 3 deletions
diff --git a/board/ryu/board.c b/board/ryu/board.c
index 51f34de305..9f87faf6b6 100644
--- a/board/ryu/board.c
+++ b/board/ryu/board.c
@@ -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"
@@ -52,6 +53,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));
diff --git a/board/ryu/board.h b/board/ryu/board.h
index c6793aa157..0ab4a88e38 100644
--- a/board/ryu/board.h
+++ b/board/ryu/board.h
@@ -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
diff --git a/common/mkbp_event.c b/common/mkbp_event.c
index d78db48a2d..c8b8d3bced 100644
--- a/common/mkbp_event.c
+++ b/common/mkbp_event.c
@@ -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)