From: Richard Zhao <richard.zhao@linaro.org>
To: "Turquette, Mike" <mturquette@ti.com>
Cc: <linux-arm-kernel@lists.infradead.org>, <paul@pwsan.com>,
<linaro-dev@lists.linaro.org>, <linus.walleij@stericsson.com>,
<patches@linaro.org>, <sboyd@quicinc.com>,
<broonie@opensource.wolfsonmicro.com>, <magnus.damm@gmail.com>,
<linux-kernel@vger.kernel.org>, <amit.kucheria@linaro.org>,
<grant.likely@secretlab.ca>, <dsaxena@linaro.org>,
<tglx@linutronix.de>, <eric.miao@linaro.org>,
<linux@arm.linux.org.uk>, <skannan@quicinc.com>,
<jeremy.kerr@canonical.com>, <shawn.guo@freescale.com>,
<arnd.bergmann@linaro.org>
Subject: Re: [PATCH v2 1/7] clk: Add a generic clock infrastructure
Date: Mon, 17 Oct 2011 19:31:51 +0800 [thread overview]
Message-ID: <20111017113150.GD20184@b20223-02.ap.freescale.net> (raw)
In-Reply-To: <CAJOA=zOvAV1f+rXP1jYNPOXAchyJPEEAvCdrNfGVg=iZn3Q3Ag@mail.gmail.com>
On Sun, Oct 16, 2011 at 02:17:29PM -0700, Turquette, Mike wrote:
> On Fri, Oct 14, 2011 at 7:24 PM, Richard Zhao <richard.zhao@linaro.org> wrote:
> > On Fri, Oct 14, 2011 at 11:14:19AM -0700, Turquette, Mike wrote:
> >> On Thu, Sep 22, 2011 at 3:26 PM, Mike Turquette <mturquette@ti.com> wrote:
> >> unsigned long omap_recalc_rate(struct clk_hw *hw)
> >> {
> >> struct clk *parent;
> >> struct clk_hw_omap *oclk;
> >>
> >> parent = hw->clk->parent;
> > clk drivers can not see struct clk details. I use clk_get_parent.
>
> clk_get_parent should query the hardware to see what the parent is.
> This can have undesireable overhead. It is quite acceptable to
> reference a clock's parent through clk->parent, just as it is
> acceptable to get a clock rate through clk->rate.
IMHO, we only need to get parent from hw at register/init time.
clk_get_parent can get it from cache, like current code.
>
> An analogous situation is a clk_get_rate call which uses a clk's
> .recalc. There is undesirable overhead involved in .recalc for clocks
> whose rates won't change behind our backs, so best to just treat the
> data in struct clk as cache and reference it directly.
>
> >> oclk = to_clk_omap(hw);
> >> ...
> >> }
> >>
> ...
> >>
> >> unsigned long omap_recalc_rate(struct clk *clk)
> >> {
> >> struct clk *parent;
> >> struct clk_hw_omap *oclk;
> >>
> >> parent = clk->parent;
> >> oclk = to_clk_omap(clk->hw);
> >> ...
> >> }
> > In my understanding, struct clk stores things specific to clk core,
> > struct clk_hw stores common things needed by clk drivers. For static clk driver
> > there' some problems:
> > - For clocks without mux, I need duplicate a .parent and set .get_parent.
> > Even when we adopt DT and dynamicly create clk, it's still a problem.
> > Moving .parent to clk_hw can fix it.
>
> For clocks with a fixed parent we should just pass it in at
> register-time. We should definitely not move .parent out of struct
> clk, since struct clk should be the platform agnostic bit that lets us
> do tree walks, build topology, etc etc.
>
> If you really want a .parent outside of struct clk then duplicate it
> in your struct clk_hw_imx
I don't have clk_hw_imx. I just use generic clks like clk_hw_gate, clk_hw_divider,
clk_hw_mux, and some specific clks.
> and teach your .ops about it (analogous to
> struct clk_hw_fixed->rate).
I have to define things like below:
stuct pair {
struct clk_hw *clk = clk_hw_gate.hw;
struct clk_hw_ops *ops;
};
and use for (.. ) to register the clk array.
>
> > - When I define a clk array, I don't need to find another place to store .ops.
> > It's not problem for dynamic creating clock.
>
> Something like the following?
>
> static struct clk aess_fclk;
>
> static const clk_hw_ops aess_fclk_ops = {
> .recalc = &omap2_clksel_recalc,
> .round_rate = &omap2_clksel_round_rate,
> .set_rate = &omap2_clksel_set_rate,
> };
>
> static struct clk_hw_omap aess_fclk_hw = {
> .hw = {
> .clk = &aess_fclk,
> },
> .clksel = &aess_fclk_div,
> .clksel_reg = OMAP4430_CM1_ABE_AESS_CLKCTRL,
> .clksel_mask = OMAP4430_CLKSEL_AESS_FCLK_MASK,
> };
>
> static struct clk aess_fclk = {
> .name = "aess_fclk",
> .ops = &aess_fclk_ops,
> .hw = &aess_fclk_hw.hw,
> .parent = &abe_clk,
> };
If we don't protect struct clk members, how about the below:
struct clk_hw_omap aess_fclk = {
.clk = {
.name = "aess_fclk",
.ops = &aess_fclk_ops,
.parent = &abe_clk,
};
.clksel = &aess_fclk_div,
.clksel_reg = OMAP4430_CM1_ABE_AESS_CLKCTRL,
.clksel_mask = OMAP4430_CLKSEL_AESS_FCLK_MASK,
};
>
> > - As I mentioned in another mail, clk group need no lock version prepare/unprepare
> > and enable/disable functions
>
> Clock groups are out of scope for this first series. We should
> discuss more what the needs are for your clock groups. If it boils
> down to just enabling all of the clocks for a given device then you
> might want to abstract that away with pm_runtime_* calls, and maybe a
> supplementary layer like OMAP's hwmod. But I might be way off base, I
> really don't understand your use case for clock groups.
clk group is clk function dependency. I talked about it in another email in this thread.
That's ok to leave it to other framework.
>
> > Another way is, add a "{struct clk_hw *clks; int count}" in clk_hw, let clk
> > core handle it.
> > I prefer the second way, but I'm not sure whether it's common enough. It's
> > still a problem for dynamic creating clock.
>
> struct clk_hw is just a pointer for navigating from struct clk ->
> struct your_custom_clk and vice versa. Again can you elaborate on
> your needs for managing multiple clocks with a single struct clk_hw?
>
> Thanks,
> Mike
>
> >
> > Thanks
> > Richard
> >>
> >> It is a small nitpick, but it affects the API for everybody so best to
> >> get it right now before folks start migrating over to it.
> >>
> >> Thanks,
> >> Mike
> >>
> >> > int (*set_rate)(struct clk_hw *,
> >> > unsigned long, unsigned long *);
> >> > long (*round_rate)(struct clk_hw *, unsigned long);
> >> > int (*set_parent)(struct clk_hw *, struct clk *);
> >> > struct clk * (*get_parent)(struct clk_hw *);
> >> > };
> >>
> >> _______________________________________________
> >> linux-arm-kernel mailing list
> >> linux-arm-kernel@lists.infradead.org
> >> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
> >>
> >
> >
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
next prev parent reply other threads:[~2011-10-17 11:32 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-22 22:26 [PATCH v2 0/7] Add a generic struct clk Mike Turquette
2011-09-22 22:26 ` [PATCH v2 1/7] clk: Add a generic clock infrastructure Mike Turquette
2011-09-25 3:55 ` Grant Likely
2011-09-25 5:26 ` Turquette, Mike
2011-10-03 14:17 ` Rob Herring
2011-10-03 14:25 ` Mark Brown
2011-10-03 15:24 ` Rob Herring
2011-10-03 16:31 ` Mark Brown
2011-10-03 16:43 ` Russell King - ARM Linux
2011-10-03 17:05 ` Mark Brown
2011-10-04 18:09 ` Grant Likely
2011-10-27 11:54 ` Domenico Andreoli
2011-10-03 22:02 ` Rob Herring
2011-10-03 22:15 ` Turquette, Mike
2011-10-06 1:17 ` Saravana Kannan
2011-10-06 16:11 ` Turquette, Mike
2011-10-11 11:25 ` Richard Zhao
2011-10-13 14:44 ` Russell King - ARM Linux
2011-10-13 17:16 ` Turquette, Mike
2011-10-14 8:10 ` Richard Zhao
2011-10-14 10:05 ` Mark Brown
2011-10-14 10:32 ` Richard Zhao
2011-10-16 17:55 ` Sascha Hauer
2011-10-17 8:48 ` Richard Zhao
2011-10-17 9:20 ` Mark Brown
2011-10-17 10:53 ` Richard Zhao
2011-10-17 11:05 ` Sascha Hauer
2011-10-17 11:30 ` Russell King - ARM Linux
2011-10-14 18:14 ` Turquette, Mike
2011-10-15 2:24 ` Richard Zhao
2011-10-15 2:34 ` Richard Zhao
2011-10-16 21:17 ` Turquette, Mike
2011-10-17 11:31 ` Richard Zhao [this message]
2011-10-21 9:00 ` Richard Zhao
2011-10-23 12:55 ` Shawn Guo
2011-10-23 16:49 ` Turquette, Mike
2011-09-22 22:26 ` [PATCH v2 2/7] clk: Implement clk_set_rate Mike Turquette
2011-10-11 11:49 ` Richard Zhao
2011-10-23 14:24 ` Shawn Guo
2011-10-23 16:50 ` Turquette, Mike
2011-09-22 22:26 ` [PATCH v2 3/7] clk: Add fixed-rate clock Mike Turquette
2011-10-23 14:30 ` Shawn Guo
2011-10-23 16:51 ` Turquette, Mike
2011-09-22 22:26 ` [PATCH v2 4/7] clk: Add simple gated clock Mike Turquette
2011-09-25 4:02 ` Grant Likely
2011-09-25 5:27 ` Turquette, Mike
2011-09-26 18:33 ` Rob Herring
2011-09-26 18:40 ` Jamie Iles
2011-09-26 19:10 ` Rob Herring
2011-09-26 19:37 ` Jamie Iles
2011-09-26 22:37 ` Turquette, Mike
2011-09-26 23:30 ` Rob Herring
2011-10-05 1:41 ` Saravana Kannan
2011-10-12 6:46 ` Richard Zhao
2011-10-12 14:59 ` Turquette, Mike
2011-10-16 18:26 ` Sascha Hauer
2011-10-17 6:42 ` Richard Zhao
2011-10-17 17:46 ` Turquette, Mike
2011-10-13 14:45 ` Russell King - ARM Linux
2011-10-13 17:18 ` Turquette, Mike
2011-09-22 22:27 ` [PATCH v2 5/7] clk: Add Kconfig option to build all generic clk drivers Mike Turquette
2011-09-22 22:27 ` [PATCH v2 6/7] clk: Add initial WM831x clock driver Mike Turquette
2011-09-25 4:08 ` Grant Likely
2011-09-25 5:29 ` Turquette, Mike
2011-09-26 9:38 ` Mark Brown
2011-10-04 18:18 ` Grant Likely
2011-10-04 20:50 ` Mark Brown
2011-10-04 23:22 ` Grant Likely
2011-09-22 22:27 ` [PATCH v2 7/7] x86: Enable generic clk API on x86 Mike Turquette
2011-09-22 23:17 ` [PATCH v2 0/7] Add a generic struct clk Turquette, Mike
2011-09-25 4:10 ` Grant Likely
2011-09-29 18:54 ` Mark Brown
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=20111017113150.GD20184@b20223-02.ap.freescale.net \
--to=richard.zhao@linaro.org \
--cc=amit.kucheria@linaro.org \
--cc=arnd.bergmann@linaro.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=dsaxena@linaro.org \
--cc=eric.miao@linaro.org \
--cc=grant.likely@secretlab.ca \
--cc=jeremy.kerr@canonical.com \
--cc=linaro-dev@lists.linaro.org \
--cc=linus.walleij@stericsson.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=magnus.damm@gmail.com \
--cc=mturquette@ti.com \
--cc=patches@linaro.org \
--cc=paul@pwsan.com \
--cc=sboyd@quicinc.com \
--cc=shawn.guo@freescale.com \
--cc=skannan@quicinc.com \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®