summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Lok <ben.lok@mediatek.com>2015-09-17 13:31:51 +0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2016-12-23 04:09:29 +0000
commitb611f157c3455fbc12158c8fe9c3b543110316f0 (patch)
treed2d4e32a4f5ba77560f6832b121fbc4456a71c41
parent72f85a11b34d4ce8fc79686f093f5b1f9b4dab14 (diff)
downloadchrome-ec-b611f157c3455fbc12158c8fe9c3b543110316f0.tar.gz
BACKPORT: mkbp_event: prevent AC power change events to wakeup AP.
It may use MKBP event to send PD power change events to AP via interrupt. According to the spec, AC power change events do not be allowed to wake up AP. In order to avoid it, define a white list in board level, only allow those events to wakeup the AP during S3 power state. BRANCH=none BUG=chrome-os-partner:45127 TEST=manual Plug PD power adapter to oak, if system is in S3/S5 and it should starts charging, but should not wake up system/AP at all. Signed-off-by: Ben Lok <ben.lok@mediatek.com> Reviewed-on: https://chromium-review.googlesource.com/300360 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit 0596b551dfd45dd4af2e8f7a0baad1141d25bfb8) Conflicts: board/oak/board.h include/config.h Change-Id: I2f86697d5d3bd24d7de840e21064b91e8841f0eb Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> Reviewed-on: https://chromium-review.googlesource.com/419942 Reviewed-by: Simon Glass <sjg@google.com> Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--common/mkbp_event.c18
-rw-r--r--include/config.h6
2 files changed, 24 insertions, 0 deletions
diff --git a/common/mkbp_event.c b/common/mkbp_event.c
index 1ec99adcf7..31b4b7b364 100644
--- a/common/mkbp_event.c
+++ b/common/mkbp_event.c
@@ -6,6 +6,7 @@
*/
#include "atomic.h"
+#include "chipset.h"
#include "gpio.h"
#include "host_command.h"
#include "link_defs.h"
@@ -46,6 +47,23 @@ static void set_host_interrupt(int active)
void mkbp_send_event(uint8_t event_type)
{
set_event(event_type);
+
+#ifdef CONFIG_MKBP_WAKEUP_MASK
+ /* checking the event if AP suspended */
+ if (chipset_in_state(CHIPSET_STATE_SUSPEND)) {
+ uint32_t events;
+ events = *(uint32_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS);
+ /*
+ * interrupt the AP if it is a wakeup event
+ * which is defined in the white list.
+ */
+ if (events & CONFIG_MKBP_WAKEUP_MASK)
+ set_host_interrupt(1);
+
+ return;
+ }
+#endif
+
set_host_interrupt(1);
}
diff --git a/include/config.h b/include/config.h
index 2ed9df5bf1..4feb759441 100644
--- a/include/config.h
+++ b/include/config.h
@@ -956,6 +956,12 @@
/* MKBP events are sent using host event */
#undef CONFIG_MKBP_USE_HOST_EVENT
+/*
+ * With this option, we can define the MKBP wakeup events in this mask (as a
+ * white list) in board level, those events allow to interrupt AP during S3.
+ */
+#undef CONFIG_MKBP_WAKEUP_MASK
+
/* Support memory protection unit (MPU) */
#undef CONFIG_MPU