summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2013-10-07 12:23:35 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-10-15 00:27:14 +0000
commitc5b90d7e77511e45f2c0021c1a0bc18b09310933 (patch)
treeaf3ab9f0b74cb239808cca51c681be840d32a107 /include
parent193f2298bd1a078f1ac07aacf9dc50132cbb39d3 (diff)
downloadchrome-ec-c5b90d7e77511e45f2c0021c1a0bc18b09310933.tar.gz
lm4: Add a low power idle task.stabilize-4825.B
First implementation of a low power idle task for the LM4 chip. The low power mode is selected by defining CONFIG_LOW_POWER_IDLE in a board.h file. This commit turns it on for Peppy, Slippy, and Falco only because those are the only boards tested. When using the low power idle task, the chip goes in to deep sleep when it can. Deep sleep disables clocks to most peripherals and puts the onboard flash and RAM into a low power mode. The chip is woken out of deep sleep using the RTC in the hibernate module. Increased the idle task stack size to handle more involved idle task. In board.c, the array of GPIO info can be used to select which GPIO points can wake up the EC from deep sleep. Currenlty selected are the power button, lid open, AC present, PCH_SLP_S3, and PCH_SLP_S5. Additionally the port with the KB scan row GPIO point is also enabled to wake up the EC from deep sleep. Signed-off-by: Alec Berg <alecaberg@chromium.org> BUG=None BRANCH=none TEST=Passes all unit tests. Runs on slippy, peppy, and falco with no noticeable side affects. Verified that the power consumed by the EC is lower when in S3, S5 and G3 by scoping the sense resistor powering the chip. Change-Id: I83fa9a159a4b79201b99f2c32678dc4fc8921726 Reviewed-on: https://chromium-review.googlesource.com/172183 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org> Tested-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/clock.h15
-rw-r--r--include/config.h1
-rw-r--r--include/console.h1
-rw-r--r--include/system.h70
4 files changed, 72 insertions, 15 deletions
diff --git a/include/clock.h b/include/clock.h
index 343b43ecee..875be91006 100644
--- a/include/clock.h
+++ b/include/clock.h
@@ -55,18 +55,6 @@ void clock_enable_pll(int enable, int notify);
*/
void clock_wait_cycles(uint32_t cycles);
-/* Low power modes for idle API */
-
-enum {
- SLEEP_MASK_AP_RUN = (1 << 0), /* the main CPU is running */
- SLEEP_MASK_UART = (1 << 1), /* UART communication on-going */
- SLEEP_MASK_I2C = (1 << 2), /* I2C master communication on-going */
- SLEEP_MASK_CHARGING = (1 << 3), /* Charging loop on-going */
- SLEEP_MASK_USB_PWR = (1 << 4), /* USB power loop on-going */
-
- SLEEP_MASK_FORCE = (1 << 31), /* Force disabling low power modes */
-};
-
/* Clock gate control modes for clock_enable_peripheral() */
#define CGC_MODE_RUN (1 << 0)
#define CGC_MODE_SLEEP (1 << 1)
@@ -93,7 +81,4 @@ void clock_enable_peripheral(uint32_t offset, uint32_t mask, uint32_t mode);
*/
void clock_disable_peripheral(uint32_t offset, uint32_t mask, uint32_t mode);
-void enable_sleep(uint32_t mask);
-void disable_sleep(uint32_t mask);
-
#endif /* __CROS_EC_CLOCK_H */
diff --git a/include/config.h b/include/config.h
index 72dffe49c2..e44a97e96c 100644
--- a/include/config.h
+++ b/include/config.h
@@ -214,6 +214,7 @@
#undef CONFIG_CMD_POWERLED
#undef CONFIG_CMD_SCRATCHPAD
#undef CONFIG_CMD_SLEEP
+#undef CONFIG_CMD_RTC_ALARM
/*****************************************************************************/
diff --git a/include/console.h b/include/console.h
index 623d5a5551..1dd37e42c9 100644
--- a/include/console.h
+++ b/include/console.h
@@ -30,6 +30,7 @@ enum console_channel {
* inside a console command routine. */
CC_CHARGER,
CC_CHIPSET,
+ CC_CLOCK,
CC_DMA,
CC_EVENTS,
CC_GPIO,
diff --git a/include/system.h b/include/system.h
index 26e61932c0..0c2936a33c 100644
--- a/include/system.h
+++ b/include/system.h
@@ -8,7 +8,9 @@
#ifndef __CROS_EC_SYSTEM_H
#define __CROS_EC_SYSTEM_H
+#include "atomic.h"
#include "common.h"
+#include "timer.h"
/* Reset causes */
#define RESET_FLAG_OTHER (1 << 0) /* Other known reason */
@@ -268,4 +270,72 @@ void system_hibernate(uint32_t seconds, uint32_t microseconds);
int system_get_console_force_enabled(void);
int system_set_console_force_enabled(int enabled);
+/**
+ * Read the real-time clock.
+ *
+ * @return The real-time clock value as a timestamp.
+ */
+timestamp_t system_get_rtc(void);
+
+/**
+ * Enable hibernate interrupt
+ */
+void system_enable_hib_interrupt(void);
+
+/* Low power modes for idle API */
+enum {
+ SLEEP_MASK_AP_RUN = (1 << 0), /* the main CPU is running */
+ SLEEP_MASK_UART = (1 << 1), /* UART communication on-going */
+ SLEEP_MASK_I2C = (1 << 2), /* I2C master communication on-going */
+ SLEEP_MASK_CHARGING = (1 << 3), /* Charging loop on-going */
+ SLEEP_MASK_USB_PWR = (1 << 4), /* USB power loop on-going */
+
+ SLEEP_MASK_FORCE = (1 << 31), /* Force disabling low power modes */
+};
+
+/*
+ * Current sleep mask. You may read from this variable, but must NOT
+ * modify it; use enable_sleep() or disable_sleep() to do that.
+ */
+extern uint32_t sleep_mask;
+
+/**
+ * Enable low power sleep mask. For low power sleep to take affect, all masks
+ * in the sleep mask enum above must be enabled.
+ *
+ * @param Sleep mask to enable.
+ */
+static inline void enable_sleep(uint32_t mask)
+{
+ atomic_clear(&sleep_mask, mask);
+}
+
+/**
+ * Disable low power sleep mask. For low power sleep to take affect, all masks
+ * in the sleep mask enum above must be enabled.
+ *
+ * @param Sleep mask to enable.
+ */
+static inline void disable_sleep(uint32_t mask)
+{
+ atomic_or(&sleep_mask, mask);
+}
+
+/**
+ * Use hibernate module to set up an RTC interrupt at a given
+ * time from now
+ *
+ * Note: If time given is less than HIB_SET_RTC_MATCH_DELAY_USEC, then it will
+ * set the interrupt at exactly HIB_SET_RTC_MATCH_DELAY_USEC.
+ *
+ * @param seconds Number of seconds before RTC interrupt
+ * @param microseconds Number of microseconds before RTC interrupt
+ */
+void system_set_rtc_alarm(uint32_t seconds, uint32_t microseconds);
+
+/**
+ * Disable and clear the RTC interrupt.
+ */
+void system_reset_rtc_alarm(void);
+
#endif /* __CROS_EC_SYSTEM_H */