From: Brian Masney <bmasney@redhat.com>
To: Anirudh Srinivasan <asrinivasan@oss.tenstorrent.com>
Cc: Drew Fustini <dfustini@oss.tenstorrent.com>,
Joel Stanley <jms@oss.tenstorrent.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
linux-riscv@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
joel@jms.id.au, fustini@kernel.org, mpe@kernel.org,
mpe@oss.tenstorrent.com, npiggin@oss.tenstorrent.com,
agross@kernel.org, agross@oss.tenstorrent.com,
Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Subject: Re: [PATCH v7 3/3] clk: tenstorrent: Add Atlantis clock controller driver
Date: Wed, 4 Mar 2026 17:21:23 -0500 [thread overview]
Message-ID: <aaiwYxQuoptMDbBk@redhat.com> (raw)
In-Reply-To: <CAEev2e9fEsFqN5b4sAT9cbjVAvJEPvqxoqy74e5mG8K10xBQdg@mail.gmail.com>
Hi Anirudh,
On Wed, Mar 04, 2026 at 11:53:38AM -0600, Anirudh Srinivasan wrote:
> Sorry for the follow up, but wanted to run something by you.
>
> On Wed, Mar 4, 2026 at 10:40 AM Anirudh Srinivasan <
> asrinivasan@oss.tenstorrent.com> wrote:
> >
> > Hello Brian,
> >
> > On Tue, Mar 3, 2026 at 4:32 PM Brian Masney <bmasney@redhat.com> wrote:
> > >
> > > Hi Anirudh,
> > >
> > > Thanks for the patch. A few minor comments below with some minor
> > > nitpicks, additional places to use FIELD_GET(), plus some suggestions
> > > for additional regmap helpers to use.
> > >
>
>
> > > > +
> > > > +static int atlantis_clk_pll_is_enabled(struct clk_hw *hw)
> > > > +{
> > > > + struct atlantis_clk_pll *pll = hw_to_atlantis_pll(hw);
> > > > + u32 val, en_val, cg_val;
> > > > +
> > > > + regmap_read(pll->common.regmap, pll->config.reg_offset, &val);
> > > > + regmap_read(pll->common.regmap, pll->config.en_reg_offset,
> &en_val);
> > > > + regmap_read(pll->common.regmap, pll->config.cg_reg_offset,
> &cg_val);
> > > > +
> > > > + /* Check if PLL is powered on, locked, not bypassed and Gate
> clk is enabled */
> > > > + return !!(en_val & PLL_CFG_EN_BIT) && !!(val &
> PLL_CFG_LOCK_BIT) &&
> > > > + (!pll->config.cg_reg_enable || (cg_val &
> pll->config.cg_reg_enable)) &&
> > > > + !(val & PLL_CFG_BYPASS_BIT);
> > >
> > > Could regmap_test_bits() make this a bit cleaner?
> > >
> > > > +}
> > > > +
> > > > +static int atlantis_clk_pll_enable(struct clk_hw *hw)
> > > > +{
> > > > + struct atlantis_clk_pll *pll = hw_to_atlantis_pll(hw);
> > > > + u32 val, en_val, cg_val;
> > > > + int ret;
> > > > +
> > > > + regmap_read(pll->common.regmap, pll->config.reg_offset, &val);
> > > > + regmap_read(pll->common.regmap, pll->config.en_reg_offset,
> &en_val);
> > > > + regmap_read(pll->common.regmap, pll->config.cg_reg_offset,
> &cg_val);
> > > > +
> > > > + /* Check if PLL is already enabled, locked, not bypassed and
> Gate clk is enabled */
> > > > + if ((en_val & PLL_CFG_EN_BIT) && (val & PLL_CFG_LOCK_BIT) &&
> > > > + (!pll->config.cg_reg_enable || (cg_val &
> pll->config.cg_reg_enable)) &&
> > > > + !(val & PLL_CFG_BYPASS_BIT)) {
> > >
> > > Same about regmap_test_bits() here.
> >
> > These instances have it reading 3 different registers (unlike almost
> > all the other examples that just read one) and testing bits across
> > them. But I guess it should be possible to use test_bits here too. I
> > will update them.
>
> This ends up becoming like this.
>
> static int atlantis_clk_pll_is_enabled(struct clk_hw *hw)
>
> {
>
> struct atlantis_clk_pll *pll = hw_to_atlantis_pll(hw);
>
>
>
>
> /* Check if PLL is powered on, locked, not bypassed and Gate clk is
> enabled */
> return regmap_test_bits(pll->common.regmap, pll->config.reg_offset,
> PLL_CFG_LOCK_BIT) &&
>
> regmap_test_bits(pll->common.regmap,
> pll->config.en_reg_offset, PLL_CFG_EN_BIT) &&
>
> regmap_test_bits(pll->common.regmap,
> pll->config.cg_reg_offset, pll->config.cg_reg_enable) &&
>
> !regmap_test_bits(pll->common.regmap,
> pll->config.reg_offset, PLL_CFG_BYPASS_BIT);
>
> }
>
> We can't use a single call of regmap_test_bits to the
> pll->config.reg_offset register cause we need to check if PLL_CFG_LOCK_BIT
> is set and PLL_CFG_BYPASS_BIT is unset. We end up needing to make 2 reads
> to that register.
>
> Any thoughts on whether I should still be using regmap_test_bits here?
If it's not looking good in practice once you implement it, then just
fall back to the older behavior. It was just a suggestion.
I haven't used this yet, however there are also the regmap_field_xxx()
helpers that are also available. drivers/clk/mstar/clk-msc313-mpll.c
uses these helpers. I don't know if it would help to simplify your code.
Brian
next prev parent reply other threads:[~2026-03-04 22:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 17:36 [PATCH v7 0/3] Add Tenstorrent Atlantis Clock/Reset Controller Anirudh Srinivasan
2026-03-03 17:36 ` [PATCH v7 1/3] dt-bindings: clk: tenstorrent: Add tenstorrent,atlantis-prcm-rcpu Anirudh Srinivasan
2026-03-03 17:36 ` [PATCH v7 2/3] reset: tenstorrent: Add reset controller for Atlantis Anirudh Srinivasan
2026-03-03 17:36 ` [PATCH v7 3/3] clk: tenstorrent: Add Atlantis clock controller driver Anirudh Srinivasan
2026-03-03 22:32 ` Brian Masney
2026-03-04 16:40 ` Anirudh Srinivasan
[not found] ` <CAEev2e9fEsFqN5b4sAT9cbjVAvJEPvqxoqy74e5mG8K10xBQdg@mail.gmail.com>
2026-03-04 22:21 ` Brian Masney [this message]
2026-03-04 23:43 ` Anirudh Srinivasan
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=aaiwYxQuoptMDbBk@redhat.com \
--to=bmasney@redhat.com \
--cc=agross@kernel.org \
--cc=agross@oss.tenstorrent.com \
--cc=asrinivasan@oss.tenstorrent.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dfustini@oss.tenstorrent.com \
--cc=fustini@kernel.org \
--cc=jms@oss.tenstorrent.com \
--cc=joel@jms.id.au \
--cc=krzk+dt@kernel.org \
--cc=krzysztof.kozlowski@oss.qualcomm.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mpe@kernel.org \
--cc=mpe@oss.tenstorrent.com \
--cc=mturquette@baylibre.com \
--cc=npiggin@oss.tenstorrent.com \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=sboyd@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