From patchwork Thu Feb 24 11:17:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12758395 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 EEC55C433EF for ; Thu, 24 Feb 2022 11:18:53 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2132D17F5; Thu, 24 Feb 2022 12:18:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2132D17F5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645701532; bh=weJYzImlb8PYqxKjpCG0T3WpHF3vng06j6VcZzOxVc8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=lu2ruC/zLk6T19++4iQ6h6PuOh0BPh1zo9gdJ0DrhGzZ4UsJ3RxiMxpFJljlayh/j maGBWM8hKdw1URWum4eWpy0Th9zHBvbAJxJNoEMSyQy2JD7v+OWJi6YdvxKvJ0uwgj ICFJQoZ9uqmW6s7nvbZltKvy+Z/PdA4Ys1orcKHg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C4DFAF80169; Thu, 24 Feb 2022 12:17:32 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id F06C6F800B6; Thu, 24 Feb 2022 12:17:30 +0100 (CET) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C29ECF800F3 for ; Thu, 24 Feb 2022 12:17:24 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C29ECF800F3 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="himXMgwq" Received: by mail-wr1-x42e.google.com with SMTP id b5so1474928wrr.2 for ; Thu, 24 Feb 2022 03:17:24 -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=ceUQI8pUhjwWr7cwe8PfSIpA4DyG+G2Rz7beXile+P0=; b=himXMgwqxUWpRMrFbC97dlxMwb1qkLSvrgWmiX0R+wVTPDdmvC0ZMKzn5lLCPKOeXL fjcncNVLW9vUQpZy24Zu8rY2s0sc+Qt8JhEF9bMaMJV9rdVk9ha0qZOaL4v84ItkAg1m PBUjNz51VnrHBZpvsf0ZsT60sZeEyP/XG9woWpL9zXF+tARotwNUZKL+LcKUbTO0E6Hr vv/D0XM4U7yvkJ7+GkIvoYepaSPKvR5jFVZxDd8Fp4NhPn9mgOB/dLf6S6w2fpkMv0WZ 2efScThgcgILM861QEvBNEFjGXUo37ZknHn/CbTHNs1KT1fyKGuFVrgoR5LHN58tFZbQ fq+A== 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=ceUQI8pUhjwWr7cwe8PfSIpA4DyG+G2Rz7beXile+P0=; b=nfaftfDuAJlic/xXHd5ymu1kpxg92F+vqAxtkCkjlr9G5/2w7v4dWp0rPOia+KwHpc XFE7XkoR7zhph+KA/bzwmCGaWpm2X7ofrvVoVQdAzDIKg9vsmyr8BgwJld8wny3RF2H3 eDgpUVMA9vi3ssyQVjkAAOqBJwAtObWVXzvsgPjnL+krdgS5jy8XSBmw2iZlOWm7prdg 9eozr5FoXZolNPePu5mkh9+a73i0aHz07UYr6jNAXPBOKG2FYR3PzCFaeyDz31xiqYQi ViqSCzo3dRu0ohbJJekvRfZmeYniED89w4OwnK0WCze0rpWslMqX9ZEYtNJMegicO4M0 BIOw== X-Gm-Message-State: AOAM532HRSF7n1wJB8awqV/zR3MZpVlum7uvmXrK4hD8L1OiEJvazOH/ 8QJ7dK8usUnnkI5tzBGief+yjA== X-Google-Smtp-Source: ABdhPJyF9hlhdYn3QgLA1hMGpxlSnPQtvk5TT0UYfuCo7gdjJ6fCLnBsBQreeycYv1PvBEnz4lzOTg== X-Received: by 2002:a5d:6108:0:b0:1e3:3a73:d34a with SMTP id v8-20020a5d6108000000b001e33a73d34amr1819381wrt.290.1645701443219; Thu, 24 Feb 2022 03:17:23 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:22 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 01/16] ASoC: codecs: va-macro: move to individual clks from bulk Date: Thu, 24 Feb 2022 11:17:03 +0000 Message-Id: <20220224111718.6264-2-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 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Using bulk clocks and referencing them individually using array index is not great for readers. So move them to individual clocks handling and also remove some unnecessary error handling in the code. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-va-macro.c | 65 ++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 22 deletions(-) diff --git a/sound/soc/codecs/lpass-va-macro.c b/sound/soc/codecs/lpass-va-macro.c index e14c277e6a8b..ff8120886eca 100644 --- a/sound/soc/codecs/lpass-va-macro.c +++ b/sound/soc/codecs/lpass-va-macro.c @@ -193,7 +193,9 @@ struct va_macro { int dec_mode[VA_MACRO_NUM_DECIMATORS]; struct regmap *regmap; - struct clk_bulk_data clks[VA_NUM_CLKS_MAX]; + struct clk *mclk; + struct clk *macro; + struct clk *dcodec; struct clk_hw hw; s32 dmic_0_1_clk_cnt; @@ -1321,7 +1323,7 @@ static const struct clk_ops fsgen_gate_ops = { static int va_macro_register_fsgen_output(struct va_macro *va) { - struct clk *parent = va->clks[2].clk; + struct clk *parent = va->mclk; struct device *dev = va->dev; struct device_node *np = dev->of_node; const char *parent_clk_name; @@ -1404,15 +1406,18 @@ static int va_macro_probe(struct platform_device *pdev) return -ENOMEM; va->dev = dev; - va->clks[0].id = "macro"; - va->clks[1].id = "dcodec"; - va->clks[2].id = "mclk"; - ret = devm_clk_bulk_get_optional(dev, VA_NUM_CLKS_MAX, va->clks); - if (ret) { - dev_err(dev, "Error getting VA Clocks (%d)\n", ret); - return ret; - } + va->macro = devm_clk_get_optional(dev, "macro"); + if (IS_ERR(va->macro)) + return PTR_ERR(va->macro); + + va->dcodec = devm_clk_get_optional(dev, "dcodec"); + if (IS_ERR(va->dcodec)) + return PTR_ERR(va->dcodec); + + va->mclk = devm_clk_get(dev, "mclk"); + if (IS_ERR(va->mclk)) + return PTR_ERR(va->mclk); ret = of_property_read_u32(dev->of_node, "qcom,dmic-sample-rate", &sample_rate); @@ -1425,12 +1430,6 @@ static int va_macro_probe(struct platform_device *pdev) return -EINVAL; } - /* mclk rate */ - clk_set_rate(va->clks[1].clk, VA_MACRO_MCLK_FREQ); - ret = clk_bulk_prepare_enable(VA_NUM_CLKS_MAX, va->clks); - if (ret) - return ret; - base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(base)) { ret = PTR_ERR(base); @@ -1444,21 +1443,41 @@ static int va_macro_probe(struct platform_device *pdev) } dev_set_drvdata(dev, va); - ret = va_macro_register_fsgen_output(va); + + /* mclk rate */ + clk_set_rate(va->mclk, 2 * VA_MACRO_MCLK_FREQ); + + ret = clk_prepare_enable(va->macro); if (ret) goto err; + ret = clk_prepare_enable(va->dcodec); + if (ret) + goto err_dcodec; + + ret = clk_prepare_enable(va->mclk); + if (ret) + goto err_mclk; + + ret = va_macro_register_fsgen_output(va); + if (ret) + goto err_clkout; + ret = devm_snd_soc_register_component(dev, &va_macro_component_drv, va_macro_dais, ARRAY_SIZE(va_macro_dais)); if (ret) - goto err; + goto err_clkout; - return ret; + return 0; +err_clkout: + clk_disable_unprepare(va->mclk); +err_mclk: + clk_disable_unprepare(va->dcodec); +err_dcodec: + clk_disable_unprepare(va->macro); err: - clk_bulk_disable_unprepare(VA_NUM_CLKS_MAX, va->clks); - return ret; } @@ -1466,7 +1485,9 @@ static int va_macro_remove(struct platform_device *pdev) { struct va_macro *va = dev_get_drvdata(&pdev->dev); - clk_bulk_disable_unprepare(VA_NUM_CLKS_MAX, va->clks); + clk_disable_unprepare(va->mclk); + clk_disable_unprepare(va->dcodec); + clk_disable_unprepare(va->macro); return 0; } From patchwork Thu Feb 24 11:17:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12758396 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 913BCC433EF for ; Thu, 24 Feb 2022 11:19:11 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id DD44B1817; Thu, 24 Feb 2022 12:18:19 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DD44B1817 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645701549; bh=lYCnQREJ99nbwCOUeyO+ubN3tvGOgqRHABHChgQ9SU4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OZs/3HOrCwDkeuGEGzgq/NCFVwM4UL8DWHhdaBN6tyiptnqopmGMFUrLus7lJCL/r q2bRWmkzNcL4X3tYmRTdB/uwPd63aQTvpFbV/guvIrWpVZJsoPLw+TowBXWWG8u+5C ynyQ4CdqpyvtYCw17ZHgj0TiJqaCSje+8h+AfRd0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 0961DF80517; Thu, 24 Feb 2022 12:17:35 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C4C94F80508; Thu, 24 Feb 2022 12:17:31 +0100 (CET) Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 885ACF8030F for ; Thu, 24 Feb 2022 12:17:25 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 885ACF8030F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="RR/+PwJj" Received: by mail-wr1-x429.google.com with SMTP id s1so2421279wrg.10 for ; Thu, 24 Feb 2022 03:17:25 -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=qWsSPZ5U3+bqYjJaCO6OED1zl8vj8mnYeogeLtvqmRM=; b=RR/+PwJjsVqGDzeC9JrdPksN+ltMOCoIRXBnYkZ9bXG40+tZNmGkF8zQk1c80L7mEE 4IVPjgxbvK6jPj+hGYZg4rRf40Y2c7roBRh2AOgxHm8+Z6lLyI9ClogLiaTtKJSUvQ4h /CKjYlUJI22yX0Aeq38Umd4d0WzYEc7fHphBinSK9huuwoilOu08Ko2SrndDmVjGhyjn qN2egLYVdGXsceETkTO0QckDYHwQMw8sCJ0c9J1lEluRULmAl9Ljqaq9lK+NY9XYaCMc 4kYi7T7l9xwQq20yv3t15WBlvhHNl9BCSCuFNir60cXYbysXkC/QCHfK7PYiezt1Qa8T BCSg== 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=qWsSPZ5U3+bqYjJaCO6OED1zl8vj8mnYeogeLtvqmRM=; b=40OX3jXs/mVsgusIPI9ZCkSoybV44zgMQl0dyQlZZGltv8+G3QHsPpuHvcKUm2unjQ YJzT/K72FrcPadbrY6t5Vn1yZHQEWwfrYlmj+3TKxebW8WhZOOFU9Xz7q1UL4Op2Dtup iSdo6LhZoTy+uxv9EKaDnfK21sulsT8gTtU9FJzK6uP8tWUmmkbgDaaE7Qc/iLhBQFyF rXAxD6QqyARvtLP6yn8WkEE9gSUa11HN/6O1sPdMZpKDhVah2HxBeREOeV7qonzARKY4 n6Yfv5e9cLVYsG40E7MuLs//YBj4fJc0o+pcSqn9cbN73/SI+/i9OrhK7Xq+iNvMENdA RjDA== X-Gm-Message-State: AOAM5329hkweavMtxNCx+NO/l+1BX2Fh/5yGNblazqTHNgZnJg8DCQPx Wgnf+B1URLYFrrK/Ekz//ZgkMw== X-Google-Smtp-Source: ABdhPJzIi7dV/bk4DmzD358ma3NticqhA9MhGRi1I3omiaBHEtqLdbOEJWsPweglGrtEdoDdDbMkHQ== X-Received: by 2002:adf:fb06:0:b0:1e6:8b27:f1ea with SMTP id c6-20020adffb06000000b001e68b27f1eamr1802817wrr.353.1645701444328; Thu, 24 Feb 2022 03:17:24 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:23 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 02/16] ASoC: codecs: rx-macro: move clk provider to managed variants Date: Thu, 24 Feb 2022 11:17:04 +0000 Message-Id: <20220224111718.6264-3-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 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" move clk provider registration to managed api variants, this should help with some code tidyup. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-rx-macro.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index 3a3dc0539d92..6c61b4d35df9 100644 --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c @@ -3479,10 +3479,9 @@ static const struct clk_ops swclk_gate_ops = { }; -static struct clk *rx_macro_register_mclk_output(struct rx_macro *rx) +static int rx_macro_register_mclk_output(struct rx_macro *rx) { struct device *dev = rx->dev; - struct device_node *np = dev->of_node; const char *parent_clk_name = NULL; const char *clk_name = "lpass-rx-mclk"; struct clk_hw *hw; @@ -3498,13 +3497,11 @@ static struct clk *rx_macro_register_mclk_output(struct rx_macro *rx) init.num_parents = 1; rx->hw.init = &init; hw = &rx->hw; - ret = clk_hw_register(rx->dev, hw); + ret = devm_clk_hw_register(rx->dev, hw); if (ret) - return ERR_PTR(ret); - - of_clk_add_provider(np, of_clk_src_simple_get, hw->clk); + return ret; - return NULL; + return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw); } static const struct snd_soc_component_driver rx_macro_component_drv = { @@ -3562,22 +3559,26 @@ static int rx_macro_probe(struct platform_device *pdev) if (ret) return ret; - rx_macro_register_mclk_output(rx); + ret = rx_macro_register_mclk_output(rx); + if (ret) + goto err; ret = devm_snd_soc_register_component(dev, &rx_macro_component_drv, rx_macro_dai, ARRAY_SIZE(rx_macro_dai)); if (ret) - clk_bulk_disable_unprepare(RX_NUM_CLKS_MAX, rx->clks); + goto err; return ret; +err: + clk_bulk_disable_unprepare(RX_NUM_CLKS_MAX, rx->clks); + return ret; } static int rx_macro_remove(struct platform_device *pdev) { struct rx_macro *rx = dev_get_drvdata(&pdev->dev); - of_clk_del_provider(pdev->dev.of_node); clk_bulk_disable_unprepare(RX_NUM_CLKS_MAX, rx->clks); return 0; } From patchwork Thu Feb 24 11:17:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12758397 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 063B4C433EF for ; Thu, 24 Feb 2022 11:19:27 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 49B5B17EF; Thu, 24 Feb 2022 12:18:35 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 49B5B17EF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645701565; bh=EK9A666tCNq+7r/BQqRKvEyWeuGXzX3zoRdxigVPKVo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Kvk2skDLYisvKlDg6nCVYdPC+4ejFl3VeqSC0ogvF50O2LDmDVQs7RtGQX34uy2I/ QfFLFFBLi85OePUaSaZhwtLFLoLy9FMiCu5CadIyJJbWOnBwzv80F+nRciTUoRu6ZA HlskmV+CVKQZEEhUS+NFEPhMEHgLtuHxZZOxnEEE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9ADEDF8051B; Thu, 24 Feb 2022 12:17:35 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4AE81F80508; Thu, 24 Feb 2022 12:17:32 +0100 (CET) Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2DC2DF80169 for ; Thu, 24 Feb 2022 12:17:26 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2DC2DF80169 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="n1L4xpTz" Received: by mail-wr1-x429.google.com with SMTP id d3so2468603wrf.1 for ; Thu, 24 Feb 2022 03:17:25 -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=4BM5CJMOAHhPAmpP71sdzK8wbdwXXqGTSZfCgqYugXg=; b=n1L4xpTzRA0q8gh+4j2RqBvCcWy1klX3V/ib8KM0vfbFhkOWyjB9pXS/5oJpm51rQq INweqZjGSUBpP2Q1odh3RRNLafB1nUBSoMAgIjXGZkk55Pq4UTgXrfWA2YzovmoOCOTi FG/Egy5crEl/WFOcsapHiZrZhmlqhLH14+lhYXF/DNJ7pVCLkhab+1+RjT7Y00RxHG2V cDj7qQxtE1bFZFM1uWCe9IRvQmZNUZtSUh8NyXTd7gJ0q+KsUL/3EScbhc1OJMJ0o9oU jCa4GrX4MpQ00hsslCcfVfbDwbnLHE79BPt3gu0JJpIMe8Le1/oroCffXzQemP+vGQ6c iX5w== 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=4BM5CJMOAHhPAmpP71sdzK8wbdwXXqGTSZfCgqYugXg=; b=zq1alQZzPIMkWFtFgKyGdMAR1UhiKo68zvCdIZryEU/uHfYj3MkUpjQxvgnzpjwG8n X8YqVdiuh1TV63m6NRzutWNoZCngLEZBcm3klga24XTi6d2yMn8OwkCbv7hGSEpiELAO LatJXW89pFffFkYUqX9J1kETog6BEctahaswF8Rfo6ive09TeL1h8JcyDciSfoKGrNf5 ex+SXvRqHESIDTET8uDupWY7C5QRy0KJ8XDmXnqLJhnTmmhYZoDxDwX+wUevreIkzLQa VcLZHXa79BpqR5TbcHENwngquEe7OhiOuOFPlbfbK7wXfDGKu3yPcVerqmEKBZv6ykcD HpPw== X-Gm-Message-State: AOAM531kGwa2YZ5szDdu8iK5urYw8tWukXTcwoGVS+UDDGNsqcgh6HS4 WvWh+G9kCtt/Ung6Fp81oQ0y3g== X-Google-Smtp-Source: ABdhPJz1C94utP8QKj8W69ks5id0NikmOu8cCjYgpbdqcoMNOqv9qC5629Z+024K827DsNT10sjlyA== X-Received: by 2002:a05:6000:178a:b0:1ea:7db1:3159 with SMTP id e10-20020a056000178a00b001ea7db13159mr1819550wrg.9.1645701445430; Thu, 24 Feb 2022 03:17:25 -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.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:24 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 03/16] ASoC: codecs: tx-macro: move clk provider to managed variants Date: Thu, 24 Feb 2022 11:17:05 +0000 Message-Id: <20220224111718.6264-4-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 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" move clk provider registration to managed api variants, this should help with some code tidyup. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-tx-macro.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c index bd549b387862..75a5513bff16 100644 --- a/sound/soc/codecs/lpass-tx-macro.c +++ b/sound/soc/codecs/lpass-tx-macro.c @@ -1745,10 +1745,9 @@ static const struct clk_ops swclk_gate_ops = { }; -static struct clk *tx_macro_register_mclk_output(struct tx_macro *tx) +static int tx_macro_register_mclk_output(struct tx_macro *tx) { struct device *dev = tx->dev; - struct device_node *np = dev->of_node; const char *parent_clk_name = NULL; const char *clk_name = "lpass-tx-mclk"; struct clk_hw *hw; @@ -1764,13 +1763,11 @@ static struct clk *tx_macro_register_mclk_output(struct tx_macro *tx) init.num_parents = 1; tx->hw.init = &init; hw = &tx->hw; - ret = clk_hw_register(tx->dev, hw); + ret = devm_clk_hw_register(dev, hw); if (ret) - return ERR_PTR(ret); - - of_clk_add_provider(np, of_clk_src_simple_get, hw->clk); + return ret; - return NULL; + return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw); } static const struct snd_soc_component_driver tx_macro_component_drv = { @@ -1843,7 +1840,9 @@ static int tx_macro_probe(struct platform_device *pdev) if (ret) return ret; - tx_macro_register_mclk_output(tx); + ret = tx_macro_register_mclk_output(tx); + if (ret) + goto err; ret = devm_snd_soc_register_component(dev, &tx_macro_component_drv, tx_macro_dai, @@ -1861,8 +1860,6 @@ static int tx_macro_remove(struct platform_device *pdev) { struct tx_macro *tx = dev_get_drvdata(&pdev->dev); - of_clk_del_provider(pdev->dev.of_node); - clk_bulk_disable_unprepare(TX_NUM_CLKS_MAX, tx->clks); return 0; From patchwork Thu Feb 24 11:17:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12758402 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 1E48FC433EF for ; Thu, 24 Feb 2022 11:20:54 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4C0941866; Thu, 24 Feb 2022 12:20:02 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4C0941866 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645701652; bh=2RRtirZpeO3Ma6QoBWpYkUjAaB0QYFN2rYv5YSpi2Rg=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=qPSenKXyPE5Fb0GejmUNCGeIzZ7okFTll1pMTmlHj+3JOfOvkFhDrlYt1Xi0Uxo0H oc/+v89iMFTiKw/pSU0d56Cfrb/Vrlk70PBWNJT/uEzxH+BLsMySbzolmdqWRsf1xb P/FtLfykokiO/x+tVKHQFNH/Zli3PfJyltyzCMJ8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 4B2C4F80539; Thu, 24 Feb 2022 12:17:48 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B04AAF800F3; Thu, 24 Feb 2022 12:17:41 +0100 (CET) Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B5E1DF80430 for ; Thu, 24 Feb 2022 12:17:27 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B5E1DF80430 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="z6JE71CN" Received: by mail-wr1-x429.google.com with SMTP id s13so2447107wrb.6 for ; Thu, 24 Feb 2022 03:17:27 -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=5S4jXtQt9zJ/FIRoN63CnQsA0xt3UoiFNydOwJT7zD0=; b=z6JE71CNpxeyixCb5JaVsSk+O1A7pELVFqhrIgDySs+Jcfd0zkkOszUfV0rIukSnQP 7adLbDNkyvEXin/k9GziX1kzVZns79F42T6OCz6xsFQ9BqZequUOkrCfl1lhvxra+iKm 9qs9nDExoCTnc9/8FKhCYGm/tIevqh2zFyda3kE9JHnPmTrCivpYrHCcmv7uPaYtwVSU QOxVlpD4R8JGiZoC7FMMP+NDAIndxsBVRCsqQ3t1uBe5ibckSDmbDuqWSJS+ShTEHUsN aiByH/S+88QMkusp2rOo7BN0z3RPNnPIccwcGKG//jxbviWMCPIA+LpyVjUef/D+0KPV ZJ/A== 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=5S4jXtQt9zJ/FIRoN63CnQsA0xt3UoiFNydOwJT7zD0=; b=vF+zDUjlEILb5zA5YwU5Ef7b3fKiMrxsW6WnEjrtAi/6HNrcDEKEVWImtH7EOxflq+ X3Qofp0XxCYW9svqkCLT+/7Iy9uNRy8KyC4NkkuZjbyn1/BPSk0a5w3oklyol9+GClh9 ZrF4TAfgI3UZQ2ugxR4XKppkWHy+D8snHyesC/NXnuBGB5ZzGOEbp2H4nTTLEMPgNGIr 01ba9rjXs5nsXkp4G8jRir4kleoKDWSyjtQjvU+dqU9LEucq/fMooxukWSaKty7byLdM Qo9nDEnafRKCzGS+n0M0OoMLjfxcT9o9W+AuZGcUDOOCzmfmXEhFTMWqnsf9WIoZJD9r mDrg== X-Gm-Message-State: AOAM530Wcb6qEfv70EqKIFEqw2Fma44RvhXKT6LN2+zdHCGGA/FnyEYs ndTCy4cgalnhTh4gU3fmHov3Ag== X-Google-Smtp-Source: ABdhPJyaqVEQef4+d4t/15H05ZMObVdYcIsikILB5quawSWQpvCzVILcxu0ingwfWR6rQGI2Xm7WUA== X-Received: by 2002:a5d:44cf:0:b0:1ea:9cc3:504e with SMTP id z15-20020a5d44cf000000b001ea9cc3504emr1845612wrr.706.1645701446658; Thu, 24 Feb 2022 03:17:26 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:26 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 04/16] ASoC: codecs: rx-macro: move to individual clks from bulk Date: Thu, 24 Feb 2022 11:17:06 +0000 Message-Id: <20220224111718.6264-5-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 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Using bulk clocks and referencing them individually using array index is not great for readers. So move them to individual clocks handling and also remove some unnecessary error handling in the code. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-rx-macro.c | 85 +++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 21 deletions(-) diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index 6c61b4d35df9..83b570403c59 100644 --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c @@ -608,7 +608,11 @@ struct rx_macro { int softclip_clk_users; struct regmap *regmap; - struct clk_bulk_data clks[RX_NUM_CLKS_MAX]; + struct clk *mclk; + struct clk *npl; + struct clk *macro; + struct clk *dcodec; + struct clk *fsgen; struct clk_hw hw; }; #define to_rx_macro(_hw) container_of(_hw, struct rx_macro, hw) @@ -3488,7 +3492,7 @@ static int rx_macro_register_mclk_output(struct rx_macro *rx) struct clk_init_data init; int ret; - parent_clk_name = __clk_get_name(rx->clks[2].clk); + parent_clk_name = __clk_get_name(rx->mclk); init.name = clk_name; init.ops = &swclk_gate_ops; @@ -3526,17 +3530,25 @@ static int rx_macro_probe(struct platform_device *pdev) if (!rx) return -ENOMEM; - rx->clks[0].id = "macro"; - rx->clks[1].id = "dcodec"; - rx->clks[2].id = "mclk"; - rx->clks[3].id = "npl"; - rx->clks[4].id = "fsgen"; + rx->macro = devm_clk_get_optional(dev, "macro"); + if (IS_ERR(rx->macro)) + return PTR_ERR(rx->macro); - ret = devm_clk_bulk_get_optional(dev, RX_NUM_CLKS_MAX, rx->clks); - if (ret) { - dev_err(dev, "Error getting RX Clocks (%d)\n", ret); - return ret; - } + rx->dcodec = devm_clk_get_optional(dev, "dcodec"); + if (IS_ERR(rx->dcodec)) + return PTR_ERR(rx->dcodec); + + rx->mclk = devm_clk_get(dev, "mclk"); + if (IS_ERR(rx->mclk)) + return PTR_ERR(rx->mclk); + + rx->npl = devm_clk_get(dev, "npl"); + if (IS_ERR(rx->npl)) + return PTR_ERR(rx->npl); + + rx->fsgen = devm_clk_get(dev, "fsgen"); + if (IS_ERR(rx->fsgen)) + return PTR_ERR(rx->fsgen); base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(base)) @@ -3552,26 +3564,52 @@ static int rx_macro_probe(struct platform_device *pdev) rx->dev = dev; /* set MCLK and NPL rates */ - clk_set_rate(rx->clks[2].clk, MCLK_FREQ); - clk_set_rate(rx->clks[3].clk, 2 * MCLK_FREQ); + clk_set_rate(rx->mclk, MCLK_FREQ); + clk_set_rate(rx->npl, 2 * MCLK_FREQ); - ret = clk_bulk_prepare_enable(RX_NUM_CLKS_MAX, rx->clks); + ret = clk_prepare_enable(rx->macro); if (ret) - return ret; + goto err; + + ret = clk_prepare_enable(rx->dcodec); + if (ret) + goto err_dcodec; + + ret = clk_prepare_enable(rx->mclk); + if (ret) + goto err_mclk; + + ret = clk_prepare_enable(rx->npl); + if (ret) + goto err_npl; + + ret = clk_prepare_enable(rx->fsgen); + if (ret) + goto err_fsgen; ret = rx_macro_register_mclk_output(rx); if (ret) - goto err; + goto err_clkout; ret = devm_snd_soc_register_component(dev, &rx_macro_component_drv, rx_macro_dai, ARRAY_SIZE(rx_macro_dai)); if (ret) - goto err; + goto err_clkout; - return ret; + return 0; + +err_clkout: + clk_disable_unprepare(rx->fsgen); +err_fsgen: + clk_disable_unprepare(rx->npl); +err_npl: + clk_disable_unprepare(rx->mclk); +err_mclk: + clk_disable_unprepare(rx->dcodec); +err_dcodec: + clk_disable_unprepare(rx->macro); err: - clk_bulk_disable_unprepare(RX_NUM_CLKS_MAX, rx->clks); return ret; } @@ -3579,7 +3617,12 @@ static int rx_macro_remove(struct platform_device *pdev) { struct rx_macro *rx = dev_get_drvdata(&pdev->dev); - clk_bulk_disable_unprepare(RX_NUM_CLKS_MAX, rx->clks); + clk_disable_unprepare(rx->mclk); + clk_disable_unprepare(rx->npl); + clk_disable_unprepare(rx->fsgen); + clk_disable_unprepare(rx->macro); + clk_disable_unprepare(rx->dcodec); + return 0; } From patchwork Thu Feb 24 11:17:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12758400 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 094C3C433EF for ; Thu, 24 Feb 2022 11:20:19 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3C09D1888; Thu, 24 Feb 2022 12:19:27 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3C09D1888 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645701617; bh=rrMwlt9FMqzvUXc6GVf83UkPGRThkpjzexTxONFVVuE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=E+iIXXj/HK8WwOVCIv89EheDLohnXOZX6fS1zj74DvmN3P4X/p7xbB9jUaFINtnaE J/j04+F9a/v+3Ero8nlsgZGvAueNmzJqJoGD41FAIAGFgfzDmRqTtQy5dX7KUq3V3T p7ef1YiCBblwXQ+v8LytAkixgTV0IMaEhsSCNWU4= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id ABD08F80524; Thu, 24 Feb 2022 12:17:45 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7E1B5F80539; Thu, 24 Feb 2022 12:17:41 +0100 (CET) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 8C85FF800F3 for ; Thu, 24 Feb 2022 12:17:28 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8C85FF800F3 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="mWWsTocp" Received: by mail-wr1-x42a.google.com with SMTP id n14so2074661wrq.7 for ; Thu, 24 Feb 2022 03:17:28 -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=MGwet8zq/q+oBO0cHbSkm6maZjXBTGE7Z1lKpvdPae8=; b=mWWsTocp+FaeXz7m6q2G2l6HK5IYTE8CBN/r+4zYwmSlwTs8jvDyI5kpnqO/55AZIj Mr3mWD0Mud3PA7EUu88qZ/uSSn0yLLYRJxgV5XqLEVjhTUTyMXM0kA5kq4B94T8M2JUf SQ24J0/n7Y+TjfEpntKWKgJeCAT3rfF0p1QXBfMEDY7nvr/NbFuaOQ6xf7aUTHaFWHs/ ocRU7fNhUxLAgMeC7bySbxvSXtED6drR7kNSMrXQLR7ghStTK5y2QGA2xt9ZS1NUKjk+ O9Gv5jQFdLp9Mx/378+VicOE0YufzQsokqZjAxm9/Yy1s37N+JITqE+WAXVeoMhQYf2p ZqHQ== 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=MGwet8zq/q+oBO0cHbSkm6maZjXBTGE7Z1lKpvdPae8=; b=Rq5VhdbapSeozi/2xYemp1PAvPIg6NW6laMixgXNbWwNue672IDFSSQya5C4RWBV7v PNDb9bRummaN6EOeZgpw5AQkf69ZfRYsCTq6mWLISrvIQKL74pz3kZovSmNDPtdwKqM9 fQmgryY7I/OZBeetysi7dqxPq3nQNZw0ZKO3OA8GCbFCE8JtyYtrm4zeyWOFAFei7E/g MCBEgWV8YY460f69isHbeIbTvjboEp+xgNJnqUjcZ421FejQdMwOcLOndO9T4Nun7z09 v8h2cifmn60rb3BTuICxXq1Kwsjk41RfhtB0uch9xbYzcamp38dQLwZI1nVqxbEyPfxp Er+g== X-Gm-Message-State: AOAM530O8mbGWVcnis+uMP8rjoBA8GUvkK27e1Jna82v4UzUeeONkWa0 PIUsfXAaJ7cusxuLqTKWxqLisQ== X-Google-Smtp-Source: ABdhPJybg1t1xKJqLsGn0nQIlVpKXFYckwd6gkVxdYrY1KAog6yCEynqxw1UNdzl30rR089a6pB39Q== X-Received: by 2002:a5d:64ce:0:b0:1e4:9b8d:4ccd with SMTP id f14-20020a5d64ce000000b001e49b8d4ccdmr1891746wri.37.1645701447824; Thu, 24 Feb 2022 03:17:27 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:27 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 05/16] ASoC: codecs: tx-macro: move to individual clks from bulk Date: Thu, 24 Feb 2022 11:17:07 +0000 Message-Id: <20220224111718.6264-6-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 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Using bulk clocks and referencing them individually using array index is not great for readers. So move them to individual clocks handling and also remove some unnecessary error handling in the code. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-tx-macro.c | 87 +++++++++++++++++++++++-------- 1 file changed, 65 insertions(+), 22 deletions(-) diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c index 75a5513bff16..920b6e93fbaa 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 @@ -258,7 +259,11 @@ struct tx_macro { unsigned long active_ch_cnt[TX_MACRO_MAX_DAIS]; unsigned long active_decimator[TX_MACRO_MAX_DAIS]; struct regmap *regmap; - struct clk_bulk_data clks[TX_NUM_CLKS_MAX]; + struct clk *mclk; + struct clk *npl; + struct clk *macro; + struct clk *dcodec; + struct clk *fsgen; struct clk_hw hw; bool dec_active[NUM_DECIMATORS]; bool reset_swr; @@ -1754,7 +1759,7 @@ static int tx_macro_register_mclk_output(struct tx_macro *tx) struct clk_init_data init; int ret; - parent_clk_name = __clk_get_name(tx->clks[2].clk); + parent_clk_name = __clk_get_name(tx->mclk); init.name = clk_name; init.ops = &swclk_gate_ops; @@ -1793,17 +1798,25 @@ static int tx_macro_probe(struct platform_device *pdev) if (!tx) return -ENOMEM; - tx->clks[0].id = "macro"; - tx->clks[1].id = "dcodec"; - tx->clks[2].id = "mclk"; - tx->clks[3].id = "npl"; - tx->clks[4].id = "fsgen"; + tx->macro = devm_clk_get_optional(dev, "macro"); + if (IS_ERR(tx->macro)) + return PTR_ERR(tx->macro); - ret = devm_clk_bulk_get_optional(dev, TX_NUM_CLKS_MAX, tx->clks); - if (ret) { - dev_err(dev, "Error getting RX Clocks (%d)\n", ret); - return ret; - } + tx->dcodec = devm_clk_get_optional(dev, "dcodec"); + if (IS_ERR(tx->dcodec)) + return PTR_ERR(tx->dcodec); + + tx->mclk = devm_clk_get(dev, "mclk"); + if (IS_ERR(tx->mclk)) + return PTR_ERR(tx->mclk); + + tx->npl = devm_clk_get(dev, "npl"); + if (IS_ERR(tx->npl)) + return PTR_ERR(tx->npl); + + tx->fsgen = devm_clk_get(dev, "fsgen"); + if (IS_ERR(tx->fsgen)) + return PTR_ERR(tx->fsgen); base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(base)) @@ -1833,26 +1846,52 @@ static int tx_macro_probe(struct platform_device *pdev) tx->dev = dev; /* set MCLK and NPL rates */ - clk_set_rate(tx->clks[2].clk, MCLK_FREQ); - clk_set_rate(tx->clks[3].clk, 2 * MCLK_FREQ); + clk_set_rate(tx->mclk, MCLK_FREQ); + clk_set_rate(tx->npl, 2 * MCLK_FREQ); - ret = clk_bulk_prepare_enable(TX_NUM_CLKS_MAX, tx->clks); + ret = clk_prepare_enable(tx->macro); if (ret) - return ret; + goto err; + + ret = clk_prepare_enable(tx->dcodec); + if (ret) + goto err_dcodec; + + ret = clk_prepare_enable(tx->mclk); + if (ret) + goto err_mclk; + + ret = clk_prepare_enable(tx->npl); + if (ret) + goto err_npl; + + ret = clk_prepare_enable(tx->fsgen); + if (ret) + goto err_fsgen; ret = tx_macro_register_mclk_output(tx); if (ret) - goto err; + goto err_clkout; ret = devm_snd_soc_register_component(dev, &tx_macro_component_drv, tx_macro_dai, ARRAY_SIZE(tx_macro_dai)); if (ret) - goto err; - return ret; -err: - clk_bulk_disable_unprepare(TX_NUM_CLKS_MAX, tx->clks); + goto err_clkout; + return 0; + +err_clkout: + clk_disable_unprepare(tx->fsgen); +err_fsgen: + clk_disable_unprepare(tx->npl); +err_npl: + clk_disable_unprepare(tx->mclk); +err_mclk: + clk_disable_unprepare(tx->dcodec); +err_dcodec: + clk_disable_unprepare(tx->macro); +err: return ret; } @@ -1860,7 +1899,11 @@ static int tx_macro_remove(struct platform_device *pdev) { struct tx_macro *tx = dev_get_drvdata(&pdev->dev); - clk_bulk_disable_unprepare(TX_NUM_CLKS_MAX, tx->clks); + clk_disable_unprepare(tx->macro); + clk_disable_unprepare(tx->dcodec); + clk_disable_unprepare(tx->mclk); + clk_disable_unprepare(tx->npl); + clk_disable_unprepare(tx->fsgen); return 0; } From patchwork Thu Feb 24 11:17:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12758401 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 C3BC6C433EF for ; Thu, 24 Feb 2022 11:20:34 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 008CF1884; Thu, 24 Feb 2022 12:19:43 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 008CF1884 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645701633; bh=DnKdTzFijA9f9sj/wFfkSjlRJr87gS/wi1IRyljQZa0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=rSA7TPBiLhWeaV8qffmn6oTifWE9DS2254gqUalDzkT2k/Dk9CfeSGw5IKWIku0Rj UM/GVfkHam2BJ1lHOuxgAniCM2HMywkyKPP47FRVr7e9zpCypmnqgXkxvdGwyiN4ZH edD62Pvo60oSdVWERV7nzCL7J/10HCsBCHSlxOwI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 29881F80538; Thu, 24 Feb 2022 12:17:47 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A05B0F80537; Thu, 24 Feb 2022 12:17:41 +0100 (CET) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C1CB1F804FC for ; Thu, 24 Feb 2022 12:17:29 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C1CB1F804FC Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="OP7gussU" Received: by mail-wr1-x431.google.com with SMTP id r10so1440210wrp.3 for ; Thu, 24 Feb 2022 03:17:29 -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=+dWp2Fe/HSQ+rB2BK7g54G2X9Fg00bBu78re9wNgZTM=; b=OP7gussUK/k/nGkTuGchNVAg0jPit6crNED+AQEbariWj8nKHtbiO6QItPUloFGTOF XrpznEN1BzBHqaXn2qi4X9ROvqh/MPxRGE1Nl84AGKaceSli87k2gvevOFJQd5x1cYca aQ0rgAgpVPGjg3LTBogyj5AZKIMP3CZKpwMCbuuax32CGELtjml/jhiBYTZmYUvlIHYZ JbR4gYyGUG0BqDlDufpfycd2L2YyPN+cUcnhumMQ6J3Mni6YraHJiryITYvuq7kyFned +rZakHzcLXuEEVJ8dEebmuLm245drguBb2yEKxrw8AKlpkJcClJ86H3F0TBVGshXpt76 eA1g== 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=+dWp2Fe/HSQ+rB2BK7g54G2X9Fg00bBu78re9wNgZTM=; b=8KPJ7XR/ETLSGDcoCiLY+fNcSZ+mjtN9bmnrnwwuYBd9HFjpcoQzG1CKbzxnEag4ah sRXZtmwogAhmdDtRBBELU8BfL2WSsUcBQ1xVVLwga6oWupQwe7fK6Se4G/I3nxN7vNTd ZQOc2itydaXVju0bZcet9R4FKyANL0QKu2O2fB9BLaUVEGUwUuHWdHlQMuOl3ps0Mbjf rq9WNacjiqk+jH/AvuVPdj/DYimt0q1xfEP+pVBZxt4uG1WrI++nt7jI2JAKyDs23SRQ VZ9KOdevSWQNUF0DYKoOdULMn6BiHYsgVKfJqFI3Hy/K32nr/hA0PbPbNsV0XMZBzMPY +RBA== X-Gm-Message-State: AOAM530UAbcH9STD1snJf4ye9vmr1Y/tX4PThwTEOXxBkljqeUq7tjp0 5cx0dD6kH75upb/g3S5Jco/cQQ== X-Google-Smtp-Source: ABdhPJwE3TDJ0aj5cjMLlFFgTarElFfnvkUpMJoteRHH9/WRjApx63jVvNg8Wq3Ty1x3b/vq07Befg== X-Received: by 2002:a05:6000:1547:b0:1ea:7d56:83e8 with SMTP id 7-20020a056000154700b001ea7d5683e8mr1909079wry.404.1645701449140; Thu, 24 Feb 2022 03:17:29 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:28 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 06/16] ASoC: codecs: wsa-macro: move to individual clks from bulk Date: Thu, 24 Feb 2022 11:17:08 +0000 Message-Id: <20220224111718.6264-7-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 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Using bulk clocks and referencing them individually using array index is not great for readers. So move them to individual clocks handling and also remove some unnecessary error handling in the code. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-wsa-macro.c | 88 ++++++++++++++++++++++-------- 1 file changed, 66 insertions(+), 22 deletions(-) diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c index ddde17e2dc35..ac5f94fff0a9 100644 --- a/sound/soc/codecs/lpass-wsa-macro.c +++ b/sound/soc/codecs/lpass-wsa-macro.c @@ -347,7 +347,11 @@ struct wsa_macro { int is_softclip_on[WSA_MACRO_SOFTCLIP_MAX]; int softclip_clk_users[WSA_MACRO_SOFTCLIP_MAX]; struct regmap *regmap; - struct clk_bulk_data clks[WSA_NUM_CLKS_MAX]; + struct clk *mclk; + struct clk *npl; + struct clk *macro; + struct clk *dcodec; + struct clk *fsgen; struct clk_hw hw; }; #define to_wsa_macro(_hw) container_of(_hw, struct wsa_macro, hw) @@ -2350,7 +2354,7 @@ static int wsa_macro_register_mclk_output(struct wsa_macro *wsa) struct clk_init_data init; int ret; - parent_clk_name = __clk_get_name(wsa->clks[2].clk); + parent_clk_name = __clk_get_name(wsa->mclk); init.name = clk_name; init.ops = &swclk_gate_ops; @@ -2388,17 +2392,25 @@ static int wsa_macro_probe(struct platform_device *pdev) if (!wsa) return -ENOMEM; - wsa->clks[0].id = "macro"; - wsa->clks[1].id = "dcodec"; - wsa->clks[2].id = "mclk"; - wsa->clks[3].id = "npl"; - wsa->clks[4].id = "fsgen"; + wsa->macro = devm_clk_get_optional(dev, "macro"); + if (IS_ERR(wsa->macro)) + return PTR_ERR(wsa->macro); - ret = devm_clk_bulk_get(dev, WSA_NUM_CLKS_MAX, wsa->clks); - if (ret) { - dev_err(dev, "Error getting WSA Clocks (%d)\n", ret); - return ret; - } + wsa->dcodec = devm_clk_get_optional(dev, "dcodec"); + if (IS_ERR(wsa->dcodec)) + return PTR_ERR(wsa->dcodec); + + wsa->mclk = devm_clk_get(dev, "mclk"); + if (IS_ERR(wsa->mclk)) + return PTR_ERR(wsa->mclk); + + wsa->npl = devm_clk_get(dev, "npl"); + if (IS_ERR(wsa->npl)) + return PTR_ERR(wsa->npl); + + wsa->fsgen = devm_clk_get(dev, "fsgen"); + if (IS_ERR(wsa->fsgen)) + return PTR_ERR(wsa->fsgen); base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(base)) @@ -2414,25 +2426,53 @@ static int wsa_macro_probe(struct platform_device *pdev) wsa->dev = dev; /* set MCLK and NPL rates */ - clk_set_rate(wsa->clks[2].clk, WSA_MACRO_MCLK_FREQ); - clk_set_rate(wsa->clks[3].clk, WSA_MACRO_MCLK_FREQ); + clk_set_rate(wsa->mclk, WSA_MACRO_MCLK_FREQ); + clk_set_rate(wsa->npl, WSA_MACRO_MCLK_FREQ); - ret = clk_bulk_prepare_enable(WSA_NUM_CLKS_MAX, wsa->clks); + ret = clk_prepare_enable(wsa->macro); if (ret) - return ret; + goto err; + + ret = clk_prepare_enable(wsa->dcodec); + if (ret) + goto err_dcodec; + + ret = clk_prepare_enable(wsa->mclk); + if (ret) + goto err_mclk; + + ret = clk_prepare_enable(wsa->npl); + if (ret) + goto err_npl; + + ret = clk_prepare_enable(wsa->fsgen); + if (ret) + goto err_fsgen; + + ret = wsa_macro_register_mclk_output(wsa); + if (ret) + goto err_clkout; - wsa_macro_register_mclk_output(wsa); ret = devm_snd_soc_register_component(dev, &wsa_macro_component_drv, wsa_macro_dai, ARRAY_SIZE(wsa_macro_dai)); if (ret) - goto err; + goto err_clkout; - return ret; -err: - clk_bulk_disable_unprepare(WSA_NUM_CLKS_MAX, wsa->clks); + return 0; +err_clkout: + clk_disable_unprepare(wsa->fsgen); +err_fsgen: + clk_disable_unprepare(wsa->npl); +err_npl: + clk_disable_unprepare(wsa->mclk); +err_mclk: + clk_disable_unprepare(wsa->dcodec); +err_dcodec: + clk_disable_unprepare(wsa->macro); +err: return ret; } @@ -2441,7 +2481,11 @@ static int wsa_macro_remove(struct platform_device *pdev) { struct wsa_macro *wsa = dev_get_drvdata(&pdev->dev); - clk_bulk_disable_unprepare(WSA_NUM_CLKS_MAX, wsa->clks); + clk_disable_unprepare(wsa->macro); + clk_disable_unprepare(wsa->dcodec); + clk_disable_unprepare(wsa->mclk); + clk_disable_unprepare(wsa->npl); + clk_disable_unprepare(wsa->fsgen); return 0; } From patchwork Thu Feb 24 11:17:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12758398 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 E7393C433EF for ; Thu, 24 Feb 2022 11:19:42 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2B4CA1853; Thu, 24 Feb 2022 12:18:51 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2B4CA1853 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645701581; bh=g4hY5B5uYPkp+dRtTHSyZy9GYAPQNAC2Im1pVYuhAHA=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=iOUEJRFHTekpEcVaG0PJ5pNKY0S09zOAnUVwtj1/AZ+c0d7RXUnJZA2V+IiMfhG9q 5BkFWpGBKOLBHpZ4icg2p2DEdLHoLv3AWfdg9bSJWeJT3uyyrJxGcPswAINX4gdNCG D6aS6bBqYnHGYfZj87YG6ALAQNuuV6MiefJM46Po= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 56316F8051E; Thu, 24 Feb 2022 12:17:38 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 34A5CF8051F; Thu, 24 Feb 2022 12:17:37 +0100 (CET) Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 33C1EF800B6 for ; Thu, 24 Feb 2022 12:17:30 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 33C1EF800B6 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="s2cKWb6E" Received: by mail-wm1-x330.google.com with SMTP id p184-20020a1c29c1000000b0037f76d8b484so1023664wmp.5 for ; Thu, 24 Feb 2022 03:17:30 -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=9GMeWI1tNkbi4OC/4dfJqIUQ1pnya35dc/9sZ3BiKI4=; b=s2cKWb6EDkhhedxiJav26MCdH3kvZL4oXoyUzVMDonmIlmWO8HCeGGC/4VuT+12jqv Xx+8Gkx3sK87+vHG1TQp6IZ1deqaUQIJCfaqJSjOXZqK1TG8CH11fJnor5dYAgAE8YyV H5sP0w3jdVZNugAAyib2SRUfEQOrcGRRXkIIBphxMDA3SLNEd8Jn8h7B+IX/kMMe46xr qt4551B+yXJMx+Kg6Jy+WFujN8b3Qv5z3Lx6bpcaNoSLPPSnbSdIjxjMCtof6ehq6F1D AVIP7oRMiFnh9E1I4/V6zlZy1HvfW4dhn2EzQ3A+wY801E4gUs6gHyCCPG5vhMUVEG6e YydA== 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=9GMeWI1tNkbi4OC/4dfJqIUQ1pnya35dc/9sZ3BiKI4=; b=U1c8zMMdkKPNwn3lFTq64gWflwOXjsx6Sxx79gn5J9lDi5IkbxyTkrQHw4h/9xjkOn nwmJcXbvqEkfEo28BGQqDINDO4SQzfiyc/ZR3cNLodPrVKoRnISwzieQX9i9a0x1NXou Ii+axPIr/hHI7alAeSbFzR9OO2vcUHmu6gqfJiIh0inoo80pwrJCelfKSPIqArwlZ+I+ z7kgt8puPGcIIi6QCI4hfvg0so0CmG5vQNGZtBKoSrRVhDNxC/6D7Qzog6CXv39PY40e u5Y/LPm4NNzcNNteiwCXSUWuJ2S2bFRRvnSLEPdu+CvOixztSpG8KeO1jOaF6hj3PKqr udfQ== X-Gm-Message-State: AOAM531qX1B8dMQWyEoxmBEE+dvNPT7y+oNVudNNRPUfYMsG6SmMcHJp UZA99BplvH/9bDPi0/DC8WWOAg== X-Google-Smtp-Source: ABdhPJwOYHMnZNvU9zDMlws3RLTrnptEO39DLfuc1HloQdZsLISrYC/aqj4jFlONbQulW1YEZbcU0Q== X-Received: by 2002:a05:600c:4f54:b0:37b:fe6a:ea9c with SMTP id m20-20020a05600c4f5400b0037bfe6aea9cmr1900585wmq.169.1645701450266; Thu, 24 Feb 2022 03:17:30 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:29 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 07/16] ASoC: codecs: wsa-macro: setup soundwire clks correctly Date: Thu, 24 Feb 2022 11:17:09 +0000 Message-Id: <20220224111718.6264-8-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 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" For SoundWire Frame sync to be generated correctly we need both MCLK and MCLKx2 (npl). Without pm runtime enabled these two clocks will remain on, however after adding pm runtime support its possible that NPl clock could be turned off even when SoundWire controller is active. Fix this by enabling mclk and npl clk when SoundWire clks are enabled. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-wsa-macro.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c index ac5f94fff0a9..2586d6350f20 100644 --- a/sound/soc/codecs/lpass-wsa-macro.c +++ b/sound/soc/codecs/lpass-wsa-macro.c @@ -2260,6 +2260,13 @@ static int wsa_swrm_clock(struct wsa_macro *wsa, bool enable) struct regmap *regmap = wsa->regmap; if (enable) { + int ret; + + ret = clk_prepare_enable(wsa->mclk); + if (ret) { + dev_err(wsa->dev, "failed to enable mclk\n"); + return ret; + } wsa_macro_mclk_enable(wsa, true); /* reset swr ip */ @@ -2284,6 +2291,7 @@ static int wsa_swrm_clock(struct wsa_macro *wsa, bool enable) regmap_update_bits(regmap, CDC_WSA_CLK_RST_CTRL_SWR_CONTROL, CDC_WSA_SWR_CLK_EN_MASK, 0); wsa_macro_mclk_enable(wsa, false); + clk_disable_unprepare(wsa->mclk); } return 0; @@ -2354,7 +2362,7 @@ static int wsa_macro_register_mclk_output(struct wsa_macro *wsa) struct clk_init_data init; int ret; - parent_clk_name = __clk_get_name(wsa->mclk); + parent_clk_name = __clk_get_name(wsa->npl); init.name = clk_name; init.ops = &swclk_gate_ops; From patchwork Thu Feb 24 11:17:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12758399 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 B6E92C433F5 for ; Thu, 24 Feb 2022 11:20:04 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id CB0D917EC; Thu, 24 Feb 2022 12:19:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CB0D917EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645701602; bh=9wkrz4c2ZeMGZZ7uOSVLK3VHlbFmzGRJpYkctDHwYOo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=V4gIkqyZFdZm6PWTznEYelutX0s6aUL1iXao20anJj8pbm7KD57HH8cpA+PHyLIRi UweSVzrVtmYV2iAKXlS9KtvFFvtkhJmMev+H9XH3+XxhvJOW1EATPcuPJjGt9eJQXj cyYL7NUoXKSw1pZILMwjYd6xnLvmnyISQlPeT4is= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 00AEFF80534; Thu, 24 Feb 2022 12:17:41 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A3845F8051F; Thu, 24 Feb 2022 12:17:38 +0100 (CET) Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id AC5D9F804FD for ; Thu, 24 Feb 2022 12:17:31 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz AC5D9F804FD Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NpUHOi8O" Received: by mail-wr1-x433.google.com with SMTP id d28so2455072wra.4 for ; Thu, 24 Feb 2022 03:17:31 -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=8veggn84WTDPG1EzzuuowEnBUzJbPrvW+5/W0Ult+cg=; b=NpUHOi8Obu4FUugi29GayDY/BGYAT6n6DPvbj68hPa0y/lkD0LmhRybNRPTyKjS6I4 kCob7oaYOr8zNOk/y+b40DUFGtMqAnRgPFPJYH3G88zh13zD9zvNvMCMxkUyV+/8FTbm aefSjdGmOZJR23tmid51Uz5YoY9kGuuxrnlGstgnLQJuxTGyn6v4rQQhwQQa1PVaIctv pMbq6bsZoC5/hzxTmYykE7F4B/9l5qpqy+WOv/JLEngGa/b3UNpZrrOjYkBXA5ShN2bh 5pj/6ZdLV4CxYkv2X8Q7ray6R+WYyNJ2FdUTp2r0xeKlkR1qTfEjNzbXtt5YEcLzg6Rs cVSw== 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=8veggn84WTDPG1EzzuuowEnBUzJbPrvW+5/W0Ult+cg=; b=X51BZ715Gq25OwQs+nGQEyCZ+1nufFC4amc+9sDU9irT2vXqw3kNJKRXZcctfBZdYq 596q/u4+L58jo6MhObcyapujRq3P2XLjUbDX1O8PZzvenyWtg4/oUpFULtAc0QH96ZmQ IUr5zltfbwRzPtI/u6RPKkBubZZT2CXaQuoy6ejIZpH1PrSPZtmXyAo7CLcQ+5/oebAP LETU36j5cJW/jqnknZWEsq0ZB6L8fpHD9F7HIl/nqcksOvvHWb+BX84IQ2z3b+d0k78l f1XqKEpDKu8mUesjO7EScsgAD5ZaNv9IRGHHX/6UinVv5iI6Brm5bpz4nWp1MI/84U8U TidA== X-Gm-Message-State: AOAM531zpD95XFl78Tf7iXE5r71+Lwh/COCJqO3XBGKxJdI3MooLqymO /RjLD0eCrV+Wf+ZBfXVtZXGspQ== X-Google-Smtp-Source: ABdhPJxKj97YqBBS+rvtIhUx243DLI4rxm9/PBcoPfDt8qdKLDowWWEZ8Pr+d5o7uGgTXgoB2rLhhQ== X-Received: by 2002:a05:6000:2c4:b0:1ea:910c:151c with SMTP id o4-20020a05600002c400b001ea910c151cmr1797216wry.92.1645701451345; Thu, 24 Feb 2022 03:17:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:30 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 08/16] ASoC: codecs: tx-macro: setup soundwire clks correctly Date: Thu, 24 Feb 2022 11:17:10 +0000 Message-Id: <20220224111718.6264-9-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 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" For SoundWire Frame sync to be generated correctly we need both MCLK and MCLKx2 (npl). Without pm runtime enabled these two clocks will remain on, however after adding pm runtime support its possible that NPl clock could be turned off even when SoundWire controller is active. Fix this by enabling mclk and npl clk when SoundWire clks are enabled. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-tx-macro.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c index 920b6e93fbaa..b32235a9e1e5 100644 --- a/sound/soc/codecs/lpass-tx-macro.c +++ b/sound/soc/codecs/lpass-tx-macro.c @@ -1696,6 +1696,13 @@ static int swclk_gate_enable(struct clk_hw *hw) { struct tx_macro *tx = to_tx_macro(hw); struct regmap *regmap = tx->regmap; + int ret; + + ret = clk_prepare_enable(tx->mclk); + if (ret) { + dev_err(tx->dev, "failed to enable mclk\n"); + return ret; + } tx_macro_mclk_enable(tx, true); if (tx->reset_swr) @@ -1723,6 +1730,7 @@ static void swclk_gate_disable(struct clk_hw *hw) CDC_TX_SWR_CLK_EN_MASK, 0x0); tx_macro_mclk_enable(tx, false); + clk_disable_unprepare(tx->mclk); } static int swclk_gate_is_enabled(struct clk_hw *hw) @@ -1759,7 +1767,7 @@ static int tx_macro_register_mclk_output(struct tx_macro *tx) struct clk_init_data init; int ret; - parent_clk_name = __clk_get_name(tx->mclk); + parent_clk_name = __clk_get_name(tx->npl); init.name = clk_name; init.ops = &swclk_gate_ops; From patchwork Thu Feb 24 11:17:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12758403 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 38694C433EF for ; Thu, 24 Feb 2022 11:21:10 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 67A131FA; Thu, 24 Feb 2022 12:20:18 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 67A131FA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645701668; bh=OaBHCimOLNaQGF5VAf0VI2zcJT2E3VuptCg0gSGr6Ew=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=iDg5Hl/ECzjf8qzitR4okcKFwP82ntnJHxeQJLQ1bXraf1eB4qmB82qlkc+4+6oSz 1UITlxhn3juCuiLrhtevq8s+HAmaDEEz0+ub77SYqD0lHAghBTy1zt/pWlWDq6qv9M p/lZam+K9bwhnOJVtoKymy1v5j5jQPyzIRkFOIRM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 1B373F8053D; Thu, 24 Feb 2022 12:17:49 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 8DEF5F80537; Thu, 24 Feb 2022 12:17:43 +0100 (CET) Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id BC878F800B6 for ; Thu, 24 Feb 2022 12:17:34 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz BC878F800B6 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="y0wC2iSa" Received: by mail-wr1-x434.google.com with SMTP id j22so2402646wrb.13 for ; Thu, 24 Feb 2022 03:17:34 -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=zE6/nZIDlJdrpc8fSPwZfEWaQMFLh+eWf0SbooVP2Cs=; b=y0wC2iSaTfuMnX+xZjLGomf6N3YABPJaIUbLdMN9PI7FX2tlh9OC9gex041qeCWkbE tkveBABwMnZVwGABeOznGoCqZv58ce7PD3oaDmsf9SX3QmE2it0VbRyMxID1sCLM7YSF PenArZceaij7jQy2DdwKAaQGbPqplbjWiSQb5QzQ/x4CERjEaG1TSzJn5dsJohZT11rv sgcZtn1mTdI3gUFuUJSUlGusNXqjl456Nnc1iRA5iq7AzR1cnxCh7pkjFue/Yj4A/Ux6 Kfk7OxE0R/ReiW34BRYX4Uds99Sn7KSPy1ZA5EKxGk9/IyDAxwG4O7JJfGypS8JMTLw+ tLbw== 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=zE6/nZIDlJdrpc8fSPwZfEWaQMFLh+eWf0SbooVP2Cs=; b=TlLNIExBSyXtlSV3cF/rc4XPQJC7r+WKeQqF4WUPdu4G+EtQGsxqRl/4alNF0Yso8w BemONrpM9/o4eq6YjL8c1WXQXOkK+pnHdx/DAvLnk/zKBcTv6ZKduDOb4DPQl9VhC/KU H/PShJFIyYGWv8DeXtF+3ZE2hBkO4RNJ1aVruIoM0OeHrd6AAHCIlBPaBndN9m+f+iGh mksD8QRAjYOTwYcjXVX6Hm/rQC4Xu+r5qstuJ7oaUkzZPIQea+eY4TIalPNPx//k7Y/L 9yolmUF2KUsAS4GFYOsDsNNKQKwgzb9G0KMZYLyAoJ+TDMn/uiOGBjugMMiebiv29q4x 8AKg== X-Gm-Message-State: AOAM533PZXwrcKE2ukHgQTx63ekFCDnNaLWcCH7fYgO0EMcd1j2NKBr4 Nj/yiKidP3OYOChcGIagYFMLVQ== X-Google-Smtp-Source: ABdhPJw3NfB3x04KEBXGRKtfaIopOFoSnpJaNQZBGPeNyhHXjJQxGlGlxdY1AzUUWu4ZgFrUhRwcgQ== X-Received: by 2002:adf:fb06:0:b0:1e6:8b27:f1ea with SMTP id c6-20020adffb06000000b001e68b27f1eamr1803259wrr.353.1645701452462; Thu, 24 Feb 2022 03:17:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:31 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 09/16] ASoC: codecs: rx-macro: setup soundwire clks correctly Date: Thu, 24 Feb 2022 11:17:11 +0000 Message-Id: <20220224111718.6264-10-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 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" For SoundWire Frame sync to be generated correctly we need both MCLK and MCLKx2 (npl). Without pm runtime enabled these two clocks will remain on, however after adding pm runtime support its possible that NPl clock could be turned off even when SoundWire controller is active. Fix this by enabling mclk and npl clk when SoundWire clks are enabled. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-rx-macro.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c index 83b570403c59..a2f49a21678b 100644 --- a/sound/soc/codecs/lpass-rx-macro.c +++ b/sound/soc/codecs/lpass-rx-macro.c @@ -3430,6 +3430,13 @@ static int rx_macro_component_probe(struct snd_soc_component *component) static int swclk_gate_enable(struct clk_hw *hw) { struct rx_macro *rx = to_rx_macro(hw); + int ret; + + ret = clk_prepare_enable(rx->mclk); + if (ret) { + dev_err(rx->dev, "unable to prepare mclk\n"); + return ret; + } rx_macro_mclk_enable(rx, true); if (rx->reset_swr) @@ -3456,6 +3463,7 @@ static void swclk_gate_disable(struct clk_hw *hw) CDC_RX_SWR_CLK_EN_MASK, 0); rx_macro_mclk_enable(rx, false); + clk_disable_unprepare(rx->mclk); } static int swclk_gate_is_enabled(struct clk_hw *hw) @@ -3492,7 +3500,7 @@ static int rx_macro_register_mclk_output(struct rx_macro *rx) struct clk_init_data init; int ret; - parent_clk_name = __clk_get_name(rx->mclk); + parent_clk_name = __clk_get_name(rx->npl); init.name = clk_name; init.ops = &swclk_gate_ops; From patchwork Thu Feb 24 11:17:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12758407 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 23652C433F5 for ; Thu, 24 Feb 2022 11:22:17 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 57C38186C; Thu, 24 Feb 2022 12:21:25 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 57C38186C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645701735; bh=sibmX9Elp88A36YjDgJchhVf7Cv0ue61UPJqj8YLK2I=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=NEzUj7fE4/7eLyEsqrYGjybMeNsEY2tB15Wwd2zon4Nq9jJeBtSEn0ez0cxpKGrHQ yaOmsLSojrqaA5+4Muex2o3F7ZlC73NP5/KLcJOV1+F0ZO1i8rlpiDG4Id9aEgDBdx 96EBTBxUC+NRtww/x1XKSBb7di23vvWQRFUr42DY= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id C4233F80567; Thu, 24 Feb 2022 12:17:53 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CCE69F8053C; Thu, 24 Feb 2022 12:17:47 +0100 (CET) Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C028AF8052E for ; Thu, 24 Feb 2022 12:17:35 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C028AF8052E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iHgn2n0X" Received: by mail-wr1-x435.google.com with SMTP id b5so1475796wrr.2 for ; Thu, 24 Feb 2022 03:17:35 -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=QnhpDOk4CUU3lYsv0PpUfinJqZMQJnvxRMmJ0Ek2uv8=; b=iHgn2n0Xbc0eS5i5rmuVlIhBnrk1T9JqOx4lAmr9MjuuLqLPefIrWkjeUB03q3UJdk JcYDwzltbGzolGWroQQt8Gc6b1IoXLn8Agdj9/jJkDhkrcX5btQlkOFD8kmicnTI8mfw kQC15wMyxH7qrfe74fHBcLB6eSioWOWbGVFFev0Xmd6HZz5zyQZGi/3fE9VvSQuNwVje wugyuVvpNoeRhvzMmdW71VcyBtTpu8JnZgJOrRp9q9GkEf+8J2UhRtNGJ08Rn1bFqwW+ GLErTgSwojHatENPHxxIP7hCsR3UF1UFlXyJzy7Xd/wSy+F7YK8LNI/+8fYhBHVvqRxM 6xPw== 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=QnhpDOk4CUU3lYsv0PpUfinJqZMQJnvxRMmJ0Ek2uv8=; b=5kB/6Kb/jOvvJFTgADnKm0d4qfqiA+1a9kkIxdfzG/rWVH4Ndd5XFVf4uARv+CsdM6 LllawrEUjAwFXd820CSto4JsdgVFml4j/R7KbHU9Qg089eoDOHUIxmvsUzG9kTEtZimh u86/5WIVcih+DdARzSp52ZR8yN6lKZr03EWy0buCSBbrlgeuXUuF6+WAMzjEvi3stB/l 1QdUq3FAq46QQrPndJB8zzEEyqK3PixA6sa6ea9Bzatkm7X8SUNBmlFYdtnm/XnQg4Qm BNQlkyDPTXKfgBNU7pIWt6c4aczpJOD19OHTOu4QvsCtCAt56MCRs5VJ0hXfVzTIW+Ey ZWnQ== X-Gm-Message-State: AOAM532OZsKHItUbemnaSX4Z+D/FdpJAO+WHHDKYiQS8HHuP8xOoQOzA OVCl3iW957Grpy+1G2ql+VEOXQ== X-Google-Smtp-Source: ABdhPJxGJ8YMd6U1ZvlIMkNGjumB115CP6WBkh2oFxGcgtmx9Xosrnqs/8pck2bBAImBOr/InU6k5A== X-Received: by 2002:a05:6000:178a:b0:1ea:7db1:3159 with SMTP id e10-20020a056000178a00b001ea7db13159mr1819995wrg.9.1645701453670; Thu, 24 Feb 2022 03:17:33 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:33 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 10/16] ASoC: codecs: va-macro: add runtime pm support Date: Thu, 24 Feb 2022 11:17:12 +0000 Message-Id: <20220224111718.6264-11-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 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Add pm runtime support to VA Macro. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-va-macro.c | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/sound/soc/codecs/lpass-va-macro.c b/sound/soc/codecs/lpass-va-macro.c index ff8120886eca..34aeee50332a 100644 --- a/sound/soc/codecs/lpass-va-macro.c +++ b/sound/soc/codecs/lpass-va-macro.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -1469,6 +1470,12 @@ static int va_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: @@ -1492,6 +1499,39 @@ static int va_macro_remove(struct platform_device *pdev) return 0; } +static int __maybe_unused va_macro_runtime_suspend(struct device *dev) +{ + struct va_macro *va = dev_get_drvdata(dev); + + regcache_cache_only(va->regmap, true); + regcache_mark_dirty(va->regmap); + + clk_disable_unprepare(va->mclk); + + return 0; +} + +static int __maybe_unused va_macro_runtime_resume(struct device *dev) +{ + struct va_macro *va = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(va->mclk); + if (ret) { + dev_err(va->dev, "unable to prepare mclk\n"); + return ret; + } + + regcache_cache_only(va->regmap, false); + regcache_sync(va->regmap); + return 0; +} + + +static const struct dev_pm_ops va_macro_pm_ops = { + SET_RUNTIME_PM_OPS(va_macro_runtime_suspend, va_macro_runtime_resume, NULL) +}; + static const struct of_device_id va_macro_dt_match[] = { { .compatible = "qcom,sc7280-lpass-va-macro" }, { .compatible = "qcom,sm8250-lpass-va-macro" }, @@ -1504,6 +1544,7 @@ static struct platform_driver va_macro_driver = { .name = "va_macro", .of_match_table = va_macro_dt_match, .suppress_bind_attrs = true, + .pm = &va_macro_pm_ops, }, .probe = va_macro_probe, .remove = va_macro_remove, From patchwork Thu Feb 24 11:17:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12758404 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 D219BC433EF for ; Thu, 24 Feb 2022 11:21:25 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 26E7518A0; Thu, 24 Feb 2022 12:20:34 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 26E7518A0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645701684; bh=wXm8+7A7oZb6zV9jJ42M7SnF+x4Un9g5R48U6zgupZE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=m4qUWKHEqWQ+Il/MRp8rCeNjS3vGz4s8trrcqVpJEPdFhhZnAMUcxR0Aa53fyYlTU JdwPhfTZh24Jmltj+PjknWC1QkybtHBy5TQOQaXkz5T0kbpy/2YMWFKEXc3HhHTg+S IfkFA94jw1uYlNM2Y0xLBR3y7oFd4c8VHGxQeYzk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A1561F80544; Thu, 24 Feb 2022 12:17:49 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3F9A3F80537; Thu, 24 Feb 2022 12:17:44 +0100 (CET) Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 82C9BF80524 for ; Thu, 24 Feb 2022 12:17:37 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 82C9BF80524 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="BgqwvFh2" Received: by mail-wm1-x32b.google.com with SMTP id az26-20020a05600c601a00b0037c078db59cso1024275wmb.4 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=8cbjsxCnwDWXHhy887xSacuizUGg3UE/QEHYO2FNZug=; b=BgqwvFh2NPOZWo/43igYz9dplEN9ywPQIC+tP75/FD9MiDSMm2FPbL22A//EuT73hU 7vhj8McsZuFw+RvtPOqiD+gxu/rxLUMd7oQYYOf+qe30OhlisjwrGmVDpMteh2mFst/b jILEiDTzLgsnCF5Kgm3Igoponk+Osh1zGm9jnm2oMv4RfCIKdfZ++7s1I4DlYgP/DsxH HHiI3sR4nCLsWr8AK5loL92+wKbZjHB+qG0P0dhOZ044KvP4CuODA0uJnHKQ4S3iRnbQ 2T663q+al/5JFIGlwZnTFgYxS5f55AKQDlcPNWVdt4H+dC4Q8iMYymzUpJ5rp7IRdwAp X4yg== 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=8cbjsxCnwDWXHhy887xSacuizUGg3UE/QEHYO2FNZug=; b=DkAwIbS/XJXEM1BTkxGo9VhBXu4GtzXv12mq4SyRDb1bV0e7GaH/RZz0JAvg1mRcPm tW9RfH0Ve0Tet+c/V288VH7/ONh0XCeMHVAfBlZd49LgqW1GqwvqUXx0gQx4PBewcaxC ESInmiu6pxKVyvAc+We+VG4vM1gyBTZNFyMMJ3eXCBhmqWnKHwfBB5Sgt2ScvTSkkSXd s4FlYOpST0lpjzXOjSNVqjqWmAeuPI6jJAqQE2gQtTLsBljoUydninhUE35DCWWqEeMo yppP4WGe5twxCeX9fq8xofJEcsXt08cw3MPIsAR46vPChY6+cymyWvcUjbp3fqigcvqV cBSA== X-Gm-Message-State: AOAM531DFBCjJyZAUKI+wjlxLEqBAhgEsckvfRRc5c3hYVprXu1NubSt skHzv7QCp/lPA1XeELmZdDWaqw== X-Google-Smtp-Source: ABdhPJz5yjsGGYmbzbcKMglDTtROqnuOEqI3XWpxcYBLcKIQk4RLuVyxqapOo5JrHW4l9FhodTmeZg== X-Received: by 2002:a05:600c:384c:b0:37b:c771:499c with SMTP id s12-20020a05600c384c00b0037bc771499cmr11105362wmr.141.1645701454723; Thu, 24 Feb 2022 03:17:34 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:34 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 11/16] ASoC: codecs: wsa-macro: add runtime pm support Date: Thu, 24 Feb 2022 11:17:13 +0000 Message-Id: <20220224111718.6264-12-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 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-wsa-macro.c | 61 ++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/sound/soc/codecs/lpass-wsa-macro.c b/sound/soc/codecs/lpass-wsa-macro.c index 2586d6350f20..97ef788ab65d 100644 --- a/sound/soc/codecs/lpass-wsa-macro.c +++ b/sound/soc/codecs/lpass-wsa-macro.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include "lpass-wsa-macro.h" @@ -2468,6 +2469,12 @@ static int wsa_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: @@ -2498,6 +2505,59 @@ static int wsa_macro_remove(struct platform_device *pdev) return 0; } +static int __maybe_unused wsa_macro_runtime_suspend(struct device *dev) +{ + struct wsa_macro *wsa = dev_get_drvdata(dev); + + regcache_cache_only(wsa->regmap, true); + regcache_mark_dirty(wsa->regmap); + + clk_disable_unprepare(wsa->mclk); + clk_disable_unprepare(wsa->npl); + clk_disable_unprepare(wsa->fsgen); + + return 0; +} + +static int __maybe_unused wsa_macro_runtime_resume(struct device *dev) +{ + struct wsa_macro *wsa = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(wsa->mclk); + if (ret) { + dev_err(dev, "unable to prepare mclk\n"); + return ret; + } + + ret = clk_prepare_enable(wsa->npl); + if (ret) { + dev_err(dev, "unable to prepare mclkx2\n"); + goto err_npl; + } + + ret = clk_prepare_enable(wsa->fsgen); + if (ret) { + dev_err(dev, "unable to prepare fsgen\n"); + goto err_fsgen; + } + + regcache_cache_only(wsa->regmap, false); + regcache_sync(wsa->regmap); + + return 0; +err_fsgen: + clk_disable_unprepare(wsa->npl); +err_npl: + clk_disable_unprepare(wsa->mclk); + + return ret; +} + +static const struct dev_pm_ops wsa_macro_pm_ops = { + SET_RUNTIME_PM_OPS(wsa_macro_runtime_suspend, wsa_macro_runtime_resume, NULL) +}; + static const struct of_device_id wsa_macro_dt_match[] = { {.compatible = "qcom,sc7280-lpass-wsa-macro"}, {.compatible = "qcom,sm8250-lpass-wsa-macro"}, @@ -2509,6 +2569,7 @@ static struct platform_driver wsa_macro_driver = { .driver = { .name = "wsa_macro", .of_match_table = wsa_macro_dt_match, + .pm = &wsa_macro_pm_ops, }, .probe = wsa_macro_probe, .remove = wsa_macro_remove, From patchwork Thu Feb 24 11:17:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12758405 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 A9B83C433F5 for ; Thu, 24 Feb 2022 11:21:49 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id D679318B3; Thu, 24 Feb 2022 12:20:57 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D679318B3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645701707; bh=POFCCXytIsjGE75xZA9ZpyaHCbbMYGOu5GGTt68pNK0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=AUWOuE+ajikrts/A9zTKq+4NSN1rR1OfgTBFCstuf4WHZdJGKV4HyvstbId/+C70v 2RK2R0txPi507P85BYML8GXEuN45HzVQEEWhf7/cdFM+nXMhQtvAJRz4w+ouhnvWHm YxMDMQMN7dxfEBbdtIDxMzbrrnymU/S8E46W6a+c= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8C0F1F80558; Thu, 24 Feb 2022 12:17:52 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 207E8F80524; Thu, 24 Feb 2022 12:17:45 +0100 (CET) Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id D464FF80526 for ; Thu, 24 Feb 2022 12:17:37 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D464FF80526 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="CAztRwtv" Received: by mail-wr1-x433.google.com with SMTP id s13so2447842wrb.6 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=pD573zxu/OxKJyOUyOCIDnYuYRLWz8/VHBu0OWEDONCxQyt0YeSxCtzqDRlx42HXfy Qc3/D1hxa8ppIq3qeDifjQ03Hys0qXV1ILU9JW88kigzMmLcXfa3tLp8QbiP+MNM1LD6 F2r7eoivB7FfOK9GqKSxecUKawDj88eb5uqsldyaQ7GFa0n2S/KgT1i+JADW6ZyHWofp QJ2Uf5Zm+lO/5/uOHktpZlBa88lZ/HDwjDBMaotBqjL56skh/WUOz/L5erHBaDhtjlPt CdN9EWCjpcLUpNuq1fgAwoXT+99klE5LEkemR1zFaxBR0a7OYvjKIVrq10dauEb1vQHg k7Ow== X-Gm-Message-State: AOAM530GOlCVEPymVQc+JhQmetIsDZMY29exZ3a4fKmNXLb4JhiPoJaZ A7Zu9QxscOK0oVFwwVS/bNo2zg== X-Google-Smtp-Source: ABdhPJxFwqIv17XbkPAGUFEk1/FooN+/RsYed3Q2KhAOJZC9eVgY/J8T/Cw/4GeSyGQvbfdPGN9fbA== 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 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 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" 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, From patchwork Thu Feb 24 11:17:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12758410 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 E6EEFC433F5 for ; Thu, 24 Feb 2022 11:23:08 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2081C18BD; Thu, 24 Feb 2022 12:22:17 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2081C18BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645701787; bh=SoqPMdlX+r5GsWhurtYbOsZ9hPg72HtLQcLL2GkxPGI=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=jgo6XikuhkBvlbuaKaznULdg/mK2VxYn1G+GhQ3pHBwmicahKjcVtqeP0L1QOr0ei O1W0Tamv3gt+XapYjdCqHW92ed8kMzEw5QLtVtaeCt2t0Efm5CKRa07k1hva/KSVvO HReE7jgF8uuciyiD9i28VqZCc4n8qHBqeJbKVqhI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id A59F4F80588; Thu, 24 Feb 2022 12:17:55 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A4415F80551; Thu, 24 Feb 2022 12:17:50 +0100 (CET) Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 33BE6F804FC for ; Thu, 24 Feb 2022 12:17:37 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 33BE6F804FC Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="RFQzpDwg" Received: by mail-wr1-x432.google.com with SMTP id p9so2411818wra.12 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=NBRWbGG3hXrowhqp61BdFvJmp09eFX4PXrA2EU5LRPo=; b=RFQzpDwgQRIX0yGLn4YfC6ANknqYHJ6rJ/TY2pD6gHlbityGXrfOMxGVYg340Ddr9k a6QwKq0nHHECWIAW5QTRZNZNpJYFjK7o8opbLHX656DjtzraCU0ZGg5aq1gzPliOQvou WhuVlsmrYWkUhqO4Ggd/ruelD0oB6U9elXIBgIhQeO839VxzGkAsuKe87pfbXmKp/u4i VRr9oNXWkSroGZfbeeR+XOEHHDbqzVGA9IF8kdVrUxWl20+s5o3cn9ZBHWkAh55WH0q+ npod77c4D1IRi5B1UU0lRF04uM51uVVPFdEO+VaLC4gH1URjWIZonJQksJ/epWwcHjcU 0+fg== 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=NBRWbGG3hXrowhqp61BdFvJmp09eFX4PXrA2EU5LRPo=; b=IYB+FmlFvdZg7QcNGqs4x+nyIx9t9017/+szH+0SQIb+XTVFgGE0zOAnm8MvCW4JUE ZaQu1OIvP6k5LxYtWluKEuN4Wh4796Omk+xhTa1WsMd5Dm0Yckez/5ROR8ySeuq8Of52 bwuU1OboGhL41nKKrpSfoJhIAwlkecFHDwLDyzvIDGi/QhOkw3rrqLriSYM8kEeFNWjw a47ERrzVbpa7JQCyjfzfO/zTqmXncvY5D7yHfVbrS2v8aa+u04M5HQ97eKrs5YV4wft2 jIuG1foPWz9Cv8Aj+0QPZEt6t2IAUaQ0v63gbEEpqO4zwuUgeTy9n3r0xjzNB8NM6O96 PkJg== X-Gm-Message-State: AOAM532kHZDV53ybpFp43GjFYPEbIpLPioyf3iiA/5ogjcmGhOSyb3m5 +w4OCY95LH9RDOVfS5DBu/UgBA2JT0xcwg== X-Google-Smtp-Source: ABdhPJx4PbfZIRdTPPLjfaKJk9COSJSQw2JAq202emZ0PODnzYAXfVQ3C/JVsLYSfYFLHFZjHMI+jA== X-Received: by 2002:a5d:64ce:0:b0:1e4:9b8d:4ccd with SMTP id f14-20020a5d64ce000000b001e49b8d4ccdmr1892266wri.37.1645701456920; Thu, 24 Feb 2022 03:17:36 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:36 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 13/16] ASoC: codecs: tx-macro: add runtime pm support Date: Thu, 24 Feb 2022 11:17:15 +0000 Message-Id: <20220224111718.6264-14-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 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/lpass-tx-macro.c | 61 +++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c index b32235a9e1e5..2b2b93ddb4d6 100644 --- a/sound/soc/codecs/lpass-tx-macro.c +++ b/sound/soc/codecs/lpass-tx-macro.c @@ -1887,6 +1887,12 @@ static int tx_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: @@ -1916,6 +1922,60 @@ 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->mclk); + clk_disable_unprepare(tx->npl); + clk_disable_unprepare(tx->fsgen); + + return 0; +} + +static int __maybe_unused tx_macro_runtime_resume(struct device *dev) +{ + struct tx_macro *tx = dev_get_drvdata(dev); + int ret; + + ret = clk_prepare_enable(tx->mclk); + if (ret) { + dev_err(dev, "unable to prepare mclk\n"); + return ret; + } + + ret = clk_prepare_enable(tx->npl); + if (ret) { + dev_err(dev, "unable to prepare npl\n"); + goto err_npl; + } + + ret = clk_prepare_enable(tx->fsgen); + if (ret) { + dev_err(dev, "unable to prepare fsgen\n"); + goto err_fsgen; + } + + regcache_cache_only(tx->regmap, false); + regcache_sync(tx->regmap); + tx->reset_swr = true; + + return 0; +err_fsgen: + clk_disable_unprepare(tx->npl); +err_npl: + clk_disable_unprepare(tx->mclk); + + return ret; +} + +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" }, @@ -1927,6 +1987,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, From patchwork Thu Feb 24 11:17:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12758408 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 A974CC433F5 for ; Thu, 24 Feb 2022 11:22:37 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id DC680186B; Thu, 24 Feb 2022 12:21:45 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DC680186B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645701755; bh=cY97V2drznY0qmUgcTcnlUbrPiqnqVj17XpxKBP6E7c=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=EZeDEiCMRyShLdqkQg31H7Khqkwd4/4ELfpgBcxeKZYm7ivmXu4pJVJ10j1j2FqAW 0P6lm0H7RhBTyRnibmmwCgc54hK+I/ImaAIDOGYkCwlVG7Y5QMQ6PXwnBXYxXdYxH+ KK110tYNiT0SXyE9jquUUNVPbHj1kO1aqyAkfVOg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 5D251F80571; Thu, 24 Feb 2022 12:17:54 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3B3FAF8053C; Thu, 24 Feb 2022 12:17:48 +0100 (CET) Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 71D00F8052F for ; Thu, 24 Feb 2022 12:17:38 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 71D00F8052F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NfUN2OoN" Received: by mail-wm1-x32b.google.com with SMTP id v2-20020a7bcb42000000b0037b9d960079so3288165wmj.0 for ; Thu, 24 Feb 2022 03:17:38 -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=cBlO6+QQYN/Gw44r4nZsqtR1gJo3qJphktwBmqjgWgE=; b=NfUN2OoNdSIUwbF2vz+6N9QYFuIm6mPeRPgbJun9BPuLln8VnChH/60n4PczkMddEN XK2kJjRzY4QhjVJQgy1dM5JMZSSmG+5RN4fxF8EuK/CoNLUXP12HhqG1c0GjAGNqqwpJ MNHE+3mXdi1ff6rAS9FyuCW7AzOSPVguKN3M0RwOQzOWZhOg6l4PXhKwufXS5tshoR5D YwZH3R0rKMqKX94Sk4I8FfWm/25qt8/H+KDKL6Jx4NUYZK2/bvqSg2u+jQb//cv6freg EsmhMobAium0Ght+9x7u5rlSW+FqfnF3g8QpuKnEihC9XWIR1vtMEBBQ4LtiBa4NY2iX p2yQ== 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=cBlO6+QQYN/Gw44r4nZsqtR1gJo3qJphktwBmqjgWgE=; b=qaJNJDKkzICI4BBK099SqAHkfSeAXa12gr+mox6u9rp1v8EXO2kDJB6LD3lX0r4ecd EEnC4YrTLkwTkDg/qZ30CH9v7xKmPeWNpXS9ZP4Lr9nwCI2GKwqGF40coD6YQc1fpjAU v2B5nWBxExBaUfbfoD8wDB0TFgvVQqlW2gPPJYOvqnhd06J5BLRQzaKCc6FoyYFU5eF5 yhJ6x75qZSejBdL0iThafj88H78mVIN6Jd9ATzPI9yOQJl6uuZ0gakpmR7tyXEUIva9+ i4zqjPwLljUT8JOV4SNetzjLOSFzwtF2L8E684PAIvKqcECHcmcwftf+3IeilMZWLo4P 3kMA== X-Gm-Message-State: AOAM532t4StnDN32q/X2H5jbRttxGzdfcczZfZzgV9SlT8uPXXNA7Ns2 b0wQTcvH/0O8QikcO5FzE4okLQ== X-Google-Smtp-Source: ABdhPJxQ3QSzr1Eg+1cVlL2up0UZavy1cnm3tuaVArkPSnaU2PMkFqaHrbsyBhO8hxxQF8bRraFtIw== X-Received: by 2002:a1c:2904:0:b0:37b:ea53:4cbf with SMTP id p4-20020a1c2904000000b0037bea534cbfmr1909592wmp.46.1645701458101; Thu, 24 Feb 2022 03:17:38 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:37 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 14/16] ASoC: codecs: wsa881x: add runtime pm support Date: Thu, 24 Feb 2022 11:17:16 +0000 Message-Id: <20220224111718.6264-15-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 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" WSA881x codecs can not cope up with clk stop and requires a full reset after suspend. WSA SoundWire Controller connected to this instances do a full soft reset on suspend. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/wsa881x.c | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/sound/soc/codecs/wsa881x.c b/sound/soc/codecs/wsa881x.c index 0222370ff95d..d851ba14fbdd 100644 --- a/sound/soc/codecs/wsa881x.c +++ b/sound/soc/codecs/wsa881x.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -198,6 +199,7 @@ #define WSA881X_OCP_CTL_TIMER_SEC 2 #define WSA881X_OCP_CTL_TEMP_CELSIUS 25 #define WSA881X_OCP_CTL_POLL_TIMER_SEC 60 +#define WSA881X_PROBE_TIMEOUT 1000 #define WSA881X_PA_GAIN_TLV(xname, reg, shift, max, invert, tlv_array) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ @@ -747,6 +749,12 @@ static int wsa881x_put_pa_gain(struct snd_kcontrol *kc, unsigned int mask = (1 << fls(max)) - 1; int val, ret, min_gain, max_gain; + ret = pm_runtime_get_sync(comp->dev); + if (ret < 0 && ret != -EACCES) { + pm_runtime_put_noidle(comp->dev); + return ret; + } + max_gain = (max - ucontrol->value.integer.value[0]) & mask; /* * Gain has to set incrementally in 4 steps @@ -773,6 +781,9 @@ static int wsa881x_put_pa_gain(struct snd_kcontrol *kc, usleep_range(1000, 1010); } + pm_runtime_mark_last_busy(comp->dev); + pm_runtime_put_autosuspend(comp->dev); + return 1; } @@ -1101,6 +1112,7 @@ static int wsa881x_probe(struct sdw_slave *pdev, const struct sdw_device_id *id) { struct wsa881x_priv *wsa881x; + struct device *dev = &pdev->dev; wsa881x = devm_kzalloc(&pdev->dev, sizeof(*wsa881x), GFP_KERNEL); if (!wsa881x) @@ -1124,6 +1136,7 @@ static int wsa881x_probe(struct sdw_slave *pdev, pdev->prop.sink_ports = GENMASK(WSA881X_MAX_SWR_PORTS, 0); pdev->prop.sink_dpn_prop = wsa_sink_dpn_prop; pdev->prop.scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY; + pdev->prop.simple_clk_stop_capable = true; gpiod_direction_output(wsa881x->sd_n, 1); wsa881x->regmap = devm_regmap_init_sdw(pdev, &wsa881x_regmap_config); @@ -1132,12 +1145,52 @@ static int wsa881x_probe(struct sdw_slave *pdev, return PTR_ERR(wsa881x->regmap); } + 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 devm_snd_soc_register_component(&pdev->dev, &wsa881x_component_drv, wsa881x_dais, ARRAY_SIZE(wsa881x_dais)); } +static int __maybe_unused wsa881x_runtime_suspend(struct device *dev) +{ + struct regmap *regmap = dev_get_regmap(dev, NULL); + struct wsa881x_priv *wsa881x = dev_get_drvdata(dev); + + gpiod_direction_output(wsa881x->sd_n, 0); + + regcache_cache_only(regmap, true); + regcache_mark_dirty(regmap); + + return 0; +} + +static int __maybe_unused wsa881x_runtime_resume(struct device *dev) +{ + struct sdw_slave *slave = dev_to_sdw_dev(dev); + struct regmap *regmap = dev_get_regmap(dev, NULL); + struct wsa881x_priv *wsa881x = dev_get_drvdata(dev); + + gpiod_direction_output(wsa881x->sd_n, 1); + + wait_for_completion_timeout(&slave->initialization_complete, + msecs_to_jiffies(WSA881X_PROBE_TIMEOUT)); + + regcache_cache_only(regmap, false); + regcache_sync(regmap); + + return 0; +} + +static const struct dev_pm_ops wsa881x_pm_ops = { + SET_RUNTIME_PM_OPS(wsa881x_runtime_suspend, wsa881x_runtime_resume, NULL) +}; + static const struct sdw_device_id wsa881x_slave_id[] = { SDW_SLAVE_ENTRY(0x0217, 0x2010, 0), SDW_SLAVE_ENTRY(0x0217, 0x2110, 0), @@ -1151,6 +1204,7 @@ static struct sdw_driver wsa881x_codec_driver = { .id_table = wsa881x_slave_id, .driver = { .name = "wsa881x-codec", + .pm = &wsa881x_pm_ops, } }; module_sdw_driver(wsa881x_codec_driver); From patchwork Thu Feb 24 11:17:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12758406 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 6F109C433F5 for ; Thu, 24 Feb 2022 11:22:01 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8750D18B2; Thu, 24 Feb 2022 12:21:09 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8750D18B2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645701719; bh=e56jG/lyd6oGBZ52c9erwIAX8hNA9r6AzEtczhHWtZo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Ogq+VmmS3XXtm580vqGIBzw1+PNpfK1dWEbAMjWMXVTNLXL999o/4Zyrk4A6WRBMc c6JjJ8aJ6/fYZGG/zLG9S8v56sMJoY/qv1x1AOzhjDImdRsO2H+ablZMLjIVLd2d7a 1XaPRNB/vEDTT3JX6S2SdODcxEcCgWbjjB87EMXI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2BB05F8055A; Thu, 24 Feb 2022 12:17:53 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DCDA8F80539; Thu, 24 Feb 2022 12:17:46 +0100 (CET) Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C4CBCF80430 for ; Thu, 24 Feb 2022 12:17:40 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C4CBCF80430 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="r7/l65/1" Received: by mail-wm1-x331.google.com with SMTP id i20so897282wmc.3 for ; Thu, 24 Feb 2022 03:17:40 -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=LfKStxRvgTEmdqhNQGyq07ydIW9Hyz4sxw/jfz5hVYw=; b=r7/l65/1oIcrXfeQMVC71/5ogGArMOi/oLoSasc+FcBBcXlOrqSYFlPWedgjDjMnhb gJmBZPCFhf71QLIyP9+ilt7CBR2VUVRTLRCr26CThISQ0VBSERN11vsNDHWjlHRgxrkD iInDeLhpIy1O4W/EuP2sxdzBVIyuOM5FQ0JgZakch9wTfzx7N88xoJcfl3B1iPtNRmW0 3wuTRxjxYWr7DjdNt6Bde8ukt47mSQWK8R2m+BwzXpzoyejcUo2XAo02FPoOyMU9kpTM yaNA4iW3xIKaNLZ7S2vvWNQh9PLo7AFZ8cFCp2eZVC6mgT8D0uej0iayS4bTrbmCiIqA uclQ== 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=LfKStxRvgTEmdqhNQGyq07ydIW9Hyz4sxw/jfz5hVYw=; b=AanJMj0Qp+66HOQZcj1kZSMyl6rrE8iAxwwJF0nWCahSRlLvir61Bsou5M5Lg0u7bt KxqqyTKGmqf0e9kAmAhTp8ysdREds+mCAxun7SjAbYkRJKL+ux8bnfH5Ndzb1/JqbTnt 0uhECOGBktjymAFCKqoLqGb1mCPp9eQIyw07bSWG2s6wpioMwIYB5Hf6sULtiwp1pbMY KHept3aGQ+2kWLPDhtB5QbPMw9WNLntnREVuYIUUOTgpgZG4GXnXEGYbTYY5ieOxSCG5 m66p2gMz4/Tx+klGd+c2DPysYtjHT+OEP3bkioWc0poKeTtGPtCwUf1B+hpWf8oJM387 BKbg== X-Gm-Message-State: AOAM532xhhknUY+xaUcfRJhp1YI/mLk914qaPnHPso2ImvTv5hnCVRmh R8lsEJd7s19Wyr4gin2F2pTEYA== X-Google-Smtp-Source: ABdhPJzYjVTN9x+GL1LFM9oLjla4Nv5U4uIq7XL0Lqv3bedGcqZkNI5nSpYhXrImHNanSLu+5Isiog== X-Received: by 2002:a1c:a7ca:0:b0:380:e40f:c31a with SMTP id q193-20020a1ca7ca000000b00380e40fc31amr1874845wme.85.1645701459163; Thu, 24 Feb 2022 03:17:39 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:38 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 15/16] ASoC: codecs: wcd938x: add simple clk stop support Date: Thu, 24 Feb 2022 11:17:17 +0000 Message-Id: <20220224111718.6264-16-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 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" mark WCD938x as clock stop capable. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/wcd938x-sdw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/wcd938x-sdw.c b/sound/soc/codecs/wcd938x-sdw.c index 1fa05ec7459a..1bf3c06a2b62 100644 --- a/sound/soc/codecs/wcd938x-sdw.c +++ b/sound/soc/codecs/wcd938x-sdw.c @@ -249,6 +249,7 @@ static int wcd9380_probe(struct sdw_slave *pdev, SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY; pdev->prop.lane_control_support = true; + pdev->prop.simple_clk_stop_capable = true; if (wcd->is_tx) { pdev->prop.source_ports = GENMASK(WCD938X_MAX_SWR_PORTS, 0); pdev->prop.src_dpn_prop = wcd938x_dpn_prop; From patchwork Thu Feb 24 11:17:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 12758409 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 4A44BC433EF for ; Thu, 24 Feb 2022 11:22:53 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8D0FC18D3; Thu, 24 Feb 2022 12:22:01 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8D0FC18D3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645701771; bh=sf/C1D3uZu2irFWKc3hKP9pwQ55D0OiPpXYgIvqHxb4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=F5y2EGS0HvuNyKjLLeQUESOvHnqDWdqIeo7rI4lWX38NhQgE8e6SsBmllqWQF175G vxldfZQRaPShfnsUm4u+PgkaG06ZKUwdHtMC6AmSPAVzFtBLcwTv8B0hJL/46zqvBp In+doGJ788ICN1rRLcv9XqlOHOka70ioG9EajqfA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 19B2FF80578; Thu, 24 Feb 2022 12:17:55 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A080FF8053D; Thu, 24 Feb 2022 12:17:48 +0100 (CET) Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 474A5F80535 for ; Thu, 24 Feb 2022 12:17:41 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 474A5F80535 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="FhYFTNt+" Received: by mail-wr1-x436.google.com with SMTP id u1so2413176wrg.11 for ; Thu, 24 Feb 2022 03:17:40 -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=vyVwZE5kS8xGdR91o+WjovvMprsI53ZLyaYZnmErV2U=; b=FhYFTNt+x3zszGAAc6gGVhzw88T2nJfziV8IMyz+t5pRZHT/uQUpG/qBROnyUaOInX t6ydRexMU9xeDqLPuLmfDwCcCcley4x4U48EGfc4N6WukdVvYf8DZlawzrDNKd8C7FFV piEKh1CH2rdUJ1/FKZ0wmHE4/5BGxIbZHJG5Ki926kOMial7fMtmRNM3mz5ZKagcqQjk tL4T4laIIAgpVqkFPZUZZNUePbs6aG+cQbu0t7oetR3A6Br0XbUtDfDTA3TY2Orv2o9P yyD0rt+BDpSTqiVwmhzn7HbDPMIxaJxxqu9Fsoa9qSLz8xyqDGQHvgI9lumtnZ6NGpm4 c+gw== 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=vyVwZE5kS8xGdR91o+WjovvMprsI53ZLyaYZnmErV2U=; b=khG+Zr7a0OvNI8TVG03mNz/UOhZ8pr1mKNOsgTVbDja0/otBqZVnBEzj5nXfIfw15e C3JpBSymOOrWO3wLtw4nVoiHYVkRAPvXeVWGeDd5q4B12vi6w91T4Lb0SWs83+VybqpW GOitWuH3fAQGis5EYs0JoAxVo47tDvISj+uK8gh19+35yO0yofzAMxiTPLfYkG+6/oKq qfCTOlTXtC8Vg7G7tsLBPC509O4lU7tc/tyshV1cIJut46Gf9RHZvTH404pzCxG8diom xrTrj9X4tN6QJb8566hPfSyCCHR1eLl/XFWSrBlXwg3hH5OHbIwv3jTWNsq5cNszh3U+ c8aw== X-Gm-Message-State: AOAM530DnYQCpDCmvMRv1t8hmc3e0nojzhbG+LSLrk3RJs15qFdskpzC bZsHhM9eP2BYc9bxLNdT07Nwog== X-Google-Smtp-Source: ABdhPJyAAhwj8cEam23zueLna4wetFnGKEXHXXgZhuqBgsSnzAi5Elri6zJEPYc0C7b8nXQqOuN60A== X-Received: by 2002:a05:6000:2ad:b0:1ea:793a:3284 with SMTP id l13-20020a05600002ad00b001ea793a3284mr1835943wry.63.1645701460101; Thu, 24 Feb 2022 03:17:40 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 03:17:39 -0800 (PST) From: Srinivas Kandagatla To: broonie@kernel.org Subject: [PATCH v2 16/16] ASoC: codecs: wcd-mbhc: add runtime pm support Date: Thu, 24 Feb 2022 11:17:18 +0000 Message-Id: <20220224111718.6264-17-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 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, pierre-louis.bossart@linux.intel.com, tiwai@suse.com, Srinivas Kandagatla , quic_srivasam@quicinc.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" under low power state a SoundWire Wake IRQ could trigger MBHC interrupts so make sure that codec is not in suspended state when this happens. Signed-off-by: Srinivas Kandagatla --- sound/soc/codecs/wcd-mbhc-v2.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sound/soc/codecs/wcd-mbhc-v2.c b/sound/soc/codecs/wcd-mbhc-v2.c index 7488a150a138..c53c2ef33e1a 100644 --- a/sound/soc/codecs/wcd-mbhc-v2.c +++ b/sound/soc/codecs/wcd-mbhc-v2.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -711,6 +712,16 @@ static irqreturn_t wcd_mbhc_hphr_ocp_irq(int irq, void *data) static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc) { struct snd_soc_component *component = mbhc->component; + int ret; + + ret = pm_runtime_get_sync(component->dev); + if (ret < 0 && ret != -EACCES) { + dev_err_ratelimited(component->dev, + "pm_runtime_get_sync failed in %s, ret %d\n", + __func__, ret); + pm_runtime_put_noidle(component->dev); + return ret; + } mutex_lock(&mbhc->lock); @@ -751,6 +762,9 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc) mutex_unlock(&mbhc->lock); + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); + return 0; } @@ -1078,10 +1092,19 @@ static void wcd_correct_swch_plug(struct work_struct *work) int output_mv, cross_conn, hs_threshold, try = 0, micbias_mv; bool is_spl_hs = false; bool is_pa_on; + int ret; mbhc = container_of(work, struct wcd_mbhc, correct_plug_swch); component = mbhc->component; + ret = pm_runtime_get_sync(component->dev); + if (ret < 0 && ret != -EACCES) { + dev_err_ratelimited(component->dev, + "pm_runtime_get_sync failed in %s, ret %d\n", + __func__, ret); + pm_runtime_put_noidle(component->dev); + return; + } micbias_mv = wcd_mbhc_get_micbias(mbhc); hs_threshold = wcd_mbhc_adc_get_hs_thres(mbhc); @@ -1232,6 +1255,9 @@ static void wcd_correct_swch_plug(struct work_struct *work) if (mbhc->mbhc_cb->hph_pull_down_ctrl) mbhc->mbhc_cb->hph_pull_down_ctrl(component, true); + + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); } static irqreturn_t wcd_mbhc_adc_hs_rem_irq(int irq, void *data)