From: Simon Horman <horms@verge.net.au> To: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Linux-Renesas <linux-renesas-soc@vger.kernel.org>, linux-arm-kernel@lists.infradead.org, Magnus Damm <magnus.damm@gmail.com>, Takeshi Kihara <takeshi.kihara.df@renesas.com> Subject: Re: [PATCH v4 2/6] clk: renesas: rcar-gen3: Add Z2 clock divider support Date: Fri, 5 Jan 2018 15:04:05 +0100 [thread overview] Message-ID: <20180105140401.7iitpzdrlyqtasvz@verge.net.au> (raw) In-Reply-To: <CAMuHMdXcLhFD825Xi2Uk=6_OAgLd7BEp14rWpgb7pv6rOM2H2Q@mail.gmail.com> On Wed, Jan 03, 2018 at 01:47:08PM +0100, Geert Uytterhoeven wrote: > Hi Simon, > > On Wed, Jan 3, 2018 at 1:18 PM, Simon Horman <horms+renesas@verge.net.au> wrote: > > From: Takeshi Kihara <takeshi.kihara.df@renesas.com> > > > > This patch adds Z2 clock divider support for R-Car Gen3 SoC. > > > > Signed-off-by: Takeshi Kihara <takeshi.kihara.df@renesas.com> > > Signed-off-by: Simon Horman <horms+renesas@verge.net.au> > > --- > > v4 [Simon Horman] > > * Rebase > > * Use __ffs as FIELD_{GET,PREP} don't not work with non-constant masks > > * Use correct mask in cpg_z_clk_recalc_rate() > > Thanks for the update! > > > --- a/drivers/clk/renesas/rcar-gen3-cpg.c > > +++ b/drivers/clk/renesas/rcar-gen3-cpg.c > > @@ -63,7 +63,7 @@ static void cpg_simple_notifier_register(struct raw_notifier_head *notifiers, > > } > > > > /* > > - * Z Clock > > + * Z Clock & Z2 Clock > > * > > * Traits of this clock: > > * prepare - clk_prepare only ensures that parents are prepared > > @@ -75,11 +75,13 @@ static void cpg_simple_notifier_register(struct raw_notifier_head *notifiers, > > #define CPG_FRQCRB_KICK BIT(31) > > #define CPG_FRQCRC 0x000000e0 > > #define CPG_FRQCRC_ZFC_MASK GENMASK(12, 8) > > +#define CPG_FRQCRC_Z2FC_MASK GENMASK(4, 0) > > > > struct cpg_z_clk { > > struct clk_hw hw; > > void __iomem *reg; > > void __iomem *kick_reg; > > + unsigned long mask; > > }; > > > > #define to_z_clk(_hw) container_of(_hw, struct cpg_z_clk, hw) > > @@ -89,8 +91,10 @@ static unsigned long cpg_z_clk_recalc_rate(struct clk_hw *hw, > > { > > struct cpg_z_clk *zclk = to_z_clk(hw); > > unsigned int mult; > > + u32 val; > > > > - mult = 32 - FIELD_GET(CPG_FRQCRC_ZFC_MASK, clk_readl(zclk->reg)); > > + val = clk_readl(zclk->reg) & zclk->mask; > > + mult = 32 - (val >> (__ffs(zclk->mask) - 1)); > > Shouldn't that be > > mult = 32 - (val >> __ffs(zclk->mask)); > > (same below)? > > __ffs() returns 0..31, so you will shift right by 7 (Z) or -1 (Z2)? Thanks, I'll look at fixing that. > As the CPG/MSSR driver now has suspend/resume support, do we need > a notifier to restore the Z or Z2 registers? Or is that handled automatically > by cpufreq during system resume, for both the primary and the secondary > CPU cores? I am a bit unsure. When using the A57 cores, which is the default case, the Z clk is queried by CPUFreq on resume. It appears that on my system its already set to the correct value but I assume if it was not then it would be reset. However, this does not cover Z2 clk. So perhaps to be safe we need to register notifiers and make sure they they play nicely with CPUFreq?
WARNING: multiple messages have this Message-ID (diff)
From: horms@verge.net.au (Simon Horman) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 2/6] clk: renesas: rcar-gen3: Add Z2 clock divider support Date: Fri, 5 Jan 2018 15:04:05 +0100 [thread overview] Message-ID: <20180105140401.7iitpzdrlyqtasvz@verge.net.au> (raw) In-Reply-To: <CAMuHMdXcLhFD825Xi2Uk=6_OAgLd7BEp14rWpgb7pv6rOM2H2Q@mail.gmail.com> On Wed, Jan 03, 2018 at 01:47:08PM +0100, Geert Uytterhoeven wrote: > Hi Simon, > > On Wed, Jan 3, 2018 at 1:18 PM, Simon Horman <horms+renesas@verge.net.au> wrote: > > From: Takeshi Kihara <takeshi.kihara.df@renesas.com> > > > > This patch adds Z2 clock divider support for R-Car Gen3 SoC. > > > > Signed-off-by: Takeshi Kihara <takeshi.kihara.df@renesas.com> > > Signed-off-by: Simon Horman <horms+renesas@verge.net.au> > > --- > > v4 [Simon Horman] > > * Rebase > > * Use __ffs as FIELD_{GET,PREP} don't not work with non-constant masks > > * Use correct mask in cpg_z_clk_recalc_rate() > > Thanks for the update! > > > --- a/drivers/clk/renesas/rcar-gen3-cpg.c > > +++ b/drivers/clk/renesas/rcar-gen3-cpg.c > > @@ -63,7 +63,7 @@ static void cpg_simple_notifier_register(struct raw_notifier_head *notifiers, > > } > > > > /* > > - * Z Clock > > + * Z Clock & Z2 Clock > > * > > * Traits of this clock: > > * prepare - clk_prepare only ensures that parents are prepared > > @@ -75,11 +75,13 @@ static void cpg_simple_notifier_register(struct raw_notifier_head *notifiers, > > #define CPG_FRQCRB_KICK BIT(31) > > #define CPG_FRQCRC 0x000000e0 > > #define CPG_FRQCRC_ZFC_MASK GENMASK(12, 8) > > +#define CPG_FRQCRC_Z2FC_MASK GENMASK(4, 0) > > > > struct cpg_z_clk { > > struct clk_hw hw; > > void __iomem *reg; > > void __iomem *kick_reg; > > + unsigned long mask; > > }; > > > > #define to_z_clk(_hw) container_of(_hw, struct cpg_z_clk, hw) > > @@ -89,8 +91,10 @@ static unsigned long cpg_z_clk_recalc_rate(struct clk_hw *hw, > > { > > struct cpg_z_clk *zclk = to_z_clk(hw); > > unsigned int mult; > > + u32 val; > > > > - mult = 32 - FIELD_GET(CPG_FRQCRC_ZFC_MASK, clk_readl(zclk->reg)); > > + val = clk_readl(zclk->reg) & zclk->mask; > > + mult = 32 - (val >> (__ffs(zclk->mask) - 1)); > > Shouldn't that be > > mult = 32 - (val >> __ffs(zclk->mask)); > > (same below)? > > __ffs() returns 0..31, so you will shift right by 7 (Z) or -1 (Z2)? Thanks, I'll look at fixing that. > As the CPG/MSSR driver now has suspend/resume support, do we need > a notifier to restore the Z or Z2 registers? Or is that handled automatically > by cpufreq during system resume, for both the primary and the secondary > CPU cores? I am a bit unsure. When using the A57 cores, which is the default case, the Z clk is queried by CPUFreq on resume. It appears that on my system its already set to the correct value but I assume if it was not then it would be reset. However, this does not cover Z2 clk. So perhaps to be safe we need to register notifiers and make sure they they play nicely with CPUFreq?
next prev parent reply other threads:[~2018-01-05 14:04 UTC|newest] Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-01-03 12:18 [PATCH v4 0/6] clk: renesas: r8a779[56]: Add Z and Z2 clock support Simon Horman 2018-01-03 12:18 ` Simon Horman 2018-01-03 12:18 ` [PATCH v4 1/6] clk: renesas: rcar-gen3: Add Z clock divider support Simon Horman 2018-01-03 12:18 ` Simon Horman 2018-01-03 12:18 ` [PATCH v4 2/6] clk: renesas: rcar-gen3: Add Z2 " Simon Horman 2018-01-03 12:18 ` Simon Horman 2018-01-03 12:47 ` Geert Uytterhoeven 2018-01-03 12:47 ` Geert Uytterhoeven 2018-01-05 14:04 ` Simon Horman [this message] 2018-01-05 14:04 ` Simon Horman 2018-01-05 14:35 ` Geert Uytterhoeven 2018-01-05 14:35 ` Geert Uytterhoeven 2018-01-08 8:02 ` Simon Horman 2018-01-08 8:02 ` Simon Horman 2018-01-08 8:06 ` Geert Uytterhoeven 2018-01-08 8:06 ` Geert Uytterhoeven 2018-01-29 14:24 ` Simon Horman 2018-01-29 14:24 ` Simon Horman 2018-01-29 15:01 ` Geert Uytterhoeven 2018-01-29 15:01 ` Geert Uytterhoeven 2018-01-29 15:19 ` Simon Horman 2018-01-29 15:19 ` Simon Horman 2018-01-29 15:46 ` Geert Uytterhoeven 2018-01-29 15:46 ` Geert Uytterhoeven 2018-01-29 16:42 ` Simon Horman 2018-01-29 16:42 ` Simon Horman 2018-01-29 15:51 ` Simon Horman 2018-01-29 15:51 ` Simon Horman 2018-01-29 16:31 ` Simon Horman 2018-01-29 16:31 ` Simon Horman 2018-01-03 12:18 ` [PATCH v4 3/6] clk: renesas: r8a7795: Add Z clock Simon Horman 2018-01-03 12:18 ` Simon Horman 2018-01-03 12:18 ` [PATCH v4 4/6] clk: renesas: r8a7795: Add Z2 clock Simon Horman 2018-01-03 12:18 ` Simon Horman 2018-01-03 12:18 ` [PATCH v4 5/6] clk: renesas: r8a7796: Add Z clock Simon Horman 2018-01-03 12:18 ` Simon Horman 2018-01-03 12:18 ` [PATCH v4 6/6] clk: renesas: r8a7796: Add Z2 clock Simon Horman 2018-01-03 12:18 ` Simon Horman
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=20180105140401.7iitpzdrlyqtasvz@verge.net.au \ --to=horms@verge.net.au \ --cc=geert@linux-m68k.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-renesas-soc@vger.kernel.org \ --cc=magnus.damm@gmail.com \ --cc=takeshi.kihara.df@renesas.com \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.