From 23cb9982058092993f319b2b30fefd52639af288 Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Wed, 1 May 2013 07:06:54 +0800 Subject: stm32: Fix ADC watchdog bug and extend sample time This fixes a bug in ADC watchdog that sample sequence is not set before enabling ADC watchdog. Also, current sample time isn't long enough for some weakly driven net. This extends ADC sample time to 13.5 cycles. BUG=chrome-os-partner:17928 TEST=Test with Toad cable and video dongle on Spring BRANCH=spring Change-Id: Iecdfd4aada4e974225a41144e213e92897f4797b Signed-off-by: Vic Yang Reviewed-on: https://gerrit.chromium.org/gerrit/49680 Reviewed-by: Vincent Palatin --- chip/stm32/adc.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/chip/stm32/adc.c b/chip/stm32/adc.c index 1aad5d5744..99b014ef29 100644 --- a/chip/stm32/adc.c +++ b/chip/stm32/adc.c @@ -95,6 +95,8 @@ static int adc_enable_watchdog_no_lock(void) return EC_ERROR_UNKNOWN; /* Set channel */ + STM32_ADC_SQR3 = watchdog_ain_id; + STM32_ADC_SQR1 = 0; STM32_ADC_CR1 = (STM32_ADC_CR1 & ~0x1f) | watchdog_ain_id; /* Clear interrupt bit */ @@ -271,11 +273,11 @@ static void adc_init(void) STM32_ADC_CR2 &= ~(1 << 11); /* - * Set sample time of all channels to 7.5 cycles. - * Conversion takes 8.75 us. + * Set sample time of all channels to 13.5 cycles. + * Conversion takes 15.75 us. */ - STM32_ADC_SMPR1 = 0x00249249; - STM32_ADC_SMPR2 = 0x09249249; + STM32_ADC_SMPR1 = 0x00492492; + STM32_ADC_SMPR2 = 0x12492492; } DECLARE_HOOK(HOOK_INIT, adc_init, HOOK_PRIO_DEFAULT); -- cgit v1.2.1