diff options
author | Alec Berg <alecaberg@chromium.org> | 2013-10-24 14:19:50 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-10-25 01:32:36 +0000 |
commit | 55abd0b93cdadc717175ce9dbe732576ff36986f (patch) | |
tree | 70cacf57b4bb13276780e9e09b61c7930ea81172 | |
parent | c0fbbaefed2b82bacf4a202cda529658b5d6d058 (diff) | |
download | chrome-ec-55abd0b93cdadc717175ce9dbe732576ff36986f.tar.gz |
lm4: Disable ADC module when not in use.
Changed ADC clock gating to disable the ADC module to conserve power,
and only enable it when needed. This saves about 15% of the power
consumed by the EC when the AP is running.
BUG=none
BRANCH=none
TEST=Run the ADC stress test. This runs 2000 consecutive ADC
reads of all the channels and verifies that the ADC module
successfully records the samples. Note that when running this
test make sure all other calls to read an ADC channel are
disabled because the ADC read function does not protect
against different tasks accesses.
Change-Id: I9ca3671d8cf68e09d21c9c2594856f9c08476398
Signed-off-by: Alec Berg <alecaberg@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/174580
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | chip/lm4/adc.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/chip/lm4/adc.c b/chip/lm4/adc.c index 365a2776c9..b3e24809a8 100644 --- a/chip/lm4/adc.c +++ b/chip/lm4/adc.c @@ -120,7 +120,17 @@ static void lm4_adc_configure(const struct adc_t *adc) int adc_read_channel(enum adc_channel ch) { const struct adc_t *adc = adc_channels + ch; - int rv = lm4_adc_flush_and_read(adc->sequencer); + int rv; + + /* Enable ADC0 module in run and sleep modes. */ + clock_enable_peripheral(CGC_OFFSET_ADC, 0x1, + CGC_MODE_RUN | CGC_MODE_SLEEP); + + rv = lm4_adc_flush_and_read(adc->sequencer); + + /* Disable ADC0 module to conserve power. */ + clock_disable_peripheral(CGC_OFFSET_ADC, 0x1, + CGC_MODE_RUN | CGC_MODE_SLEEP); if (rv == ADC_READ_ERROR) return ADC_READ_ERROR; @@ -236,5 +246,9 @@ static void adc_init(void) /* Initialize ADC sequencer */ for (i = 0; i < ADC_CH_COUNT; ++i) lm4_adc_configure(adc_channels + i); + + /* Disable ADC0 module until it is needed to conserve power. */ + clock_disable_peripheral(CGC_OFFSET_ADC, 0x1, + CGC_MODE_RUN | CGC_MODE_SLEEP); } DECLARE_HOOK(HOOK_INIT, adc_init, HOOK_PRIO_DEFAULT); |