Skip to contentSkip to conversation

patch "iio: adc: stm32: fix a current leak by resetting pcsel before" added to char-misc-linus

PATCH [email protected] 1 participant 1 message Dec 8, 2021

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

iio: adc: stm32: fix a current leak by resetting pcsel before

to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-linus branch.

The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.

If you have any questions about this process, please let me know.

From f711f28e71e965c0d1141c830fa7131b41abbe75 Mon Sep 17 00:00:00 2001
From: Fabrice Gasnier <[email protected]>
Date: Fri, 22 Oct 2021 14:19:29 +0200
Subject: iio: adc: stm32: fix a current leak by resetting pcsel before
disabling vdda

Some I/Os are connected to ADC input channels, when the corresponding bit in PCSEL register are set on STM32H7 and STM32MP15. This is done in the prepare routine of stm32-adc driver.
There are constraints here, as PCSEL shouldn't be set when VDDA supply is disabled. Enabling/disabling of VDDA supply in done via stm32-adc-core runtime PM routines (before/after ADC is enabled/disabled).

Currently, PCSEL remains set when disabling ADC. Later on, PM runtime can disable the VDDA supply. This creates some conditions on I/Os that can start to leak current.
So PCSEL needs to be cleared when disabling the ADC.

---
 drivers/iio/adc/stm32-adc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/adc/stm32-adc.c +1 -0
index 6245434f8377..60f2ccf7e342 100644
@@ -1117,6 +1117,7 @@ static void stm32h7_adc_unprepare(struct iio_dev *indio_dev)
 {
 	struct stm32_adc *adc = iio_priv(indio_dev);
 
+	stm32_adc_writel(adc, STM32H7_ADC_PCSEL, 0);
 	stm32h7_adc_disable(indio_dev);
 	stm32_adc_int_ch_disable(adc);
 	stm32h7_adc_enter_pwr_down(adc);
Signature · 1 line
2.34.1