Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4061986pxb; Mon, 21 Feb 2022 11:14:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyDTD6oDr8tPS+MVI9vfjuLXeLNMgL+vo3a8BLaDGotkLYOVBDPe22EBI81+nCi/l/qqV1L X-Received: by 2002:a50:d6c7:0:b0:403:c81e:5971 with SMTP id l7-20020a50d6c7000000b00403c81e5971mr22690486edj.244.1645470880227; Mon, 21 Feb 2022 11:14:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645470880; cv=none; d=google.com; s=arc-20160816; b=Cgw8iz4D0M0PrHLCyViFEP589hwkN2kYr0moMHlm6WURSGMvNBmpBjMOwfrKIwfRyA nQiHZkHG06Rq9qfaqENXr1JKcSFGliqwDGDhVNEArVAurO5IrZ7pJDqsLrKvPc6FHoR/ qqQcZGGfbr+MLiUfKNcaSC7aHuSYGAKKhoOa8eDOhfLhC1fWv78JwY9knKOqPEeCUyj4 W1RHM5wZhmdrVUciMJC68+3bOaqQFfd8Vm2SD1QSIYUahVyjWxzsJM6FhSAAwZFMAVRW 3VUfSUXPg931iMi/geYainkZT52x/ok2nLFt8RLQiCDBvlAfl75hYuOIJ1sBKjKY0K1W Ymag== 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=u/873brHhZR6xm18sDiZdhD33uqz5ep38GtGCx69qMY=; b=sFO3WMMfAndDNHOAw94FBMd/JImWYbrX0KsT1t72zg9aLWg47EEzSistttPVg5jA7K gaB1Ro12pcaY6kprrq5HsGC9qqBn9oyNP4tRghnBjgdFb3I0rPNaNuzQLQirRf6YfwmC eWr7c5QDZPJQGzjeRSTsuSuQCWatUQ5DN/5Nu4836lbwtrMe6kTFXyot45HVWrfertyW TIW5RGuxqdJX8xZulJdiPMJxL6tGen+aZxNmdyhhJlwF36UuiEDjBm7Ah8wZbG9Ok7U4 8kEeHr+y7lzpfTUEfSYmu4Lu+gG7JZAd+lu6fCS+9KL0crYnvkl3GqtX9NSHUAppSffC nVBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="WWR2i/oD"; 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 u2si11053946edx.242.2022.02.21.11.14.17; Mon, 21 Feb 2022 11:14:40 -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="WWR2i/oD"; 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 S1358656AbiBUNLb (ORCPT + 99 others); Mon, 21 Feb 2022 08:11:31 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358654AbiBUNLK (ORCPT ); Mon, 21 Feb 2022 08:11:10 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C49FB1EC6B for ; Mon, 21 Feb 2022 05:10:46 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id az26-20020a05600c601a00b0037c078db59cso11159953wmb.4 for ; Mon, 21 Feb 2022 05:10:46 -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=u/873brHhZR6xm18sDiZdhD33uqz5ep38GtGCx69qMY=; b=WWR2i/oD1/ImYmqzvGm+tSJJ7MlYn6oWxndq5vCHMn2AFVVnhZ/RRBzCsMw6c831ag +5JoERRNMn0iyyrGiJxWZv6FFkwWZRl9yv32YVwUpqYgbh28p7CYJV7h+9P867hF010F r9gP6OdjsJuWvEZ6BIxpy84WwiSP8clBu/odr+AgHbHNqlRYq3YZ8pTwaJtxSqY3HmGy NG7tReTFSjSfIeBzXa7yaIxwjoZcEaaPtpo7mXeyubfh/lBjeNlLp5Z1qTozN0i9ub0R dq0L6M1nwXV5wBuMnUEb9/zMUQdVainoXaQ9FZp2P6Py7yg7TWFfqdRqZ0S0EVI5kF2W 6IQQ== 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=u/873brHhZR6xm18sDiZdhD33uqz5ep38GtGCx69qMY=; b=urSMzteMXd+kP9qH+Z7Y8+ojlO6A68JK2yFpuULkio+M2mdzL7j1bC+402bQU6A0o0 bIrkF5dR1vKhCtq24AlyCeFBnpZnBCHuPNH5Y8TTWHhGl+r1BwpOqISSpF+sGVmKbG5F 11J+eCzCKmCWN0hpqR6uJE1RYfXpa0C3jjd/fNXl1tPkQsZmmOoGbOPP/BkR5M5pyQI/ S74HuxgDCsH5i/UqlghGjmE5fHjjTuLnFLG4UXvhBfLLBYFkGg7/0k7f2duQ9Rlen+XD StTSiUrDKQi8Us7jh9GLIXWat3qcyKSu7Lva1njY3wBG2i1+EtPBkzT2Vo3J1W4oyfSH O+Ew== X-Gm-Message-State: AOAM532xsADHvSjpwIod6ESWQ2dz8FgKQ0pLgPGpmOd8hRC6Q4f9Funj 3TKNzLRtf2QxGqy3ysBPvmZNQg== X-Received: by 2002:a05:600c:384a:b0:37b:e8ac:851f with SMTP id s10-20020a05600c384a00b0037be8ac851fmr9358623wmr.158.1645449045225; Mon, 21 Feb 2022 05:10:45 -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 3sm49412801wrz.86.2022.02.21.05.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 05:10:44 -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 04/10] ASoC: codecs: tx-macro: add runtime pm support Date: Mon, 21 Feb 2022 13:10:31 +0000 Message-Id: <20220221131037.8809-5-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20220221131037.8809-1-srinivas.kandagatla@linaro.org> References: <20220221131037.8809-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-tx-macro.c | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c index 7347d79a6329..1c0f0d27ed42 100644 --- a/sound/soc/codecs/lpass-tx-macro.c +++ b/sound/soc/codecs/lpass-tx-macro.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -1844,6 +1845,13 @@ static int tx_macro_probe(struct platform_device *pdev) ARRAY_SIZE(tx_macro_dai)); if (ret) goto err; + + 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 ret; err: clk_bulk_disable_unprepare(TX_NUM_CLKS_MAX, tx->clks); @@ -1862,6 +1870,38 @@ static int tx_macro_remove(struct platform_device *pdev) return 0; } +static int __maybe_unused tx_macro_runtime_suspend(struct device *dev) +{ + struct tx_macro *tx = dev_get_drvdata(dev); + + regcache_cache_only(tx->regmap, true); + regcache_mark_dirty(tx->regmap); + + clk_disable_unprepare(tx->clks[2].clk); + clk_disable_unprepare(tx->clks[3].clk); + clk_disable_unprepare(tx->clks[4].clk); + + return 0; +} + +static int __maybe_unused tx_macro_runtime_resume(struct device *dev) +{ + struct tx_macro *tx = dev_get_drvdata(dev); + + clk_prepare_enable(tx->clks[2].clk); + clk_prepare_enable(tx->clks[3].clk); + clk_prepare_enable(tx->clks[4].clk); + regcache_cache_only(tx->regmap, false); + regcache_sync(tx->regmap); + tx->reset_swr = true; + + return 0; +} + +static const struct dev_pm_ops tx_macro_pm_ops = { + SET_RUNTIME_PM_OPS(tx_macro_runtime_suspend, tx_macro_runtime_resume, NULL) +}; + static const struct of_device_id tx_macro_dt_match[] = { { .compatible = "qcom,sc7280-lpass-tx-macro" }, { .compatible = "qcom,sm8250-lpass-tx-macro" }, @@ -1873,6 +1913,7 @@ static struct platform_driver tx_macro_driver = { .name = "tx_macro", .of_match_table = tx_macro_dt_match, .suppress_bind_attrs = true, + .pm = &tx_macro_pm_ops, }, .probe = tx_macro_probe, .remove = tx_macro_remove, -- 2.21.0