From mboxrd@z Thu Jan 1 00:00:00 1970 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 80B79C0015E for ; Sat, 22 Jul 2023 17:14:15 +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:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wpuw9d2GigXEqHD6bz95oBMam23klqsucTvcJhjIPXg=; b=fRJkNEeDsYf0jD 8+ulvEURZ1vXrJQAjKy41zDlBVbyeCtYP6YbFbUx78cdKEgfvxvMssTqIRQWxrfWFw3DHuE9IA4aG mBxd6/89OogsoMp2odvlyKQUqGwa2I8QdLBEVQNNuI1sf9rkfFwmd5DElIL20Ps4zGRhs0xMbuh4u MQuC4quHmcNqFuN5+My/8p8k90axXjsBPcMaEpQ/RDO7LXyMXtRpPL1yk7T3hqwCIoU7N2QDjhPwx aMcTy4XirVPGHSgFJRFMZc8+V5Iw1ZKhj+27jNFrrrMbYUET1LAT4eVYgQzrsmihp1KPVLXVh10Hn 4EOFB1jVL5XwN+5c3JVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qNGB1-00H2TY-2l; Sat, 22 Jul 2023 17:13:55 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qNGAx-00H2Sn-2J; Sat, 22 Jul 2023 17:13:53 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 31E8960AF7; Sat, 22 Jul 2023 17:13:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C996C433C8; Sat, 22 Jul 2023 17:13:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690046030; bh=WBUDQNvPcAAQ33CTwyobl5vG7ksUY6lE1tb9THb+/rw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RINvGBcssY7x7S//6mp28SyHWEuOMCmaftZ6UiNsNaFjjH4Qr9N/d9I7QxjBNgNMx rmHDtKJBSpGILR+eL4QTpv1bOCupqz5SObFkyMBK6uxYx/qgdW562WeaFXlhs6DRO+ Kl8sXlmKDGtAUPzU5OB+MI6lsu34mpnyw42rQZOkQbeR5cZ1Ls3CaR+ide00vC9xPP tfSu8L4o5qEN1a3sEXPoSJp9w36gpu8nTdG/Pnfq0lAeV0omBibBMiSWgdjjiQr22w vdXAuk17aLFUeOZeV9sG2dHsMhZVIDPFhEx6myBXime4+OxI/fiF91emVY2hyI0rKL FrxIAjM3dSUFQ== Date: Sat, 22 Jul 2023 18:13:45 +0100 From: Jonathan Cameron To: George Stark Cc: , , , , , , , , , , , Subject: Re: [PATCH v2 1/2] iio: adc: meson: fix core clock enable/disable moment Message-ID: <20230722181345.44a79b6d@jic23-huawei> In-Reply-To: <20230721102413.255726-2-gnstark@sberdevices.ru> References: <20230721102413.255726-1-gnstark@sberdevices.ru> <20230721102413.255726-2-gnstark@sberdevices.ru> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230722_101351_858760_97CCDECC X-CRM114-Status: GOOD ( 23.43 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 21 Jul 2023 13:23:08 +0300 George Stark wrote: > Enable core clock at probe stage and disable it at remove stage. > Core clock is responsible for turning on/off the entire SoC module so > it should be on before the first module register is touched and be off > at very last moment. > > Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs") > Signed-off-by: George Stark Applied to the fixes-togreg branch of iio.git and marked for stable. The 2nd patch will have to wait as it's not a fix. Thanks, Jonathan > --- > drivers/iio/adc/meson_saradc.c | 23 ++++++++++++----------- > 1 file changed, 12 insertions(+), 11 deletions(-) > > diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c > index 2ee12f3ad312..8397a5347f32 100644 > --- a/drivers/iio/adc/meson_saradc.c > +++ b/drivers/iio/adc/meson_saradc.c > @@ -1055,12 +1055,6 @@ static int meson_sar_adc_hw_enable(struct iio_dev *indio_dev) > goto err_vref; > } > > - ret = clk_prepare_enable(priv->core_clk); > - if (ret) { > - dev_err(dev, "failed to enable core clk\n"); > - goto err_core_clk; > - } > - > regval = FIELD_PREP(MESON_SAR_ADC_REG0_FIFO_CNT_IRQ_MASK, 1); > regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG0, > MESON_SAR_ADC_REG0_FIFO_CNT_IRQ_MASK, regval); > @@ -1087,8 +1081,6 @@ static int meson_sar_adc_hw_enable(struct iio_dev *indio_dev) > regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG3, > MESON_SAR_ADC_REG3_ADC_EN, 0); > meson_sar_adc_set_bandgap(indio_dev, false); > - clk_disable_unprepare(priv->core_clk); > -err_core_clk: > regulator_disable(priv->vref); > err_vref: > meson_sar_adc_unlock(indio_dev); > @@ -1116,8 +1108,6 @@ static void meson_sar_adc_hw_disable(struct iio_dev *indio_dev) > > meson_sar_adc_set_bandgap(indio_dev, false); > > - clk_disable_unprepare(priv->core_clk); > - > regulator_disable(priv->vref); > > if (!ret) > @@ -1379,7 +1369,7 @@ static int meson_sar_adc_probe(struct platform_device *pdev) > if (IS_ERR(priv->clkin)) > return dev_err_probe(dev, PTR_ERR(priv->clkin), "failed to get clkin\n"); > > - priv->core_clk = devm_clk_get(dev, "core"); > + priv->core_clk = devm_clk_get_enabled(dev, "core"); > if (IS_ERR(priv->core_clk)) > return dev_err_probe(dev, PTR_ERR(priv->core_clk), "failed to get core clk\n"); > > @@ -1462,15 +1452,26 @@ static int meson_sar_adc_remove(struct platform_device *pdev) > static int meson_sar_adc_suspend(struct device *dev) > { > struct iio_dev *indio_dev = dev_get_drvdata(dev); > + struct meson_sar_adc_priv *priv = iio_priv(indio_dev); > > meson_sar_adc_hw_disable(indio_dev); > > + clk_disable_unprepare(priv->core_clk); > + > return 0; > } > > static int meson_sar_adc_resume(struct device *dev) > { > struct iio_dev *indio_dev = dev_get_drvdata(dev); > + struct meson_sar_adc_priv *priv = iio_priv(indio_dev); > + int ret; > + > + ret = clk_prepare_enable(priv->core_clk); > + if (ret) { > + dev_err(dev, "failed to enable core clk\n"); > + return ret; > + } > > return meson_sar_adc_hw_enable(indio_dev); > } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel