From 0195f774ba95e40808b89208b12e9e427e982e6a Mon Sep 17 00:00:00 2001 From: Alexandre Poizat Date: Wed, 6 Mar 2024 15:10:21 +0100 Subject: [PATCH] drivers: adc: stm32: disable ADC before writing oversampling bits for g0 Added the STM32G0X SOC series to the list of SOC that need to disable the ADC while setting the oversampling bits to prevent writing over the CKMODE bits. Signed-off-by: Alexandre Poizat --- drivers/adc/adc_stm32.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/adc/adc_stm32.c b/drivers/adc/adc_stm32.c index ce108e04ce2..8213310ee7b 100644 --- a/drivers/adc/adc_stm32.c +++ b/drivers/adc/adc_stm32.c @@ -641,11 +641,14 @@ static const uint32_t table_oversampling_ratio[] = { */ static void adc_stm32_oversampling_scope(ADC_TypeDef *adc, uint32_t ovs_scope) { -#if defined(CONFIG_SOC_SERIES_STM32L0X) || \ +#if defined(CONFIG_SOC_SERIES_STM32G0X) || \ + defined(CONFIG_SOC_SERIES_STM32L0X) || \ defined(CONFIG_SOC_SERIES_STM32WLX) /* - * setting OVS bits is conditioned to ADC state: ADC must be disabled - * or enabled without conversion on going : disable it, it will stop + * Setting OVS bits is conditioned to ADC state: ADC must be disabled + * or enabled without conversion on going : disable it, it will stop. + * For the G0 series, ADC must be disabled to prevent CKMODE bitfield + * from getting reset, see errata ES0418 section 2.6.4. */ if (LL_ADC_GetOverSamplingScope(adc) == ovs_scope) { return;