summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlec Berg <alecaberg@chromium.org>2013-10-14 17:55:42 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-10-21 23:59:38 +0000
commit10bd1db6d73e21619e789d73c8233dea2c493510 (patch)
treedfc03ce44ce9ef3697cb707d2f160861697628b4 /include
parent1d6687429c1ea236bf09ac32d4936888a36730e6 (diff)
downloadchrome-ec-10bd1db6d73e21619e789d73c8233dea2c493510.tar.gz
lm4: Use low speed clock in deep sleep.
Changed the low power idle task to use the low speed clock in deep sleep. The low power idle task is currently only enabled for Peppy, Slippy, and Falco. This change decreases power consumption when the AP is not running. Note that the low speed clock is slow enough that the JTAG cannot be used and the EC console UART cannot be used. To work around that, this commit detects when the JTAG is in use and when the EC console is in use, and will not use the low speed clock if either is in use. The JTAG in use never clears after being set and the console in use clears after a fixed timeout period. BUG=None BRANCH=None TEST=Passes all unit tests. Tested that the EC console works when in deep sleep. Tested that it is possible to run flash_ec when in deep sleep and using the low speed clock. Change-Id: Ia65997eb8e607a5df9b2c7d68e4826bfb1e0194c Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/173326 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/clock.h5
-rw-r--r--include/gpio.h12
-rw-r--r--include/jtag.h12
-rw-r--r--include/system.h21
-rw-r--r--include/uart.h32
5 files changed, 81 insertions, 1 deletions
diff --git a/include/clock.h b/include/clock.h
index 875be91006..62c38bcd6a 100644
--- a/include/clock.h
+++ b/include/clock.h
@@ -81,4 +81,9 @@ 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);
+/**
+ * Notify the clock module that the UART for the console is in use.
+ */
+void clock_refresh_console_in_use(void);
+
#endif /* __CROS_EC_CLOCK_H */
diff --git a/include/gpio.h b/include/gpio.h
index bdedbf4bb7..fc46e995ce 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -169,6 +169,18 @@ void gpio_set_level(enum gpio_signal signal, int value);
int gpio_enable_interrupt(enum gpio_signal signal);
/**
+ * Disable interrupts for the signal.
+ *
+ * The signal must have been defined with
+ * an interrupt handler. Normally called by the module which handles the
+ * interrupt, if it doesn't want to process interrupts.
+ *
+ * @param signal Signal to disable interrupts for
+ * @return EC_SUCCESS, or non-zero if error.
+ */
+int gpio_disable_interrupt(enum gpio_signal signal);
+
+/**
* Set flags for GPIO(s) by port and mask.
*
* Use gpio_set_flags() to set flags for an individual GPIO by id.
diff --git a/include/jtag.h b/include/jtag.h
index 690158b4ec..9c7835dfd0 100644
--- a/include/jtag.h
+++ b/include/jtag.h
@@ -15,4 +15,16 @@
*/
void jtag_pre_init(void);
+#ifdef CONFIG_LOW_POWER_IDLE
+/**
+ * Interrupt handler for JTAG clock.
+ *
+ * @param signal Signal which triggered the interrupt.
+ */
+void jtag_interrupt(enum gpio_signal signal);
+#else
+#define jtag_interrupt NULL
+#endif
+
+
#endif /* __CROS_EC_JTAG_H */
diff --git a/include/system.h b/include/system.h
index 0c2936a33c..cf936d64bf 100644
--- a/include/system.h
+++ b/include/system.h
@@ -284,13 +284,25 @@ void system_enable_hib_interrupt(void);
/* Low power modes for idle API */
enum {
+ /*
+ * Sleep masks to prevent going in to deep sleep.
+ */
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 */
+ SLEEP_MASK_FORCE_NO_DSLEEP = (1 << 15), /* Force disable. */
+
+
+ /*
+ * Sleep masks to prevent using slow speed clock in deep sleep.
+ */
+ SLEEP_MASK_JTAG = (1 << 16), /* JTAG is in use. */
+ SLEEP_MASK_CONSOLE = (1 << 17), /* Console is in use. */
+
+ SLEEP_MASK_FORCE_NO_LOW_SPEED = (1 << 31) /* Force disable. */
};
/*
@@ -299,6 +311,13 @@ enum {
*/
extern uint32_t sleep_mask;
+/*
+ * Macros to use to get whether deep sleep is allowed or whether
+ * low speed deep sleep is allowed.
+ */
+#define DEEP_SLEEP_ALLOWED (!(sleep_mask & 0x0000ffff))
+#define LOW_SPEED_DEEP_SLEEP_ALLOWED (!(sleep_mask & 0xffff0000))
+
/**
* Enable low power sleep mask. For low power sleep to take affect, all masks
* in the sleep mask enum above must be enabled.
diff --git a/include/uart.h b/include/uart.h
index 762d885f08..2f0bc8bd8c 100644
--- a/include/uart.h
+++ b/include/uart.h
@@ -101,6 +101,11 @@ void uart_tx_flush(void);
int uart_tx_ready(void);
/**
+ * Return non-zero if a transmit is in progress.
+ */
+int uart_tx_in_progress(void);
+
+/**
* Return non-zero if UART is ready to start a DMA transfer.
*/
int uart_tx_dma_ready(void);
@@ -195,6 +200,33 @@ void uart_process_input(void);
*/
void uart_process_output(void);
+/**
+ * Return boolean expressing whether UART buffer is empty or not.
+ */
+int uart_buffer_empty(void);
+
+/**
+ * Disable the EC console UART and convert the UART RX pin to a generic GPIO
+ * with an edge detect interrupt.
+ */
+void uart_enter_dsleep(void);
+
+/**
+ * Enable the EC console UART after a uart_enter_dsleep().
+ */
+void uart_exit_dsleep(void);
+
+#ifdef CONFIG_LOW_POWER_IDLE
+/**
+ * Interrupt handler for UART RX pin transition in deep sleep.
+ *
+ * @param signal Signal which triggered the interrupt.
+ */
+void uart_deepsleep_interrupt(enum gpio_signal signal);
+#else
+#define uart_deepsleep_interrupt NULL
+#endif
+
/*
* COMx functions
*/