mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-06 15:01:35 +00:00
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>
This commit is contained in:
committed by
chrome-internal-fetch
parent
c0fbbaefed
commit
55abd0b93c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user