From: Matthias Kaehlcke <mka@chromium.org>
To: Rajendra Nayak <rnayak@codeaurora.org>
Cc: viresh.kumar@linaro.org, sboyd@kernel.org,
bjorn.andersson@linaro.org, agross@kernel.org,
linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, Mark Brown <broonie@kernel.org>,
Alok Chauhan <alokc@codeaurora.org>,
Akash Asthana <akashast@codeaurora.org>,
linux-spi@vger.kernel.org
Subject: Re: [PATCH v3 02/17] spi: spi-geni-qcom: Use OPP API to set clk/perf state
Date: Tue, 28 Apr 2020 16:04:20 -0700 [thread overview]
Message-ID: <20200428230420.GJ4525@google.com> (raw)
In-Reply-To: <1588080785-6812-3-git-send-email-rnayak@codeaurora.org>
On Tue, Apr 28, 2020 at 07:02:50PM +0530, Rajendra Nayak wrote:
> geni spi needs to express a perforamnce state requirement on CX
> depending on the frequency of the clock rates. Use OPP table from
> DT to register with OPP framework and use dev_pm_opp_set_rate() to
> set the clk/perf state.
>
> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
> Cc: Mark Brown <broonie@kernel.org>
> Cc: Alok Chauhan <alokc@codeaurora.org>
> Cc: Akash Asthana <akashast@codeaurora.org>
> Cc: linux-spi@vger.kernel.org
> ---
> This patch has a dependency on the 'PATCH 01/17' in this series,
> due to the changes in include/linux/qcom-geni-se.h
> Its ideal if this and the previous patch gets merged via the
> msm tree (once reviewed and ack'ed)
> Greg has already responded he is fine with it for serial.
>
> drivers/spi/spi-geni-qcom.c | 26 +++++++++++++++++++++++---
> 1 file changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c
> index c397242..51186c3 100644
> --- a/drivers/spi/spi-geni-qcom.c
> +++ b/drivers/spi/spi-geni-qcom.c
> @@ -7,6 +7,7 @@
> #include <linux/log2.h>
> #include <linux/module.h>
> #include <linux/platform_device.h>
> +#include <linux/pm_opp.h>
> #include <linux/pm_runtime.h>
> #include <linux/qcom-geni-se.h>
> #include <linux/spi/spi.h>
> @@ -95,7 +96,6 @@ static int get_spi_clk_cfg(unsigned int speed_hz,
> {
> unsigned long sclk_freq;
> unsigned int actual_hz;
> - struct geni_se *se = &mas->se;
> int ret;
>
> ret = geni_se_clk_freq_match(&mas->se,
> @@ -112,9 +112,9 @@ static int get_spi_clk_cfg(unsigned int speed_hz,
>
> dev_dbg(mas->dev, "req %u=>%u sclk %lu, idx %d, div %d\n", speed_hz,
> actual_hz, sclk_freq, *clk_idx, *clk_div);
> - ret = clk_set_rate(se->clk, sclk_freq);
> + ret = dev_pm_opp_set_rate(mas->dev, sclk_freq);
> if (ret)
> - dev_err(mas->dev, "clk_set_rate failed %d\n", ret);
> + dev_err(mas->dev, "dev_pm_opp_set_rate failed %d\n", ret);
> return ret;
> }
>
> @@ -561,6 +561,17 @@ static int spi_geni_probe(struct platform_device *pdev)
> mas->se.wrapper = dev_get_drvdata(dev->parent);
> mas->se.base = base;
> mas->se.clk = clk;
> + mas->se.opp_table = dev_pm_opp_set_clkname(&pdev->dev, "se");
> + if (IS_ERR(mas->se.opp_table))
> + return PTR_ERR(mas->se.opp_table);
> + /* OPP table is optional */
> + ret = dev_pm_opp_of_add_table(&pdev->dev);
> + if (!ret) {
> + mas->se.has_opp_table = true;
> + } else if (ret != -ENODEV) {
> + dev_err(&pdev->dev, "Invalid OPP table in Device tree\n");
> + return ret;
> + }
>
> spi->bus_num = -1;
> spi->dev.of_node = dev->of_node;
> @@ -596,6 +607,9 @@ static int spi_geni_probe(struct platform_device *pdev)
> spi_geni_probe_runtime_disable:
> pm_runtime_disable(dev);
> spi_master_put(spi);
> + if (mas->se.has_opp_table)
> + dev_pm_opp_of_remove_table(&pdev->dev);
> + dev_pm_opp_put_clkname(mas->se.opp_table);
> return ret;
> }
>
> @@ -604,6 +618,9 @@ static int spi_geni_remove(struct platform_device *pdev)
> struct spi_master *spi = platform_get_drvdata(pdev);
> struct spi_geni_master *mas = spi_master_get_devdata(spi);
>
> + if (mas->se.has_opp_table)
> + dev_pm_opp_of_remove_table(&pdev->dev);
> + dev_pm_opp_put_clkname(mas->se.opp_table);
> /* Unregister _before_ disabling pm_runtime() so we stop transfers */
> spi_unregister_master(spi);
>
> @@ -617,6 +634,9 @@ static int __maybe_unused spi_geni_runtime_suspend(struct device *dev)
> struct spi_master *spi = dev_get_drvdata(dev);
> struct spi_geni_master *mas = spi_master_get_devdata(spi);
>
> + /* Drop the performance state vote */
> + dev_pm_opp_set_rate(dev, 0);
> +
> return geni_se_resources_off(&mas->se);
> }
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
next prev parent reply other threads:[~2020-04-28 23:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1588080785-6812-1-git-send-email-rnayak@codeaurora.org>
2020-04-28 13:32 ` [PATCH v3 02/17] spi: spi-geni-qcom: Use OPP API to set clk/perf state Rajendra Nayak
2020-04-28 23:04 ` Matthias Kaehlcke [this message]
2020-04-28 13:33 ` [PATCH v3 15/17] spi: spi-qcom-qspi: " Rajendra Nayak
2020-04-29 0:49 ` Matthias Kaehlcke
2020-04-29 14:21 ` Rajendra Nayak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200428230420.GJ4525@google.com \
--to=mka@chromium.org \
--cc=agross@kernel.org \
--cc=akashast@codeaurora.org \
--cc=alokc@codeaurora.org \
--cc=bjorn.andersson@linaro.org \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=rnayak@codeaurora.org \
--cc=sboyd@kernel.org \
--cc=viresh.kumar@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).