diff options
author | Philip Chen <philipchen@google.com> | 2018-02-28 17:13:18 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-03-02 15:47:00 -0800 |
commit | 6589e15e424f6a56f370a89e322240a1375839c7 (patch) | |
tree | 4be6e3e85941c9e53f8491575e85f294699e9c10 /chip | |
parent | 69c18ad6a6a77ea1c82465e6420280c8cf55b12f (diff) | |
download | chrome-ec-6589e15e424f6a56f370a89e322240a1375839c7.tar.gz |
scarlet: Turn off ADC after board version is read
We can turn off ADC after the first successful read for board version.
A few milliwatts saved is important when Scarlet is in S3.
BUG=b:72160379
BRANCH=scarlet
TEST=Try 'version' command a few times on EC console and see
correct board version.
Change-Id: Id2bef415f161431ed895f49db30d50347479176d
Signed-off-by: Philip Chen <philipchen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/942377
Commit-Ready: Philip Chen <philipchen@chromium.org>
Tested-by: Philip Chen <philipchen@chromium.org>
Reviewed-by: Scott Collyer <scollyer@chromium.org>
Reviewed-by: Derek Basehore <dbasehore@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r-- | chip/stm32/adc-stm32f0.c | 10 | ||||
-rw-r--r-- | chip/stm32/adc_chip.h | 3 | ||||
-rw-r--r-- | chip/stm32/registers.h | 1 |
3 files changed, 14 insertions, 0 deletions
diff --git a/chip/stm32/adc-stm32f0.c b/chip/stm32/adc-stm32f0.c index cffae10fd9..fd9711d44a 100644 --- a/chip/stm32/adc-stm32f0.c +++ b/chip/stm32/adc-stm32f0.c @@ -284,6 +284,16 @@ int adc_read_channel(enum adc_channel ch) return value * adc->factor_mul / adc->factor_div + adc->shift; } +void adc_disable(void) +{ + STM32_ADC_CR |= STM32_ADC_CR_ADDIS; + /* + * Note that the ADC is not in OFF state immediately. + * Once the ADC is effectively put into OFF state, + * STM32_ADC_CR_ADDIS bit will be cleared by hardware. + */ +} + static void adc_init(void) { /* diff --git a/chip/stm32/adc_chip.h b/chip/stm32/adc_chip.h index 9d28b027a8..7b40535ac0 100644 --- a/chip/stm32/adc_chip.h +++ b/chip/stm32/adc_chip.h @@ -24,6 +24,9 @@ struct adc_t { */ extern const struct adc_t adc_channels[]; +/* Disable ADC module when we don't need it anymore. */ +void adc_disable(void); + /* Minimum and maximum values returned by adc_read_channel(). */ #define ADC_READ_MIN 0 #define ADC_READ_MAX 4095 diff --git a/chip/stm32/registers.h b/chip/stm32/registers.h index c6e8321c20..432fc9a221 100644 --- a/chip/stm32/registers.h +++ b/chip/stm32/registers.h @@ -2059,6 +2059,7 @@ typedef volatile struct stm32_spi_regs stm32_spi_regs_t; #define STM32_ADC_CR REG32(STM32_ADC1_BASE + 0x08) #define STM32_ADC_CR_ADEN (1 << 0) +#define STM32_ADC_CR_ADDIS (1 << 1) #define STM32_ADC_CR_ADCAL (1 << 31) #define STM32_ADC_CFGR1 REG32(STM32_ADC1_BASE + 0x0C) /* Analog watchdog channel selection */ |