diff mbox

[v3,2/2] cpufreq: qoriq: Don't look at clock implementation details

Message ID DB6PR0402MB2837F79AC0E88F5FAEEDB823F0400@DB6PR0402MB2837.eurprd04.prod.outlook.com (mailing list archive)
State Not Applicable, archived
Delegated to: Stephen Boyd
Headers show

Commit Message

tang yuantian Feb. 6, 2017, 6:12 a.m. UTC
> -----Original Message-----
> From: Leo Li [mailto:pku.leo@gmail.com]
> Sent: Friday, February 03, 2017 2:12 AM
> To: Y.T. Tang <yuantian.tang@nxp.com>
> Cc: Scott Wood <oss@buserror.net>; Michael Turquette
> <mturquette@baylibre.com>; Russell King <linux@armlinux.org.uk>;
> Stephen Boyd <sboyd@codeaurora.org>; Viresh Kumar
> <viresh.kumar@linaro.org>; Rafael J. Wysocki <rjw@rjwysocki.net>; linux-
> clk@vger.kernel.org; linux-pm@vger.kernel.org; linuxppc-
> dev@lists.ozlabs.org; Leo Li <leoyang.li@nxp.com>; X.F. Ren
> <xiaofeng.ren@nxp.com>
> Subject: Re: [PATCH v3 2/2] cpufreq: qoriq: Don't look at clock
> implementation details
> 
> On Tue, Jul 19, 2016 at 10:02 PM, Yuantian Tang <yuantian.tang@nxp.com>
> wrote:
> >
> > PING.
> >
> > Regards,
> > Yuantian
> >
> > > -----Original Message-----
> > > From: Scott Wood [mailto:oss@buserror.net]
> > > Sent: Saturday, July 09, 2016 5:07 AM
> > > To: Michael Turquette <mturquette@baylibre.com>; Russell King
> > > <linux@armlinux.org.uk>; Stephen Boyd <sboyd@codeaurora.org>;
> Viresh
> > > Kumar <viresh.kumar@linaro.org>; Rafael J. Wysocki
> > > <rjw@rjwysocki.net>
> > > Cc: linux-clk@vger.kernel.org; linux-pm@vger.kernel.org; linuxppc-
> > > dev@lists.ozlabs.org; Yuantian Tang <yuantian.tang@nxp.com>;
> > > Yang-Leo Li <leoyang.li@nxp.com>; Xiaofeng Ren
> > > <xiaofeng.ren@nxp.com>
> > > Subject: Re: [PATCH v3 2/2] cpufreq: qoriq: Don't look at clock
> > > implementation details
> > >
> > > On Thu, 2016-07-07 at 19:26 -0700, Michael Turquette wrote:
> > > > Quoting Scott Wood (2016-07-06 21:13:23)
> > > > >
> > > > > On Wed, 2016-07-06 at 18:30 -0700, Michael Turquette wrote:
> > > > > >
> > > > > > Quoting Scott Wood (2016-06-15 23:21:25)
> > > > > > >
> > > > > > >
> > > > > > > -static struct device_node *cpu_to_clk_node(int cpu)
> > > > > > > +static struct clk *cpu_to_clk(int cpu)
> > > > > > >  {
> > > > > > > -       struct device_node *np, *clk_np;
> > > > > > > +       struct device_node *np;
> > > > > > > +       struct clk *clk;
> > > > > > >
> > > > > > >         if (!cpu_present(cpu))
> > > > > > >                 return NULL; @@ -112,37 +80,28 @@ static
> > > > > > > struct device_node *cpu_to_clk_node(int
> > > > > > > cpu)
> > > > > > >         if (!np)
> > > > > > >                 return NULL;
> > > > > > >
> > > > > > > -       clk_np = of_parse_phandle(np, "clocks", 0);
> > > > > > > -       if (!clk_np)
> > > > > > > -               return NULL;
> > > > > > > -
> > > > > > > +       clk = of_clk_get(np, 0);
> > > > > > Why not use devm_clk_get here?
> > > > > devm_clk_get() is a wrapper around clk_get() which is not the
> > > > > same as of_clk_get().  What device would you pass to
> > > > > devm_clk_get(), and what name would you pass?
> > > > I'm fuzzy on whether or not you get a struct device from a cpufreq
> > > > driver. If so, then that would be the one to use. I would hope
> > > > that cpufreq drivers model cpus as devices, but I'm really not
> > > > sure without looking into the code.
> > >
> > > It's not the cpufreq code that provides it, but get_cpu_device()
> > > could be used.
> > >
> > > Do you have any comments on the first patch of this set?
> 
> 
> Any action on this patch?  This patch is still a dependency for cpufreq to work
> on all QorIQ platforms.
> 
This patch can be accepted on condition that the attached patch is accepted.
But unfortunately, the attached patch has been sent for a really long time and no feedback.

Regards,
Yuantian

> Regards,
> Leo
From: Scott Wood <scottwood@freescale.com>

Commit fc4a05d4b0eb ("clk: Remove unused provider APIs") removed
__clk_get_num_parents() and clk_hw_get_parent_by_index(), leaving only
true provider API versions that operate on struct clk_hw.

qoriq-cpufreq needs these functions in order to determine the options
it has for calling clk_set_parent() and thus populate the cpufreq
table, so revive them as legitimate consumer APIs.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
Previously sent as http://patchwork.ozlabs.org/patch/519803/

Russell, could you please either ACK this or comment, as CLK API
maintainer?

 drivers/clk/clk.c   | 19 +++++++++++++++++++
 include/linux/clk.h | 31 +++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)

