From patchwork Tue Jun 28 15:16:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 12898467 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 5848BC43334 for ; Tue, 28 Jun 2022 15:19:02 +0000 (UTC) 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:References:In-Reply-To: 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: List-Owner; bh=PYxaKp2mjfxuLqJt3HsRCz5GZlmbfB++/bUPj/wyfR0=; b=nV0zUG4BNiaLAC 1RrVbAl17h5a8IDW3NEzbF1QavV+zH93Br5haW3UC7W9gzwaxRCd0n8A2kwllW0lBnczWpAhiuWAP X4YcEC4oGNt0zN6fbJUBeFxRkk1Z8zH6m8zkWFMZ0T9OEtn8ggjOHlbeIwMeas2EJvmkbUd780ZsU hmTQRHfZdTjMDp1EmF/nHDoKnwAg2tAEK3bt5yHLcUaWYG6u9vZh+UzNv/KHmEyDV6ok9OHMgJh0F +P8AFvNagVe/wW+Khq92iLbGv0bMY/9E1FOTSaazwyQzBa2oNElqlXweH7S6RKnAQ+KalYJMKBNlt 2IDC61RxOSouvvrMyqVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6CyS-006r73-Jk; Tue, 28 Jun 2022 15:17:56 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6Cv4-006pvE-Pi for linux-arm-kernel@lists.infradead.org; Tue, 28 Jun 2022 15:14:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1656429266; x=1687965266; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OXG7YlbsOZ3z/WgmYcYRa9YBKV8mMjd6Oe/SsZqOqYE=; b=jWJnBVryta3aRa1IW3REBpozbQDOXoKuDHvtkrDgl0xiuoZkiBDLnHb/ NUocSLrotxc5NekcPwDsHVapjWsyrNj5f52IaXbqzUFfU18A9lcaQ0lWO qOMQsJFKLbJjGOCERorNXtKARe9ySuWVn/oHKHRV/ER1W8XVStCxFwieg MOeMZ7c1FEBerHudI0cbjYX7aWukZFVw4BY9DrPlECVZ/dCKQ3b2XJNjR YGkRRDpBldXnN0NO4/aYSXY9ohuHi2GSWMIq0HaDVtFZujECeN6+/TGKt oJXQshgJsEYeKRwE/hR9fuykSAxlFik/b/5R8ko/4st+rCtfUlt+3UYF+ g==; X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="170219131" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 28 Jun 2022 08:14:26 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.17; Tue, 28 Jun 2022 08:14:26 -0700 Received: from localhost.localdomain (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2375.17 via Frontend Transport; Tue, 28 Jun 2022 08:14:23 -0700 From: Claudiu Beznea To: , , , , , , , CC: , , , Subject: [PATCH v2 04/19] iio: adc: at91-sama5d2_adc: disable/prepare buffer on suspend/resume Date: Tue, 28 Jun 2022 18:16:16 +0300 Message-ID: <20220628151631.3116454-5-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220628151631.3116454-1-claudiu.beznea@microchip.com> References: <20220628151631.3116454-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220628_081426_900531_B2B4AB55 X-CRM114-Status: GOOD ( 13.99 ) 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 In case triggered buffers are enabled while system is suspended they will not work anymore after resume. For this call at91_adc_buffer_postdisable() on suspend and at91_adc_buffer_prepare() on resume. On tests it has been seen that at91_adc_buffer_postdisable() call is not necessary but it has been kept because it also does the book keeping for DMA. On resume path there is no need to call at91_adc_configure_touch() as it is embedded in at91_adc_buffer_prepare(). Fixes: 073c662017f2f ("iio: adc: at91-sama5d2_adc: add support for DMA") Signed-off-by: Claudiu Beznea --- drivers/iio/adc/at91-sama5d2_adc.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index 40a95d2fd5c8..2c087d52f164 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -2116,6 +2116,9 @@ static __maybe_unused int at91_adc_suspend(struct device *dev) struct iio_dev *indio_dev = dev_get_drvdata(dev); struct at91_adc_state *st = iio_priv(indio_dev); + if (iio_buffer_enabled(indio_dev)) + at91_adc_buffer_postdisable(indio_dev); + /* * Do a sofware reset of the ADC before we go to suspend. * this will ensure that all pins are free from being muxed by the ADC @@ -2159,14 +2162,11 @@ static __maybe_unused int at91_adc_resume(struct device *dev) if (!iio_buffer_enabled(indio_dev)) return 0; - /* check if we are enabling triggered buffer or the touchscreen */ - if (at91_adc_current_chan_is_touch(indio_dev)) - return at91_adc_configure_touch(st, true); - else - return at91_adc_configure_trigger(st->trig, true); + ret = at91_adc_buffer_prepare(indio_dev); + if (ret) + goto vref_disable_resume; - /* not needed but more explicit */ - return 0; + return at91_adc_configure_trigger(st->trig, true); vref_disable_resume: regulator_disable(st->vref);