From: Jamie Iles <jamie@jamieiles.com>
To: Rob Herring <robherring2@gmail.com>
Cc: Mike Turquette <mturquette@ti.com>,
linux-kernel@vger.kernel.org, paul@pwsan.com,
linaro-dev@lists.linaro.org, linus.walleij@stericsson.com,
patches@linaro.org, eric.miao@linaro.org,
broonie@opensource.wolfsonmicro.com, magnus.damm@gmail.com,
arnd.bergmann@linaro.org, Jamie Iles <jamie@jamieiles.com>,
skannan@quicinc.com, linux@arm.linux.org.uk,
jeremy.kerr@canonical.com, tglx@linutronix.de,
linux-arm-kernel@lists.infradead.org, sboyd@quiinc.com
Subject: Re: [PATCH v2 4/7] clk: Add simple gated clock
Date: Mon, 26 Sep 2011 19:40:24 +0100 [thread overview]
Message-ID: <20110926184024.GB9194@gallagher> (raw)
In-Reply-To: <4E80C564.3050004@gmail.com>
Hi Rob,
On Mon, Sep 26, 2011 at 01:33:08PM -0500, Rob Herring wrote:
> Mike,
>
> On 09/22/2011 05:26 PM, Mike Turquette wrote:
> > From: Jeremy Kerr <jeremy.kerr@canonical.com>
> >
> > Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
> > Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> > Signed-off-by: Jamie Iles <jamie@jamieiles.com>
> > Signed-off-by: Mike Turquette <mturquette@ti.com>
> > ---
> > Changes since v1:
> > Add copyright header
> > Fold in Jamie's patch for set-to-disable clks
> > Use BIT macro instead of shift
> >
> > drivers/clk/Kconfig | 4 ++
> > drivers/clk/Makefile | 1 +
> > drivers/clk/clk-gate.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++
> > include/linux/clk.h | 13 ++++++++
> > 4 files changed, 96 insertions(+), 0 deletions(-)
> > create mode 100644 drivers/clk/clk-gate.c
> >
> > diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> > index d8313d7..a78967c 100644
> > --- a/drivers/clk/Kconfig
> > +++ b/drivers/clk/Kconfig
> > @@ -12,3 +12,7 @@ config GENERIC_CLK
> > config GENERIC_CLK_FIXED
> > bool
> > depends on GENERIC_CLK
> > +
> > +config GENERIC_CLK_GATE
> > + bool
> > + depends on GENERIC_CLK
> > diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> > index 9a3325a..d186446 100644
> > --- a/drivers/clk/Makefile
> > +++ b/drivers/clk/Makefile
> > @@ -2,3 +2,4 @@
> > obj-$(CONFIG_CLKDEV_LOOKUP) += clkdev.o
> > obj-$(CONFIG_GENERIC_CLK) += clk.o
> > obj-$(CONFIG_GENERIC_CLK_FIXED) += clk-fixed.o
> > +obj-$(CONFIG_GENERIC_CLK_GATE) += clk-gate.o
> > diff --git a/drivers/clk/clk-gate.c b/drivers/clk/clk-gate.c
> > new file mode 100644
> > index 0000000..a1d8e79
> > --- /dev/null
> > +++ b/drivers/clk/clk-gate.c
> > @@ -0,0 +1,78 @@
> > +/*
> > + * Copyright (C) 2010-2011 Canonical Ltd <jeremy.kerr@canonical.com>
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License version 2 as
> > + * published by the Free Software Foundation.
> > + *
> > + * Simple clk gate implementation
> > + */
> > +
> > +#include <linux/clk.h>
> > +#include <linux/module.h>
> > +#include <asm/io.h>
>
> use linux/io.h
>
> > +
> > +#define to_clk_gate(clk) container_of(clk, struct clk_gate, hw)
> > +
> > +static unsigned long clk_gate_get_rate(struct clk_hw *clk)
> > +{
> > + return clk_get_rate(clk_get_parent(clk->clk));
> > +}
> > +
> > +static void clk_gate_set_bit(struct clk_hw *clk)
> > +{
> > + struct clk_gate *gate = to_clk_gate(clk);
> > + u32 reg;
> > +
> > + reg = __raw_readl(gate->reg);
> > + reg |= BIT(gate->bit_idx);
> > + __raw_writel(reg, gate->reg);
>
> Don't these read-mod-writes need a spinlock around it?
>
> It's possible to have an enable bits and dividers in the same register.
> If you did a set_rate and while doing an enable/disable, there would be
> a problem. Also, it may be 2 different clocks in the same register, so
> the spinlock needs to be shared and not per clock.
Well the prepare lock will be held here and I believe that would be
sufficient.
> > +}
> > +
> > +static void clk_gate_clear_bit(struct clk_hw *clk)
> > +{
> > + struct clk_gate *gate = to_clk_gate(clk);
> > + u32 reg;
> > +
> > + reg = __raw_readl(gate->reg);
> > + reg &= ~BIT(gate->bit_idx);
> > + __raw_writel(reg, gate->reg);
> > +}
> > +
> > +static int clk_gate_enable_set(struct clk_hw *clk)
> > +{
> > + clk_gate_set_bit(clk);
> > +
> > + return 0;
> > +}
> > +
> > +static void clk_gate_disable_clear(struct clk_hw *clk)
> > +{
> > + clk_gate_clear_bit(clk);
> > +}
> > +
> > +struct clk_hw_ops clk_gate_set_enable_ops = {
>
> const?
Yup.
> > + .recalc_rate = clk_gate_get_rate,
> > + .enable = clk_gate_enable_set,
> > + .disable = clk_gate_disable_clear,
> > +};
> > +EXPORT_SYMBOL_GPL(clk_gate_set_enable_ops);
> > +
> > +static int clk_gate_enable_clear(struct clk_hw *clk)
> > +{
> > + clk_gate_clear_bit(clk);
> > +
> > + return 0;
> > +}
> > +
> > +static void clk_gate_disable_set(struct clk_hw *clk)
> > +{
> > + clk_gate_set_bit(clk);
> > +}
>
> Are these wrapper functions really needed? Just assign set_bit and
> clear_bit functions directly to the ops structs. Only the ops struct
> name is exposed to the user.
I used the wrappers because the .enable method has to return an int, but
the disable needs to return void. It's either that or open code the
set/clear in each.
> > +
> > +struct clk_hw_ops clk_gate_set_disable_ops = {
>
> const?
Yes.
Jamie
next prev parent reply other threads:[~2011-09-26 18:40 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
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 [this message]
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=20110926184024.GB9194@gallagher \
--to=jamie@jamieiles.com \
--cc=arnd.bergmann@linaro.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=eric.miao@linaro.org \
--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=robherring2@gmail.com \
--cc=sboyd@quiinc.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;
as well as URLs for NNTP newsgroup(s).