summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShelley Chen <shchen@chromium.org>2016-05-19 16:02:45 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-05-23 13:14:17 -0700
commita84aa5ace71e5ed8ab5afc1a7c1450a3922ac5a0 (patch)
treedec8f142d4e541d4bc5c62a856ea9cb9a87fa5a6
parentb14f89cfdbf403af08f27472ac2d3ba355c85490 (diff)
downloadchrome-ec-a84aa5ace71e5ed8ab5afc1a7c1450a3922ac5a0.tar.gz
kevin: rk3399: enabling RTC wakeup
Enabled CONFIG_CMD_RTC_ALARM. EC_HOST_EVENT_RTC is enabled when the rtc_alarm goes off, alerting the AP to transition from S3->S0. BUG=chrome-os-partner:52218 BRANCH=None TEST=rtc_alarm <num> and see event set in ec console after <num> seconds. Also, check if new bit set through hostevent command in ec before/after rtc_alarm goes off. Change-Id: I53b1705ce0925000f35b9f80752035d198db3310 Signed-off-by: Shelley Chen <shchen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/345474 Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--board/kevin/board.h10
-rw-r--r--chip/npcx/gpio.c15
-rw-r--r--include/ec_commands.h3
3 files changed, 27 insertions, 1 deletions
diff --git a/board/kevin/board.h b/board/kevin/board.h
index 3c71b52949..0d14d4dc77 100644
--- a/board/kevin/board.h
+++ b/board/kevin/board.h
@@ -125,6 +125,16 @@
/* Enable Accel over SPI */
#define CONFIG_SPI_ACCEL_PORT 0 /* SPI master port (SPIP) form BMI160 */
+#define CONFIG_MKBP_EVENT
+/* Define the MKBP events which are allowed to wakeup AP in S3. */
+#define CONFIG_MKBP_WAKEUP_MASK \
+ (EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_CLOSED) |\
+ EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN) |\
+ EC_HOST_EVENT_MASK(EC_HOST_EVENT_POWER_BUTTON) |\
+ EC_HOST_EVENT_MASK(EC_HOST_EVENT_KEY_PRESSED) |\
+ EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC))
+
+
#ifndef __ASSEMBLER__
enum adc_channel {
diff --git a/chip/npcx/gpio.c b/chip/npcx/gpio.c
index 99edf5a74f..93cfd278ef 100644
--- a/chip/npcx/gpio.c
+++ b/chip/npcx/gpio.c
@@ -18,6 +18,8 @@
#include "system.h"
#include "system_chip.h"
#include "lpc_chip.h"
+#include "ec_commands.h"
+#include "host_command.h"
/* Flags for PWM IO type */
#define PWM_IO_FUNC (1 << 1) /* PWM optional func bit */
@@ -800,6 +802,17 @@ void __gpio_wk0efgh_interrupt(void)
gpio_interrupt(NPCX_IRQ_WKINTEFGH_0);
}
+void __gpio_rtc_interrupt(void)
+{
+ /* Check pending bit 7 */
+ if (NPCX_WKPND(MIWU_TABLE_0, MIWU_GROUP_4) & 0x80) {
+ /* Clear pending bit for WUI */
+ SET_BIT(NPCX_WKPCL(MIWU_TABLE_0, MIWU_GROUP_4), 7);
+ host_set_events(EC_HOST_EVENT_MASK(EC_HOST_EVENT_RTC));
+ } else
+ gpio_interrupt(NPCX_IRQ_MTC_WKINTAD_0);
+}
+
GPIO_IRQ_FUNC(__gpio_wk0ad_interrupt , NPCX_IRQ_MTC_WKINTAD_0);
GPIO_IRQ_FUNC(__gpio_wk0b_interrupt , NPCX_IRQ_TWD_WKINTB_0);
GPIO_IRQ_FUNC(__gpio_wk0c_interrupt , NPCX_IRQ_WKINTC_0);
@@ -811,7 +824,7 @@ GPIO_IRQ_FUNC(__gpio_wk1f_interrupt , NPCX_IRQ_WKINTF_1);
GPIO_IRQ_FUNC(__gpio_wk1g_interrupt , NPCX_IRQ_WKINTG_1);
GPIO_IRQ_FUNC(__gpio_wk1h_interrupt , NPCX_IRQ_WKINTH_1);
-DECLARE_IRQ(NPCX_IRQ_MTC_WKINTAD_0, __gpio_wk0ad_interrupt, 1);
+DECLARE_IRQ(NPCX_IRQ_MTC_WKINTAD_0, __gpio_rtc_interrupt, 1);
DECLARE_IRQ(NPCX_IRQ_TWD_WKINTB_0, __gpio_wk0b_interrupt, 1);
DECLARE_IRQ(NPCX_IRQ_WKINTC_0, __gpio_wk0c_interrupt, 1);
DECLARE_IRQ(NPCX_IRQ_WKINTEFGH_0, __gpio_wk0efgh_interrupt, 1);
diff --git a/include/ec_commands.h b/include/ec_commands.h
index faeeb412fb..bc5b342817 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -434,6 +434,9 @@ enum host_event_code {
/* Keyboard fastboot combo has been pressed */
EC_HOST_EVENT_KEYBOARD_FASTBOOT = 25,
+ /* EC RTC event occurred */
+ EC_HOST_EVENT_RTC = 26,
+
/*
* The high bit of the event mask is not used as a host event code. If
* it reads back as set, then the entire event mask should be