From: Conor Dooley <conor@kernel.org>
To: linux-riscv@lists.infradead.org
Cc: conor@kernel.org, Conor Dooley <conor.dooley@microchip.com>,
Daire McNamara <daire.mcnamara@microchip.com>,
Wolfgang Grandegger <wg@grandegger.com>,
Marc Kleine-Budde <mkl@pengutronix.de>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
linux-can@vger.kernel.org, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-clk@vger.kernel.org
Subject: [PATCH v2 6/7] clk: microchip: mpfs: convert MSSPLL outputs to clk_divider
Date: Mon, 22 Jan 2024 12:19:54 +0000 [thread overview]
Message-ID: <20240122-drop-down-kooky-1fdc850c16b6@spud> (raw)
In-Reply-To: <20240122-catty-roast-d3625dbb02fe@spud>
From: Conor Dooley <conor.dooley@microchip.com>
After splitting the MSSPLL in two, the PLL outputs have become
open-coded versions of clk_divider. Drop the custom clk ops structs, and
instead use the generic clk_divider_ops.
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
---
drivers/clk/microchip/clk-mpfs.c | 81 ++++++--------------------------
1 file changed, 14 insertions(+), 67 deletions(-)
diff --git a/drivers/clk/microchip/clk-mpfs.c b/drivers/clk/microchip/clk-mpfs.c
index bed6adbb8a70..22eab91a6712 100644
--- a/drivers/clk/microchip/clk-mpfs.c
+++ b/drivers/clk/microchip/clk-mpfs.c
@@ -61,13 +61,10 @@ struct mpfs_msspll_hw_clock {
struct mpfs_msspll_out_hw_clock {
void __iomem *base;
- struct clk_hw hw;
+ struct clk_divider output;
struct clk_init_data init;
unsigned int id;
u32 reg_offset;
- u32 shift;
- u32 width;
- u32 flags;
};
#define to_mpfs_msspll_out_clk(_hw) container_of(_hw, struct mpfs_msspll_out_hw_clock, hw)
@@ -177,75 +174,25 @@ static int mpfs_clk_register_mssplls(struct device *dev, struct mpfs_msspll_hw_c
* MSS PLL output clocks
*/
-static unsigned long mpfs_clk_msspll_out_recalc_rate(struct clk_hw *hw, unsigned long prate)
-{
- struct mpfs_msspll_out_hw_clock *msspll_out_hw = to_mpfs_msspll_out_clk(hw);
- void __iomem *postdiv_addr = msspll_out_hw->base + msspll_out_hw->reg_offset;
- u32 postdiv;
-
- postdiv = readl_relaxed(postdiv_addr) >> msspll_out_hw->shift;
- postdiv &= clk_div_mask(msspll_out_hw->width);
-
- return prate / postdiv;
-}
-
-static long mpfs_clk_msspll_out_round_rate(struct clk_hw *hw, unsigned long rate,
- unsigned long *prate)
-{
- struct mpfs_msspll_out_hw_clock *msspll_out_hw = to_mpfs_msspll_out_clk(hw);
-
- return divider_round_rate(hw, rate, prate, NULL, msspll_out_hw->width,
- msspll_out_hw->flags);
-}
-
-static int mpfs_clk_msspll_out_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long prate)
-{
- struct mpfs_msspll_out_hw_clock *msspll_out_hw = to_mpfs_msspll_out_clk(hw);
- void __iomem *postdiv_addr = msspll_out_hw->base + msspll_out_hw->reg_offset;
- u32 postdiv;
- int divider_setting;
- unsigned long flags;
-
- divider_setting = divider_get_val(rate, prate, NULL, msspll_out_hw->width,
- msspll_out_hw->flags);
-
- if (divider_setting < 0)
- return divider_setting;
-
- spin_lock_irqsave(&mpfs_clk_lock, flags);
-
- postdiv = readl_relaxed(postdiv_addr);
- postdiv &= ~(clk_div_mask(msspll_out_hw->width) << msspll_out_hw->shift);
- writel_relaxed(postdiv, postdiv_addr);
-
- spin_unlock_irqrestore(&mpfs_clk_lock, flags);
-
- return 0;
-}
-
-static const struct clk_ops mpfs_clk_msspll_out_ops = {
- .recalc_rate = mpfs_clk_msspll_out_recalc_rate,
- .round_rate = mpfs_clk_msspll_out_round_rate,
- .set_rate = mpfs_clk_msspll_out_set_rate,
-};
-
#define CLK_PLL_OUT(_id, _name, _parent, _flags, _shift, _width, _offset) { \
.id = _id, \
- .shift = _shift, \
- .width = _width, \
+ .output.shift = _shift, \
+ .output.width = _width, \
+ .output.table = NULL, \
.reg_offset = _offset, \
- .flags = _flags, \
- .hw.init = CLK_HW_INIT(_name, _parent, &mpfs_clk_msspll_out_ops, 0), \
+ .output.flags = _flags, \
+ .output.hw.init = CLK_HW_INIT(_name, _parent, &clk_divider_ops, 0), \
+ .output.lock = &mpfs_clk_lock, \
}
static struct mpfs_msspll_out_hw_clock mpfs_msspll_out_clks[] = {
- CLK_PLL_OUT(CLK_MSSPLL0, "clk_msspll", "clk_msspll_internal", 0,
+ CLK_PLL_OUT(CLK_MSSPLL0, "clk_msspll", "clk_msspll_internal", CLK_DIVIDER_ONE_BASED,
MSSPLL_POSTDIV02_SHIFT, MSSPLL_POSTDIV_WIDTH, REG_MSSPLL_POSTDIV01_CR),
- CLK_PLL_OUT(CLK_MSSPLL1, "clk_msspll1", "clk_msspll_internal", 0,
+ CLK_PLL_OUT(CLK_MSSPLL1, "clk_msspll1", "clk_msspll_internal", CLK_DIVIDER_ONE_BASED,
MSSPLL_POSTDIV13_SHIFT, MSSPLL_POSTDIV_WIDTH, REG_MSSPLL_POSTDIV01_CR),
- CLK_PLL_OUT(CLK_MSSPLL2, "clk_msspll2", "clk_msspll_internal", 0,
+ CLK_PLL_OUT(CLK_MSSPLL2, "clk_msspll2", "clk_msspll_internal", CLK_DIVIDER_ONE_BASED,
MSSPLL_POSTDIV02_SHIFT, MSSPLL_POSTDIV_WIDTH, REG_MSSPLL_POSTDIV23_CR),
- CLK_PLL_OUT(CLK_MSSPLL3, "clk_msspll3", "clk_msspll_internal", 0,
+ CLK_PLL_OUT(CLK_MSSPLL3, "clk_msspll3", "clk_msspll_internal", CLK_DIVIDER_ONE_BASED,
MSSPLL_POSTDIV13_SHIFT, MSSPLL_POSTDIV_WIDTH, REG_MSSPLL_POSTDIV23_CR),
};
@@ -259,13 +206,13 @@ static int mpfs_clk_register_msspll_outs(struct device *dev,
for (i = 0; i < num_clks; i++) {
struct mpfs_msspll_out_hw_clock *msspll_out_hw = &msspll_out_hws[i];
- msspll_out_hw->base = data->msspll_base;
- ret = devm_clk_hw_register(dev, &msspll_out_hw->hw);
+ msspll_out_hw->output.reg = data->msspll_base + msspll_out_hw->reg_offset;
+ ret = devm_clk_hw_register(dev, &msspll_out_hw->output.hw);
if (ret)
return dev_err_probe(dev, ret, "failed to register msspll out id: %d\n",
msspll_out_hw->id);
- data->hw_data.hws[msspll_out_hw->id] = &msspll_out_hw->hw;
+ data->hw_data.hws[msspll_out_hw->id] = &msspll_out_hw->output.hw;
}
return 0;
--
2.43.0
next prev parent reply other threads:[~2024-01-22 12:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-22 12:19 [PATCH v2 0/7] MPFS clock fixes required for correct CAN clock modeling Conor Dooley
2024-01-22 12:19 ` [PATCH v2 1/7] dt-bindings: clock: mpfs: add more MSSPLL output definitions Conor Dooley
2024-01-22 12:19 ` [PATCH v2 2/7] dt-bindings: can: mpfs: add missing required clock Conor Dooley
2024-01-22 13:13 ` Marc Kleine-Budde
2024-01-22 14:21 ` Conor Dooley
2024-01-22 14:46 ` Marc Kleine-Budde
2024-01-22 14:56 ` Conor Dooley
2024-01-22 15:31 ` Marc Kleine-Budde
2024-01-22 15:47 ` Conor Dooley
2024-01-30 12:11 ` Conor Dooley
2024-01-30 13:01 ` Marc Kleine-Budde
2024-02-06 14:19 ` Conor Dooley
2024-01-23 11:27 ` Krzysztof Kozlowski
2024-01-22 12:19 ` [PATCH v2 3/7] clk: microchip: mpfs: split MSSPLL in two Conor Dooley
2024-01-22 12:19 ` [PATCH v2 4/7] clk: microchip: mpfs: setup for using other mss pll outputs Conor Dooley
2024-01-22 12:19 ` [PATCH v2 5/7] clk: microchip: mpfs: add missing MSSPLL outputs Conor Dooley
2024-01-22 12:19 ` Conor Dooley [this message]
2024-01-22 12:19 ` [PATCH v2 7/7] riscv: dts: microchip: add missing CAN bus clocks Conor Dooley
2024-02-06 14:27 ` (subset) [PATCH v2 0/7] MPFS clock fixes required for correct CAN clock modeling Conor Dooley
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=20240122-drop-down-kooky-1fdc850c16b6@spud \
--to=conor@kernel.org \
--cc=aou@eecs.berkeley.edu \
--cc=conor.dooley@microchip.com \
--cc=daire.mcnamara@microchip.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=kuba@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mkl@pengutronix.de \
--cc=mturquette@baylibre.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=robh+dt@kernel.org \
--cc=sboyd@kernel.org \
--cc=wg@grandegger.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: 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).