Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1668746pxm; Thu, 24 Feb 2022 07:18:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzJc067KYEmvVd3wNqzkolAFNr2pFagO/YSq0vMMcTZ/NU4CsojC8ONQkxhRt7xvysTVqo X-Received: by 2002:a63:e24e:0:b0:33e:9849:526e with SMTP id y14-20020a63e24e000000b0033e9849526emr2662144pgj.468.1645715926055; Thu, 24 Feb 2022 07:18:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645715926; cv=none; d=google.com; s=arc-20160816; b=nCU2hKOqIC6WgRftw8RdtmzU/KbR4s4l784jfrQ3w0bDrbDXKYauN8IG7lK5UZRY1F JYqeGPpJzxqFLEKP3n8PqbF7mxSZhUbzoZoXYkkd54iGeNb3gV0b8s9+ow8bNlwUHdLt WG9sksQa0Mh2/nCOzLh25LT13oukWZvX+8PwnLwAaLc+aakXWhckVE1Kfa811Ufpw17V 0EwypxgNBRZC+L6URv6w9F6FmB12ei7fhncgtBRfDiFeN1ljkBG4pPJqieJkgyvKOB/u 5Hq4WCdMiaMEPWiqulqE8cYgROIWUmHHsFksjj8aVmeuxySWIjslroX1Hex0ThPSEORd 9mGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WNHsk/5D9xGPuJd373nmHea73ZrQBMQ8kphOXj5avdc=; b=f57C2ja6mF9M0WXZ2N9zbCi+AA1khfEn2mBRcjJ5AgFgAMDsKJQorObz7oQ7miH117 DFNXSu9Bg7wh3oyJhRMpnLGmnOgXbyL5O+NgaY/Vvy8aOoO9H5JPhEYZgGL7StrqQTsV 3LqS5RaoZYJtCeu50omp75l4yktd6krCrz24bsmMp16viA/7MWm3CwUoSbCqWUpPrQRH PRV5mHatu877p/1F5mAZcfpRrwVQnGzhW7+pdKt1oP2fnW2F8bH3XbAldDvmoX1ZVXNt KQTqpedBv1T8VdEjjYNzrt2toWAf80p/MW4k4Iox8znbememtHL9Vl411a3E60PmvcSb XJnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CAztRwtv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u14si2583940pgf.517.2022.02.24.07.18.28; Thu, 24 Feb 2022 07:18:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CAztRwtv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234059AbiBXLSx (ORCPT + 99 others); Thu, 24 Feb 2022 06:18:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234010AbiBXLSH (ORCPT ); Thu, 24 Feb 2022 06:18:07 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A94215A23A for ; Thu, 24 Feb 2022 03:17:37 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id d3so2469437wrf.1 for ; Thu, 24 Feb 2022 03:17:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WNHsk/5D9xGPuJd373nmHea73ZrQBMQ8kphOXj5avdc=; b=CAztRwtvkUV4S/jm0VRCSY3/l6SYaa3FYziJw4jCHUV/3ExCknj5i6ayCefxIAqzSC kG9WgCMWy8FVch3L0V0n8ICxsoWJKfSN/f6Tu7foDLn5FXExsAJl50LfxsAvcTSXXbul x+1GXhyHoGAq7sYB/kMdZmjIS7n3QxTO3VmTPhn3M/ZR2+ViLKT3DIKeR9IeQDRzA10B 3ND4iaYG0x3kBKKCdzYTBtJHrKyEVHZ+atcNHEJFUxltIeS7pC+k49o1yxkbloVz/hyC qUIaYKNy337fHJ6H8rFOotqmXV6nweemfI6jbDAX2GbNvq57z3sxydYi+FOHY8u073zd C6nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WNHsk/5D9xGPuJd373nmHea73ZrQBMQ8kphOXj5avdc=; b=nU/dCqKfAdOAL8iIiZCRDAipHBNwKQ1xrsITjSgvxx/LCVjeNqg8mQh7lkivlAuNF5 VXQWK8v5jskLUtYbf9h3Yn16lBQLK2XoT3f5Y3ay8FFqtCkF3KAPYCwcAVsuOGA1YIay 49P0fpkVAB7Yh7Sps2gcr9hEHBlzYdX0lpfBOVaZysd8ao1DpN6q9GfZWpKiJcKbG1SZ gnvZV4DKrw7D2iPge0RpBYUai/V6xEDwo+HwHq8gs8CluGg1WI/yjm0UJ75em5MWXc2O r0ggQTvfENH1YFjU+bPkNfR5lBzD785vC7JflHzNF8AghAlcfjvg1X1tHqPtMQ71tZXZ iV7A== X-Gm-Message-State: AOAM530CZ5Daj7ZgUqFHjrHhY8PiyvmmZTlKo8/s718cN4iIuzeTDFuJ qayOYCRk3q3KlFIT+qA65zkyXw== X-Received: by 2002:a5d:6c68:0:b0:1e8:9827:b978 with SMTP id r8-20020a5d6c68000000b001e89827b978mr1716361wrz.633.1645701455898; Thu, 24 Feb 2022 03:17:35 -0800 (PST) Received: from srini-hackbox.lan (cpc90716-aztw32-2-0-cust825.18-1.cable.virginm.net. [86.26.103.58]) by smtp.gmail.com with ESMTPSA id t4sm2245737wmj.10.2022.02.24.03.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:35 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Cc: lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, quic_srivasam@quicinc.com, Srinivas Kandagatla Subject: [PATCH v2 12/16] ASoC: codecs: rx-macro: add runtime pm support Date: Thu, 24 Feb 2022 11:17:14 +0000 Message-Id: <20220224111718.6264-13-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220224111718.6264-1-srinivas.kandagatla@linaro.org> References: <20220224111718.6264-1-srinivas.kandagatla@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-rx-macro.c | 62 +++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index a2f49a21678b..67bec5befc02 100644 --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -3605,6 +3606,13 @@ static int rx_macro_probe(struct platform_device *pdev) if (ret) goto err_clkout; + + pm_runtime_set_autosuspend_delay(dev, 3000); + pm_runtime_use_autosuspend(dev); + pm_runtime_mark_last_busy(dev); + pm_runtime_set_active(dev); + pm_runtime_enable(dev); + return 0; err_clkout: @@ -3641,11 +3649,65 @@ static const struct of_device_id rx_macro_dt_match[] = { }; MODULE_DEVICE_TABLE(of, rx_macro_dt_match); +static int __maybe_unused rx_macro_runtime_suspend(struct device *dev) +{ + struct rx_macro *rx = dev_get_drvdata(dev); + + regcache_cache_only(rx->regmap, true); + regcache_mark_dirty(rx->regmap); + + clk_disable_unprepare(rx->mclk); + clk_disable_unprepare(rx->npl); + clk_disable_unprepare(rx->fsgen); + + return 0; +} + +static int __maybe_unused rx_macro_runtime_resume(struct device *dev) +{ + struct rx_macro *rx = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(rx->mclk); + if (ret) { + dev_err(dev, "unable to prepare mclk\n"); + return ret; + } + + ret = clk_prepare_enable(rx->npl); + if (ret) { + dev_err(dev, "unable to prepare mclkx2\n"); + goto err_npl; + } + + ret = clk_prepare_enable(rx->fsgen); + if (ret) { + dev_err(dev, "unable to prepare fsgen\n"); + goto err_fsgen; + } + regcache_cache_only(rx->regmap, false); + regcache_sync(rx->regmap); + rx->reset_swr = true; + + return 0; +err_fsgen: + clk_disable_unprepare(rx->npl); +err_npl: + clk_disable_unprepare(rx->mclk); + + return ret; +} + +static const struct dev_pm_ops rx_macro_pm_ops = { + SET_RUNTIME_PM_OPS(rx_macro_runtime_suspend, rx_macro_runtime_resume, NULL) +}; + static struct platform_driver rx_macro_driver = { .driver = { .name = "rx_macro", .of_match_table = rx_macro_dt_match, .suppress_bind_attrs = true, + .pm = &rx_macro_pm_ops, }, .probe = rx_macro_probe, .remove = rx_macro_remove, -- 2.21.0