stm32f0: make ADC watchdog feature modular

The ADC watchdog is about 2/3 of the ADC code size and it is not
optimized out when not used because adc_read_channel() needs to
stop/restart the watchdog if somebody is using it.

The feature is enabled by default to keep the current behavior on
STM32F0 platform, and it is turned off on samus_pd :
This is saving 448 bytes of flash (and 8 bytes of RAM).

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=none
TEST=make buildall and check the firmware size before and after.
when CONFIG_ADC_WATCHDOG is disabled, adc_enable_watchdog() is not
compiled if there is any user the build will fail.

Change-Id: Ie2450bc2a8fd97662322fd3ce87e93c3fece6c6f
Reviewed-on: https://chromium-review.googlesource.com/265303
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Vincent Palatin
2015-04-10 17:30:29 -07:00
committed by ChromeOS Commit Bot
parent 72ca4cc9f9
commit 007fadda59
3 changed files with 17 additions and 3 deletions

View File

@@ -17,6 +17,7 @@
/* Optional features */
#define CONFIG_ADC
#undef CONFIG_ADC_WATCHDOG
#define CONFIG_BOARD_PRE_INIT
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGE_RAMP

View File

@@ -18,9 +18,6 @@
struct mutex adc_lock;
static int watchdog_ain_id;
static int watchdog_delay_ms;
static const struct dma_option dma_adc_option = {
STM32_DMAC_ADC, (void *)&STM32_ADC_DR,
STM32_DMA_CCR_MSIZE_32_BIT | STM32_DMA_CCR_PSIZE_32_BIT,
@@ -35,6 +32,11 @@ static void adc_configure(int ain_id)
STM32_ADC_CFGR1 &= ~0x1;
}
#ifdef CONFIG_ADC_WATCHDOG
static int watchdog_ain_id;
static int watchdog_delay_ms;
static void adc_continuous_read(int ain_id)
{
adc_configure(ain_id);
@@ -193,6 +195,14 @@ int adc_set_watchdog_delay(int delay_ms)
return EC_SUCCESS;
}
#else /* CONFIG_ADC_WATCHDOG */
static int adc_watchdog_enabled(void) { return 0; }
static int adc_enable_watchdog_no_lock(void) { return 0; }
static int adc_disable_watchdog_no_lock(void) { return 0; }
#endif /* CONFIG_ADC_WATCHDOG */
int adc_read_channel(enum adc_channel ch)
{
const struct adc_t *adc = adc_channels + ch;

View File

@@ -54,6 +54,9 @@
/* ADC sample time selection. The value is chip-dependent. */
#undef CONFIG_ADC_SAMPLE_TIME
/* Include the ADC analog watchdog feature in the ADC code */
#define CONFIG_ADC_WATCHDOG
/*
* Some ALS modules may be connected to the EC. We need the command, and
* specific drivers for each module.