From patchwork Fri Oct 22 12:19:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrice Gasnier X-Patchwork-Id: 12577637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0C6DC433EF for ; Fri, 22 Oct 2021 12:21:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B684961163 for ; Fri, 22 Oct 2021 12:21:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B684961163 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=foss.st.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=kYJTpMwriQodh42IfuCA3vFDNwzFbu2F8PnkdyewAf0=; b=cgmc9dhEUxO9lI YlWQIgw7gW3vxsAWGxa9oc/OqHe8BKMIb6mOZuC6YO7BUmfmEdfznjCTnZVdrwvOFgRV28H5Jx0nL TFp/FVUAFn81+2MzPadMnrB0/H4G8fKzbn4brtmvt/DioZUotJdGdtjeXhRaqeXddmHoPSW2fV6wu QPQETf6x+fkdsGIcjV6lA5XPjTuywrCuaDw+htZ8f9pASP8+Xh3cZ40mEQ6qamI2mXLa3ACY/jzb7 qEWjY39zie6cRgTJWL1VXIJBYzrnq45XyY+hCcF/Lin7jYaGJz2GSxqCnFhcQa5Fx9jjOhIOd/vIq 8r2QUlMotmLrAnMs8D/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdtWZ-00AouE-8i; Fri, 22 Oct 2021 12:19:51 +0000 Received: from mx08-00178001.pphosted.com ([91.207.212.93] helo=mx07-00178001.pphosted.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mdtWV-00Aosr-FV for linux-arm-kernel@lists.infradead.org; Fri, 22 Oct 2021 12:19:49 +0000 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19M9KiFE026560; Fri, 22 Oct 2021 14:19:37 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=selector1; bh=W+avfcbVE3ooTZraWY0QHUAVP7fdnfpPvL3ByfAnco0=; b=xo76YZwFxb1yVWVWLUct10G1AEatspQZxwFpEc2qOPRksjPznO/QS2ou35TQ8LRg/kls 60FqDZo9ZtrJGCLa3EEwe+cP+ZJqB9+xvzhydouxqLiXqzsmRTVxiUSt8PPC/99S7ALD GTzVLxbhKVELW42zz3Txtq4mz8etZ+krUn9Snyx2x01yhuTff6UUxyPMeyCO0vZouPJs vtSZ3ZFb8P201Qa2ADi9BTdJJx+ilHL3bgB609x+A4UW79mk2Y5hzgOCdGT4cmOTsCaK nk95SQ8umpVKR9uUgoGNG+bjyEF60gzGTsKOcgzA2mmgkDQTUFJBpLCXVWXhP1BB4w7k Mg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 3butka12ar-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 22 Oct 2021 14:19:37 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E20CD10002A; Fri, 22 Oct 2021 14:19:36 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id D639C218111; Fri, 22 Oct 2021 14:19:36 +0200 (CEST) Received: from localhost (10.75.127.48) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 22 Oct 2021 14:19:36 +0200 From: Fabrice Gasnier To: CC: , , , , , , Subject: [PATCH] iio: adc: stm32: fix a leak by resetting pcsel before disabling vdda Date: Fri, 22 Oct 2021 14:19:29 +0200 Message-ID: <1634905169-23762-1-git-send-email-fabrice.gasnier@foss.st.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG2NODE1.st.com (10.75.127.4) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-22_03,2021-10-21_02,2020-04-07_01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211022_051947_912094_4D76C812 X-CRM114-Status: GOOD ( 16.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. Fixes: 95e339b6e85d ("iio: adc: stm32: add support for STM32H7") Signed-off-by: Fabrice Gasnier Reviewed-by: Olivier Moysan --- drivers/iio/adc/stm32-adc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index 5088de8..e3e7541 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -975,6 +975,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); stm32h7_adc_enter_pwr_down(adc); }