From f58eff670034fe460c6082f964598ef47ffddde2 Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Wed, 27 May 2015 14:10:44 -0700 Subject: 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 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 Commit-Queue: Vincent Palatin Tested-by: Vincent Palatin --- board/ryu_p4p5/board.c | 34 ++++++++++++++++++++++++++++++++-- board/ryu_p4p5/board.h | 1 + 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/board/ryu_p4p5/board.c b/board/ryu_p4p5/board.c index ec383dc72b..28e2c20cb4 100644 --- a/board/ryu_p4p5/board.c +++ b/board/ryu_p4p5/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" @@ -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)); diff --git a/board/ryu_p4p5/board.h b/board/ryu_p4p5/board.h index 7cfb1266b4..9fbf93221b 100644 --- a/board/ryu_p4p5/board.h +++ b/board/ryu_p4p5/board.h @@ -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 -- cgit v1.2.1