From: Stephen Boyd <sboyd@kernel.org>
To: Kishon Vijay Abraham I <kishon@kernel.org>,
Sean Anderson <sean.anderson@seco.com>,
Vinod Koul <vkoul@kernel.org>,
linux-phy@lists.infradead.org
Cc: linux-arm-kernel@lists.infradead.org,
Camelia Alexandra Groza <camelia.groza@nxp.com>,
Madalin Bucur <madalin.bucur@nxp.com>,
Bagas Sanjaya <bagasdotme@gmail.com>,
Rob Herring <robh+dt@kernel.org>,
Ioana Ciornei <ioana.ciornei@nxp.com>,
linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
Sean Anderson <sean.anderson@seco.com>,
Michael Turquette <mturquette@baylibre.com>,
linux-clk@vger.kernel.org
Subject: Re: [PATCH v9 04/10] clk: Add Lynx 10G SerDes PLL driver
Date: Fri, 27 Jan 2023 12:59:36 -0800 [thread overview]
Message-ID: <1abf9cb3e1fb1f01976c903cd8723b0f.sboyd@kernel.org> (raw)
In-Reply-To: <20221230000139.2846763-5-sean.anderson@seco.com>
Quoting Sean Anderson (2022-12-29 16:01:33)
> This adds support for the PLLs found in Lynx 10G "SerDes" devices found on
> various NXP QorIQ SoCs. There are two PLLs in each SerDes. This driver has
> been split from the main PHY driver to allow for better review, even though
> these PLLs are not present anywhere else besides the SerDes. An auxiliary
> device is not used as it offers no benefits over a function call (and there
> is no need to have a separate device).
>
> The PLLs are modeled as clocks proper to let us take advantage of the
> existing clock infrastructure.
What advantage do we gain?
> I have not given the same treatment to the
> per-lane clocks because they need to be programmed in-concert with the rest
> of the lane settings. One tricky thing is that the VCO (PLL) rate exceeds
> 2^32 (maxing out at around 5GHz). This will be a problem on 32-bit
> platforms, since clock rates are stored as unsigned longs. To work around
> this, the pll clock rate is generally treated in units of kHz.
This looks like a disadvantage. Are we reporting the frequency in kHz to
the clk framework?
>
> The PLLs are configured rather interestingly. Instead of the usual direct
> programming of the appropriate divisors, the input and output clock rates
> are selected directly. Generally, the only restriction is that the input
> and output must be integer multiples of each other. This suggests some kind
> of internal look-up table. The datasheets generally list out the supported
> combinations explicitly, and not all input/output combinations are
> documented. I'm not sure if this is due to lack of support, or due to an
> oversight. If this becomes an issue, then some combinations can be
> blacklisted (or whitelisted). This may also be necessary for other SoCs
> which have more stringent clock requirements.
I'm wondering if a clk provider should be created at all here. Who is
the consumer of the clk? The phy driver itself? Does the clk provided
need to interact with other clks in the system? Or is the clk tree
wholly self-contained?
Can the phy consumer configure the output frequency directly via
phy_configure() or when the phy is enabled? I'm thinking the phy driver
can call clk_set_rate() on the parent 'rfclk' before or after setting
the bits to control the output rate, and use clk_round_rate() to figure
out what input frequencies are supported for the output frequency
desired. This would avoid kHz overflowing 32-bits, and the big clk lock
getting blocked on some other clk in the system changing rates.
BTW, what sort of phy is this? Some networking device?
>
> diff --git a/drivers/clk/clk-fsl-lynx-10g.c b/drivers/clk/clk-fsl-lynx-10g.c
> new file mode 100644
> index 000000000000..61f68b5ae675
> --- /dev/null
> +++ b/drivers/clk/clk-fsl-lynx-10g.c
> @@ -0,0 +1,509 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2022 Sean Anderson <sean.anderson@seco.com>
> + *
> + * This file contains the implementation for the PLLs found on Lynx 10G phys.
> + *
> + * XXX: The VCO rate of the PLLs can exceed ~4GHz, which is the maximum rate
> + * expressable in an unsigned long. To work around this, rates are specified in
> + * kHz. This is as if there was a division by 1000 in the PLL.
> + */
> +
> +#include <linux/clk.h>
Is this include used? If not, please remove.
> +#include <linux/clk-provider.h>
> +#include <linux/device.h>
> +#include <linux/bitfield.h>
> +#include <linux/math64.h>
> +#include <linux/phy/lynx-10g.h>
> +#include <linux/regmap.h>
> +#include <linux/slab.h>
> +#include <linux/units.h>
> +#include <dt-bindings/clock/fsl,lynx-10g.h>
> +
> +#define PLL_STRIDE 0x20
> +#define PLLa(a, off) ((a) * PLL_STRIDE + (off))
> +#define PLLaRSTCTL(a) PLLa(a, 0x00)
> +#define PLLaCR0(a) PLLa(a, 0x04)
> +
> +#define PLLaRSTCTL_RSTREQ BIT(31)
> +#define PLLaRSTCTL_RST_DONE BIT(30)
> +#define PLLaRSTCTL_RST_ERR BIT(29)
[...]
> +
> +static int lynx_clk_init(struct clk_hw_onecell_data *hw_data,
> + struct device *dev, struct regmap *regmap,
> + unsigned int index)
> +{
> + const struct clk_hw *ex_dly_parents;
> + struct clk_parent_data pll_parents[1] = { };
> + struct clk_init_data pll_init = {
> + .ops = &lynx_pll_clk_ops,
> + .parent_data = pll_parents,
> + .num_parents = 1,
> + .flags = CLK_GET_RATE_NOCACHE | CLK_SET_RATE_PARENT |
Why is the nocache flag used?
> + CLK_OPS_PARENT_ENABLE,
> + };
> + struct clk_init_data ex_dly_init = {
> + .ops = &lynx_ex_dly_clk_ops,
> + .parent_hws = &ex_dly_parents,
> + .num_parents = 1,
> + };
> + struct lynx_clk *clk;
> + int ret;
next prev parent reply other threads:[~2023-01-27 20:59 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-30 0:01 [PATCH v9 00/10] phy: Add support for Lynx 10G SerDes Sean Anderson
2022-12-30 0:01 ` [PATCH v9 01/10] dt-bindings: phy: Add 2500BASE-X and 10GBASE-R Sean Anderson
2022-12-30 0:01 ` [PATCH v9 02/10] dt-bindings: phy: Add Lynx 10G phy binding Sean Anderson
2023-01-12 20:37 ` Rob Herring
2022-12-30 0:01 ` [PATCH v9 03/10] dt-bindings: clock: Add ids for Lynx 10g PLLs Sean Anderson
2022-12-30 0:01 ` [PATCH v9 04/10] clk: Add Lynx 10G SerDes PLL driver Sean Anderson
2023-01-27 20:59 ` Stephen Boyd [this message]
2023-01-27 21:51 ` Sean Anderson
2023-03-03 17:25 ` Sean Anderson
2022-12-30 0:01 ` [PATCH v9 05/10] phy: fsl: Add Lynx 10G SerDes driver Sean Anderson
2023-01-03 18:30 ` kernel test robot
2022-12-30 0:01 ` [PATCH v9 06/10] arm64: dts: ls1046a: Add serdes bindings Sean Anderson
2023-01-25 23:46 ` Shawn Guo
2023-01-26 16:43 ` Sean Anderson
2023-01-27 7:53 ` Shawn Guo
2022-12-30 0:01 ` [PATCH v9 07/10] arm64: dts: ls1046ardb: " Sean Anderson
2023-01-25 23:43 ` Shawn Guo
2023-01-26 16:48 ` Sean Anderson
2023-01-27 7:52 ` Shawn Guo
2023-01-27 16:11 ` Sean Anderson
2023-01-27 16:15 ` Krzysztof Kozlowski
2023-01-27 16:22 ` Sean Anderson
2023-01-27 16:41 ` Krzysztof Kozlowski
2023-01-27 16:42 ` Sean Anderson
2023-01-27 16:44 ` Krzysztof Kozlowski
2022-12-30 0:01 ` [PATCH v9 08/10] arm64: dts: ls1088a: " Sean Anderson
2023-01-25 23:48 ` Shawn Guo
2023-01-26 17:54 ` Sean Anderson
2022-12-30 0:01 ` [PATCH v9 09/10] arm64: dts: ls1088a: Prevent PCSs from probing as phys Sean Anderson
2022-12-30 0:01 ` [PATCH v9 10/10] arm64: dts: ls1088ardb: Add serdes bindings Sean Anderson
2023-01-17 16:46 ` [PATCH v9 00/10] phy: Add support for Lynx 10G SerDes Sean Anderson
2023-01-18 16:54 ` Vinod Koul
2023-01-19 16:22 ` Sean Anderson
2023-01-20 8:06 ` Vinod Koul
2023-01-20 16:43 ` Sean Anderson
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=1abf9cb3e1fb1f01976c903cd8723b0f.sboyd@kernel.org \
--to=sboyd@kernel.org \
--cc=bagasdotme@gmail.com \
--cc=camelia.groza@nxp.com \
--cc=devicetree@vger.kernel.org \
--cc=ioana.ciornei@nxp.com \
--cc=kishon@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=madalin.bucur@nxp.com \
--cc=mturquette@baylibre.com \
--cc=robh+dt@kernel.org \
--cc=sean.anderson@seco.com \
--cc=vkoul@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).