[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210517033705.uw5kfj46k6w6ptcl@vireshk-i7>
Date: Mon, 17 May 2021 09:07:05 +0530
From: Viresh Kumar <viresh.kumar@...aro.org>
To: Dmitry Osipenko <digetx@...il.com>
Cc: Thierry Reding <thierry.reding@...il.com>,
Jonathan Hunter <jonathanh@...dia.com>,
Paul Fertser <fercerpav@...il.com>,
Matt Merhar <mattmerhar@...tonmail.com>,
Peter Geis <pgwipeout@...il.com>,
Nicolas Chauvet <kwizart@...il.com>,
Viresh Kumar <vireshk@...nel.org>,
Stephen Boyd <sboyd@...nel.org>,
Krzysztof Kozlowski <krzk@...nel.org>,
linux-tegra@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 1/1] soc/tegra: Add
devm_tegra_core_dev_init_opp_table()
I am not sure why you divided this into three different patchsets,
while it should really have been one. Like this one just adds the API
but doesn't use it.
On 16-05-21, 23:51, Dmitry Osipenko wrote:
> Add common helper which initializes OPP table for Tegra SoC core devices.
>
> Tested-by: Peter Geis <pgwipeout@...il.com> # Ouya T30
> Tested-by: Paul Fertser <fercerpav@...il.com> # PAZ00 T20
> Tested-by: Nicolas Chauvet <kwizart@...il.com> # PAZ00 T20 and TK1 T124
> Tested-by: Matt Merhar <mattmerhar@...tonmail.com> # Ouya T30
> Signed-off-by: Dmitry Osipenko <digetx@...il.com>
> ---
> drivers/soc/tegra/common.c | 112 +++++++++++++++++++++++++++++++++++++
> include/soc/tegra/common.h | 30 ++++++++++
> 2 files changed, 142 insertions(+)
>
> diff --git a/drivers/soc/tegra/common.c b/drivers/soc/tegra/common.c
> index 3dc54f59cafe..c3fd2facfc2d 100644
> --- a/drivers/soc/tegra/common.c
> +++ b/drivers/soc/tegra/common.c
> @@ -3,9 +3,16 @@
> * Copyright (C) 2014 NVIDIA CORPORATION. All rights reserved.
> */
>
> +#define dev_fmt(fmt) "tegra-soc: " fmt
> +
> +#include <linux/clk.h>
> +#include <linux/device.h>
> +#include <linux/export.h>
> #include <linux/of.h>
> +#include <linux/pm_opp.h>
>
> #include <soc/tegra/common.h>
> +#include <soc/tegra/fuse.h>
>
> static const struct of_device_id tegra_machine_match[] = {
> { .compatible = "nvidia,tegra20", },
> @@ -31,3 +38,108 @@ bool soc_is_tegra(void)
>
> return match != NULL;
> }
> +
> +static int tegra_core_dev_init_opp_state(struct device *dev)
> +{
> + struct dev_pm_opp *opp;
> + unsigned long rate;
> + struct clk *clk;
> + int err;
> +
> + clk = devm_clk_get(dev, NULL);
> + if (IS_ERR(clk)) {
> + dev_err(dev, "failed to get clk: %pe\n", clk);
> + return PTR_ERR(clk);
> + }
> +
> + rate = clk_get_rate(clk);
> + if (!rate) {
> + dev_err(dev, "failed to get clk rate\n");
> + return -EINVAL;
> + }
> +
> + opp = dev_pm_opp_find_freq_ceil(dev, &rate);
> +
> + if (opp == ERR_PTR(-ERANGE))
> + opp = dev_pm_opp_find_freq_floor(dev, &rate);
> +
> + err = PTR_ERR_OR_ZERO(opp);
> + if (err) {
> + dev_err(dev, "failed to get OPP for %ld Hz: %d\n",
> + rate, err);
> + return err;
> + }
Why do you need to do this floor/ceil thing? Why can't you simply do
set-rate ?
> +
> + dev_pm_opp_put(opp);
> +
> + /* first dummy rate-setting initializes voltage vote */
> + err = dev_pm_opp_set_rate(dev, rate);
> + if (err) {
> + dev_err(dev, "failed to initialize OPP clock: %d\n", err);
> + return err;
> + }
> +
> + return 0;
> +}
--
viresh
Powered by blists - more mailing lists