From: Andrea della Porta <andrea.porta@suse.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Andrea della Porta <andrea.porta@suse.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Florian Fainelli <florian.fainelli@broadcom.com>,
Broadcom internal kernel review list
<bcm-kernel-feedback-list@broadcom.com>,
Lorenzo Pieralisi <lpieralisi@kernel.org>,
Krzysztof Wilczynski <kw@linux.com>,
Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
Bjorn Helgaas <bhelgaas@google.com>,
Linus Walleij <linus.walleij@linaro.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Derek Kiernan <derek.kiernan@amd.com>,
Dragan Cvetic <dragan.cvetic@amd.com>,
Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Saravana Kannan <saravanak@google.com>,
linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
linux-gpio@vger.kernel.org,
Masahiro Yamada <masahiroy@kernel.org>,
Stefan Wahren <wahrenst@gmx.net>,
Herve Codina <herve.codina@bootlin.com>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Andrew Lunn <andrew@lunn.ch>
Subject: Re: [PATCH v6 05/10] clk: rp1: Add support for clocks provided by RP1
Date: Fri, 7 Feb 2025 10:50:52 +0100 [thread overview]
Message-ID: <Z6XXfL1-ER2dLmZI@apocalypse> (raw)
In-Reply-To: <20250203234443.GA810409@bhelgaas>
Hi Bjorn,
On 17:44 Mon 03 Feb , Bjorn Helgaas wrote:
> On Mon, Jan 13, 2025 at 03:58:04PM +0100, Andrea della Porta wrote:
> > RaspberryPi RP1 is an MFD providing, among other peripherals, several
> > clock generators and PLLs that drives the sub-peripherals.
> > Add the driver to support the clock providers.
>
> > +#define PLL_PRIM_DIV1_SHIFT 16
> > +#define PLL_PRIM_DIV1_WIDTH 3
> > +#define PLL_PRIM_DIV1_MASK GENMASK(PLL_PRIM_DIV1_SHIFT + \
> > + PLL_PRIM_DIV1_WIDTH - 1, \
> > + PLL_PRIM_DIV1_SHIFT)
> > +
> > +#define PLL_PRIM_DIV2_SHIFT 12
> > +#define PLL_PRIM_DIV2_WIDTH 3
> > +#define PLL_PRIM_DIV2_MASK GENMASK(PLL_PRIM_DIV2_SHIFT + \
> > + PLL_PRIM_DIV2_WIDTH - 1, \
> > + PLL_PRIM_DIV2_SHIFT)
>
> Maybe this is standard drivers/clk style, but this seems like overkill
> to me. I think this would be sufficient and easier to read:
>
> #define PLL_PRIM_DIV1_MASK GENMASK(18, 16)
> #define PLL_PRIM_DIV2_MASK GENMASK(14, 12)
Ack.
>
> > +static unsigned long rp1_pll_recalc_rate(struct clk_hw *hw,
> > + unsigned long parent_rate)
> > +{
> > + struct rp1_clk_desc *pll = container_of(hw, struct rp1_clk_desc, hw);
> > + struct rp1_clockman *clockman = pll->clockman;
> > + const struct rp1_pll_data *data = pll->data;
> > + u32 prim, prim_div1, prim_div2;
> > +
> > + prim = clockman_read(clockman, data->ctrl_reg);
> > + prim_div1 = (prim & PLL_PRIM_DIV1_MASK) >> PLL_PRIM_DIV1_SHIFT;
> > + prim_div2 = (prim & PLL_PRIM_DIV2_MASK) >> PLL_PRIM_DIV2_SHIFT;
>
> And then here, I think you can just use FIELD_GET():
>
> prim_div1 = FIELD_GET(PLL_PRIM_DIV1_MASK, prim);
> prim_div2 = FIELD_GET(PLL_PRIM_DIV2_MASK, prim);
>
> It looks like the same could be done for PLL_SEC_DIV_MASK,
> PLL_CS_REFDIV_SHIFT, PLL_PH_PHASE_SHIFT, CLK_CTRL_AUXSRC_MASK, etc.
Ack.
Regards,
Andrea
next prev parent reply other threads:[~2025-02-07 9:51 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 14:57 [PATCH v6 00/10] Add support for RaspberryPi RP1 PCI device using a DT overlay Andrea della Porta
2025-01-13 14:58 ` [PATCH v6 01/10] dt-bindings: clock: Add RaspberryPi RP1 clock bindings Andrea della Porta
2025-01-17 16:49 ` Florian Fainelli
2025-01-13 14:58 ` [PATCH v6 02/10] dt-bindings: pinctrl: Add RaspberryPi RP1 gpio/pinctrl/pinmux bindings Andrea della Porta
2025-01-17 16:48 ` Florian Fainelli
2025-01-13 14:58 ` [PATCH v6 03/10] dt-bindings: pci: Add common schema for devices accessible through PCI BARs Andrea della Porta
2025-01-17 16:48 ` Florian Fainelli
2025-01-13 14:58 ` [PATCH v6 04/10] dt-bindings: misc: Add device specific bindings for RaspberryPi RP1 Andrea della Porta
2025-01-17 16:52 ` Florian Fainelli
2025-01-13 14:58 ` [PATCH v6 05/10] clk: rp1: Add support for clocks provided by RP1 Andrea della Porta
2025-02-03 23:44 ` Bjorn Helgaas
2025-02-07 9:50 ` Andrea della Porta [this message]
2025-01-13 14:58 ` [PATCH v6 06/10] pinctrl: rp1: Implement RaspberryPi RP1 gpio support Andrea della Porta
2025-01-13 14:58 ` [PATCH v6 07/10] arm64: dts: rp1: Add support for RaspberryPi's RP1 device Andrea della Porta
2025-01-17 16:51 ` Florian Fainelli
2025-01-13 14:58 ` [PATCH v6 08/10] misc: rp1: RaspberryPi RP1 misc driver Andrea della Porta
2025-01-17 11:47 ` Greg Kroah-Hartman
2025-01-21 8:43 ` Andrea della Porta
2025-01-21 8:48 ` Greg Kroah-Hartman
2025-01-21 13:59 ` Andrea della Porta
2025-01-21 14:18 ` Greg Kroah-Hartman
2025-01-21 14:38 ` Andrea della Porta
2025-01-21 14:49 ` Greg Kroah-Hartman
2025-01-21 15:15 ` Herve Codina
2025-01-21 15:19 ` Andrea della Porta
2025-01-21 14:53 ` Andrew Lunn
2025-01-21 15:11 ` Andrea della Porta
2025-01-13 14:58 ` [PATCH v6 09/10] arm64: dts: bcm2712: Add external clock for RP1 chipset on Rpi5 Andrea della Porta
2025-01-17 16:51 ` Florian Fainelli
2025-01-13 14:58 ` [PATCH v6 10/10] arm64: defconfig: Enable RP1 misc/clock/gpio drivers Andrea della Porta
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=Z6XXfL1-ER2dLmZI@apocalypse \
--to=andrea.porta@suse.com \
--cc=andrew@lunn.ch \
--cc=arnd@arndb.de \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bhelgaas@google.com \
--cc=brgl@bgdev.pl \
--cc=catalin.marinas@arm.com \
--cc=conor+dt@kernel.org \
--cc=derek.kiernan@amd.com \
--cc=devicetree@vger.kernel.org \
--cc=dragan.cvetic@amd.com \
--cc=florian.fainelli@broadcom.com \
--cc=gregkh@linuxfoundation.org \
--cc=helgaas@kernel.org \
--cc=herve.codina@bootlin.com \
--cc=krzk+dt@kernel.org \
--cc=kw@linux.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=lpieralisi@kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=manivannan.sadhasivam@linaro.org \
--cc=masahiroy@kernel.org \
--cc=mturquette@baylibre.com \
--cc=robh@kernel.org \
--cc=saravanak@google.com \
--cc=sboyd@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=wahrenst@gmx.net \
--cc=will@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 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.