--
2.5.0
diff mbox

Patch

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index d584004..d61a3fe 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -290,6 +290,12 @@  struct clk_hw *__clk_get_hw(struct clk *clk)
 }
 EXPORT_SYMBOL_GPL(__clk_get_hw);

+unsigned int clk_get_num_parents(struct clk *clk)
+{
+       return !clk ? 0 : clk->core->num_parents;
+}
+EXPORT_SYMBOL_GPL(clk_get_num_parents);
+
 unsigned int clk_hw_get_num_parents(const struct clk_hw *hw)
 {
        return hw->core->num_parents;
@@ -358,6 +364,19 @@  static struct clk_core *clk_core_get_parent_by_index(struct clk_core *core,
        return core->parents[index];
 }

+struct clk *clk_get_parent_by_index(struct clk *clk, unsigned int index)
+{
+       struct clk_core *parent;
+
+       if (!clk)
+               return NULL;
+
+       parent = clk_core_get_parent_by_index(clk->core, index);
+
+       return !parent ? NULL : parent->hw->clk;
+}
+EXPORT_SYMBOL_GPL(clk_get_parent_by_index);
+
 struct clk_hw *
 clk_hw_get_parent_by_index(const struct clk_hw *hw, unsigned int index)
 {
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 0df4a51..937de0e 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -392,6 +392,26 @@  int clk_set_parent(struct clk *clk, struct clk *parent);
 struct clk *clk_get_parent(struct clk *clk);

 /**
+ * clk_get_parent_by_index - get a possible parent clock by index
+ * @clk: clock source
+ * @index: index into the array of possible parents of this clock
+ *
+ * Returns struct clk corresponding to the requested possible
+ * parent clock source, or NULL.
+ */
+struct clk *clk_get_parent_by_index(struct clk *clk,
+                                   unsigned int index);
+
+/**
+ * clk_get_num_parents - get number of possible parents
+ * @clk: clock source
+ *
+ * Returns the number of possible parents of this clock,
+ * which can then be enumerated using clk_get_parent_by_index().
+ */
+unsigned int clk_get_num_parents(struct clk *clk);
+
+/**
  * clk_get_sys - get a clock based upon the device name
  * @dev_id: device name
  * @con_id: connection ID
@@ -461,6 +481,17 @@  static inline struct clk *clk_get_parent(struct clk *clk)
        return NULL;
 }

+struct clk *clk_get_parent_by_index(struct clk *clk,
+                                   unsigned int index)
+{
+       return NULL;
+}
+
+unsigned int clk_get_num_parents(struct clk *clk)
+{
+       return 0;
+}
+
 #endif

 /* clk_prepare_enable helps cases using clk_enable in non-atomic context. */