From patchwork Wed Oct 14 21:05:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 11838419 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0989F17C9 for ; Thu, 15 Oct 2020 01:59:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D551322264 for ; Thu, 15 Oct 2020 01:59:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="QfFbFDAW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389101AbgJOB7t (ORCPT ); Wed, 14 Oct 2020 21:59:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388639AbgJOB7j (ORCPT ); Wed, 14 Oct 2020 21:59:39 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C62A0C0613E0 for ; Wed, 14 Oct 2020 14:13:30 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id a1so500066pjd.1 for ; Wed, 14 Oct 2020 14:13:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XXXVW8LaNsSK90nR0fVqNTLLxxo+uN8rx6WyyMCGIqU=; b=QfFbFDAWvdwuJNtRGDEJ+4jQLfUu4dtYrqt375pRq+u0Dv2ZX2eDJlK45YLFadyX+m hpWDEVApkwfktJTstvyeNq1QJX+M8OGBGETL2KOqGWC1sh2+yk4MBRtbyMSQZoxNFX/i ZGPe0JO6EfJFxshk65T9Mxn+11MAkDIRtJTw0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XXXVW8LaNsSK90nR0fVqNTLLxxo+uN8rx6WyyMCGIqU=; b=FV04u76W+TJ0WDHUORh3GJaMBZXE7nNDanabs92g71LnAd+IxTBqQ/txQJKeudbp4Z TmKhbMgg/2YUy+EJBdkD35eFELZVts4/0EQAqqIAcbRZYmbYQogfN//Oe9dwkKlKmtKW 6NpGQ/xku07k0444W6vxo1qJhCBWd2pWvhF22H1u7gTiOjSvd+obvJclKAL1K3ScFG6D SZNSPQZLMy+tzCoxaahtPeDPEGXlk3niN2osqt0IzF+mDfo3aK+1+BTdFUN0/ZbyC74h PrFD8FzHmazvqh0hn96MlJS44gdQGNpJXGVyrbIjRDB692korld2lkKdakzIfOnGi3Se CU6g== X-Gm-Message-State: AOAM530P1dw9xFonypWyuBcNEkQzmKDzCtY2Roy0ZKmrunVa2QUncHPp V8yg+5zO1dpZ4b/4sFmasQfCUg== X-Google-Smtp-Source: ABdhPJyWzB7PQNM2L2E7jMBzdy13qHYz2fsBChWv51asF/Dv9wMqyArFHgIaMI2T7Sc9RZwlGiO/5Q== X-Received: by 2002:a17:90b:1392:: with SMTP id hr18mr1017220pjb.182.1602710010286; Wed, 14 Oct 2020 14:13:30 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id p19sm517713pfn.204.2020.10.14.14.13.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 14:13:29 -0700 (PDT) From: Douglas Anderson To: Stephen Boyd Cc: Taniya Das , linux-soc@vger.kernel.org, David Brown , Rajendra Nayak , Douglas Anderson , Andy Gross , Bjorn Andersson , Michael Turquette , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/3] clk: qcom: lpasscc-sc7810: Use devm in probe Date: Wed, 14 Oct 2020 14:05:21 -0700 Message-Id: <20201014140507.v3.1.I4567b5e7e17bbb15ef063d447cb83fd43746cb18@changeid> X-Mailer: git-send-email 2.28.0.1011.ga647a8990f-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Let's convert the lpass clock control driver to use devm. This is a few more lines of code, but it will be useful in a later patch which disentangles the two devices handled by this driver. Signed-off-by: Douglas Anderson --- Changes in v3: - ("clk: qcom: lpasscc-sc7810: Use devm in probe") new for v3. drivers/clk/qcom/lpasscorecc-sc7180.c | 38 +++++++++++++++------------ 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/drivers/clk/qcom/lpasscorecc-sc7180.c b/drivers/clk/qcom/lpasscorecc-sc7180.c index 228d08f5d26f..abcf36006926 100644 --- a/drivers/clk/qcom/lpasscorecc-sc7180.c +++ b/drivers/clk/qcom/lpasscorecc-sc7180.c @@ -412,40 +412,44 @@ static const struct of_device_id lpass_core_cc_sc7180_match_table[] = { }; MODULE_DEVICE_TABLE(of, lpass_core_cc_sc7180_match_table); +static void lpass_pm_runtime_disable(void *data) +{ + pm_runtime_disable(data); +} + +static void lapss_pm_clk_destroy(void *data) +{ + pm_clk_destroy(data); +} + static int lpass_core_sc7180_probe(struct platform_device *pdev) { int (*clk_probe)(struct platform_device *p); int ret; pm_runtime_enable(&pdev->dev); + ret = devm_add_action_or_reset(&pdev->dev, lpass_pm_runtime_disable, &pdev->dev); + if (ret) + return ret; + ret = pm_clk_create(&pdev->dev); if (ret) - goto disable_pm_runtime; + return ret; + ret = devm_add_action_or_reset(&pdev->dev, lapss_pm_clk_destroy, &pdev->dev); + if (ret) + return ret; ret = pm_clk_add(&pdev->dev, "iface"); if (ret < 0) { dev_err(&pdev->dev, "failed to acquire iface clock\n"); - goto destroy_pm_clk; + return ret; } - ret = -EINVAL; clk_probe = of_device_get_match_data(&pdev->dev); if (!clk_probe) - goto destroy_pm_clk; - - ret = clk_probe(pdev); - if (ret) - goto destroy_pm_clk; - - return 0; - -destroy_pm_clk: - pm_clk_destroy(&pdev->dev); - -disable_pm_runtime: - pm_runtime_disable(&pdev->dev); + return -EINVAL; - return ret; + return clk_probe(pdev); } static const struct dev_pm_ops lpass_core_cc_pm_ops = { From patchwork Wed Oct 14 21:05:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 11838415 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 57C9614B5 for ; Thu, 15 Oct 2020 01:59:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3087422257 for ; Thu, 15 Oct 2020 01:59:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="LBmYPQyT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732525AbgJOB7i (ORCPT ); Wed, 14 Oct 2020 21:59:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732513AbgJOB7i (ORCPT ); Wed, 14 Oct 2020 21:59:38 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EEC1C0613E3 for ; Wed, 14 Oct 2020 14:13:32 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id a17so459782pju.1 for ; Wed, 14 Oct 2020 14:13:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ylSV4Oq4qz/xX1YAW+l4G+GXioVSyeB5dhzFjO2+tps=; b=LBmYPQyTXwj0PY8V23RGlNZ4Grq/Xekx8vxkcidHqMpuIqC6Sn9TtxPyskOTL11nxt cxDRxQmZoTLiYAevOv11KX9vfC7lRLtaYOahxcJxllpKncjoOfErmmmi7XM/uyBNsF9q LGEa5CS0uqZhlPeKSkBsLI/50/STjc63erwzk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ylSV4Oq4qz/xX1YAW+l4G+GXioVSyeB5dhzFjO2+tps=; b=UHhtCX8/h+rFS9DLv/aeLaywU/PUxQhQbc6uQTXf/+gdKpoSsewyCiqYYTy5c8L67a WVn7VPbY2rjHafeRQBVW0yTe/TVbdLD2E4ui6kScC3Tfbz0Qp3oiwG8F3YLTE/wtXeHe uylXwSJCbfd6DfgKu/H+CsnbALr9RgC3Dj6EkBsChA4h1S0SEi5Uyd+K/dJEmuJQCTKT 0v82vq9NspUkb+kBQsEzuv1uROkqhk7chthtsJm5yeQ8Hem8XzGpx6Ul2ygseiE/Hb6g rnHzKrOwaHMjP+j6jXHSOk8BxtNZ0szjoIUB89MzIk1zKcU2cD8SwYvT++fAezMhEtE4 SPfA== X-Gm-Message-State: AOAM530SjNO8HGOzhcHCZuvewpeaRNchAejDfm1om6hLDz9td6S6Uc62 gnv0qXI+ahEuqOaTagm+x9fXzw== X-Google-Smtp-Source: ABdhPJwwKbRc+Px6RO9uTHVXyy2OpFqERo2NOmZYWoDpx+OnO6nwhsgh97BiSfjYs/q8gT9/P4+jzQ== X-Received: by 2002:a17:90a:8403:: with SMTP id j3mr1026621pjn.127.1602710011884; Wed, 14 Oct 2020 14:13:31 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id p19sm517713pfn.204.2020.10.14.14.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 14:13:31 -0700 (PDT) From: Douglas Anderson To: Stephen Boyd Cc: Taniya Das , linux-soc@vger.kernel.org, David Brown , Rajendra Nayak , Douglas Anderson , Andy Gross , Bjorn Andersson , Michael Turquette , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/3] clk: qcom: lpass-sc7180: Disentangle the two clock devices Date: Wed, 14 Oct 2020 14:05:22 -0700 Message-Id: <20201014140507.v3.2.I75c409497d4dea9daefa53ec5f93824081c4ecbe@changeid> X-Mailer: git-send-email 2.28.0.1011.ga647a8990f-goog In-Reply-To: <20201014140507.v3.1.I4567b5e7e17bbb15ef063d447cb83fd43746cb18@changeid> References: <20201014140507.v3.1.I4567b5e7e17bbb15ef063d447cb83fd43746cb18@changeid> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The sc7180 lpass clock driver manages two different devices. These two devices were tangled together, using one probe and a lookup to figure out the real probe. I think it's cleaner to really separate the probe for these two devices since they're really different things, just both managed by the same driver. Signed-off-by: Douglas Anderson --- Changes in v3: - ("clk: qcom: lpass-sc7180: Disentangle the two clock devices") new for v3. drivers/clk/qcom/lpasscorecc-sc7180.c | 121 +++++++++++++++----------- 1 file changed, 72 insertions(+), 49 deletions(-) diff --git a/drivers/clk/qcom/lpasscorecc-sc7180.c b/drivers/clk/qcom/lpasscorecc-sc7180.c index abcf36006926..48d370e2108e 100644 --- a/drivers/clk/qcom/lpasscorecc-sc7180.c +++ b/drivers/clk/qcom/lpasscorecc-sc7180.c @@ -356,12 +356,48 @@ static const struct qcom_cc_desc lpass_audio_hm_sc7180_desc = { .num_gdscs = ARRAY_SIZE(lpass_audio_hm_sc7180_gdscs), }; +static void lpass_pm_runtime_disable(void *data) +{ + pm_runtime_disable(data); +} + +static void lapss_pm_clk_destroy(void *data) +{ + pm_clk_destroy(data); +} + +static int lpass_create_pm_clks(struct platform_device *pdev) +{ + int ret; + + pm_runtime_enable(&pdev->dev); + ret = devm_add_action_or_reset(&pdev->dev, lpass_pm_runtime_disable, &pdev->dev); + if (ret) + return ret; + + ret = pm_clk_create(&pdev->dev); + if (ret) + return ret; + ret = devm_add_action_or_reset(&pdev->dev, lapss_pm_clk_destroy, &pdev->dev); + if (ret) + return ret; + + ret = pm_clk_add(&pdev->dev, "iface"); + if (ret < 0) + dev_err(&pdev->dev, "failed to acquire iface clock\n"); + return ret; +} + static int lpass_core_cc_sc7180_probe(struct platform_device *pdev) { const struct qcom_cc_desc *desc; struct regmap *regmap; int ret; + ret = lpass_create_pm_clks(pdev); + if (ret) + return ret; + lpass_core_cc_sc7180_regmap_config.name = "lpass_audio_cc"; desc = &lpass_audio_hm_sc7180_desc; ret = qcom_cc_probe_by_index(pdev, 1, desc); @@ -392,6 +428,11 @@ static int lpass_core_cc_sc7180_probe(struct platform_device *pdev) static int lpass_hm_core_probe(struct platform_device *pdev) { const struct qcom_cc_desc *desc; + int ret; + + ret = lpass_create_pm_clks(pdev); + if (ret) + return ret; lpass_core_cc_sc7180_regmap_config.name = "lpass_hm_core"; desc = &lpass_core_hm_sc7180_desc; @@ -399,65 +440,28 @@ static int lpass_hm_core_probe(struct platform_device *pdev) return qcom_cc_probe_by_index(pdev, 0, desc); } -static const struct of_device_id lpass_core_cc_sc7180_match_table[] = { +static const struct of_device_id lpass_hm_sc7180_match_table[] = { { .compatible = "qcom,sc7180-lpasshm", - .data = lpass_hm_core_probe, }, + { } +}; +MODULE_DEVICE_TABLE(of, lpass_hm_sc7180_match_table); + +static const struct of_device_id lpass_core_cc_sc7180_match_table[] = { { .compatible = "qcom,sc7180-lpasscorecc", - .data = lpass_core_cc_sc7180_probe, }, { } }; MODULE_DEVICE_TABLE(of, lpass_core_cc_sc7180_match_table); -static void lpass_pm_runtime_disable(void *data) -{ - pm_runtime_disable(data); -} - -static void lapss_pm_clk_destroy(void *data) -{ - pm_clk_destroy(data); -} - -static int lpass_core_sc7180_probe(struct platform_device *pdev) -{ - int (*clk_probe)(struct platform_device *p); - int ret; - - pm_runtime_enable(&pdev->dev); - ret = devm_add_action_or_reset(&pdev->dev, lpass_pm_runtime_disable, &pdev->dev); - if (ret) - return ret; - - ret = pm_clk_create(&pdev->dev); - if (ret) - return ret; - ret = devm_add_action_or_reset(&pdev->dev, lapss_pm_clk_destroy, &pdev->dev); - if (ret) - return ret; - - ret = pm_clk_add(&pdev->dev, "iface"); - if (ret < 0) { - dev_err(&pdev->dev, "failed to acquire iface clock\n"); - return ret; - } - - clk_probe = of_device_get_match_data(&pdev->dev); - if (!clk_probe) - return -EINVAL; - - return clk_probe(pdev); -} - static const struct dev_pm_ops lpass_core_cc_pm_ops = { SET_RUNTIME_PM_OPS(pm_clk_suspend, pm_clk_resume, NULL) }; static struct platform_driver lpass_core_cc_sc7180_driver = { - .probe = lpass_core_sc7180_probe, + .probe = lpass_core_cc_sc7180_probe, .driver = { .name = "lpass_core_cc-sc7180", .of_match_table = lpass_core_cc_sc7180_match_table, @@ -465,17 +469,36 @@ static struct platform_driver lpass_core_cc_sc7180_driver = { }, }; -static int __init lpass_core_cc_sc7180_init(void) +static const struct dev_pm_ops lpass_hm_pm_ops = { + SET_RUNTIME_PM_OPS(pm_clk_suspend, pm_clk_resume, NULL) +}; + +static struct platform_driver lpass_hm_sc7180_driver = { + .probe = lpass_hm_core_probe, + .driver = { + .name = "lpass_hm-sc7180", + .of_match_table = lpass_hm_sc7180_match_table, + .pm = &lpass_hm_pm_ops, + }, +}; + +static int __init lpass_sc7180_init(void) { - return platform_driver_register(&lpass_core_cc_sc7180_driver); + int ret; + + ret = platform_driver_register(&lpass_core_cc_sc7180_driver); + if (ret) + return ret; + return platform_driver_register(&lpass_hm_sc7180_driver); } -subsys_initcall(lpass_core_cc_sc7180_init); +subsys_initcall(lpass_sc7180_init); -static void __exit lpass_core_cc_sc7180_exit(void) +static void __exit lpass_sc7180_exit(void) { + platform_driver_unregister(&lpass_hm_sc7180_driver); platform_driver_unregister(&lpass_core_cc_sc7180_driver); } -module_exit(lpass_core_cc_sc7180_exit); +module_exit(lpass_sc7180_exit); MODULE_DESCRIPTION("QTI LPASS_CORE_CC SC7180 Driver"); MODULE_LICENSE("GPL v2"); From patchwork Wed Oct 14 21:05:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 11838427 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC33C14B5 for ; Thu, 15 Oct 2020 02:00:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 959AB22257 for ; Thu, 15 Oct 2020 02:00:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="oVDjvWnu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732497AbgJOB7h (ORCPT ); Wed, 14 Oct 2020 21:59:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732483AbgJOB7h (ORCPT ); Wed, 14 Oct 2020 21:59:37 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E58CAC0613E8 for ; Wed, 14 Oct 2020 14:13:33 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id p21so463615pju.0 for ; Wed, 14 Oct 2020 14:13:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UCnQG1cBhMq8sAEfp9YHwGGr20fDNSgoS19LMKh/BP8=; b=oVDjvWnuq1U6NeeWwlpTVoVBHcOhNPJwfmQuSij8FuzR03FnSwtAezNIrY+JS2xK5K vIb0Io2w7OqoXINqo7E/25Yms26wCE/zJN/L2M5fDt9uyO2JDS5vEbtJl75H4FMnamKt Asoyph0LcVWoPqpHLQfb/wtylUabh0MDV14NU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UCnQG1cBhMq8sAEfp9YHwGGr20fDNSgoS19LMKh/BP8=; b=QCG0TlDkZfKmfjjA82MHYmO3LSZGE6pIc9m0jU1aNBLA0LvP30uq0b90/O3671yTXB vHlnEpe/LwM4Sbi6+VziiMrp0HFPwuyPatoZ8mOrjvWM75WzwatiE6lS1LJ3LIWbPFD+ xNxNYuJgR1iIqrCzbWefwbxXDL1WeVQFDrAH8i55cjg8J7HANBQb3I2Gr3BxY8zoXh8O qQwh84i5eOX8r/aDQc5llJ5r8OtcHKGpzjtedOtGbnCx4UjBQd4hWBUFwvHcUjR4mzqE mlxGLwI5KRAuP/TtSVBags6gFEmUlkUK/SsJo+FioFciTFqrNaPuwXYFzdN1sydBa/8Q M2Fw== X-Gm-Message-State: AOAM531igWFuhjD+7usUhwmTdmf/o02EuzXGkgCzX4dT8VfdC51k+1ZJ lJiCVIPjbaRJ+XtbAc9uHVOZpLyLv5Lz0Q== X-Google-Smtp-Source: ABdhPJzmnhmXwPmAM9QvkGG3hYxCXL8UxTqQTC8Zzu5uRBiRSDcAniSEJ0ogn4kjvYagyoaJx+ixeQ== X-Received: by 2002:a17:90b:128f:: with SMTP id fw15mr1013609pjb.107.1602710013501; Wed, 14 Oct 2020 14:13:33 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id p19sm517713pfn.204.2020.10.14.14.13.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 14:13:32 -0700 (PDT) From: Douglas Anderson To: Stephen Boyd Cc: Taniya Das , linux-soc@vger.kernel.org, David Brown , Rajendra Nayak , Douglas Anderson , Andy Gross , Bjorn Andersson , Michael Turquette , linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/3] clk: qcom: lpasscc-sc7180: Re-configure the PLL in case lost Date: Wed, 14 Oct 2020 14:05:23 -0700 Message-Id: <20201014140507.v3.3.Id0cc5d859e2422082a29a7909658932c857f5a81@changeid> X-Mailer: git-send-email 2.28.0.1011.ga647a8990f-goog In-Reply-To: <20201014140507.v3.1.I4567b5e7e17bbb15ef063d447cb83fd43746cb18@changeid> References: <20201014140507.v3.1.I4567b5e7e17bbb15ef063d447cb83fd43746cb18@changeid> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Taniya Das In the case where the PLL configuration is lost, then the pm runtime resume will reconfigure before usage. Fixes: edab812d802d ("clk: qcom: lpass: Add support for LPASS clock controller for SC7180") Signed-off-by: Taniya Das Signed-off-by: Douglas Anderson --- Changes in v3: - Now based on a series which disentangles the two clock devices. - Use dev_get_regmap(). - Better comment about reading PLL_L_VAL. Changes in v2: - Don't needlessly have a 2nd copy of dev_pm_ops and jam it in. - Check the return value of pm_clk_resume() - l_val should be unsigned int. drivers/clk/qcom/lpasscorecc-sc7180.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/clk/qcom/lpasscorecc-sc7180.c b/drivers/clk/qcom/lpasscorecc-sc7180.c index 48d370e2108e..e12d4c2b1b70 100644 --- a/drivers/clk/qcom/lpasscorecc-sc7180.c +++ b/drivers/clk/qcom/lpasscorecc-sc7180.c @@ -388,6 +388,25 @@ static int lpass_create_pm_clks(struct platform_device *pdev) return ret; } +static int lpass_core_cc_pm_clk_resume(struct device *dev) +{ + struct regmap *regmap = dev_get_regmap(dev, "lpass_core_cc"); + unsigned int l_val; + int ret; + + ret = pm_clk_resume(dev); + if (ret) + return ret; + + /* If PLL_L_VAL was cleared then we should re-init the whole PLL */ + regmap_read(regmap, 0x1004, &l_val); + if (!l_val) + clk_fabia_pll_configure(&lpass_lpaaudio_dig_pll, regmap, + &lpass_lpaaudio_dig_pll_config); + + return 0; +} + static int lpass_core_cc_sc7180_probe(struct platform_device *pdev) { const struct qcom_cc_desc *desc; @@ -457,7 +476,7 @@ static const struct of_device_id lpass_core_cc_sc7180_match_table[] = { MODULE_DEVICE_TABLE(of, lpass_core_cc_sc7180_match_table); static const struct dev_pm_ops lpass_core_cc_pm_ops = { - SET_RUNTIME_PM_OPS(pm_clk_suspend, pm_clk_resume, NULL) + SET_RUNTIME_PM_OPS(pm_clk_suspend, lpass_core_cc_pm_clk_resume, NULL) }; static struct platform_driver lpass_core_cc_sc7180_driver = {