From patchwork Thu Oct 15 00:13:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 11838377 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 7239E15E6 for ; Thu, 15 Oct 2020 01:29:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 501022225C for ; Thu, 15 Oct 2020 01:29:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="n/pQVtSF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388736AbgJOB3x (ORCPT ); Wed, 14 Oct 2020 21:29:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388164AbgJOB3k (ORCPT ); Wed, 14 Oct 2020 21:29:40 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5746EC00216D for ; Wed, 14 Oct 2020 17:13:42 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id az3so685400pjb.4 for ; Wed, 14 Oct 2020 17:13:42 -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=hBFR7u8W8fPpDczYmcT6Q2hEHSshZFLSX2fbsmOIlpQ=; b=n/pQVtSFE+LJjmQRstcLPkZjAGTvZ7Sx7qtn5LnWRNUKysjkdlErRGmFk4phHthqy4 JsAXYWX+8KG2JR/8WgZv7HJCvIJi9lPSguqFgnzMSCKDEKG+XQDgFRWxxO8DLT6yXKyJ yXvwlmlG14RP/HAdMdQfEmbUL1NivqyiE927o= 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=hBFR7u8W8fPpDczYmcT6Q2hEHSshZFLSX2fbsmOIlpQ=; b=pPIY9A0r2smhBOP/JcDJ0PmZlExRQPCswx8XWzYHtRPR1CLBXQ1Eb0tVoFfK9sKzoz cwqa2l3VOsDSI7FnbqOo2UbZptnRU31INDuV8690y9tZuTFCivVS8nJhsVUS2XPtfD2f sVs7v6wb6z0nsQ5Ft6af2+iT1knFtnBmCc9dG71ea4qwgiDFk1HJIOmXzP3tV7HSNMyK fAoly6uGbEoD/4rBrDdunrdcab9ghYY82sbk8ZX8g3CT+qT2F/S1cXLBWOX2n3wgeH/f 7+1tEu+XcvaOiWSpakawwOzY6oExGwRqMh87ILCPn7eMQyX5ZkPoRRDBFELzb/PZPpeP mOfg== X-Gm-Message-State: AOAM5303hQ2C0u+jSX/zltvUlSOYMEKl/Ygx7ifuZ277iTQf52iWkqpN QH6knrinuOINnPujo5TjVfmibA== X-Google-Smtp-Source: ABdhPJwZKwgdYs33EhxkHoKhaR+nWFMYZa6zx28QW3oi0Ys5vVbHJembzqd3BtHXegYNTTaZZBelIg== X-Received: by 2002:a17:90a:fa48:: with SMTP id dt8mr1641953pjb.108.1602720821925; Wed, 14 Oct 2020 17:13:41 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id r16sm726485pjo.19.2020.10.14.17.13.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 17:13:41 -0700 (PDT) From: Douglas Anderson To: Stephen Boyd Cc: David Brown , Taniya Das , linux-soc@vger.kernel.org, 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 v4 1/3] clk: qcom: lpasscc-sc7810: Use devm in probe Date: Wed, 14 Oct 2020 17:13:27 -0700 Message-Id: <20201014171259.v4.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-clk@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 v4: - Fixed typo lapss => lpass - Moved lpass_pm_runtime_disable() lpass_pm_clk_destroy() in file. 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..2d15e33ec837 100644 --- a/drivers/clk/qcom/lpasscorecc-sc7180.c +++ b/drivers/clk/qcom/lpasscorecc-sc7180.c @@ -356,6 +356,16 @@ 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 lpass_pm_clk_destroy(void *data) +{ + pm_clk_destroy(data); +} + static int lpass_core_cc_sc7180_probe(struct platform_device *pdev) { const struct qcom_cc_desc *desc; @@ -418,34 +428,28 @@ static int lpass_core_sc7180_probe(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) - goto disable_pm_runtime; + return ret; + ret = devm_add_action_or_reset(&pdev->dev, lpass_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 Thu Oct 15 00:13:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 11838381 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 D9FF715E6 for ; Thu, 15 Oct 2020 01:30:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B0E9522258 for ; Thu, 15 Oct 2020 01:30:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Vk9W4Mlu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732247AbgJOB3i (ORCPT ); Wed, 14 Oct 2020 21:29:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732227AbgJOB3h (ORCPT ); Wed, 14 Oct 2020 21:29:37 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB2FDC0D9425 for ; Wed, 14 Oct 2020 17:13:43 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id d23so579773pll.7 for ; Wed, 14 Oct 2020 17:13:43 -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=UlbiRK9FPIASJdWjbFlxZN7JKEjeG321ukcvNxoIW+Y=; b=Vk9W4Mlu++ARKTCbhumJfJo840Ddq86v5pd4GoUMiZ/jn8R87NXlQrqOw7qIIGNcXt fU1NlnVPlWdNDyyJJCP2gdIg/b1Y1ZHCDcU5ZC6iCuS+ZRcexPofZIeE4cKqhzUFoJJW zRJktZcKqenkCO26pNfD4jRlhToWAoJ2wJrMs= 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=UlbiRK9FPIASJdWjbFlxZN7JKEjeG321ukcvNxoIW+Y=; b=D63o195Ymp+eCElC/VEjgNhS+E4eKIb+CAKpBm6eKTp4fNdEdRqTEHeWOulMQ1kkiB HsUZP+ALumK1Wv5HsIrKVfZk4wj5eRJa/bU/diXpNVuPGz9OsHulV4YpKu8j5as3UAKn 0m/StGucBmO5LJA7YsETVxaS+j4o6V1fyqAoXfCLfsf4nk4TcZGT8+bjDl27GZJ1O6gQ FV8e7FzNZizDXsU0TAYOJlzenVS3RtI6FJmt5iNbmGfqh0APgXNLVGyuog9Ihs8Nb8JC LejQltYyDtIdiMekDvO8sDcuutZzW2Pim2jM4SOouDNmVBBqXgenTtuICFiCCYSQEqn8 g5HQ== X-Gm-Message-State: AOAM5309J6d3cV/IhuHI1R89RRao6Z0yaTfaQ++oCDlp97xyNPHtMwWS HQIprc9BbkPiFKJmMJbibGTzrQ== X-Google-Smtp-Source: ABdhPJzUyM8QxDdPbJVsk13aEs2SgZMLJmPvtbxWE6eGgQv8WrXmx97oZcbONE04yikGH3baniEedg== X-Received: by 2002:a17:90a:8c17:: with SMTP id a23mr1625454pjo.112.1602720823467; Wed, 14 Oct 2020 17:13:43 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id r16sm726485pjo.19.2020.10.14.17.13.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 17:13:42 -0700 (PDT) From: Douglas Anderson To: Stephen Boyd Cc: David Brown , Taniya Das , linux-soc@vger.kernel.org, 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 v4 2/3] clk: qcom: lpass-sc7180: Disentangle the two clock devices Date: Wed, 14 Oct 2020 17:13:28 -0700 Message-Id: <20201014171259.v4.2.I75c409497d4dea9daefa53ec5f93824081c4ecbe@changeid> X-Mailer: git-send-email 2.28.0.1011.ga647a8990f-goog In-Reply-To: <20201014171259.v4.1.I4567b5e7e17bbb15ef063d447cb83fd43746cb18@changeid> References: <20201014171259.v4.1.I4567b5e7e17bbb15ef063d447cb83fd43746cb18@changeid> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-clk@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 --- (no changes since v3) Changes in v3: - ("clk: qcom: lpass-sc7180: Disentangle the two clock devices") new for v3. drivers/clk/qcom/lpasscorecc-sc7180.c | 101 ++++++++++++++++---------- 1 file changed, 62 insertions(+), 39 deletions(-) diff --git a/drivers/clk/qcom/lpasscorecc-sc7180.c b/drivers/clk/qcom/lpasscorecc-sc7180.c index 2d15e33ec837..4ed766ca08bb 100644 --- a/drivers/clk/qcom/lpasscorecc-sc7180.c +++ b/drivers/clk/qcom/lpasscorecc-sc7180.c @@ -366,12 +366,38 @@ static void lpass_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, lpass_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); @@ -402,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; @@ -409,55 +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 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, lpass_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 Thu Oct 15 00:13:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 11838373 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 EA79914B5 for ; Thu, 15 Oct 2020 01:29:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C3B0622257 for ; Thu, 15 Oct 2020 01:29:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="TE8dv7eT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732228AbgJOB3j (ORCPT ); Wed, 14 Oct 2020 21:29:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732227AbgJOB3j (ORCPT ); Wed, 14 Oct 2020 21:29:39 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CBAEC0F26CE for ; Wed, 14 Oct 2020 17:13:45 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id y14so674086pgf.12 for ; Wed, 14 Oct 2020 17:13:45 -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=BqRdEIfaW1cSjL9M5tOy5HvQpahMFQmaQASv402ubfE=; b=TE8dv7eTCHypqfsa/XxveRdbShZgYmuGPccz20vGOOCcT4WqLHhp7KGORzYLtv7jJd FcXWgFMQKdjgc4217Axx7WNbh9d6skIQpvMd5AOGeDimPY7B4hSclIa6OMroQar1XjYH lxymnJ0kaRge07OjRg3HGukXkWH9wWawNmAWQ= 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=BqRdEIfaW1cSjL9M5tOy5HvQpahMFQmaQASv402ubfE=; b=p0RKC0bgHwNfO/u06pvFLFwLuztQXnOnlS9A1SL5NVSejSC++j8LwmpVPUTu8uYSru HNXzysKslydR6gq0b80pDO60ggFbzudS4fx8lN1oCD0knNlWPlperBudTHAtUMKQljuP HnxDQW93OnAYkdh90NQm9+dhW42uDM7NSAWLS3h7fdEUL1QsHaZ0GWduqit1sOhtT+vJ 6F6T7wiR7X55aqLROcyAv/kppdx5vi+GbbpBmDeRJLPIlIiLiAGzjsp1lUbJMRzM0eJq JzpmaWGMsSUh1PbFGZeaGXHfpyjE7OlpqhXCwypkDlngr9ue+wTp83gLC6xs8b8jKMw6 vlGg== X-Gm-Message-State: AOAM533nZg7nN7setjoG27rVcQyNOH3QjCD6jQF4uLOiaem9+ogYg9Np agJITnGvkI5X/Qx2OtkRuRbZhw== X-Google-Smtp-Source: ABdhPJyq2aRyoyAEO/ytsdUTIC9Ptwmc8zbbHavJW1I1k8IE+039pcPqcMP+EGTV5Y6cas/Trqym2Q== X-Received: by 2002:a63:d008:: with SMTP id z8mr1127511pgf.357.1602720825012; Wed, 14 Oct 2020 17:13:45 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:42b0:34ff:fe3d:58e6]) by smtp.gmail.com with ESMTPSA id r16sm726485pjo.19.2020.10.14.17.13.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Oct 2020 17:13:44 -0700 (PDT) From: Douglas Anderson To: Stephen Boyd Cc: David Brown , Taniya Das , linux-soc@vger.kernel.org, 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 v4 3/3] clk: qcom: lpasscc-sc7180: Re-configure the PLL in case lost Date: Wed, 14 Oct 2020 17:13:29 -0700 Message-Id: <20201014171259.v4.3.Id0cc5d859e2422082a29a7909658932c857f5a81@changeid> X-Mailer: git-send-email 2.28.0.1011.ga647a8990f-goog In-Reply-To: <20201014171259.v4.1.I4567b5e7e17bbb15ef063d447cb83fd43746cb18@changeid> References: <20201014171259.v4.1.I4567b5e7e17bbb15ef063d447cb83fd43746cb18@changeid> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-clk@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 v4: - Put regmap names in "static const char *" globals. 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 | 28 ++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/drivers/clk/qcom/lpasscorecc-sc7180.c b/drivers/clk/qcom/lpasscorecc-sc7180.c index 4ed766ca08bb..d7586858760c 100644 --- a/drivers/clk/qcom/lpasscorecc-sc7180.c +++ b/drivers/clk/qcom/lpasscorecc-sc7180.c @@ -21,6 +21,9 @@ #include "common.h" #include "gdsc.h" +static const char *lpass_audio_cc_regmap_name = "lpass_audio_cc"; +static const char *lpass_core_cc_regmap_name = "lpass_core_cc"; + enum { P_BI_TCXO, P_LPASS_LPAAUDIO_DIG_PLL_OUT_ODD, @@ -388,6 +391,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_regmap_name); + 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; @@ -398,13 +420,13 @@ static int lpass_core_cc_sc7180_probe(struct platform_device *pdev) if (ret) return ret; - lpass_core_cc_sc7180_regmap_config.name = "lpass_audio_cc"; + lpass_core_cc_sc7180_regmap_config.name = lpass_audio_cc_regmap_name; desc = &lpass_audio_hm_sc7180_desc; ret = qcom_cc_probe_by_index(pdev, 1, desc); if (ret) return ret; - lpass_core_cc_sc7180_regmap_config.name = "lpass_core_cc"; + lpass_core_cc_sc7180_regmap_config.name = lpass_core_cc_regmap_name; regmap = qcom_cc_map(pdev, &lpass_core_cc_sc7180_desc); if (IS_ERR(regmap)) return PTR_ERR(regmap); @@ -457,7 +479,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 = {