Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4423361pxb; Mon, 21 Feb 2022 21:08:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxkFcV9izuo5TvO/IDwuo+kbvtTlxA2ZcyKmdi85ZOvfCY/0MhH3VgAKh/MVVVDX6yp5v4u X-Received: by 2002:a63:da0d:0:b0:364:b771:ff4 with SMTP id c13-20020a63da0d000000b00364b7710ff4mr18742369pgh.514.1645506538904; Mon, 21 Feb 2022 21:08:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645506538; cv=none; d=google.com; s=arc-20160816; b=ugaKJQu9cBVKvxxSuCpQkLPNHkTWMwN+6kSK6gd5jWr9f3k9LcNGI6zQu9gw2pw5fa ndKFFN5k6fnIM+UoU6cxLhJ2WG1jZj2hbGbMCQ8p8CVNdb9PWjDHzcaQ6St2D+ZDOLNv IC1au/sw3yIU9dVt7GIbm+93dVxcntuMv1s9WDJzOEjLlGQa1EFb38blW6ov6OeLRoEU /HaQs1uT6jYkukDIlm7YZcNdbfArLLUVlIe1bSPBo1Ds52wU7ZkRkkSXzSPKmw0rhmlB Nl+jlTMIQ+7h2YpjJJ4BgRGZQ4V1ttfy5iKKVoGlVvYyanYKqkrSlUkUOFR22rzyQbR5 P76A== 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=RewL+3EtNxhC0ou/pYILBVrh1qSfkoLM81IegMwgi94=; b=kpfUh1OaRpQWZocCFdC8wK+VL+XStDd7VcmBUsQOxsrvsG3bzYAxPUWsPNbDej3MWc ZvB3C641UIT8NdPYbTpp7DtQiQdg4KfRcKKP1nCRN7srnFW1CJfm0dS6fmcuHeiVngz3 UQu+jqMocUFPOML5K8i019kd+qRVuKTBec3k6NcSBKp24P834VPaXVkpqxh603GR7anQ WL9Pm2rwwoqpuNNuIXeCK5Mv8XLRUIBI8TRoUSi1VVEKBkTNYqdqphIrKJEAdl8BU+o+ eB+EVaKqm9eF4dUEKF4tWJC5i/FvuNftKw33kNGmurYtMtBeiQjVe597ez/R3gLuhuHm CrFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CnZFhCDb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e5si6920348plx.598.2022.02.21.21.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 21:08:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CnZFhCDb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 205CDA6450; Mon, 21 Feb 2022 20:42:01 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358665AbiBUNLX (ORCPT + 99 others); Mon, 21 Feb 2022 08:11:23 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358658AbiBUNLJ (ORCPT ); Mon, 21 Feb 2022 08:11:09 -0500 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 812891EC6F for ; Mon, 21 Feb 2022 05:10:45 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id p14-20020a05600c1d8e00b0037f881182a8so1339306wms.2 for ; Mon, 21 Feb 2022 05:10:45 -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=RewL+3EtNxhC0ou/pYILBVrh1qSfkoLM81IegMwgi94=; b=CnZFhCDbVNq8YUQgIUgkcn7+ZwM1cLOb2I1C7hnWQq/B7122caLSKIX1vYxPKwTVI9 tAGaU4oDRPjyZ5ZfScYain86omjfyxk0tYYwx6JxRIt+CdACoJXVIXIPObS9i7LdM43t 4GVsw7WZNQNwNYXzapJaFtgt+WwQalTTvOTIlhFjCnjRv41VHKLkHX1TPY9HEG45IV70 mKYifBTkAZZ9sCLKrnFXOhxTWnpniQc24Y6feTJb+2AHWQGbP0ex/lQX34OYpwqD1WMH 85SzasVkc/Vn44HV+j4UA83UZvQUXKkVXychSJEhW77gfKkWmlWhNOxUhvsYm/HZRcRL Du9w== 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=RewL+3EtNxhC0ou/pYILBVrh1qSfkoLM81IegMwgi94=; b=y4N+3VV8tI7c5R7wnc90moN1Z5FZGRCxGC3WXNshh2ZM0prXM6C2jwvyou/NPd2ewU UvlxzDt96600W70IyCNkcjWEvvgoKwuoNFTzks3grmHKLrUruejmKNIL4Iary9Bt3rnM 8U6AvcOZKVMbgthbdk5xr0tsfYhDD3xYM7UxRo7CQvf7lM6s/URJRTEi9Vd9/Y9JvQei zf3yz4V3gGDx8eSTqOwHsoJ6SsJOh2+PyLK4a4w6S9ny4NtY/peuvSIMN4pj47EW8kbr AqQfZzE7G227XECLiGE9Sr+Xea7GcFEcNvhoRIOgHN6GVMDdpbYc14r69cgCREMIWT7/ 7ZsA== X-Gm-Message-State: AOAM533ogPP7DkofErdKsaqx6Vj2lAebVoEJhbcAosx0hYZcM0EhC9NK CXRckTyDEwWjBE8QhcEO+RsKnQ== X-Received: by 2002:a05:600c:410d:b0:37b:b8f2:a1b1 with SMTP id j13-20020a05600c410d00b0037bb8f2a1b1mr16948525wmi.123.1645449044140; Mon, 21 Feb 2022 05:10:44 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 05:10:43 -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 03/10] ASoC: codecs: rx-macro: add runtime pm support Date: Mon, 21 Feb 2022 13:10:30 +0000 Message-Id: <20220221131037.8809-4-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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 | 45 ++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index 0ed032b220a4..fb5d4bb8bd8b 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 @@ -3568,8 +3569,17 @@ static int rx_macro_probe(struct platform_device *pdev) rx_macro_dai, ARRAY_SIZE(rx_macro_dai)); if (ret) - clk_bulk_disable_unprepare(RX_NUM_CLKS_MAX, rx->clks); + 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(RX_NUM_CLKS_MAX, rx->clks); return ret; } @@ -3589,11 +3599,44 @@ 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->clks[2].clk); + clk_disable_unprepare(rx->clks[3].clk); + clk_disable_unprepare(rx->clks[4].clk); + + return 0; +} + +static int __maybe_unused rx_macro_runtime_resume(struct device *dev) +{ + struct rx_macro *rx = dev_get_drvdata(dev); + + clk_prepare_enable(rx->clks[2].clk); + clk_prepare_enable(rx->clks[3].clk); + clk_prepare_enable(rx->clks[4].clk); + regcache_cache_only(rx->regmap, false); + regcache_sync(rx->regmap); + rx->reset_swr = true; + + return 0; +} + +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