linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Abel Vesa <abel.vesa@nxp.com>
Cc: Dong Aisheng <aisheng.dong@nxp.com>,
	Rob Herring <robh@kernel.org>, Peng Fan <peng.fan@nxp.com>,
	Jacky Bai <ping.bai@nxp.com>, Anson Huang <anson.huang@nxp.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Mike Turquette <mturquette@baylibre.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	NXP Linux Team <linux-imx@nxp.com>,
	Sascha Hauer <kernel@pengutronix.de>,
	Fabio Estevam <fabio.estevam@nxp.com>,
	Shawn Guo <shawnguo@kernel.org>,
	linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] clk: imx: gate2: Fix the is_enabled op
Date: Wed, 28 Oct 2020 11:15:52 +0100	[thread overview]
Message-ID: <20201028101552.GA26805@pengutronix.de> (raw)
In-Reply-To: <20201028095057.cuaxqqr4yzxvzwvp@fsr-ub1664-175>

On Wed, Oct 28, 2020 at 11:50:57AM +0200, Abel Vesa wrote:
> On 20-10-28 09:24:12, Sascha Hauer wrote:
> > Hi Abel,
> > 
> > On Mon, Oct 26, 2020 at 08:50:48PM +0200, Abel Vesa wrote:
> > > The clock is considered to be enabled only if the controlling bits
> > > match the cgr_val mask. Also make sure the is_enabled returns the
> > > correct vaule by locking the access to the register.
> > > 
> > > Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
> > > Fixes: 1e54afe9fcfe ("clk: imx: gate2: Allow single bit gating clock")
> > > ---
> > >  drivers/clk/imx/clk-gate2.c | 60 ++++++++++++++++++++-------------------------
> > >  drivers/clk/imx/clk.h       |  8 ++----
> > >  2 files changed, 29 insertions(+), 39 deletions(-)
> > > 
> > > diff --git a/drivers/clk/imx/clk-gate2.c b/drivers/clk/imx/clk-gate2.c
> > > index 7eed708..f320bd2b 100644
> > > --- a/drivers/clk/imx/clk-gate2.c
> > > +++ b/drivers/clk/imx/clk-gate2.c
> > > @@ -37,10 +37,22 @@ struct clk_gate2 {
> > >  
> > >  #define to_clk_gate2(_hw) container_of(_hw, struct clk_gate2, hw)
> > >  
> > > +static void clk_gate2_do_shared_clks(struct clk_hw *hw, bool enable)
> > > +{
> > > +	struct clk_gate2 *gate = to_clk_gate2(hw);
> > > +	u32 reg;
> > > +
> > > +	reg = readl(gate->reg);
> > > +	if (enable)
> > > +		reg |= gate->cgr_val << gate->bit_idx;
> > > +	else
> > > +		reg &= ~(gate->cgr_val << gate->bit_idx);
> > 
> > Shouldn't this be:
> > 
> > 	reg &= ~(3 << gate->bit_idx);
> > 	if (enable)
> > 		reg |= gate->cgr_val << gate->bit_idx;
> > 
> > At least that's how it was without this patch and that's how it makes
> > sense to me with cgr_val != 3.
> > 
> 
> Well, that's the actual problem. The value 3 forces all the clocks
> that register with this clock type to have 2 bits for controlling the gate.
> 
> My patch (though now I think I should split it into 2 separate patches) allows
> two HW gates to be controlled by as many bits necessary. For example, there
> could be multiple HW gates that are controled by the same bit. By passing
> the cgr_val when registering the clocks you can specify how many bits (as a mask)
> control all those HW gates that share their control bits.

cgr_val is not a mask, it's a value that shall be written to the two
bits to enable the clock. cgr_val could also be 0b10, see imx_clk_gate2_cgr().

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-10-28 10:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26 18:50 [PATCH] clk: imx: gate2: Fix the is_enabled op Abel Vesa
2020-10-28  8:24 ` Sascha Hauer
2020-10-28  9:50   ` Abel Vesa
2020-10-28 10:15     ` Sascha Hauer [this message]
2020-10-28 11:15       ` Abel Vesa

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=20201028101552.GA26805@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=abel.vesa@nxp.com \
    --cc=aisheng.dong@nxp.com \
    --cc=anson.huang@nxp.com \
    --cc=fabio.estevam@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=peng.fan@nxp.com \
    --cc=ping.bai@nxp.com \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=shawnguo@kernel.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).