diff options
-rw-r--r-- | board/ryu_p4p5/board.c | 34 | ||||
-rw-r--r-- | 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" @@ -50,6 +51,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 |